Commit 684fd0af authored by Marek Olšák's avatar Marek Olšák Committed by Alex Deucher

drm/syncobj: add a new helper drm_syncobj_get_fd

Reviewed-by: default avatarDave Airlie <airlied@redhat.com>
Signed-off-by: default avatarMarek Olšák <marek.olsak@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 1321fd2c
...@@ -386,33 +386,38 @@ static int drm_syncobj_alloc_file(struct drm_syncobj *syncobj) ...@@ -386,33 +386,38 @@ static int drm_syncobj_alloc_file(struct drm_syncobj *syncobj)
return 0; return 0;
} }
static int drm_syncobj_handle_to_fd(struct drm_file *file_private, int drm_syncobj_get_fd(struct drm_syncobj *syncobj, int *p_fd)
u32 handle, int *p_fd)
{ {
struct drm_syncobj *syncobj = drm_syncobj_find(file_private, handle);
int ret; int ret;
int fd; int fd;
if (!syncobj)
return -EINVAL;
fd = get_unused_fd_flags(O_CLOEXEC); fd = get_unused_fd_flags(O_CLOEXEC);
if (fd < 0) { if (fd < 0)
drm_syncobj_put(syncobj);
return fd; return fd;
}
if (!syncobj->file) { if (!syncobj->file) {
ret = drm_syncobj_alloc_file(syncobj); ret = drm_syncobj_alloc_file(syncobj);
if (ret) if (ret) {
goto out_put_fd; put_unused_fd(fd);
return ret;
}
} }
fd_install(fd, syncobj->file); fd_install(fd, syncobj->file);
drm_syncobj_put(syncobj);
*p_fd = fd; *p_fd = fd;
return 0; return 0;
out_put_fd: }
put_unused_fd(fd); EXPORT_SYMBOL(drm_syncobj_get_fd);
static int drm_syncobj_handle_to_fd(struct drm_file *file_private,
u32 handle, int *p_fd)
{
struct drm_syncobj *syncobj = drm_syncobj_find(file_private, handle);
int ret;
if (!syncobj)
return -EINVAL;
ret = drm_syncobj_get_fd(syncobj, p_fd);
drm_syncobj_put(syncobj); drm_syncobj_put(syncobj);
return ret; return ret;
} }
......
...@@ -140,5 +140,6 @@ int drm_syncobj_create(struct drm_syncobj **out_syncobj, uint32_t flags, ...@@ -140,5 +140,6 @@ int drm_syncobj_create(struct drm_syncobj **out_syncobj, uint32_t flags,
struct dma_fence *fence); struct dma_fence *fence);
int drm_syncobj_get_handle(struct drm_file *file_private, int drm_syncobj_get_handle(struct drm_file *file_private,
struct drm_syncobj *syncobj, u32 *handle); struct drm_syncobj *syncobj, u32 *handle);
int drm_syncobj_get_fd(struct drm_syncobj *syncobj, int *p_fd);
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment