diff options
author | Sinclair Yeh <syeh@vmware.com> | 2017-05-08 14:08:40 -0700 |
---|---|---|
committer | Sinclair Yeh <syeh@vmware.com> | 2017-06-14 19:39:41 +0200 |
commit | 0662261816ff6cf175e329444b7d69b31e6b6477 (patch) | |
tree | 294337dae5bf24f24c58fcb02ec2cbd05ae463b5 /vmwgfx_execbuf.c | |
parent | e7976dcd1bfa9a2d234c2e296f5c3992177907c2 (diff) |
vmwgfx: Add support for imported Fence File Descriptor
This allows vmwgfx to wait on a fence created by another
device.
v2:
* Remove special handling for vmwgfx fence and just use dma_fence_wait()
* Use interruptible waits
* Added function documentation
Signed-off-by: Sinclair Yeh <syeh@vmware.com>
Reviewed-by: Deepak Singh Rawat <drawat@vmware.com>
Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>
Diffstat (limited to 'vmwgfx_execbuf.c')
-rw-r--r-- | vmwgfx_execbuf.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/vmwgfx_execbuf.c b/vmwgfx_execbuf.c index b75e670..a37085e 100644 --- a/vmwgfx_execbuf.c +++ b/vmwgfx_execbuf.c @@ -24,6 +24,7 @@ * USE OR OTHER DEALINGS IN THE SOFTWARE. * **************************************************************************/ +#include "core/sync_file.h" #include "vmwgfx_drv.h" #include "vmwgfx_reg.h" @@ -4416,6 +4417,7 @@ int vmw_execbuf_ioctl(struct drm_device *dev, unsigned long data, static const size_t copy_offset[] = { offsetof(struct drm_vmw_execbuf_arg, context_handle), sizeof(struct drm_vmw_execbuf_arg)}; + struct dma_fence *in_fence = NULL; if (unlikely(size < copy_offset[0])) { DRM_ERROR("Invalid command size, ioctl %d\n", @@ -4455,6 +4457,21 @@ int vmw_execbuf_ioctl(struct drm_device *dev, unsigned long data, break; } + + /* If imported a fence FD from elsewhere, then wait on it */ + if (arg.flags & DRM_VMW_EXECBUF_FLAG_IMPORT_FENCE_FD) { + in_fence = sync_file_get_fence(arg.imported_fence_fd); + + if (!in_fence) { + DRM_ERROR("Cannot get imported fence\n"); + return -EINVAL; + } + + ret = vmw_wait_dma_fence(dev_priv->fman, in_fence); + if (ret) + goto out; + } + ret = ttm_read_lock(&dev_priv->reservation_sem, true); if (unlikely(ret != 0)) return ret; @@ -4467,9 +4484,12 @@ int vmw_execbuf_ioctl(struct drm_device *dev, unsigned long data, NULL); ttm_read_unlock(&dev_priv->reservation_sem); if (unlikely(ret != 0)) - return ret; + goto out; vmw_kms_cursor_post_execbuf(dev_priv); - return 0; +out: + if (in_fence) + dma_fence_put(in_fence); + return ret; } |