iris: Fix import sync-file into syncobj
authorChris Wilson <chris@chris-wilson.co.uk>
Sat, 22 Feb 2020 15:51:15 +0000 (15:51 +0000)
committerMarge Bot <eric+marge@anholt.net>
Mon, 24 Feb 2020 15:43:19 +0000 (15:43 +0000)
When importing a sync-file, the kernel expects to be told which syncobj
to replace with the new fence -- it does not automatically create a new
handle for us. Abide by this rule and create a new syncobj for the
imported sync-file.

Fixes: f459c56be6bf ("iris: Add fence support using drm_syncobj")
Cc: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3919>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3919>

src/gallium/drivers/iris/iris_fence.c

index d8c3bd932ce7a9f798409b5720dd9b8dc265563f..0d3144d61cce8a8d87f79d178a87f26d61632253 100644 (file)
@@ -356,12 +356,14 @@ iris_fence_create_fd(struct pipe_context *ctx,
 
    struct iris_screen *screen = (struct iris_screen *)ctx->screen;
    struct drm_syncobj_handle args = {
+      .handle = gem_syncobj_create(screen->fd, DRM_SYNCOBJ_CREATE_SIGNALED),
       .flags = DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_IMPORT_SYNC_FILE,
       .fd = fd,
    };
    if (gen_ioctl(screen->fd, DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE, &args) == -1) {
       fprintf(stderr, "DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE failed: %s\n",
               strerror(errno));
+      gem_syncobj_destroy(screen->fd, args.handle);
       *out = NULL;
       return;
    }