[PATCH 11/12] drm/syncobj: add drm_syncobj_export_sync_file
From: Julian Orth
Date: Sat May 16 2026 - 07:12:57 EST
This makes the logic from drm_syncobj_export_sync_file_by_handle
available to callers that have a drm_syncobj instead of a
drm_file/handle pair.
Signed-off-by: Julian Orth <ju.orth@xxxxxxxxx>
---
drivers/gpu/drm/drm_syncobj.c | 39 ++++++++++++++++++++++++++++++++++-----
include/drm/drm_syncobj.h | 2 ++
2 files changed, 36 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c
index 4c1667c67cb7..d5e633738730 100644
--- a/drivers/gpu/drm/drm_syncobj.c
+++ b/drivers/gpu/drm/drm_syncobj.c
@@ -815,8 +815,34 @@ int drm_syncobj_import_sync_file(struct drm_syncobj *syncobj,
}
EXPORT_SYMBOL(drm_syncobj_import_sync_file);
-static int drm_syncobj_export_sync_file(struct drm_file *file_private,
- int handle, u64 point, int *p_fd)
+static int drm_syncobj_export_sync_file_by_handle(struct drm_file *file_private,
+ int handle, u64 point,
+ int *p_fd)
+{
+ struct drm_syncobj *syncobj;
+ int ret;
+
+ syncobj = drm_syncobj_find(file_private, handle);
+ if (!syncobj)
+ return -ENOENT;
+
+ ret = drm_syncobj_export_sync_file(syncobj, point, p_fd);
+
+ drm_syncobj_put(syncobj);
+
+ return ret;
+}
+
+/**
+ * drm_syncobj_export_sync_file - export a syncobj fence as a sync_file fd
+ * @syncobj: syncobj to export from
+ * @point: timeline point or 0
+ * @p_fd: out parameter for the new file descriptor
+ *
+ * Returns 0 on success or a negative error value on failure.
+ */
+int drm_syncobj_export_sync_file(struct drm_syncobj *syncobj,
+ u64 point, int *p_fd)
{
int ret;
struct dma_fence *fence;
@@ -826,7 +852,7 @@ static int drm_syncobj_export_sync_file(struct drm_file *file_private,
if (fd < 0)
return fd;
- ret = drm_syncobj_find_fence(file_private, handle, point, 0, &fence);
+ ret = drm_syncobj_fence_lookup(syncobj, point, 0, &fence);
if (ret)
goto err_put_fd;
@@ -847,6 +873,8 @@ static int drm_syncobj_export_sync_file(struct drm_file *file_private,
put_unused_fd(fd);
return ret;
}
+EXPORT_SYMBOL(drm_syncobj_export_sync_file);
+
/**
* drm_syncobj_open - initializes syncobj file-private structures at devnode open time
* @file_private: drm file-private structure to set up
@@ -933,8 +961,9 @@ drm_syncobj_handle_to_fd_ioctl(struct drm_device *dev, void *data,
point = args->point;
if (args->flags & DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE)
- return drm_syncobj_export_sync_file(file_private, args->handle,
- point, &args->fd);
+ return drm_syncobj_export_sync_file_by_handle(file_private,
+ args->handle,
+ point, &args->fd);
if (args->point)
return -EINVAL;
diff --git a/include/drm/drm_syncobj.h b/include/drm/drm_syncobj.h
index 1571ffa12a5c..48476c570595 100644
--- a/include/drm/drm_syncobj.h
+++ b/include/drm/drm_syncobj.h
@@ -145,6 +145,8 @@ int drm_syncobj_query(struct drm_syncobj **syncobjs, u64 user_points,
u32 count, u32 flags);
int drm_syncobj_import_sync_file(struct drm_syncobj *syncobj,
int sync_file_fd, u64 point);
+int drm_syncobj_export_sync_file(struct drm_syncobj *syncobj,
+ u64 point, int *p_fd);
void drm_syncobj_free(struct kref *kref);
int drm_syncobj_create(struct drm_syncobj **out_syncobj, uint32_t flags,
struct dma_fence *fence);
--
2.54.0