drm: add support of syncobj timeline point wait v4
Subsystems (3)
PATCH 1/5 drm: add support of syncobj timeline point wait v4
points array is one-to-one match with syncobjs array. v2:
add seperate ioctl for timeline point wait, otherwise break uapi. v3:
userspace can specify two kinds waits::
a. Wait for time point to be completed.
b. and wait for time point to become available
v4:
rebase
--- drivers/gpu/drm/drm_internal.h | 2 + drivers/gpu/drm/drm_ioctl.c | 2 + drivers/gpu/drm/drm_syncobj.c | 115 ++++++++++++++++++++++++++++----- include/uapi/drm/drm.h | 18 ++++++ 4 files changed, 121 insertions(+), 16 deletions(-)
drivers/gpu/drm/drm_internal.h +2 -0
@@ -183,6 +183,8 @@ int drm_syncobj_fd_to_handle_ioctl(struct drm_device *dev, void *data, struct drm_file *file_private);int drm_syncobj_wait_ioctl (struct drm_device *dev,void *data,struct drm_file *file_private); +int drm_syncobj_timeline_wait_ioctl (struct drm_device *dev,void *data, +struct drm_file *file_private);int drm_syncobj_reset_ioctl (struct drm_device *dev,void *data,struct drm_file *file_private); int drm_syncobj_signal_ioctl(struct drm_device *dev, void *data,
drivers/gpu/drm/drm_ioctl.c +2 -0
@@ -675,6 +675,8 @@ static const struct drm_ioctl_desc drm_ioctls[] = { DRM_UNLOCKED|DRM_RENDER_ALLOW),DRM_IOCTL_DEF (DRM_IOCTL_SYNCOBJ_WAIT , drm_syncobj_wait_ioctl,DRM_UNLOCKED |DRM_RENDER_ALLOW ), +DRM_IOCTL_DEF (DRM_IOCTL_SYNCOBJ_TIMELINE_WAIT , drm_syncobj_timeline_wait_ioctl, +DRM_UNLOCKED |DRM_RENDER_ALLOW ),DRM_IOCTL_DEF (DRM_IOCTL_SYNCOBJ_RESET , drm_syncobj_reset_ioctl,DRM_UNLOCKED |DRM_RENDER_ALLOW ), DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_SIGNAL, drm_syncobj_signal_ioctl,
drivers/gpu/drm/drm_syncobj.c +99 -16
191 lines not on this page · raw message
include/uapi/drm/drm.h +18 -0
@@ -738,6 +738,10 @@ struct drm_syncobj_handle {#define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALL (1 << 0)#define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT (1 << 1) +/* wait for time point to be completed */ +#define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_COMPLETED (1 << 2) +/* wait for time point to become available */ +#define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_AVAILABLE (1 << 3)struct drm_syncobj_wait {__u64 handles;/* absolute timeout */
@@ -748,6 +752,19 @@ struct drm_syncobj_wait {__u32 pad; }; +struct drm_syncobj_timeline_wait { +__u64 handles; +/* wait on specific timeline point for every handles*/ +__u64 points; +/* absolute timeout */ +__s64 timeout_nsec; +__u32 count_handles; +__u32 flags; +__u32 first_signaled;/* only valid when not waiting all */ +__u32 pad; +}; + +struct drm_syncobj_array {__u64 handles;__u32 count_handles;
@@ -910,6 +927,7 @@ extern "C" {#define DRM_IOCTL_MODE_GET_LEASE DRM_IOWR(0xC8, struct drm_mode_get_lease)#define DRM_IOCTL_MODE_REVOKE_LEASE DRM_IOWR(0xC9, struct drm_mode_revoke_lease) +#define DRM_IOCTL_SYNCOBJ_TIMELINE_WAIT DRM_IOWR(0xCA, struct drm_syncobj_timeline_wait)/** * Device specific ioctls should only be in their respective headers * The device specific ioctl range is from 0x40 to 0x9f.
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 2/5 drm: add timeline syncobj payload query ioctl v2
user mode can query timeline payload.
v2: check return value of copy_to_user
--- drivers/gpu/drm/drm_internal.h | 2 ++ drivers/gpu/drm/drm_ioctl.c | 2 ++ drivers/gpu/drm/drm_syncobj.c | 52 ++++++++++++++++++++++++++++++++++ include/uapi/drm/drm.h | 11 +++++++ 4 files changed, 67 insertions(+)
drivers/gpu/drm/drm_internal.h +2 -0
@@ -189,6 +189,8 @@ int drm_syncobj_reset_ioctl(struct drm_device *dev, void *data, struct drm_file *file_private);int drm_syncobj_signal_ioctl (struct drm_device *dev,void *data,struct drm_file *file_private); +int drm_syncobj_query_ioctl (struct drm_device *dev,void *data, +struct drm_file *file_private);/* drm_framebuffer.c */ void drm_framebuffer_print_info(struct drm_printer *p, unsigned int indent,
drivers/gpu/drm/drm_ioctl.c +2 -0
@@ -681,6 +681,8 @@ static const struct drm_ioctl_desc drm_ioctls[] = { DRM_UNLOCKED|DRM_RENDER_ALLOW),DRM_IOCTL_DEF (DRM_IOCTL_SYNCOBJ_SIGNAL , drm_syncobj_signal_ioctl,DRM_UNLOCKED |DRM_RENDER_ALLOW ), +DRM_IOCTL_DEF (DRM_IOCTL_SYNCOBJ_QUERY , drm_syncobj_query_ioctl, +DRM_UNLOCKED |DRM_RENDER_ALLOW ),DRM_IOCTL_DEF (DRM_IOCTL_CRTC_GET_SEQUENCE , drm_crtc_get_sequence_ioctl,DRM_UNLOCKED ),DRM_IOCTL_DEF (DRM_IOCTL_CRTC_QUEUE_SEQUENCE , drm_crtc_queue_sequence_ioctl,DRM_UNLOCKED ), DRM_IOCTL_DEF(DRM_IOCTL_MODE_CREATE_LEASE, drm_mode_create_lease_ioctl, DRM_MASTER|DRM_UNLOCKED),
drivers/gpu/drm/drm_syncobj.c +52 -0
55 lines not on this page · raw message
include/uapi/drm/drm.h +11 -0
@@ -771,6 +771,15 @@ struct drm_syncobj_array {__u32 pad; }; +struct drm_syncobj_timeline_query { +__u64 handles; +/* points are timeline syncobjs payloads returned by query ioctl */ +__u64 points; +__u32 count_handles; +__u32 pad; +}; + +/* Query current scanout sequence number */ struct drm_crtc_get_sequence {__u32 crtc_id;/* requested crtc_id */
@@ -928,6 +937,8 @@ extern "C" {#define DRM_IOCTL_MODE_REVOKE_LEASE DRM_IOWR(0xC9, struct drm_mode_revoke_lease)#define DRM_IOCTL_SYNCOBJ_TIMELINE_WAIT DRM_IOWR(0xCA, struct drm_syncobj_timeline_wait) +#define DRM_IOCTL_SYNCOBJ_QUERY DRM_IOWR(0xCB, struct drm_syncobj_timeline_query) +/** * Device specific ioctls should only be in their respective headers * The device specific ioctl range is from 0x40 to 0x9f.
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/5] drm: add timeline syncobj payload query ioctl v2
Am 02.11.18 um 09:25 schrieb Chunming Zhou:
Quoted 86 lines
user mode can query timeline payload.
v2: check return value ofcopy_to_userSigned-off-by Chunming Zhou <[email protected]>Cc Daniel Rakos <[email protected]>Cc Jason Ekstrand <[email protected]>Cc Bas Nieuwenhuizen <[email protected]>Cc Dave Airlie <[email protected]>Cc Christian König <[email protected]>Cc Chris Wilson <[email protected]>--- drivers/gpu/drm/drm_internal.h | 2 ++ drivers/gpu/drm/drm_ioctl.c | 2 ++ drivers/gpu/drm/drm_syncobj.c | 52 ++++++++++++++++++++++++++++++++++ include/uapi/drm/drm.h | 11 +++++++ 4 files changed, 67 insertions(+)drivers/gpu/drm/drm_internal.h +2
-0@@ -189,6 +189,8 @@ int drm_syncobj_reset_ioctl(struct drm_device *dev, void *data, struct drm_file *file_private);int drm_syncobj_signal_ioctl (struct drm_device *dev,void *data,struct drm_file *file_private); +int drm_syncobj_query_ioctl (struct drm_device *dev,void *data, +struct drm_file *file_private);/* drm_framebuffer.c */ void drm_framebuffer_print_info(struct drm_printer *p, unsigned int indent,drivers/gpu/drm/drm_ioctl.c +2
-0@@ -681,6 +681,8 @@ static const struct drm_ioctl_desc drm_ioctls[] = { DRM_UNLOCKED|DRM_RENDER_ALLOW),DRM_IOCTL_DEF (DRM_IOCTL_SYNCOBJ_SIGNAL , drm_syncobj_signal_ioctl,DRM_UNLOCKED |DRM_RENDER_ALLOW ), +DRM_IOCTL_DEF (DRM_IOCTL_SYNCOBJ_QUERY , drm_syncobj_query_ioctl, +DRM_UNLOCKED |DRM_RENDER_ALLOW ),DRM_IOCTL_DEF (DRM_IOCTL_CRTC_GET_SEQUENCE , drm_crtc_get_sequence_ioctl,DRM_UNLOCKED ),DRM_IOCTL_DEF (DRM_IOCTL_CRTC_QUEUE_SEQUENCE , drm_crtc_queue_sequence_ioctl,DRM_UNLOCKED ), DRM_IOCTL_DEF(DRM_IOCTL_MODE_CREATE_LEASE, drm_mode_create_lease_ioctl, DRM_MASTER|DRM_UNLOCKED),drivers/gpu/drm/drm_syncobj.c +35
-0@@ -1291,3 +1291,55 @@ drm_syncobj_signal_ioctl(struct drm_device *dev, void *data,return ret; } + +static void drm_syncobj_timeline_query_payload (struct drm_syncobj *syncobj, +uint64_t *point) +{ +if (syncobj->type !=DRM_SYNCOBJ_TYPE_TIMELINE ) { +DRM_ERROR ("Normal syncobj cann't be queried!" ); + *point =0 ; +return ; + } + *point = syncobj->signal_point; +} + +int drm_syncobj_query_ioctl (struct drm_device *dev,void *data, +struct drm_file *file_private) +{ +struct drm_syncobj_timeline_query *args = data; +struct drm_syncobj **syncobjs; +uint64_t *points; +uint32_t i; +int ret; + +if (!drm_core_check_feature (dev,DRIVER_SYNCOBJ )) +return -ENODEV ; + +if (args->count_handles ==0 ) +return -EINVAL ; + + ret =drm_syncobj_array_find (file_private, +u64_to_user_ptr (args->handles), + args->count_handles, + &syncobjs); +if (ret <0 ) +return ret; + +
drivers/gpu/drm/drm_syncobj.c drm_syncobj_signal_ioctl(struct drm_device *dev, void *data, · line 1338
Quoted 10 lines
drivers/gpu/drm/drm_syncobj.c +10
-0+ points =kmalloc_array (args->count_handles,sizeof (*points), +GFP_KERNEL ); +if (points ==NULL ) { + ret = -ENOMEM ; + goto out; + } +for (i =0 ; i < args->count_handles; i++) +drm_syncobj_timeline_query_payload (syncobjs[i], &points[i]); + ret =copy_to_user (u64_to_user_ptr (args->points), points, +sizeof (uint64_t ) * args->count_handles) ? -EFAULT :0 ;
Is it really better to allocate an array for this? Why not just handle it entry by entry?
Christian.
Quoted 28 lines
drivers/gpu/drm/drm_syncobj.c +7
-0+ +kfree (points); +out: +drm_syncobj_array_free (syncobjs, args->count_handles); + +return ret; +}include/uapi/drm/drm.h +9
-0@@ -771,6 +771,15 @@ struct drm_syncobj_array {__u32 pad; }; +struct drm_syncobj_timeline_query { +__u64 handles; +/* points are timeline syncobjs payloads returned by query ioctl */ +__u64 points; +__u32 count_handles; +__u32 pad; +}; + +/* Query current scanout sequence number */ struct drm_crtc_get_sequence {__u32 crtc_id;/* requested crtc_id */
include/uapi/drm/drm.h extern "C" { · line 944
Quoted 8 lines
include/uapi/drm/drm.h +2
-0@@ -928,6 +937,8 @@ extern "C" {#define DRM_IOCTL_MODE_REVOKE_LEASE DRM_IOWR(0xC9, struct drm_mode_revoke_lease)#define DRM_IOCTL_SYNCOBJ_TIMELINE_WAIT DRM_IOWR(0xCA, struct drm_syncobj_timeline_wait) +#define DRM_IOCTL_SYNCOBJ_QUERY DRM_IOWR(0xCB, struct drm_syncobj_timeline_query) +/** * Device specific ioctls should only be in their respective headers * The device specific ioctl range is from 0x40 to 0x9f.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 3/5 drm: add timeline support for syncobj export/import
In reply to Chunming Zhouuser space can specify timeline point fence to export/import.
--- drivers/gpu/drm/drm_internal.h | 4 ++ drivers/gpu/drm/drm_ioctl.c | 4 ++ drivers/gpu/drm/drm_syncobj.c | 76 ++++++++++++++++++++++++++++++---- include/uapi/drm/drm.h | 11 +++++ 4 files changed, 88 insertions(+), 7 deletions(-)
drivers/gpu/drm/drm_internal.h +4 -0
@@ -181,6 +181,10 @@ int drm_syncobj_handle_to_fd_ioctl(struct drm_device *dev, void *data, struct drm_file *file_private);int drm_syncobj_fd_to_handle_ioctl (struct drm_device *dev,void *data,struct drm_file *file_private); +int drm_syncobj_handle_to_fd_ioctl2 (struct drm_device *dev,void *data, +struct drm_file *file_private); +int drm_syncobj_fd_to_handle_ioctl2 (struct drm_device *dev,void *data, +struct drm_file *file_private);int drm_syncobj_wait_ioctl (struct drm_device *dev,void *data,struct drm_file *file_private); int drm_syncobj_timeline_wait_ioctl(struct drm_device *dev, void *data,
drivers/gpu/drm/drm_ioctl.c +4 -0
@@ -673,6 +673,10 @@ static const struct drm_ioctl_desc drm_ioctls[] = { DRM_UNLOCKED|DRM_RENDER_ALLOW),DRM_IOCTL_DEF (DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE , drm_syncobj_fd_to_handle_ioctl,DRM_UNLOCKED |DRM_RENDER_ALLOW ), +DRM_IOCTL_DEF (DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD2 , drm_syncobj_handle_to_fd_ioctl2, +DRM_UNLOCKED |DRM_RENDER_ALLOW ), +DRM_IOCTL_DEF (DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE2 , drm_syncobj_fd_to_handle_ioctl2, +DRM_UNLOCKED |DRM_RENDER_ALLOW ),DRM_IOCTL_DEF (DRM_IOCTL_SYNCOBJ_WAIT , drm_syncobj_wait_ioctl,DRM_UNLOCKED |DRM_RENDER_ALLOW ), DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_TIMELINE_WAIT, drm_syncobj_timeline_wait_ioctl,
drivers/gpu/drm/drm_syncobj.c +69 -7
121 lines not on this page · raw message
include/uapi/drm/drm.h +11 -0
@@ -735,6 +735,15 @@ struct drm_syncobj_handle {__s32 fd;__u32 pad; }; +struct drm_syncobj_handle2 { +__u32 handle; +__u32 flags; +__u64 point; + +__s32 fd; +__u32 pad; +}; +#define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALL (1 << 0)#define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT (1 << 1)
@@ -938,6 +947,8 @@ extern "C" {#define DRM_IOCTL_SYNCOBJ_TIMELINE_WAIT DRM_IOWR(0xCA, struct drm_syncobj_timeline_wait)#define DRM_IOCTL_SYNCOBJ_QUERY DRM_IOWR(0xCB, struct drm_syncobj_timeline_query) +#define DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD2 DRM_IOWR(0xCC, struct drm_syncobj_handle2) +#define DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE2 DRM_IOWR(0xCD, struct drm_syncobj_handle2)/** * Device specific ioctls should only be in their respective headers
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 3/5] drm: add timeline support for syncobj export/import
Am 02.11.18 um 09:25 schrieb Chunming Zhou:
Quoted 9 lines
user space can specify timeline point fence to export/import.
Signed-off-by Chunming Zhou <[email protected]>Cc Daniel Rakos <[email protected]>Cc Jason Ekstrand <[email protected]>Cc Bas Nieuwenhuizen <[email protected]>Cc Dave Airlie <[email protected]>Cc Christian König <[email protected]>Cc Chris Wilson <[email protected]>
From the coding it looks good to me, but I can't judge if that really makes sense to export/import individual points.
I would have rather expected that always the whole timeline is exported/imported. Otherwise the whole thing with waiting for sync points to appear doesn't really make sense to me.
Christian.
Quoted 188 lines
--- drivers/gpu/drm/drm_internal.h | 4 ++ drivers/gpu/drm/drm_ioctl.c | 4 ++ drivers/gpu/drm/drm_syncobj.c | 76 ++++++++++++++++++++++++++++++---- include/uapi/drm/drm.h | 11 +++++ 4 files changed, 88 insertions(+), 7 deletions(-)drivers/gpu/drm/drm_internal.h +4
-0@@ -181,6 +181,10 @@ int drm_syncobj_handle_to_fd_ioctl(struct drm_device *dev, void *data, struct drm_file *file_private);int drm_syncobj_fd_to_handle_ioctl (struct drm_device *dev,void *data,struct drm_file *file_private); +int drm_syncobj_handle_to_fd_ioctl2 (struct drm_device *dev,void *data, +struct drm_file *file_private); +int drm_syncobj_fd_to_handle_ioctl2 (struct drm_device *dev,void *data, +struct drm_file *file_private);int drm_syncobj_wait_ioctl (struct drm_device *dev,void *data,struct drm_file *file_private); int drm_syncobj_timeline_wait_ioctl(struct drm_device *dev, void *data,drivers/gpu/drm/drm_ioctl.c +4
-0@@ -673,6 +673,10 @@ static const struct drm_ioctl_desc drm_ioctls[] = { DRM_UNLOCKED|DRM_RENDER_ALLOW),DRM_IOCTL_DEF (DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE , drm_syncobj_fd_to_handle_ioctl,DRM_UNLOCKED |DRM_RENDER_ALLOW ), +DRM_IOCTL_DEF (DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD2 , drm_syncobj_handle_to_fd_ioctl2, +DRM_UNLOCKED |DRM_RENDER_ALLOW ), +DRM_IOCTL_DEF (DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE2 , drm_syncobj_fd_to_handle_ioctl2, +DRM_UNLOCKED |DRM_RENDER_ALLOW ),DRM_IOCTL_DEF (DRM_IOCTL_SYNCOBJ_WAIT , drm_syncobj_wait_ioctl,DRM_UNLOCKED |DRM_RENDER_ALLOW ), DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_TIMELINE_WAIT, drm_syncobj_timeline_wait_ioctl,drivers/gpu/drm/drm_syncobj.c +69
-7@@ -677,7 +677,7 @@ static int drm_syncobj_fd_to_handle(struct drm_file *file_private, }static int drm_syncobj_import_sync_file_fence (struct drm_file *file_private, -int fd,int handle) +int fd,int handle,uint64_t point) {struct dma_fence *fence =sync_file_get_fence (fd);struct drm_syncobj *syncobj;@@ -691,14 +691,14 @@ static int drm_syncobj_import_sync_file_fence(struct drm_file *file_private,return -ENOENT ; } -drm_syncobj_replace_fence (syncobj,0 , fence); +drm_syncobj_replace_fence (syncobj, point, fence);dma_fence_put (fence);drm_syncobj_put (syncobj);return 0 ; }static int drm_syncobj_export_sync_file (struct drm_file *file_private, -int handle,int *p_fd) +int handle,uint64_t point,int *p_fd) {int ret;struct dma_fence *fence;@@ -708,7 +708,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,0 ,0 , &fence); + ret =drm_syncobj_find_fence (file_private, handle, point,0 , &fence);if (ret) goto err_put_fd;@@ -817,9 +817,14 @@ drm_syncobj_handle_to_fd_ioctl(struct drm_device *dev, void *data, args->flags != DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE)return -EINVAL ; -if (args->flags &DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE ) +if (args->flags &DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE ) { +struct drm_syncobj *syncobj =drm_syncobj_find (file_private, + args->handle); +if (!syncobj || syncobj->type !=DRM_SYNCOBJ_TYPE_BINARY ) +return -EINVAL ;return drm_syncobj_export_sync_file (file_private, args->handle, - &args->fd); +0 , &args->fd); + }return drm_syncobj_handle_to_fd (file_private, args->handle, &args->fd);@@ -841,15 +846,72 @@ drm_syncobj_fd_to_handle_ioctl(struct drm_device *dev, void *data, args->flags != DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_IMPORT_SYNC_FILE) return -EINVAL; +if (args->flags &DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_IMPORT_SYNC_FILE ) { +struct drm_syncobj *syncobj =drm_syncobj_find (file_private, + args->handle); +if (!syncobj || syncobj->type !=DRM_SYNCOBJ_TYPE_BINARY ) +return -EINVAL ; +return drm_syncobj_import_sync_file_fence (file_private, + args->fd, + args->handle, +0 ); + } + +return drm_syncobj_fd_to_handle (file_private, args->fd, + &args->handle); +} + +int +drm_syncobj_handle_to_fd_ioctl2 (struct drm_device *dev,void *data, +struct drm_file *file_private) +{ +struct drm_syncobj_handle2 *args = data; + +if (!drm_core_check_feature (dev,DRIVER_SYNCOBJ )) +return -ENODEV ; + +if (args->pad) +return -EINVAL ; + +if (args->flags !=0 && + args->flags !=DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE ) +return -EINVAL ; + +if (args->flags &DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE ) +return drm_syncobj_export_sync_file (file_private, args->handle, + args->point, &args->fd); + +return drm_syncobj_handle_to_fd (file_private, args->handle, + &args->fd); +} + +int +drm_syncobj_fd_to_handle_ioctl2 (struct drm_device *dev,void *data, +struct drm_file *file_private) +{ +struct drm_syncobj_handle2 *args = data; + +if (!drm_core_check_feature (dev,DRIVER_SYNCOBJ )) +return -ENODEV ; + +if (args->pad) +return -EINVAL ; + +if (args->flags !=0 && + args->flags !=DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_IMPORT_SYNC_FILE ) +return -EINVAL ; +if (args->flags &DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_IMPORT_SYNC_FILE )return drm_syncobj_import_sync_file_fence (file_private, args->fd, - args->handle); + args->handle, + args->point);return drm_syncobj_fd_to_handle (file_private, args->fd, &args->handle); } +struct syncobj_wait_entry {struct task_struct *task;struct dma_fence *fence;include/uapi/drm/drm.h +9
-0@@ -735,6 +735,15 @@ struct drm_syncobj_handle {__s32 fd;__u32 pad; }; +struct drm_syncobj_handle2 { +__u32 handle; +__u32 flags; +__u64 point; + +__s32 fd; +__u32 pad; +}; +#define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALL (1 << 0)#define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT (1 << 1)
include/uapi/drm/drm.h extern "C" { · line 954
Quoted 8 lines
include/uapi/drm/drm.h +2
-0@@ -938,6 +947,8 @@ extern "C" {#define DRM_IOCTL_SYNCOBJ_TIMELINE_WAIT DRM_IOWR(0xCA, struct drm_syncobj_timeline_wait)#define DRM_IOCTL_SYNCOBJ_QUERY DRM_IOWR(0xCB, struct drm_syncobj_timeline_query) +#define DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD2 DRM_IOWR(0xCC, struct drm_syncobj_handle2) +#define DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE2 DRM_IOWR(0xCD, struct drm_syncobj_handle2)/** * Device specific ioctls should only be in their respective headers
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 3/5] drm: add timeline support for syncobj export/import
Quoted 11 lines · Christian König
Am 02.11.18 um 09:25 schrieb Chunming Zhou:
Quoted 9 lines
user space can specify timeline point fence to export/import.
Signed-off-by Chunming Zhou <[email protected]>Cc Daniel Rakos <[email protected]>Cc Jason Ekstrand <[email protected]>Cc Bas Nieuwenhuizen <[email protected]>Cc Dave Airlie <[email protected]>Cc Christian König <[email protected]>Cc Chris Wilson <[email protected]>
Quoted 3 lines
From the coding it looks good to me, but I can't judge if that really makes sense to export/import individual points.
I would have rather expected that always the whole timeline is exported/imported. Otherwise the whole thing with waiting for sync points to appear doesn't really make sense to me.
We can Cpu wait on individual points, why can not we export/import them?
I confirmed with Daniel before, he said the extension need both them, export/import individual points and export/import the whole timeline semaphore. More discussion is https://gitlab.khronos.org/vulkan/vulkan/merge_requests/2696
Thanks,
David Zhou
Quoted 189 lines
Christian.
Quoted 186 lines
---
drivers/gpu/drm/drm_internal.h| 4 ++ drivers/gpu/drm/drm_ioctl.c | 4 ++ drivers/gpu/drm/drm_syncobj.c | 76 ++++++++++++++++++++++++++++++---- include/uapi/drm/drm.h | 11 +++++4 files changed, 88 insertions(+), 7 deletions(-)drivers/gpu/drm/drm_internal.h +4
-0@@ -181,6 +181,10 @@ int drm_syncobj_handle_to_fd_ioctl(struct drm_device *dev, void *data, struct drm_file *file_private); int drm_syncobj_fd_to_handle_ioctl(struct drm_device *dev, void *data, struct drm_file *file_private); +int drm_syncobj_handle_to_fd_ioctl2 (struct drm_device *dev,void *data, + struct drm_file *file_private); +int drm_syncobj_fd_to_handle_ioctl2 (struct drm_device *dev,void *data, + struct drm_file *file_private); int drm_syncobj_wait_ioctl(struct drm_device *dev, void *data, struct drm_file *file_private);int drm_syncobj_timeline_wait_ioctl(struct
drm_device*dev, void *data,drivers/gpu/drm/drm_ioctl.c +4
-0@@ -673,6 +673,10 @@ static const struct drm_ioctl_desc drm_ioctls[] = { DRM_UNLOCKED|DRM_RENDER_ALLOW), DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE, drm_syncobj_fd_to_handle_ioctl, DRM_UNLOCKED|DRM_RENDER_ALLOW), + DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD2, drm_syncobj_handle_to_fd_ioctl2, + DRM_UNLOCKED|DRM_RENDER_ALLOW), + DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE2, drm_syncobj_fd_to_handle_ioctl2, + DRM_UNLOCKED|DRM_RENDER_ALLOW), DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_WAIT, drm_syncobj_wait_ioctl,DRM_UNLOCKED|DRM_RENDER_ALLOW), DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_TIMELINE_WAIT,
drm_syncobj_timeline_wait_ioctl,drivers/gpu/drm/drm_syncobj.c +4
-2@@ -677,7 +677,7 @@ static int drm_syncobj_fd_to_handle(structdrm_file *file_private, } static int drm_syncobj_import_sync_file_fence(struct drm_file *file_private, - int fd, int handle) + int fd, int handle, uint64_t point) { struct dma_fence *fence = sync_file_get_fence(fd); struct drm_syncobj *syncobj;@@ -691,14 +691,14 @@ static int drm_syncobj_import_sync_file_fence(struct drm_file *file_private, return -ENOENT; } - drm_syncobj_replace_fence(syncobj, 0, fence); + drm_syncobj_replace_fence(syncobj, point, fence); dma_fence_put(fence); drm_syncobj_put(syncobj); return 0; } static int drm_syncobj_export_sync_file(struct drm_file *file_private, - int handle, int *p_fd) + int handle, uint64_t point, int *p_fd) { int ret; struct dma_fence *fence;@@ -708,7 +708,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, 0, 0, &fence); + ret = drm_syncobj_find_fence(file_private, handle, point, 0, &fence); if (ret)goto
err_put_fd;
@@ -817,9 +817,14 @@drm_syncobj_handle_to_fd_ioctl(struct drm_device *dev, void *data, args->flags != DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE)return-EINVAL;
- if (args->flags&DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE)
+ if (args->flags&DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE) {
+ structdrm_syncobj*syncobj = drm_syncobj_find(file_private,
+args->handle);
+ if (!syncobj ||syncobj->type!=DRM_SYNCOBJ_TYPE_BINARY)
+ return-EINVAL;
return drm_syncobj_export_sync_file(file_private,args->handle,
-&args->fd);
+ 0,&args->fd);
+ }
returndrm_syncobj_handle_to_fd(file_private, args->handle, &args->fd);drivers/gpu/drm/drm_syncobj.c +56
-1@@ -841,15 +846,72 @@ drm_syncobj_fd_to_handle_ioctl(struct drm_device *dev, void *data, args->flags != DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_IMPORT_SYNC_FILE) return -EINVAL; + if (args->flags & DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_IMPORT_SYNC_FILE) { + struct drm_syncobj *syncobj = drm_syncobj_find(file_private, + args->handle); + if (!syncobj || syncobj->type != DRM_SYNCOBJ_TYPE_BINARY) + return -EINVAL; + return drm_syncobj_import_sync_file_fence(file_private, + args->fd, + args->handle, + 0); + } + + return drm_syncobj_fd_to_handle(file_private, args->fd, + &args->handle); +} + +int +drm_syncobj_handle_to_fd_ioctl2 (struct drm_device *dev,void *data, + struct drm_file *file_private) +{ + struct drm_syncobj_handle2 *args = data; + + if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ)) + return -ENODEV; + + if (args->pad) + return -EINVAL; + + if (args->flags != 0 && + args->flags != DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE) + return -EINVAL; + + if (args->flags & DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE) + return drm_syncobj_export_sync_file(file_private, args->handle, + args->point, &args->fd); + + return drm_syncobj_handle_to_fd(file_private, args->handle, + &args->fd); +} + +int +drm_syncobj_fd_to_handle_ioctl2 (struct drm_device *dev,void *data, + struct drm_file *file_private) +{ + struct drm_syncobj_handle2 *args = data; + + if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ)) + return -ENODEV; + + if (args->pad) + return -EINVAL; + + if (args->flags != 0 && + args->flags != DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_IMPORT_SYNC_FILE) + return -EINVAL; + if (args->flags & DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_IMPORT_SYNC_FILE) return drm_syncobj_import_sync_file_fence(file_private, args->fd, - args->handle); + args->handle, + args->point); return drm_syncobj_fd_to_handle(file_private, args->fd, &args->handle); }+
structsyncobj_wait_entry{
structtask_struct*task;
structdma_fence*fence;include/uapi/drm/drm.h +9
-0@@ -735,6 +735,15 @@ struct drm_syncobj_handle { __s32 fd; __u32 pad; }; +struct drm_syncobj_handle2 { + __u32 handle; + __u32 flags; + __u64 point; + + __s32 fd; + __u32 pad; +}; + #define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALL (1 << 0) #define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT (1 << 1)@@ -938,6 +947,8 @@ extern "C" {
Quoted 9 lines
include/uapi/drm/drm.h extern "C" { · line 954
Quoted 8 lines
include/uapi/drm/drm.h +2
-0#define DRM_IOCTL_SYNCOBJ_TIMELINE_WAIT DRM_IOWR(0xCA, struct drm_syncobj_timeline_wait) #define DRM_IOCTL_SYNCOBJ_QUERY DRM_IOWR(0xCB, struct drm_syncobj_timeline_query) +#define DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD2 DRM_IOWR(0xCC, struct drm_syncobj_handle2) +#define DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE2 DRM_IOWR(0xCD, struct drm_syncobj_handle2) /*** Device specific ioctls should only be in their respective headers
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Koenig, Christian
maintainerRe: [PATCH 3/5] drm: add timeline support for syncobj export/import
Am 02.11.18 um 10:42 schrieb zhoucm1:
Quoted 20 lines · Christian König
Quoted 11 lines
Am 02.11.18 um 09:25 schrieb Chunming Zhou:
Quoted 9 lines
user space can specify timeline point fence to export/import.
Signed-off-by Chunming Zhou <[email protected]>Cc Daniel Rakos <[email protected]>Cc Jason Ekstrand <[email protected]>Cc Bas Nieuwenhuizen <[email protected]>Cc Dave Airlie <[email protected]>Cc Christian König <[email protected]>Cc Chris Wilson <[email protected]>Quoted 6 lines
From the coding it looks good to me, but I can't judge if that really makes sense to export/import individual points.
I would have rather expected that always the whole timeline is exported/imported. Otherwise the whole thing with waiting for sync points to appear doesn't really make sense to me.
Quoted 6 lines
We can Cpu wait on individual points, why can not we export/import them? I confirmed with Daniel before, he said the extension need both them, export/import individual points and export/import the whole timeline semaphore.
More discussion is
https://gitlab.khronos.org/vulkan/vulkan/merge_requests/2696
Ah! It looked initially to me that this was the only way to export/import timeline sync objects.
Thinking more about it wouldn't it be better to provide a function to signal a sync point from another sync point?
That would provide the same functionality, would be cleaner to implement and more flexible on top.
E.g. if you want to export only a specific sync point you first create a new syncobj and the move over this sync point into the syncobj.
Otherwise you mix multiple operations into one IOCTL and that is usually not a good idea.
Regards,
Christian.
Quoted 227 lines
Thanks,
David ZhouQuoted 223 lines
Christian.
Quoted 219 lines
---
drivers/gpu/drm/drm_internal.h| 4 ++ drivers/gpu/drm/drm_ioctl.c | 4 ++ drivers/gpu/drm/drm_syncobj.c | 76
++++++++++++++++++++++++++++++----
include/uapi/drm/drm.h | 11 +++++4 files changed, 88 insertions(+), 7 deletions(-)drivers/gpu/drm/drm_internal.h +0
-0@@ -181,6 +181,10 @@ int drm_syncobj_handle_to_fd_ioctl(struct drm_device *dev, void *data, struct drm_file *file_private);int drm_syncobj_fd_to_handle_ioctl(struct
drm_device*dev, void *data,
structdrm_file*file_private); +int drm_syncobj_handle_to_fd_ioctl2(structdrm_device*dev, void *data,
+ structdrm_file*file_private); +int drm_syncobj_fd_to_handle_ioctl2(structdrm_device*dev, void *data,
+ structdrm_file*file_private); intdrm_syncobj_wait_ioctl(struct drm_device *dev, void *data, struct drm_file *file_private);
int drm_syncobj_timeline_wait_ioctl(structdrm_device*dev, void *data,drivers/gpu/drm/drm_ioctl.c +3
-0@@ -673,6 +673,10 @@ static const struct drm_ioctl_desc drm_ioctls[] = { DRM_UNLOCKED|DRM_RENDER_ALLOW), DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE, drm_syncobj_fd_to_handle_ioctl, DRM_UNLOCKED|DRM_RENDER_ALLOW), + DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD2, drm_syncobj_handle_to_fd_ioctl2, + DRM_UNLOCKED|DRM_RENDER_ALLOW), + DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE2,
drm_syncobj_fd_to_handle_ioctl2,
+ DRM_UNLOCKED|DRM_RENDER_ALLOW),DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_WAIT, drm_syncobj_wait_ioctl, DRM_UNLOCKED|DRM_RENDER_ALLOW), DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_TIMELINE_WAIT,drm_syncobj_timeline_wait_ioctl,drivers/gpu/drm/drm_syncobj.c +0
-0@@ -677,7 +677,7 @@ static int drm_syncobj_fd_to_handle(struct drm_file *file_private, }static int drm_syncobj_import_sync_file_fence(struct
drm_file*file_private,
- int fd, int handle)
+ int fd, int handle,uint64_tpoint) {
structdma_fence*fence =sync_file_get_fence(fd); structdrm_syncobj*syncobj;drivers/gpu/drm/drm_syncobj.c +1
-0@@ -691,14 +691,14 @@ static int drm_syncobj_import_sync_file_fence(struct drm_file *file_private, return -ENOENT; } - drm_syncobj_replace_fence(syncobj, 0, fence); + drm_syncobj_replace_fence(syncobj, point, fence); dma_fence_put(fence); drm_syncobj_put(syncobj); return 0; }static int drm_syncobj_export_sync_file(struct
drm_file*file_private,
- int handle, int*p_fd)
+ int handle,uint64_tpoint, int*p_fd) {
int ret;
structdma_fence*fence;drivers/gpu/drm/drm_syncobj.c +1
-0@@ -708,7 +708,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, 0, 0, &fence); + ret = drm_syncobj_find_fence(file_private, handle, point, 0, &fence);if (ret)
gotoerr_put_fd;
@@ -817,9 +817,14 @@ drm_syncobj_handle_to_fd_ioctl(structdrm_device*dev, void *data,
args->flags!=DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE)
return-EINVAL;
- if (args->flags&DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE)
+ if (args->flags&DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE) {
+ structdrm_syncobj*syncobj =drm_syncobj_find(file_private, + args->handle);
+ if (!syncobj ||syncobj->type!=DRM_SYNCOBJ_TYPE_BINARY) + return-EINVAL;
return drm_syncobj_export_sync_file(file_private,args->handle,
-&args->fd);
+ 0,&args->fd);
+ }
returndrm_syncobj_handle_to_fd(file_private, args->handle, &args->fd);drivers/gpu/drm/drm_syncobj.c +0
-0@@ -841,15 +846,72 @@ drm_syncobj_fd_to_handle_ioctl(struct drm_device *dev, void *data,
args->flags!=DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_IMPORT_SYNC_FILE)
return-EINVAL;
+ if (args->flags&DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_IMPORT_SYNC_FILE) {
+ structdrm_syncobj*syncobj =drm_syncobj_find(file_private, + args->handle);
+ if (!syncobj ||syncobj->type!=DRM_SYNCOBJ_TYPE_BINARY) + return-EINVAL;
+ return drm_syncobj_import_sync_file_fence(file_private, +args->fd,
+args->handle,
+ 0);
+ }drivers/gpu/drm/drm_syncobj.c +19
-0+ + return drm_syncobj_fd_to_handle(file_private, args->fd, + &args->handle); +} + +int +drm_syncobj_handle_to_fd_ioctl2(struct drm_device *dev, void *data, + struct drm_file *file_private) +{ + struct drm_syncobj_handle2 *args = data; + + if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ)) + return -ENODEV; + + if (args->pad) + return -EINVAL; + + if (args->flags != 0 && + args->flags !=
DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE)
+ return-EINVAL;
+
+ if (args->flags&DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE) + return drm_syncobj_export_sync_file(file_private,args->handle,
+args->point,&args->fd);drivers/gpu/drm/drm_syncobj.c +19
-0+ + return drm_syncobj_handle_to_fd(file_private, args->handle, + &args->fd); +} + +int +drm_syncobj_fd_to_handle_ioctl2(struct drm_device *dev, void *data, + struct drm_file *file_private) +{ + struct drm_syncobj_handle2 *args = data; + + if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ)) + return -ENODEV; + + if (args->pad) + return -EINVAL; + + if (args->flags != 0 && + args->flags !=
DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_IMPORT_SYNC_FILE)
+ return-EINVAL;
+
if (args->flags&DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_IMPORT_SYNC_FILE)
return drm_syncobj_import_sync_file_fence(file_private,args->fd,
-args->handle);
+args->handle,
+args->point);
returndrm_syncobj_fd_to_handle(file_private, args->fd, &args->handle);
}
+
structsyncobj_wait_entry{
structtask_struct*task;
structdma_fence*fence;include/uapi/drm/drm.h +11
-0@@ -735,6 +735,15 @@ struct drm_syncobj_handle { __s32 fd; __u32 pad; }; +struct drm_syncobj_handle2 { + __u32 handle; + __u32 flags; + __u64 point; + + __s32 fd; + __u32 pad; +}; + #define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALL (1 << 0) #define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT (1 << 1)@@ -938,6 +947,8 @@ extern "C" { #define DRM_IOCTL_SYNCOBJ_TIMELINE_WAIT DRM_IOWR(0xCA, struct drm_syncobj_timeline_wait) #define DRM_IOCTL_SYNCOBJ_QUERY DRM_IOWR(0xCB, struct drm_syncobj_timeline_query) +#define DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD2 DRM_IOWR(0xCC, struct drm_syncobj_handle2) +#define DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE2 DRM_IOWR(0xCD, struct drm_syncobj_handle2)/**
* Device specific ioctls should only be in their respective headers
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 3/5] drm: add timeline support for syncobj export/import
Quoted 28 lines · Christian
Am 02.11.18 um 10:42 schrieb zhoucm1:
Quoted 18 lines · Christian König
Quoted 10 lines
Am 02.11.18 um 09:25 schrieb Chunming Zhou:
Quoted 9 lines
user space can specify timeline point fence to export/import.
Signed-off-by Chunming Zhou <[email protected]>Cc Daniel Rakos <[email protected]>Cc Jason Ekstrand <[email protected]>Cc Bas Nieuwenhuizen <[email protected]>Cc Dave Airlie <[email protected]>Cc Christian König <[email protected]>Cc Chris Wilson <[email protected]>Quoted 6 lines
From the coding it looks good to me, but I can't judge if that really
makes sense to export/import individual points.I would have rather expected that always the whole timeline is exported/imported. Otherwise the whole thing with waiting for sync points to appear doesn't really make sense to me.
Quoted 6 lines
We can Cpu wait on individual points, why can not we export/import them? I confirmed with Daniel before, he said the extension need both them, export/import individual points and export/import the whole timeline semaphore.
More discussion is
https://gitlab.khronos.org/vulkan/vulkan/merge_requests/2696Ah! It looked initially to me that this was the only way to export/import timeline sync objects.
Quoted 8 lines
Thinking more about it wouldn't it be better to provide a function to signal a sync point from another sync point?
That would provide the same functionality, would be cleaner to implement and more flexible on top.
E.g. if you want to export only a specific sync point you first create a new syncobj and the move over this sync point into the syncobj.
Sorry, I didn't completely get your means. Could you detail a bit? but I think we need to meet export/import goals:
1. export sepcific sync point or binary syncobj fence to sync file fd or handle.
2. import fence from fd/handle to timeline sync point or banory syncobj.
3. export/import the whole timeline seamphore.
I'm still not sure how you mentioned can achieve these.
Thanks,
David
Quoted 222 lines
Otherwise you mix multiple operations into one IOCTL and that is usually not a good idea.
Regards,
Christian.Quoted 215 lines
Thanks,
David ZhouQuoted 213 lines
Christian.
Quoted 211 lines
--- drivers/gpu/drm/drm_internal.h | 4 ++ drivers/gpu/drm/drm_ioctl.c | 4 ++ drivers/gpu/drm/drm_syncobj.c | 76 ++++++++++++++++++++++++++++++---- include/uapi/drm/drm.h | 11 +++++ 4 files changed, 88 insertions(+), 7 deletions(-)drivers/gpu/drm/drm_internal.h +3
-0@@ -181,6 +181,10 @@ int drm_syncobj_handle_to_fd_ioctl(struct drm_device *dev, void *data, struct drm_file *file_private); int drm_syncobj_fd_to_handle_ioctl(struct drm_device *dev, void *data, struct drm_file *file_private); +int drm_syncobj_handle_to_fd_ioctl2 (struct drm_device *dev,void *data, + struct drm_file *file_private); +int drm_syncobj_fd_to_handle_ioctl2(struct drm_device *dev, void*data,
+ structdrm_file*file_private);
intdrm_syncobj_wait_ioctl(struct drm_device *dev, void *data, struct drm_file *file_private);
int drm_syncobj_timeline_wait_ioctl(structdrm_device*dev, void
*data,drivers/gpu/drm/drm_ioctl.c +3
-0@@ -673,6 +673,10 @@ static const struct drm_ioctl_desc drm_ioctls[] = { DRM_UNLOCKED|DRM_RENDER_ALLOW), DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE, drm_syncobj_fd_to_handle_ioctl, DRM_UNLOCKED|DRM_RENDER_ALLOW), + DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD2, drm_syncobj_handle_to_fd_ioctl2, + DRM_UNLOCKED|DRM_RENDER_ALLOW), + DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE2,
drm_syncobj_fd_to_handle_ioctl2,
+ DRM_UNLOCKED|DRM_RENDER_ALLOW),
DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_WAIT, drm_syncobj_wait_ioctl, DRM_UNLOCKED|DRM_RENDER_ALLOW), DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_TIMELINE_WAIT,drm_syncobj_timeline_wait_ioctl,drivers/gpu/drm/drm_syncobj.c +1
-1@@ -677,7 +677,7 @@ static int drm_syncobj_fd_to_handle(structdrm_file *file_private, } static int drm_syncobj_import_sync_file_fence(struct drm_file *file_private, - int fd, int handle) + int fd, int handle, uint64_t point) { struct dma_fence *fence = sync_file_get_fence(fd);struct
drm_syncobj*syncobj;drivers/gpu/drm/drm_syncobj.c +3
-1@@ -691,14 +691,14 @@ static int drm_syncobj_import_sync_file_fence(struct drm_file *file_private, return -ENOENT; } - drm_syncobj_replace_fence(syncobj, 0, fence); + drm_syncobj_replace_fence(syncobj, point, fence); dma_fence_put(fence); drm_syncobj_put(syncobj); return 0; } static int drm_syncobj_export_sync_file(struct drm_file *file_private, - int handle, int *p_fd) + int handle, uint64_t point, int *p_fd) { int ret; struct dma_fence *fence;@@ -708,7 +708,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, 0, 0, &fence); + ret = drm_syncobj_find_fence(file_private, handle, point, 0, &fence); if (ret) goto err_put_fd; @@ -817,9 +817,14 @@ drm_syncobj_handle_to_fd_ioctl(struct
drm_device*dev, void *data,
args->flags!=DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE)
return-EINVAL;
- if (args->flags&DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE)
+ if (args->flags&DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE) {
+ structdrm_syncobj*syncobj =drm_syncobj_find(file_private, + args->handle);
+ if (!syncobj ||syncobj->type!=DRM_SYNCOBJ_TYPE_BINARY) + return-EINVAL;
return drm_syncobj_export_sync_file(file_private,args->handle,
-&args->fd);
+ 0,&args->fd);
+ }
returndrm_syncobj_handle_to_fd(file_private, args->handle, &args->fd);drivers/gpu/drm/drm_syncobj.c +56
-1@@ -841,15 +846,72 @@ drm_syncobj_fd_to_handle_ioctl(struct drm_device *dev, void *data, args->flags != DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_IMPORT_SYNC_FILE) return -EINVAL; + if (args->flags &DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_IMPORT_SYNC_FILE ) { + struct drm_syncobj *syncobj = drm_syncobj_find(file_private, + args->handle); + if (!syncobj || syncobj->type != DRM_SYNCOBJ_TYPE_BINARY) + return -EINVAL; + return drm_syncobj_import_sync_file_fence(file_private, + args->fd, + args->handle, + 0); + } + + return drm_syncobj_fd_to_handle(file_private, args->fd, + &args->handle); +} + +int +drm_syncobj_handle_to_fd_ioctl2 (struct drm_device *dev,void *data, + struct drm_file *file_private) +{ + struct drm_syncobj_handle2 *args = data; + + if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ)) + return -ENODEV; + + if (args->pad) + return -EINVAL; + + if (args->flags != 0 && + args->flags !=DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE ) + return -EINVAL; + + if (args->flags & DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE) + return drm_syncobj_export_sync_file(file_private, args->handle, + args->point, &args->fd); + + return drm_syncobj_handle_to_fd(file_private, args->handle, + &args->fd); +} + +int +drm_syncobj_fd_to_handle_ioctl2 (struct drm_device *dev,void *data, + struct drm_file *file_private) +{ + struct drm_syncobj_handle2 *args = data; + + if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ)) + return -ENODEV; + + if (args->pad) + return -EINVAL; + + if (args->flags != 0 && + args->flags !=DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_IMPORT_SYNC_FILE ) + return -EINVAL; + if (args->flags &DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_IMPORT_SYNC_FILE ) return drm_syncobj_import_sync_file_fence(file_private, args->fd, - args->handle); + args->handle, + args->point); return drm_syncobj_fd_to_handle(file_private, args->fd, &args->handle); } + struct syncobj_wait_entry { struct task_struct *task; struct dma_fence *fence;include/uapi/drm/drm.h +9
-0@@ -735,6 +735,15 @@ struct drm_syncobj_handle { __s32 fd; __u32 pad; }; +struct drm_syncobj_handle2 { + __u32 handle; + __u32 flags; + __u64 point; + + __s32 fd; + __u32 pad; +}; + #define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALL (1 << 0) #define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT (1 << 1)@@ -938,6 +947,8 @@ extern "C" { #define DRM_IOCTL_SYNCOBJ_TIMELINE_WAIT DRM_IOWR(0xCA, struct drm_syncobj_timeline_wait)
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
include/uapi/drm/drm.h +2
-0#define DRM_IOCTL_SYNCOBJ_QUERY DRM_IOWR(0xCB, struct drm_syncobj_timeline_query) +#define DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD2 DRM_IOWR(0xCC, struct drm_syncobj_handle2) +#define DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE2 DRM_IOWR(0xCD, struct drm_syncobj_handle2)/**
* Device specific ioctls should only be in their respective headers
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Koenig, Christian
maintainerRe: [PATCH 3/5] drm: add timeline support for syncobj export/import
Am 02.11.18 um 11:34 schrieb zhoucm1:
Quoted 37 lines · Christian
Quoted 35 lines
Am 02.11.18 um 10:42 schrieb zhoucm1:
Quoted 18 lines · Christian König
Quoted 10 lines
Am 02.11.18 um 09:25 schrieb Chunming Zhou:
Quoted 9 lines
user space can specify timeline point fence to export/import.
Signed-off-by Chunming Zhou <[email protected]>Cc Daniel Rakos <[email protected]>Cc Jason Ekstrand <[email protected]>Cc Bas Nieuwenhuizen <[email protected]>Cc Dave Airlie <[email protected]>Cc Christian König <[email protected]>Cc Chris Wilson <[email protected]>Quoted 6 lines
From the coding it looks good to me, but I can't judge if that really makes sense to export/import individual points.
I would have rather expected that always the whole timeline is exported/imported. Otherwise the whole thing with waiting for sync points to appear doesn't really make sense to me.
Quoted 7 lines
We can Cpu wait on individual points, why can not we export/import them?
I confirmed with Daniel before, he said the extension need both them, export/import individual points and export/import the whole timeline semaphore.
More discussion is
https://gitlab.khronos.org/vulkan/vulkan/merge_requests/2696Ah! It looked initially to me that this was the only way to export/import timeline sync objects.
Thinking more about it wouldn't it be better to provide a function to signal a sync point from another sync point?
That would provide the same functionality, would be cleaner to implement and more flexible on top.
Quoted 6 lines
Quoted 2 lines
E.g. if you want to export only a specific sync point you first create a new syncobj and the move over this sync point into the syncobj.
Sorry, I didn't completely get your means. Could you detail a bit? but I think we need to meet export/import goals:
1. export sepcific sync point or binary syncobj fence to sync file fd or handle.
Well that is not an export nor import in the sense of the existing API because it creates new objects while the existing export function just return a different type of handle for the same object.
Quoted 1 line
2. import fence from fd/handle to timeline sync point or banory syncobj.
My idea is to have a "transfer" function which says signal this syncobj from this other syncobj (both can either be timeline or binary).
This way you can handle quite a bunch of use cases with just a single function.
E.g. export a specific timeline point into an fd: Create a new syncobj, transfer your sync pointer from the existing object to that one, export it as fd.
Converting a timeline synobj into a binary: Create a new binary syncobj, transfer the last sync point from the existing to that new one.
etc etc...
Regards,
Christian.
Quoted 231 lines
3. export/import the whole timeline seamphore.
I'm still not sure how you mentioned can achieve these.
Thanks,
DavidQuoted 225 lines
Otherwise you mix multiple operations into one IOCTL and that is usually not a good idea.
Regards,
Christian.Quoted 218 lines
Thanks,
David ZhouQuoted 216 lines
Christian.
Quoted 214 lines
---
drivers/gpu/drm/drm_internal.h| 4 ++ drivers/gpu/drm/drm_ioctl.c | 4 ++ drivers/gpu/drm/drm_syncobj.c | 76
++++++++++++++++++++++++++++++----
include/uapi/drm/drm.h | 11 +++++4 files changed, 88 insertions(+), 7 deletions(-)drivers/gpu/drm/drm_internal.h +0
-0@@ -181,6 +181,10 @@ int drm_syncobj_handle_to_fd_ioctl(struct drm_device *dev, void *data, struct drm_file *file_private);int drm_syncobj_fd_to_handle_ioctl(struct
drm_device*dev, void *data,
structdrm_file*file_private); +int drm_syncobj_handle_to_fd_ioctl2(structdrm_device*dev, void *data,
+ structdrm_file*file_private); +int drm_syncobj_fd_to_handle_ioctl2(structdrm_device*dev, void *data,
+ structdrm_file*file_private);
intdrm_syncobj_wait_ioctl(struct drm_device *dev, void *data, struct drm_file *file_private);
int drm_syncobj_timeline_wait_ioctl(structdrm_device*dev, void *data,drivers/gpu/drm/drm_ioctl.c +3
-0@@ -673,6 +673,10 @@ static const struct drm_ioctl_desc drm_ioctls[] = { DRM_UNLOCKED|DRM_RENDER_ALLOW), DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE, drm_syncobj_fd_to_handle_ioctl, DRM_UNLOCKED|DRM_RENDER_ALLOW), + DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD2, drm_syncobj_handle_to_fd_ioctl2, + DRM_UNLOCKED|DRM_RENDER_ALLOW), + DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE2,
drm_syncobj_fd_to_handle_ioctl2,
+ DRM_UNLOCKED|DRM_RENDER_ALLOW),DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_WAIT, drm_syncobj_wait_ioctl, DRM_UNLOCKED|DRM_RENDER_ALLOW), DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_TIMELINE_WAIT,drm_syncobj_timeline_wait_ioctl,drivers/gpu/drm/drm_syncobj.c +0
-0@@ -677,7 +677,7 @@ static int drm_syncobj_fd_to_handle(struct drm_file *file_private, }static int drm_syncobj_import_sync_file_fence(struct
drm_file*file_private,
- int fd, int handle)
+ int fd, int handle,uint64_tpoint) {
structdma_fence*fence =sync_file_get_fence(fd); structdrm_syncobj*syncobj;drivers/gpu/drm/drm_syncobj.c +1
-0@@ -691,14 +691,14 @@ static int drm_syncobj_import_sync_file_fence(struct drm_file *file_private, return -ENOENT; } - drm_syncobj_replace_fence(syncobj, 0, fence); + drm_syncobj_replace_fence(syncobj, point, fence); dma_fence_put(fence); drm_syncobj_put(syncobj); return 0; }static int drm_syncobj_export_sync_file(struct
drm_file*file_private,
- int handle, int*p_fd)
+ int handle,uint64_tpoint, int*p_fd) {
int ret;
structdma_fence*fence;drivers/gpu/drm/drm_syncobj.c +1
-0@@ -708,7 +708,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, 0, 0, &fence); + ret = drm_syncobj_find_fence(file_private, handle, point, 0, &fence);if (ret)
gotoerr_put_fd;
@@ -817,9 +817,14 @@ drm_syncobj_handle_to_fd_ioctl(structdrm_device*dev, void *data,
args->flags!=DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE)
return-EINVAL;
- if (args->flags&DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE)
+ if (args->flags&DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE) {
+ structdrm_syncobj*syncobj =drm_syncobj_find(file_private, + args->handle);
+ if (!syncobj ||syncobj->type!=DRM_SYNCOBJ_TYPE_BINARY) + return-EINVAL;
return drm_syncobj_export_sync_file(file_private,args->handle,
-&args->fd);
+ 0,&args->fd);
+ }
returndrm_syncobj_handle_to_fd(file_private, args->handle, &args->fd);drivers/gpu/drm/drm_syncobj.c +0
-0@@ -841,15 +846,72 @@ drm_syncobj_fd_to_handle_ioctl(struct drm_device *dev, void *data,
args->flags!=DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_IMPORT_SYNC_FILE)
return-EINVAL;
+ if (args->flags&DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_IMPORT_SYNC_FILE) {
+ structdrm_syncobj*syncobj =drm_syncobj_find(file_private, + args->handle);
+ if (!syncobj ||syncobj->type!=DRM_SYNCOBJ_TYPE_BINARY) + return-EINVAL;
+ return drm_syncobj_import_sync_file_fence(file_private, +args->fd,
+args->handle,
+ 0);
+ }drivers/gpu/drm/drm_syncobj.c +19
-0+ + return drm_syncobj_fd_to_handle(file_private, args->fd, + &args->handle); +} + +int +drm_syncobj_handle_to_fd_ioctl2(struct drm_device *dev, void *data, + struct drm_file *file_private) +{ + struct drm_syncobj_handle2 *args = data; + + if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ)) + return -ENODEV; + + if (args->pad) + return -EINVAL; + + if (args->flags != 0 && + args->flags !=
DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE) + return-EINVAL;
+
+ if (args->flags&DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE) + return drm_syncobj_export_sync_file(file_private,args->handle,
+args->point,&args->fd);drivers/gpu/drm/drm_syncobj.c +19
-0+ + return drm_syncobj_handle_to_fd(file_private, args->handle, + &args->fd); +} + +int +drm_syncobj_fd_to_handle_ioctl2(struct drm_device *dev, void *data, + struct drm_file *file_private) +{ + struct drm_syncobj_handle2 *args = data; + + if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ)) + return -ENODEV; + + if (args->pad) + return -EINVAL; + + if (args->flags != 0 && + args->flags !=
DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_IMPORT_SYNC_FILE)
+ return-EINVAL;
+
if (args->flags&DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_IMPORT_SYNC_FILE)
return drm_syncobj_import_sync_file_fence(file_private,args->fd,
-args->handle);
+args->handle,
+args->point);
returndrm_syncobj_fd_to_handle(file_private, args->fd, &args->handle);
}
+
structsyncobj_wait_entry{
structtask_struct*task;
structdma_fence*fence;include/uapi/drm/drm.h +9
-0@@ -735,6 +735,15 @@ struct drm_syncobj_handle { __s32 fd; __u32 pad; }; +struct drm_syncobj_handle2 { + __u32 handle; + __u32 flags; + __u64 point; + + __s32 fd; + __u32 pad; +}; + #define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALL (1 << 0) #define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT (1 << 1)@@ -938,6 +947,8 @@ extern "C" { #define DRM_IOCTL_SYNCOBJ_TIMELINE_WAIT DRM_IOWR(0xCA, struct drm_syncobj_timeline_wait) #define DRM_IOCTL_SYNCOBJ_QUERY DRM_IOWR(0xCB, struct
Quoted 9 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
include/uapi/drm/drm.h +2
-0drm_syncobj_timeline_query) +#define DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD2 DRM_IOWR(0xCC, struct drm_syncobj_handle2) +#define DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE2 DRM_IOWR(0xCD, struct drm_syncobj_handle2)/**
* Device specific ioctls should only be in their respective headers
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 4/5 drm/amdgpu: add timeline support in amdgpu CS v2
In reply to Chunming Zhousyncobj wait/signal operation is appending in command submission.
v2: separate to two kinds in/out_deps functions
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 8 +- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 111 +++++++++++++++++++++---- include/uapi/drm/amdgpu_drm.h | 9 ++ 3 files changed, 112 insertions(+), 16 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +6 -2
@@ -543,6 +543,11 @@ struct amdgpu_cs_chunk {void *kdata; }; +struct amdgpu_cs_syncobj_post_dep { +struct drm_syncobj *post_dep_syncobj; +u64 point; +}; +struct amdgpu_cs_parser {struct amdgpu_device *adev;struct drm_file *filp;
@@ -571,9 +576,8 @@ struct amdgpu_cs_parser {/* user fence */ struct amdgpu_bo_list_entry uf_entry; - +struct amdgpu_cs_syncobj_post_dep *post_dep_syncobjs;unsigned num_post_dep_syncobjs; -struct drm_syncobj **post_dep_syncobjs; }; static inline u32 amdgpu_get_ib_value(struct amdgpu_cs_parser *p,
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +97 -14
194 lines not on this page · raw message
include/uapi/drm/amdgpu_drm.h +9 -0
@@ -517,6 +517,8 @@ struct drm_amdgpu_gem_va {#define AMDGPU_CHUNK_ID_SYNCOBJ_IN 0x04#define AMDGPU_CHUNK_ID_SYNCOBJ_OUT 0x05#define AMDGPU_CHUNK_ID_BO_HANDLES 0x06 +#define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_WAIT 0x07 +#define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_SIGNAL 0x08struct drm_amdgpu_cs_chunk {__u32 chunk_id;
@@ -592,6 +594,13 @@ struct drm_amdgpu_cs_chunk_sem {__u32 handle; }; +struct drm_amdgpu_cs_chunk_syncobj { +__u32 handle; +__u32 flags; +__u64 point; +}; + +#define AMDGPU_FENCE_TO_HANDLE_GET_SYNCOBJ 0#define AMDGPU_FENCE_TO_HANDLE_GET_SYNCOBJ_FD 1#define AMDGPU_FENCE_TO_HANDLE_GET_SYNC_FILE_FD 2
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 5/5 drm/amdgpu: update version for timeline syncobj support in amdgpu
In reply to Chunming Zhou--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2 -1
@@ -71,9 +71,10 @@* - 3.25.0 - Add support for sensor query info (stable pstate sclk/mclk). * - 3.26.0 - GFX9: Process AMDGPU_IB_FLAG_TC_WB_NOT_INVALIDATE. * - 3.27.0 - Add new chunk to to AMDGPU_CS to enable BO_LIST creation. +* - 3.28.0 - Add syncobj timeline support to AMDGPU_CS. */ #define KMS_DRIVER_MAJOR 3 -#define KMS_DRIVER_MINOR 27 +#define KMS_DRIVER_MINOR 28#define KMS_DRIVER_PATCHLEVEL 0int amdgpu_vram_limit =0 ;
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Am 02.11.18 um 09:25 schrieb Chunming Zhou:
Quoted 102 lines
points array is one-to-one match with syncobjs array. v2:
add seperate ioctl for timeline point wait, otherwise break uapi. v3:
userspace can specify two kinds waits::
a. Wait for time point to be completed.
b. and wait for time point to become available
v4:
rebaseSigned-off-by Chunming Zhou <[email protected]>Cc Daniel Rakos <[email protected]>Cc Jason Ekstrand <[email protected]>Cc Bas Nieuwenhuizen <[email protected]>Cc Dave Airlie <[email protected]>Cc Christian König <[email protected]>Cc Chris Wilson <[email protected]>--- drivers/gpu/drm/drm_internal.h | 2 + drivers/gpu/drm/drm_ioctl.c | 2 + drivers/gpu/drm/drm_syncobj.c | 115 ++++++++++++++++++++++++++++----- include/uapi/drm/drm.h | 18 ++++++ 4 files changed, 121 insertions(+), 16 deletions(-)drivers/gpu/drm/drm_internal.h +2
-0@@ -183,6 +183,8 @@ int drm_syncobj_fd_to_handle_ioctl(struct drm_device *dev, void *data, struct drm_file *file_private);int drm_syncobj_wait_ioctl (struct drm_device *dev,void *data,struct drm_file *file_private); +int drm_syncobj_timeline_wait_ioctl (struct drm_device *dev,void *data, +struct drm_file *file_private);int drm_syncobj_reset_ioctl (struct drm_device *dev,void *data,struct drm_file *file_private); int drm_syncobj_signal_ioctl(struct drm_device *dev, void *data,drivers/gpu/drm/drm_ioctl.c +2
-0@@ -675,6 +675,8 @@ static const struct drm_ioctl_desc drm_ioctls[] = { DRM_UNLOCKED|DRM_RENDER_ALLOW),DRM_IOCTL_DEF (DRM_IOCTL_SYNCOBJ_WAIT , drm_syncobj_wait_ioctl,DRM_UNLOCKED |DRM_RENDER_ALLOW ), +DRM_IOCTL_DEF (DRM_IOCTL_SYNCOBJ_TIMELINE_WAIT , drm_syncobj_timeline_wait_ioctl, +DRM_UNLOCKED |DRM_RENDER_ALLOW ),DRM_IOCTL_DEF (DRM_IOCTL_SYNCOBJ_RESET , drm_syncobj_reset_ioctl,DRM_UNLOCKED |DRM_RENDER_ALLOW ), DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_SIGNAL, drm_syncobj_signal_ioctl,drivers/gpu/drm/drm_syncobj.c +8
-4@@ -153,11 +153,12 @@ static void drm_syncobj_add_callback_locked(struct drm_syncobj *syncobj, }static void drm_syncobj_fence_get_or_add_callback (struct drm_syncobj *syncobj, +uint64_t point,struct dma_fence **fence,struct drm_syncobj_cb *cb,drm_syncobj_func_t func) { -u64 pt_value =0 ; +u64 pt_value = point;WARN_ON (*fence);@@ -854,6 +855,7 @@ struct syncobj_wait_entry {struct dma_fence *fence;struct dma_fence_cb fence_cb;struct drm_syncobj_cb syncobj_cb; +u64 point; }; static void syncobj_wait_fence_func(struct dma_fence *fence,@@ -871,12 +873,13 @@ static void syncobj_wait_syncobj_func(struct drm_syncobj *syncobj,struct syncobj_wait_entry *wait = container_of(cb, struct syncobj_wait_entry, syncobj_cb); -drm_syncobj_search_fence (syncobj,0 ,0 , &wait->fence); +drm_syncobj_search_fence (syncobj, wait->point,0 , &wait->fence);wake_up_process (wait->task); } static signed long drm_syncobj_array_wait_timeout(struct drm_syncobj **syncobjs, + void __user *user_points, uint32_t count, uint32_t flags, signed long timeout,@@ -884,12 +887,37 @@ static signed long drm_syncobj_array_wait_timeout(struct drm_syncobj **syncobjs, {struct syncobj_wait_entry *entries;struct dma_fence *fence; +uint64_t *points;uint32_t signaled_count, i; - entries =kcalloc (count,sizeof (*entries),GFP_KERNEL ); -if (!entries) + points =kmalloc_array (count,sizeof (*points),GFP_KERNEL ); +if (points ==NULL )
drivers/gpu/drm/drm_syncobj.c static signed long drm_syncobj_array_wait_timeout(struct drm_syncobj **syncobjs, · line 904
Quoted 10 lines
drivers/gpu/drm/drm_syncobj.c +8
-0return -ENOMEM ; +if (!user_points) { +memset (points,0 , count *sizeof (uint64_t )); + }else if (copy_from_user (points, user_points,sizeof (uint64_t ) * count)) { + timeout = -EFAULT ; + goto err_free_points; + } + +
Double empty line here.
drivers/gpu/drm/drm_syncobj.c static signed long drm_syncobj_array_wait_timeout(struct drm_syncobj **syncobjs, · line 914
Quoted 10 lines
drivers/gpu/drm/drm_syncobj.c +10
-0+if (flags &DRM_SYNCOBJ_WAIT_FLAGS_WAIT_AVAILABLE ) { +struct dma_fence *fence; +for (i =0 ; i < count; ++i) { + timeout =drm_syncobj_search_fence (syncobjs[i], points[i], +DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT , + &fence); +if (timeout) + goto err_free_points; + } + goto err_free_points;
A comment would be nice here to note that we only wait for the fences to become available.
Alternatively it might be a good idea to make this an separate IOCTL.
Apart from those nit picks looks quite good to me, Christian.
Quoted 168 lines
drivers/gpu/drm/drm_syncobj.c +73
-12+ } + entries =kcalloc (count,sizeof (*entries),GFP_KERNEL ); +if (!entries) { + timeout = -ENOMEM ; + goto err_free_points; + }/* Walk the list of sync objects and initialize entries. We do * this up-front so that we can properly return -EINVAL if there is * a syncobj with a missing fence and then never have the chance of @@ -898,7 +926,8 @@ static signed long drm_syncobj_array_wait_timeout(struct drm_syncobj **syncobjs, signaled_count =0 ;for (i =0 ; i < count; ++i) { entries[i].task = current; -drm_syncobj_search_fence (syncobjs[i],0 ,0 , + entries[i].point = points[i]; +drm_syncobj_search_fence (syncobjs[i], points[i],0 , &entries[i].fence);if (!entries[i].fence) {if (flags &DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT ) {@@ -934,6 +963,7 @@ static signed long drm_syncobj_array_wait_timeout(struct drm_syncobj **syncobjs,continue ;drm_syncobj_fence_get_or_add_callback (syncobjs[i], + entries[i].point, &entries[i].fence, &entries[i].syncobj_cb, syncobj_wait_syncobj_func);@@ -996,6 +1026,9 @@ static signed long drm_syncobj_array_wait_timeout(struct drm_syncobj **syncobjs, }kfree (entries); +err_free_points: +kfree (points); +return timeout; }@@ -1034,19 +1067,33 @@ static signed long drm_timeout_abs_to_jiffies(int64_t timeout_nsec)static int drm_syncobj_array_wait (struct drm_device *dev,struct drm_file *file_private,struct drm_syncobj_wait *wait, -struct drm_syncobj **syncobjs) +struct drm_syncobj_timeline_wait *timeline_wait, +struct drm_syncobj **syncobjs,bool timeline) { -signed long timeout =drm_timeout_abs_to_jiffies (wait->timeout_nsec); +signed long timeout =0 ;uint32_t first = ~0 ; - timeout =drm_syncobj_array_wait_timeout (syncobjs, - wait->count_handles, - wait->flags, - timeout, &first); -if (timeout <0 ) -return timeout; - - wait->first_signaled = first; +if (!timeline) { + timeout =drm_timeout_abs_to_jiffies (wait->timeout_nsec); + timeout =drm_syncobj_array_wait_timeout (syncobjs, +NULL , + wait->count_handles, + wait->flags, + timeout, &first); +if (timeout <0 ) +return timeout; + wait->first_signaled = first; + }else { + timeout =drm_timeout_abs_to_jiffies (timeline_wait->timeout_nsec); + timeout =drm_syncobj_array_wait_timeout (syncobjs, +u64_to_user_ptr (timeline_wait->points), + timeline_wait->count_handles, + timeline_wait->flags, + timeout, &first); +if (timeout <0 ) +return timeout; + timeline_wait->first_signaled = first; + }return 0 ; }@@ -1132,13 +1179,49 @@ drm_syncobj_wait_ioctl(struct drm_device *dev, void *data,return ret; ret =drm_syncobj_array_wait (dev, file_private, - args, syncobjs); + args,NULL , syncobjs, false);drm_syncobj_array_free (syncobjs, args->count_handles);return ret; } +int +drm_syncobj_timeline_wait_ioctl (struct drm_device *dev,void *data, +struct drm_file *file_private) +{ +struct drm_syncobj_timeline_wait *args = data; +struct drm_syncobj **syncobjs; +int ret =0 ; + +if (!drm_core_check_feature (dev,DRIVER_SYNCOBJ )) +return -ENODEV ; + +if (args->flags & ~(DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALL | +DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT | +DRM_SYNCOBJ_WAIT_FLAGS_WAIT_COMPLETED | +DRM_SYNCOBJ_WAIT_FLAGS_WAIT_AVAILABLE )) +return -EINVAL ; + +if (args->count_handles ==0 ) +return -EINVAL ; + + ret =drm_syncobj_array_find (file_private, +u64_to_user_ptr (args->handles), + args->count_handles, + &syncobjs); +if (ret <0 ) +return ret; + + ret =drm_syncobj_array_wait (dev, file_private, +NULL , args, syncobjs, true); + +drm_syncobj_array_free (syncobjs, args->count_handles); + +return ret; +} + +int drm_syncobj_reset_ioctl (struct drm_device *dev,void *data,struct drm_file *file_private)include/uapi/drm/drm.h +17
-0@@ -738,6 +738,10 @@ struct drm_syncobj_handle {#define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALL (1 << 0)#define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT (1 << 1) +/* wait for time point to be completed */ +#define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_COMPLETED (1 << 2) +/* wait for time point to become available */ +#define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_AVAILABLE (1 << 3)struct drm_syncobj_wait {__u64 handles;/* absolute timeout */ @@ -748,6 +752,19 @@ struct drm_syncobj_wait {__u32 pad; }; +struct drm_syncobj_timeline_wait { +__u64 handles; +/* wait on specific timeline point for every handles*/ +__u64 points; +/* absolute timeout */ +__s64 timeout_nsec; +__u32 count_handles; +__u32 flags; +__u32 first_signaled;/* only valid when not waiting all */ +__u32 pad; +}; + +struct drm_syncobj_array {__u64 handles;__u32 count_handles;
include/uapi/drm/drm.h extern "C" { · line 933
Quoted 7 lines
include/uapi/drm/drm.h +1
-0@@ -910,6 +927,7 @@ extern "C" {#define DRM_IOCTL_MODE_GET_LEASE DRM_IOWR(0xC8, struct drm_mode_get_lease)#define DRM_IOCTL_MODE_REVOKE_LEASE DRM_IOWR(0xC9, struct drm_mode_revoke_lease) +#define DRM_IOCTL_SYNCOBJ_TIMELINE_WAIT DRM_IOWR(0xCA, struct drm_syncobj_timeline_wait)/** * Device specific ioctls should only be in their respective headers * The device specific ioctl range is from 0x40 to 0x9f.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel