dma-buf: add new dma_fence_chain container v5
Subsystems (5)
PATCH 1/9 dma-buf: add new dma_fence_chain container v5
From: Christian König <[email protected]>
Lockless container implementation similar to a dma_fence_array, but with only two elements per node and automatic garbage collection.
v2: properly document dma_fence_chain_for_each, add dma_fence_chain_find_seqno,
drop prev reference during garbage collection if it's not a chain fence.
v3: use head and iterator for dma_fence_chain_for_each
v4: fix reference count in dma_fence_chain_enable_signaling
v5: fix iteration when walking each chain node
--- drivers/dma-buf/Makefile | 3 +- drivers/dma-buf/dma-fence-chain.c | 241 ++++++++++++++++++++++++++++++ include/linux/dma-fence-chain.h | 81 ++++++++++ 3 files changed, 324 insertions(+), 1 deletion(-) create mode 100644 drivers/dma-buf/dma-fence-chain.c create mode 100644 include/linux/dma-fence-chain.h
drivers/dma-buf/Makefile +2 -1
@@ -1,4 +1,5 @@ -obj-y := dma-buf.o dma-fence.o dma-fence-array.o reservation.o seqno-fence.o +obj-y := dma-buf.o dma-fence.o dma-fence-array.o dma-fence-chain.o \ + reservation.o seqno-fence.o obj-$(CONFIG_SYNC_FILE) += sync_file.o obj-$(CONFIG_SW_SYNC) += sw_sync.o sync_debug.o obj-$(CONFIG_UDMABUF) += udmabuf.o
drivers/dma-buf/dma-fence-chain.c new file +241 -0
241 lines not on this page · raw message
include/linux/dma-fence-chain.h new file +81 -0
81 lines not on this page · raw message
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 2/9 drm/syncobj: add new drm_syncobj_add_point interface v4
From: Christian König <[email protected]>
Use the dma_fence_chain object to create a timeline of fence objects instead of just replacing the existing fence.
v2: rebase and cleanup
v3: fix garbage collection parameters
v4: add unorder point check, print a warn calltrace
--- drivers/gpu/drm/drm_syncobj.c | 39 +++++++++++++++++++++++++++++++++++ include/drm/drm_syncobj.h | 5 +++++ 2 files changed, 44 insertions(+)
drivers/gpu/drm/drm_syncobj.c +39 -0
@@ -122,6 +122,45 @@ static void drm_syncobj_remove_wait(struct drm_syncobj *syncobj,spin_unlock (&syncobj->lock); } +/** +* drm_syncobj_add_point - add new timeline point to the syncobj +* @syncobj: sync object to add timeline point do +* @chain: chain node to use to add the point +* @fence: fence to encapsulate in the chain node +* @point: sequence number to use for the point +* +* Add the chain node as new timeline point to the syncobj. +*/ +void drm_syncobj_add_point (struct drm_syncobj *syncobj, +struct dma_fence_chain *chain, +struct dma_fence *fence, +uint64_t point) +{ +struct syncobj_wait_entry *cur, *tmp; +struct dma_fence *prev; + +dma_fence_get (fence); + +spin_lock (&syncobj->lock); + + prev =drm_syncobj_fence_get (syncobj); +/* You are adding an unorder point to timeline, which could cause payload returned from query_ioctl is 0! */ +WARN_ON_ONCE (prev && prev->seqno >= point); +dma_fence_chain_init (chain, prev, fence, point); +rcu_assign_pointer (syncobj->fence, &chain->base); + +list_for_each_entry_safe (cur, tmp, &syncobj->cb_list, node) { +list_del_init (&cur->node); +syncobj_wait_syncobj_func (syncobj, cur); + } +spin_unlock (&syncobj->lock); + +/* Walk the chain once to trigger garbage collection */ +dma_fence_chain_for_each (fence, prev); +dma_fence_put (prev); +} +EXPORT_SYMBOL (drm_syncobj_add_point); +/** * drm_syncobj_replace_fence - replace fence in a sync object. * @syncobj: Sync object to replace fence in
include/drm/drm_syncobj.h +5 -0
@@ -27,6 +27,7 @@#define __DRM_SYNCOBJ_H__#include <linux/dma-fence.h> +#include <linux/dma-fence-chain.h> struct drm_file ;
@@ -112,6 +113,10 @@ drm_syncobj_fence_get(struct drm_syncobj *syncobj)struct drm_syncobj *drm_syncobj_find (struct drm_file *file_private,u32 handle); +void drm_syncobj_add_point (struct drm_syncobj *syncobj, +struct dma_fence_chain *chain, +struct dma_fence *fence, +uint64_t point);void drm_syncobj_replace_fence (struct drm_syncobj *syncobj,struct dma_fence *fence); int drm_syncobj_find_fence(struct drm_file *file_private,
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 3/9 drm/syncobj: add support for timeline point wait v8
In reply to Chunming Zhoupoints 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
v5:
add comment for xxx_WAIT_AVAILABLE
v6: rebase and rework on new container
v7: drop _WAIT_COMPLETED, it is the default anyway
v8: correctly handle garbage collected fences
--- drivers/gpu/drm/drm_internal.h | 2 + drivers/gpu/drm/drm_ioctl.c | 2 + drivers/gpu/drm/drm_syncobj.c | 153 ++++++++++++++++++++++++++------- include/uapi/drm/drm.h | 15 ++++ 4 files changed, 143 insertions(+), 29 deletions(-)
drivers/gpu/drm/drm_internal.h +2 -0
@@ -182,6 +182,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
@@ -688,6 +688,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 +124 -29
253 lines not on this page · raw message
include/uapi/drm/drm.h +15 -0
@@ -737,6 +737,7 @@ struct drm_syncobj_handle {#define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALL (1 << 0)#define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT (1 << 1) +#define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_AVAILABLE (1 << 2)struct drm_syncobj_wait {__u64 handles;/* absolute timeout */
@@ -747,6 +748,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;
@@ -909,6 +923,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
Re: [PATCH 3/9] drm/syncobj: add support for timeline point wait v8
Quoted 197 lines · Chunming Zhou
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
v5:
add comment forxxx_WAIT_AVAILABLE
v6: rebase and rework on new container
v7: drop_WAIT_COMPLETED, it is the default anyway
v8: correctly handle garbage collected fencesSigned-off-by Chunming Zhou <[email protected]>Signed-off-by Christian König <[email protected]>Cc Daniel Rakos <[email protected]>Cc Jason Ekstrand <[email protected]>Cc Bas Nieuwenhuizen <[email protected]>Cc Dave Airlie <[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 | 153 ++++++++++++++++++++++++++------- include/uapi/drm/drm.h | 15 ++++ 4 files changed, 143 insertions(+), 29 deletions(-)drivers/gpu/drm/drm_internal.h +2
-0@@ -182,6 +182,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@@ -688,6 +688,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 +52
-16@@ -61,6 +61,7 @@ struct syncobj_wait_entry {struct task_struct *task;struct dma_fence *fence;struct dma_fence_cb fence_cb; +u64 point; }; static void syncobj_wait_syncobj_func(struct drm_syncobj *syncobj,@@ -95,6 +96,8 @@ EXPORT_SYMBOL(drm_syncobj_find);static void drm_syncobj_fence_add_wait (struct drm_syncobj *syncobj,struct syncobj_wait_entry *wait) { +struct dma_fence *fence; +if (wait->fence)return ;@@ -103,11 +106,15 @@ static void drm_syncobj_fence_add_wait(struct drm_syncobj *syncobj,* have the lock, try one more time just to be sure we don't add a * callback when a fence has already been set. */ -if (syncobj->fence) - wait->fence =dma_fence_get ( -rcu_dereference_protected (syncobj->fence,1 )); -else + fence =dma_fence_get (rcu_dereference_protected (syncobj->fence,1 )); +if (!fence ||dma_fence_chain_find_seqno (&fence, wait->point)) { +dma_fence_put (fence);list_add_tail (&wait->node, &syncobj->cb_list); + }else if (!fence) { + wait->fence =dma_fence_get_stub (); + }else { + wait->fence = fence; + }spin_unlock (&syncobj->lock); }@@ -149,10 +156,8 @@ void drm_syncobj_add_point(struct drm_syncobj *syncobj,dma_fence_chain_init (chain, prev, fence, point);rcu_assign_pointer (syncobj->fence, &chain->base); -list_for_each_entry_safe (cur, tmp, &syncobj->cb_list, node) { -list_del_init (&cur->node); +list_for_each_entry_safe (cur, tmp, &syncobj->cb_list, node)syncobj_wait_syncobj_func (syncobj, cur); - }spin_unlock (&syncobj->lock);/* Walk the chain once to trigger garbage collection */ @@ -184,10 +189,8 @@ void drm_syncobj_replace_fence(struct drm_syncobj *syncobj,rcu_assign_pointer (syncobj->fence, fence);if (fence != old_fence) { -list_for_each_entry_safe (cur, tmp, &syncobj->cb_list, node) { -list_del_init (&cur->node); +list_for_each_entry_safe (cur, tmp, &syncobj->cb_list, node)syncobj_wait_syncobj_func (syncobj, cur); - } }spin_unlock (&syncobj->lock);@@ -644,13 +647,27 @@ static void syncobj_wait_fence_func(struct dma_fence *fence,static void syncobj_wait_syncobj_func (struct drm_syncobj *syncobj,struct syncobj_wait_entry *wait) { +struct dma_fence *fence; +/* This happens inside the syncobj lock */ - wait->fence =dma_fence_get (rcu_dereference_protected (syncobj->fence, -lockdep_is_held (&syncobj->lock))); + fence =rcu_dereference_protected (syncobj->fence, +lockdep_is_held (&syncobj->lock)); +dma_fence_get (fence); +if (!fence ||dma_fence_chain_find_seqno (&fence, wait->point)) { +dma_fence_put (fence); +return ; + }else if (!fence) { + wait->fence =dma_fence_get_stub (); + }else { + wait->fence = fence; + } +wake_up_process (wait->task); +list_del_init (&wait->node); } 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,@@ -658,12 +675,27 @@ 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 )return -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; + } + + 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 @@ -671,9 +703,13 @@ static signed long drm_syncobj_array_wait_timeout(struct drm_syncobj **syncobjs,*/ signaled_count =0 ;for (i =0 ; i < count; ++i) { +struct dma_fence *fence; + entries[i].task = current; - entries[i].fence =drm_syncobj_fence_get (syncobjs[i]); -if (!entries[i].fence) { + entries[i].point = points[i]; + fence =drm_syncobj_fence_get (syncobjs[i]); +if (!fence ||dma_fence_chain_find_seqno (&fence, points[i])) { +dma_fence_put (fence);if (flags &DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT ) {continue ; }else {
drivers/gpu/drm/drm_syncobj.c static signed long drm_syncobj_array_wait_timeout(struct drm_syncobj **syncobjs, · line 726
Quoted 10 lines
drivers/gpu/drm/drm_syncobj.c +6
-1@@ -682,7 +718,13 @@ static signed long drm_syncobj_array_wait_timeout(struct drm_syncobj **syncobjs, } } -if (dma_fence_is_signaled (entries[i].fence)) { +if (fence) + entries[i].fence = fence; +else + entries[i].fence =dma_fence_get_stub (); + + if ((flags & DRM_SYNCOBJ_WAIT_FLAGS_WAIT_AVAILABLE) ||
Hey David,
Could you remind me what DRM_SYNCOBJ_WAIT_FLAGS_WAIT_AVAILABLE is used for?
I didn't have a use for it in userspace,
Thanks,
-Lionel
Quoted 151 lines
drivers/gpu/drm/drm_syncobj.c +66
-12+ dma_fence_is_signaled(entries[i].fence)) {if (signaled_count ==0 && idx) *idx = i; signaled_count++;@@ -715,7 +757,8 @@ static signed long drm_syncobj_array_wait_timeout(struct drm_syncobj **syncobjs,if (!fence)continue ; - if (dma_fence_is_signaled(fence) || + if ((flags & DRM_SYNCOBJ_WAIT_FLAGS_WAIT_AVAILABLE) || + dma_fence_is_signaled(fence) || (!entries[i].fence_cb.func && dma_fence_add_callback(fence, &entries[i].fence_cb,@@ -760,6 +803,9 @@ static signed long drm_syncobj_array_wait_timeout(struct drm_syncobj **syncobjs, }kfree (entries); +err_free_points: +kfree (points); +return timeout; }@@ -799,19 +845,33 @@ EXPORT_SYMBOL(drm_timeout_abs_to_jiffies);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 ; }@@ -897,13 +957,48 @@ 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_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 +14
-0@@ -737,6 +737,7 @@ struct drm_syncobj_handle {#define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALL (1 << 0)#define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT (1 << 1) +#define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_AVAILABLE (1 << 2)struct drm_syncobj_wait {__u64 handles;/* absolute timeout */ @@ -747,6 +748,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 929
Quoted 7 lines
include/uapi/drm/drm.h +1
-0@@ -909,6 +923,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
A message that is not in the archive (sent off-list or not yet received): 5b68b54a-5d8d-9666-bd45-aa53b6b295e7-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
Re: [PATCH 3/9] drm/syncobj: add support for timeline point wait v8
Am 18.03.19 um 17:59 schrieb Lionel Landwerlin:
Quoted 217 lines · Chunming Zhou
Quoted 202 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:
rebase
v5:
add comment forxxx_WAIT_AVAILABLE
v6: rebase and rework on new container
v7: drop_WAIT_COMPLETED, it is the default anyway
v8: correctly handle garbage collected fencesSigned-off-by Chunming Zhou <[email protected]>Signed-off-by Christian König <[email protected]>Cc Daniel Rakos <[email protected]>Cc Jason Ekstrand <[email protected]>Cc Bas Nieuwenhuizen <[email protected]>Cc Dave Airlie <[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 | 153 ++++++++++++++++++++++++++------- include/uapi/drm/drm.h | 15 ++++4 files changed, 143 insertions(+), 29 deletions(-)drivers/gpu/drm/drm_internal.h +2
-0@@ -182,6 +182,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@@ -688,6 +688,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 +3
-0@@ -61,6 +61,7 @@ struct syncobj_wait_entry { struct task_struct *task; struct dma_fence *fence; struct dma_fence_cb fence_cb; + u64 point; }; static void syncobj_wait_syncobj_func(struct drm_syncobj *syncobj,@@ -95,6 +96,8 @@ EXPORT_SYMBOL(drm_syncobj_find); static void drm_syncobj_fence_add_wait(struct drm_syncobj *syncobj, struct syncobj_wait_entry *wait) { + struct dma_fence *fence; + if (wait->fence) return;@@ -103,11 +106,15 @@ static void drm_syncobj_fence_add_wait(struct
drm_syncobj*syncobj,
* have the lock, try one more time just to be sure we don't add a
* callback when a fence has already been set.
*/
- if (syncobj->fence)
-wait->fence= dma_fence_get(
-rcu_dereference_protected(syncobj->fence, 1)); - else
+ fence =dma_fence_get(rcu_dereference_protected(syncobj->fence, 1));
+ if (!fence ||dma_fence_chain_find_seqno(&fence, wait->point)) { +dma_fence_put(fence);
list_add_tail(&wait->node, &syncobj->cb_list);
+ } else if (!fence) {
+wait->fence=dma_fence_get_stub();
+ } else {
+wait->fence= fence;
+ }
spin_unlock(&syncobj->lock);
}
@@ -149,10 +156,8 @@ void drm_syncobj_add_point(structdrm_syncobj*syncobj,
dma_fence_chain_init(chain, prev, fence, point);rcu_assign_pointer(syncobj->fence, &chain->base);
-list_for_each_entry_safe(cur, tmp, &syncobj->cb_list, node){ -list_del_init(&cur->node);
+list_for_each_entry_safe(cur, tmp, &syncobj->cb_list, node)syncobj_wait_syncobj_func(syncobj, cur);
- }
spin_unlock(&syncobj->lock);
/* Walk the chain once to trigger garbage collection */drivers/gpu/drm/drm_syncobj.c +16
-5@@ -184,10 +189,8 @@ void drm_syncobj_replace_fence(structdrm_syncobj *syncobj, rcu_assign_pointer(syncobj->fence, fence); if (fence != old_fence) { - list_for_each_entry_safe(cur, tmp, &syncobj->cb_list, node) { - list_del_init(&cur->node); + list_for_each_entry_safe(cur, tmp, &syncobj->cb_list, node) syncobj_wait_syncobj_func(syncobj, cur); - } } spin_unlock(&syncobj->lock);@@ -644,13 +647,27 @@ static void syncobj_wait_fence_func(structdma_fence *fence, static void syncobj_wait_syncobj_func(struct drm_syncobj *syncobj, struct syncobj_wait_entry *wait) { + struct dma_fence *fence; + /* This happens inside the syncobj lock */ - wait->fence =dma_fence_get (rcu_dereference_protected (syncobj->fence, -lockdep_is_held (&syncobj->lock))); + fence = rcu_dereference_protected(syncobj->fence, + lockdep_is_held(&syncobj->lock)); + dma_fence_get(fence); + if (!fence || dma_fence_chain_find_seqno(&fence, wait->point)) { + dma_fence_put(fence); + return; + } else if (!fence) { + wait->fence = dma_fence_get_stub(); + } else { + wait->fence = fence; + } + wake_up_process(wait->task); + list_del_init(&wait->node); }static signed long drm_syncobj_array_wait_timeout(struct
drm_syncobj**syncobjs,
+ void__user*user_points,uint32_tcount,uint32_tflags,
signed long timeout,drivers/gpu/drm/drm_syncobj.c +16
-1@@ -658,12 +675,27 @@ 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) return -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; + } + + 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 ofdrivers/gpu/drm/drm_syncobj.c +6
-2@@ -671,9 +703,13 @@ static signed longdrm_syncobj_array_wait_timeout(struct drm_syncobj **syncobjs, */ signaled_count = 0; for (i = 0; i < count; ++i) { + struct dma_fence *fence; + entries[i].task = current; - entries[i].fence = drm_syncobj_fence_get(syncobjs[i]); - if (!entries[i].fence) { + entries[i].point = points[i]; + fence = drm_syncobj_fence_get(syncobjs[i]); + if (!fence || dma_fence_chain_find_seqno(&fence, points[i])) { + dma_fence_put(fence); if (flags & DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT) { continue;} else {
drivers/gpu/drm/drm_syncobj.c static signed long · line 727
Quoted 10 lines
drivers/gpu/drm/drm_syncobj.c +6
-0@@ -682,7 +718,13 @@ static signed long drm_syncobj_array_wait_timeout(struct drm_syncobj **syncobjs, } } - if (dma_fence_is_signaled(entries[i].fence)) { + if (fence) + entries[i].fence = fence; + else + entries[i].fence = dma_fence_get_stub(); + + if ((flags & DRM_SYNCOBJ_WAIT_FLAGS_WAIT_AVAILABLE) ||Hey David,
Quoted 4 lines
Could you remind me what
DRM_SYNCOBJ_WAIT_FLAGS_WAIT_AVAILABLEis used for?I didn't have a use for it in userspace,
The flag is used to wait for fences for a sequence number to show up.
Christian.
Quoted 152 lines
Thanks,
-Lionel
Quoted 146 lines
drivers/gpu/drm/drm_syncobj.c +1
-0+ dma_fence_is_signaled(entries[i].fence)) { if (signaled_count == 0 && idx) *idx = i;signaled_count++;
drivers/gpu/drm/drm_syncobj.c +0
-0@@ -715,7 +757,8 @@ static signed long drm_syncobj_array_wait_timeout(struct drm_syncobj **syncobjs, if (!fence) continue;- if (
dma_fence_is_signaled(fence)||
+ if ((flags &DRM_SYNCOBJ_WAIT_FLAGS_WAIT_AVAILABLE) || +dma_fence_is_signaled(fence)|| (!entries[i].fence_cb.func && dma_fence_add_callback(fence, &entries[i].fence_cb,drivers/gpu/drm/drm_syncobj.c +0
-0@@ -760,6 +803,9 @@ static signed long drm_syncobj_array_wait_timeout(struct drm_syncobj **syncobjs, } kfree(entries);+err_free_points:
+ kfree(points);
+
return timeout;
}
@@ -799,19 +845,33 @@EXPORT_SYMBOL(drm_timeout_abs_to_jiffies); static int drm_syncobj_array_wait(structdrm_device*dev, structdrm_file*file_private, structdrm_syncobj_wait*wait,
- structdrm_syncobj**syncobjs)
+ structdrm_syncobj_timeline_wait*timeline_wait, + structdrm_syncobj**syncobjs, bool timeline) {
- signed long timeout =drm_timeout_abs_to_jiffies(wait->timeout_nsec);
+ signed long timeout = 0;
uint32_tfirst = ~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;
}
@@ -897,13 +957,48 @@ drm_syncobj_wait_ioctl(structdrm_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;
}
+intdrivers/gpu/drm/drm_syncobj.c +34
-0+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_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 +13
-0@@ -737,6 +737,7 @@ struct drm_syncobj_handle { #define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALL (1 << 0) #define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT (1 << 1) +#define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_AVAILABLE (1 << 2) struct drm_syncobj_wait { __u64 handles; /* absolute timeout */@@ -747,6 +748,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;@@ -909,6 +923,7 @@ extern "C" { #define DRM_IOCTL_MODE_GET_LEASE DRM_IOWR(0xC8, struct
Quoted 10 lines
Quoted 8 lines
include/uapi/drm/drm.h +0
-0drm_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 from0x40to0x9f.
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 990db9e7-6cae-1165-637c-84aed3a9af49-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 3/9] drm/syncobj: add support for timeline point wait v8
Quoted 9 lines · Christian
Quoted 9 lines
Quoted 7 lines
- if (
dma_fence_is_signaled(entries[i].fence)) {
+ if (fence)
+ entries[i].fence = fence;
+ else
+ entries[i].fence =dma_fence_get_stub(); +
+ if ((flags &DRM_SYNCOBJ_WAIT_FLAGS_WAIT_AVAILABLE) ||Hey David,
Quoted 8 lines
Quoted 4 lines
Could you remind me what
DRM_SYNCOBJ_WAIT_FLAGS_WAIT_AVAILABLEis used for?I didn't have a use for it in userspace,
The flag is used to wait for fences for a sequence number to show up.
Christian.
Thanks Christian.
I guess I missed the additive nature of WAIT_FOR_SUBMIT.
It feels like WAIT_AVAILABLE almost deserves its own commit as it affects both timelines & binary syncobjs.
-Lionel
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 4/9 drm/syncobj: add timeline payload query ioctl v6
In reply to Chunming Zhouuser mode can query timeline payload.
v2: check return value of copy_to_user
v3: handle querying entry by entry
v4: rebase on new chain container, simplify interface
v5: query last signaled timeline point, not last point.
v6: add unorder point check
--- drivers/gpu/drm/drm_internal.h | 2 ++ drivers/gpu/drm/drm_ioctl.c | 2 ++ drivers/gpu/drm/drm_syncobj.c | 62 ++++++++++++++++++++++++++++++++++ include/uapi/drm/drm.h | 10 ++++++ 4 files changed, 76 insertions(+)
drivers/gpu/drm/drm_internal.h +2 -0
@@ -188,6 +188,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
@@ -694,6 +694,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 +62 -0
65 lines not on this page · raw message
include/uapi/drm/drm.h +10 -0
@@ -767,6 +767,14 @@ struct drm_syncobj_array {__u32 pad; }; +struct drm_syncobj_timeline_array { +__u64 handles; +__u64 points; +__u32 count_handles; +__u32 pad; +}; + +/* Query current scanout sequence number */ struct drm_crtc_get_sequence {__u32 crtc_id;/* requested crtc_id */
@@ -924,6 +932,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_array) +/** * 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
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 5/9 drm/syncobj: use the timeline point in drm_syncobj_find_fence v3
From: Christian König <[email protected]>
Implement finding the right timeline point in drm_syncobj_find_fence.
v2: return -EINVAL when the point is not submitted yet.
v3: fix reference counting bug, add flags handling as well
v4: add timeout for find fence
--- drivers/gpu/drm/drm_syncobj.c | 50 ++++++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_syncobj.c +47 -3
@@ -213,6 +213,8 @@ static void drm_syncobj_assign_null_handle(struct drm_syncobj *syncobj)dma_fence_put (fence); } +/* 5s */ +#define DRM_SYNCOBJ_WAIT_FOR_SUBMIT_TIMEOUT 5000000000/** * drm_syncobj_find_fence - lookup and reference the fence in a sync object * @file_private: drm file private pointer
@@ -233,16 +235,58 @@ int drm_syncobj_find_fence(struct drm_file *file_private, struct dma_fence **fence) {struct drm_syncobj *syncobj =drm_syncobj_find (file_private, handle); -int ret =0 ; +struct syncobj_wait_entry wait; +u64 timeout =nsecs_to_jiffies64 (DRM_SYNCOBJ_WAIT_FOR_SUBMIT_TIMEOUT ); +int ret;if (!syncobj)return -ENOENT ; *fence =drm_syncobj_fence_get (syncobj); -if (!*fence) { +drm_syncobj_put (syncobj); + +if (*fence) { + ret =dma_fence_chain_find_seqno (fence, point); +if (!ret) +return 0 ; +dma_fence_put (*fence); + }else { ret = -EINVAL ; } -drm_syncobj_put (syncobj); + +if (!(flags &DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT )) +return ret; + +memset (&wait,0 ,sizeof (wait)); + wait.task = current; + wait.point = point; +drm_syncobj_fence_add_wait (syncobj, &wait); + +do { +set_current_state (TASK_INTERRUPTIBLE ); +if (wait.fence) { + ret =0 ; +break ; + } +if (timeout ==0 ) { + ret = -ETIME ; +break ; + } + +if (signal_pending (current)) { + ret = -ERESTARTSYS ; +break ; + } + + timeout =schedule_timeout (timeout); + }while (1 ); + +__set_current_state (TASK_RUNNING ); + *fence = wait.fence; + +if (wait.node.next) +drm_syncobj_remove_wait (syncobj, &wait); +return ret; }EXPORT_SYMBOL (drm_syncobj_find_fence);
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
kbuild test robot
build botRe: [PATCH 5/9] drm/syncobj: use the timeline point in drm_syncobj_find_fence v3
I love your patch! Perhaps something to improve:
Hi Chunming,
I love your patch! Perhaps something to improve:
[auto build test WARNING on linus/master]
[also build test WARNING on next-20190306]
[cannot apply to v5.0]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Chunming-Zhou/dma-buf-add-new-dma_fence_chain-container-v5/20190316-055452
reproduce:
# apt-get install sparse
make ARCH=x86_64 allmodconfig
make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'sparse warnings: (new ones prefixed by >>)
>> drivers/gpu/drm/drm_syncobj.c:239:42: sparse: constant 5000000000 is so big it is long
include/linux/slab.h:664:13: sparse: undefined identifier '__builtin_mul_overflow' include/linux/slab.h:664:13: sparse: not a function <noident> include/linux/slab.h:664:13: sparse: not a function <noident> include/linux/slab.h:664:13: sparse: not a function <noident> include/linux/slab.h:664:13: sparse: call with no type!
vim +239 drivers/gpu/drm/drm_syncobj.c
215
216 /* 5s */
217 #define DRM_SYNCOBJ_WAIT_FOR_SUBMIT_TIMEOUT 5000000000
218 /**
219 * drm_syncobj_find_fence - lookup and reference the fence in a sync object
220 * @file_private: drm file private pointer
221 * @handle: sync object handle to lookup.
222 * @point: timeline point
223 * @flags: DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT or not
224 * @fence: out parameter for the fence
225 *
226 * This is just a convenience function that combines drm_syncobj_find() and
227 * drm_syncobj_fence_get().
228 *
229 * Returns 0 on success or a negative error value on failure. On success @fence
230 * contains a reference to the fence, which must be released by calling
231 * dma_fence_put().
232 */
233 int drm_syncobj_find_fence(struct drm_file *file_private,
234 u32 handle, u64 point, u64 flags,
235 struct dma_fence **fence)
236 {
237 struct drm_syncobj *syncobj = drm_syncobj_find(file_private, handle);
238 struct syncobj_wait_entry wait;
> 239 u64 timeout = nsecs_to_jiffies64(DRM_SYNCOBJ_WAIT_FOR_SUBMIT_TIMEOUT);
240 int ret;
241
242 if (!syncobj)
243 return -ENOENT;
244
245 *fence = drm_syncobj_fence_get(syncobj);
246 drm_syncobj_put(syncobj);
247
248 if (*fence) {
249 ret = dma_fence_chain_find_seqno(fence, point);
250 if (!ret)
251 return 0;
252 dma_fence_put(*fence);
253 } else {
254 ret = -EINVAL;
255 }
256
257 if (!(flags & DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT))
258 return ret;
259
260 memset(&wait, 0, sizeof(wait));
261 wait.task = current;
262 wait.point = point;
263 drm_syncobj_fence_add_wait(syncobj, &wait);
264
265 do {
266 set_current_state(TASK_INTERRUPTIBLE);
267 if (wait.fence) {
268 ret = 0;
269 break;
270 }
271 if (timeout == 0) {
272 ret = -ETIME;
273 break;
274 }
275
276 if (signal_pending(current)) {
277 ret = -ERESTARTSYS;
278 break;
279 }
280
281 timeout = schedule_timeout(timeout);
282 } while (1);
283
284 __set_current_state(TASK_RUNNING);
285 *fence = wait.fence;
286
287 if (wait.node.next)
288 drm_syncobj_remove_wait(syncobj, &wait);
289
290 return ret;
291 }
292 EXPORT_SYMBOL(drm_syncobj_find_fence);
293
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
_______________________________________________
dri-devel mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 7/9 drm/syncobj: add transition iotcls between binary and timeline v2
In reply to a message not in the archivewe need to import/export timeline point.
v2: unify to one transfer ioctl
--- drivers/gpu/drm/drm_internal.h | 2 + drivers/gpu/drm/drm_ioctl.c | 2 + drivers/gpu/drm/drm_syncobj.c | 74 ++++++++++++++++++++++++++++++++++ include/uapi/drm/drm.h | 10 +++++ 4 files changed, 88 insertions(+)
drivers/gpu/drm/drm_internal.h +2 -0
@@ -180,6 +180,8 @@ 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_transfer_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,
drivers/gpu/drm/drm_ioctl.c +2 -0
@@ -686,6 +686,8 @@ 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_TRANSFER , drm_syncobj_transfer_ioctl, +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 +74 -0
80 lines not on this page · raw message
include/uapi/drm/drm.h +10 -0
@@ -735,6 +735,15 @@ struct drm_syncobj_handle {__u32 pad; }; +struct drm_syncobj_transfer { +__u32 src_handle; +__u32 dst_handle; +__u64 src_point; +__u64 dst_point; +__u32 flags; +__u32 pad; +}; +#define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALL (1 << 0)#define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT (1 << 1)#define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_AVAILABLE (1 << 2)
@@ -933,6 +942,7 @@ 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_array) +#define DRM_IOCTL_SYNCOBJ_TRANSFER DRM_IOWR(0xCC, struct drm_syncobj_transfer)/** * Device specific ioctls should only be in their respective headers
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 8/9 drm/syncobj: add timeline signal ioctl for syncobj v3
In reply to a message not in the archivev2: individually allocate chain array, since chain node is free independently.
v3: all existing points must be already signaled before cpu perform signal operation,
so add check condition for that.
--- drivers/gpu/drm/drm_internal.h | 2 + drivers/gpu/drm/drm_ioctl.c | 2 + drivers/gpu/drm/drm_syncobj.c | 103 +++++++++++++++++++++++++++++++++ include/uapi/drm/drm.h | 1 + 4 files changed, 108 insertions(+)
drivers/gpu/drm/drm_internal.h +2 -0
@@ -190,6 +190,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_timeline_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);
drivers/gpu/drm/drm_ioctl.c +2 -0
@@ -696,6 +696,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_TIMELINE_SIGNAL , drm_syncobj_timeline_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),
drivers/gpu/drm/drm_syncobj.c +103 -0
109 lines not on this page · raw message
include/uapi/drm/drm.h +1 -0
@@ -943,6 +943,7 @@ 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_array)#define DRM_IOCTL_SYNCOBJ_TRANSFER DRM_IOWR(0xCC, struct drm_syncobj_transfer) +#define DRM_IOCTL_SYNCOBJ_TIMELINE_SIGNAL DRM_IOWR(0xCD, struct drm_syncobj_timeline_array)/** * Device specific ioctls should only be in their respective headers
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH 8/9] drm/syncobj: add timeline signal ioctl for syncobj v3
Quoted 80 lines · Chunming Zhou
v2: individually allocate chain array, since chain node is free independently.
v3: all existing points must be already signaled before cpu perform signal operation,
so add check condition for that.Signed-off-by Chunming Zhou <[email protected]>--- drivers/gpu/drm/drm_internal.h | 2 + drivers/gpu/drm/drm_ioctl.c | 2 + drivers/gpu/drm/drm_syncobj.c | 103 +++++++++++++++++++++++++++++++++ include/uapi/drm/drm.h | 1 + 4 files changed, 108 insertions(+)drivers/gpu/drm/drm_internal.h +2
-0@@ -190,6 +190,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_timeline_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);drivers/gpu/drm/drm_ioctl.c +2
-0@@ -696,6 +696,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_TIMELINE_SIGNAL , drm_syncobj_timeline_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),drivers/gpu/drm/drm_syncobj.c +34
-0@@ -1183,6 +1183,109 @@ drm_syncobj_signal_ioctl(struct drm_device *dev, void *data,return ret; } +int +drm_syncobj_timeline_signal_ioctl (struct drm_device *dev,void *data, +struct drm_file *file_private) +{ +struct drm_syncobj_timeline_array *args = data; +struct drm_syncobj **syncobjs; +struct dma_fence_chain **chains; +uint64_t *points; +uint32_t i, j, timeline_count =0 ; +int ret; + +if (!drm_core_check_feature (dev,DRIVER_SYNCOBJ )) +return -EOPNOTSUPP ; + +if (args->pad !=0 ) +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; + +for (i =0 ; i < args->count_handles; i++) { +struct dma_fence_chain *chain; +struct dma_fence *fence; + + fence =drm_syncobj_fence_get (syncobjs[i]); + chain =to_dma_fence_chain (fence); +if (chain) {
drivers/gpu/drm/drm_syncobj.c drm_syncobj_signal_ioctl(struct drm_device *dev, void *data, · line 1229
Quoted 10 lines
drivers/gpu/drm/drm_syncobj.c +10
-0+struct dma_fence *iter; + +dma_fence_chain_for_each (iter, fence) { +if (!iter) +break ; +if (!dma_fence_is_signaled (iter)) { +dma_fence_put (iter); +DRM_ERROR ("Client must guarantee all existing timeline points signaled before performing host signal operation!" ); + ret = -EPERM ; + goto out;
Sorry if I'm failing to remember whether we discussed this before.
Signaling a point from the host should be fine even if the previous points in the timeline are not signaled.
After all this can happen on the device side as well (out of order signaling).
I thought the thing we didn't want is out of order submission.
Just checking the last chain node seqno against the host signal point should be enough.
What about simply returning -EPERM, we can warn the application from userspace?
Quoted 34 lines
drivers/gpu/drm/drm_syncobj.c +34
-0+ } + } + } + } + + points =kmalloc_array (args->count_handles,sizeof (*points), +GFP_KERNEL ); +if (!points) { + ret = -ENOMEM ; + goto out; + } +if (!u64_to_user_ptr (args->points)) { +memset (points,0 , args->count_handles *sizeof (uint64_t )); + }else if (copy_from_user (points,u64_to_user_ptr (args->points), +sizeof (uint64_t ) * args->count_handles)) { + ret = -EFAULT ; + goto err_points; + } + + +for (i =0 ; i < args->count_handles; i++) { +if (points[i]) + timeline_count++; + } + chains =kmalloc_array (timeline_count,sizeof (void *),GFP_KERNEL ); +if (!chains) { + ret = -ENOMEM ; + goto err_points; + } +for (i =0 ; i < timeline_count; i++) { + chains[i] =kzalloc (sizeof (struct dma_fence_chain ),GFP_KERNEL ); +if (!chains[i]) { +for (j =0 ; j < i; j++) +kfree (chains[j]);
drivers/gpu/drm/drm_syncobj.c drm_syncobj_signal_ioctl(struct drm_device *dev, void *data, · line 1273
Quoted 10 lines
drivers/gpu/drm/drm_syncobj.c +10
-0+ ret = -ENOMEM ; + goto err_chains; + } + } + +for (i =0 , j =0 ; i < args->count_handles; i++) { +if (points[i]) { +struct dma_fence *fence =dma_fence_get_stub (); + + drm_syncobj_add_point(syncobjs[i], chains[j++],
Isn't this breaking with j++ ?, it should be part of the for() loop expression : for (i = 0, j = 0; i < arrags->count_handles; i++, j++)
Otherwise j will not increment at the same pace as i.
Quoted 23 lines
drivers/gpu/drm/drm_syncobj.c +15
-0+ fence, points[i]); +dma_fence_put (fence); + }else +drm_syncobj_assign_null_handle (syncobjs[i]); + } +err_chains: +kfree (chains); +err_points: +kfree (points); +out: +drm_syncobj_array_free (syncobjs, args->count_handles); + +return ret; +} +int drm_syncobj_query_ioctl (struct drm_device *dev,void *data,struct drm_file *file_private) {include/uapi/drm/drm.h +0
-0
include/uapi/drm/drm.h extern "C" { · line 949
Quoted 7 lines
include/uapi/drm/drm.h +1
-0@@ -943,6 +943,7 @@ 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_array)#define DRM_IOCTL_SYNCOBJ_TRANSFER DRM_IOWR(0xCC, struct drm_syncobj_transfer) +#define DRM_IOCTL_SYNCOBJ_TIMELINE_SIGNAL DRM_IOWR(0xCD, struct drm_syncobj_timeline_array)/** * Device specific ioctls should only be in their respective headers
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 78d9e191-7cdd-c9f1-c33e-2707b44e4932-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
Re: [PATCH 8/9] drm/syncobj: add timeline signal ioctl for syncobj v3
Quoted 99 lines · Lionel Landwerlin
Quoted 90 lines · Chunming Zhou
v2: individually allocate chain array, since chain node is free independently.
v3: all existing points must be already signaled before cpu perform signal operation, so add check condition for that.Signed-off-by Chunming Zhou <[email protected]>---
drivers/gpu/drm/drm_internal.h| 2 + drivers/gpu/drm/drm_ioctl.c | 2 + drivers/gpu/drm/drm_syncobj.c | 103 +++++++++++++++++++++++++++++++++ include/uapi/drm/drm.h | 1 +4 files changed, 108 insertions(+)drivers/gpu/drm/drm_internal.h +2
-0@@ -190,6 +190,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_timeline_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);
diff --gita/drivers/gpu/drm/drm_ioctl.cb/drivers/gpu/drm/drm_ioctl.cindex92b3b7b2fd81..d337f161909c100644drivers/gpu/drm/drm_ioctl.c +2
-0@@ -696,6 +696,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_TIMELINE_SIGNAL, drm_syncobj_timeline_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),drivers/gpu/drm/drm_syncobj.c +0
-0@@ -1183,6 +1183,109 @@ drm_syncobj_signal_ioctl(struct drm_device *dev, void *data, return ret; }+int
drivers/gpu/drm/drm_syncobj.c +41
-0+drm_syncobj_timeline_signal_ioctl(struct drm_device *dev, void *data, + struct drm_file *file_private) +{ + struct drm_syncobj_timeline_array *args = data; + struct drm_syncobj **syncobjs; + struct dma_fence_chain **chains; + uint64_t *points; + uint32_t i, j, timeline_count = 0; + int ret; + + if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ)) + return -EOPNOTSUPP; + + if (args->pad != 0) + 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; + + for (i = 0; i < args->count_handles; i++) { + struct dma_fence_chain *chain; + struct dma_fence *fence; + + fence = drm_syncobj_fence_get(syncobjs[i]); + chain = to_dma_fence_chain(fence); + if (chain) { + struct dma_fence *iter; + + dma_fence_chain_for_each(iter, fence) { + if (!iter) + break; + if (!dma_fence_is_signaled(iter)) { + dma_fence_put(iter); + DRM_ERROR("Client must guarantee all existingQuoted 3 lines
timeline points signaled before performing host signal operation!"); + ret =
-EPERM;
+ goto out;Sorry if I'm failing to remember whether we discussed this before.
Quoted 1 line
Signaling a point from the host should be fine even if the previous points in the timeline are not signaled.
ok, will remove that checking.
Quoted 10 lines
After all this can happen on the device side as well (out of order signaling).
I thought the thing we didn't want is out of order submission.
Just checking the last chain node seqno against the host signal point should be enough.
What about simply returning
-EPERM, we can warn the application from userspace?
OK, will add that.
Quoted 52 lines
Quoted 41 lines
+ }
+ }
+ }
+ }drivers/gpu/drm/drm_syncobj.c +27
-0+ + points = kmalloc_array(args->count_handles, sizeof(*points), + GFP_KERNEL); + if (!points) { + ret = -ENOMEM; + goto out; + } + if (!u64_to_user_ptr(args->points)) { + memset(points, 0, args->count_handles * sizeof(uint64_t)); + } else if (copy_from_user(points, u64_to_user_ptr(args->points), + sizeof(uint64_t) * args->count_handles)) { + ret = -EFAULT; + goto err_points; + } + + + for (i = 0; i < args->count_handles; i++) { + if (points[i]) + timeline_count++; + } + chains = kmalloc_array(timeline_count, sizeof(void *), GFP_KERNEL); + if (!chains) { + ret = -ENOMEM; + goto err_points; + } + for (i = 0; i < timeline_count; i++) { + chains[i] = kzalloc(sizeof(struct dma_fence_chain),
GFP_KERNEL);
+ if (!chains[i]) {
+ for (j = 0; j < i; j++)
+kfree(chains[j]);
+ ret =-ENOMEM;
+ gotoerr_chains;
+ }
+ }drivers/gpu/drm/drm_syncobj.c drm_syncobj_signal_ioctl(struct drm_device *dev, void *data, · line 1273
Quoted 6 lines
drivers/gpu/drm/drm_syncobj.c +6
-0+ + for (i = 0, j = 0; i < args->count_handles; i++) { + if (points[i]) { + struct dma_fence *fence = dma_fence_get_stub(); + + drm_syncobj_add_point(syncobjs[i], chains[j++],Isn't this breaking with j++ ?, it should be part of the
for()loop expression : for (i = 0, j = 0; i <arrags->count_handles; i++, j++)
Quoted 1 line
Otherwise j will not increment at the same pace as i.
I think that is intentional, because syncobj array could contain both binary and timeline. j is for timelien_count in this context.
-David
Quoted 24 lines
Quoted 24 lines
+ fence, points[i]);
+dma_fence_put(fence);
+ } else
+drm_syncobj_assign_null_handle(syncobjs[i]); + }drivers/gpu/drm/drm_syncobj.c +10
-0+err_chains: + kfree(chains); +err_points: + kfree(points); +out: + drm_syncobj_array_free(syncobjs, args->count_handles); + + return ret; +} +int
drm_syncobj_query_ioctl(struct drm_device *dev, void *data, struct drm_file *file_private)
{include/uapi/drm/drm.h +0
-0
Quoted 10 lines
include/uapi/drm/drm.h extern "C" { · line 949
Quoted 8 lines
include/uapi/drm/drm.h +1
-0@@ -943,6 +943,7 @@ 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_array) #define DRM_IOCTL_SYNCOBJ_TRANSFER DRM_IOWR(0xCC, struct drm_syncobj_transfer) +#define DRM_IOCTL_SYNCOBJ_TIMELINE_SIGNAL DRM_IOWR(0xCD, struct drm_syncobj_timeline_array) /*** Device specific ioctls should only be in their respective headers
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): e4f8f010-2649-f8fc-5949-9b652a3e977e-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 8/9] drm/syncobj: add timeline signal ioctl for syncobj v3
Quoted 171 lines · On 20/03/2019 03:53, zhoucm1 wrote:
Quoted 100 lines · Lionel Landwerlin
Quoted 91 lines · Chunming Zhou
v2: individually allocate chain array, since chain node is free independently.
v3: all existing points must be already signaled before cpu perform signal operation, so add check condition for that.Signed-off-by Chunming Zhou <[email protected]>---
drivers/gpu/drm/drm_internal.h| 2 +
drivers/gpu/drm/drm_ioctl.c | 2 +
drivers/gpu/drm/drm_syncobj.c | 103
+++++++++++++++++++++++++++++++++
include/uapi/drm/drm.h | 1 +4 files changed, 108 insertions(+)drivers/gpu/drm/drm_internal.h +2
-0@@ -190,6 +190,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_timeline_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);
diff --gita/drivers/gpu/drm/drm_ioctl.cb/drivers/gpu/drm/drm_ioctl.cindex92b3b7b2fd81..d337f161909c100644drivers/gpu/drm/drm_ioctl.c +2
-0@@ -696,6 +696,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_TIMELINE_SIGNAL, drm_syncobj_timeline_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),drivers/gpu/drm/drm_syncobj.c +0
-0@@ -1183,6 +1183,109 @@ drm_syncobj_signal_ioctl(struct drm_device *dev, void *data, return ret; }+int
drivers/gpu/drm/drm_syncobj.c +41
-0+drm_syncobj_timeline_signal_ioctl(struct drm_device *dev, void *data, + struct drm_file *file_private) +{ + struct drm_syncobj_timeline_array *args = data; + struct drm_syncobj **syncobjs; + struct dma_fence_chain **chains; + uint64_t *points; + uint32_t i, j, timeline_count = 0; + int ret; + + if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ)) + return -EOPNOTSUPP; + + if (args->pad != 0) + 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; + + for (i = 0; i < args->count_handles; i++) { + struct dma_fence_chain *chain; + struct dma_fence *fence; + + fence = drm_syncobj_fence_get(syncobjs[i]); + chain = to_dma_fence_chain(fence); + if (chain) { + struct dma_fence *iter; + + dma_fence_chain_for_each(iter, fence) { + if (!iter) + break; + if (!dma_fence_is_signaled(iter)) { + dma_fence_put(iter); + DRM_ERROR("Client must guarantee all existingQuoted 3 lines
timeline points signaled before performing host signal operation!"); + ret =
-EPERM;
+ goto out;Sorry if I'm failing to remember whether we discussed this before.
Quoted 1 line
Signaling a point from the host should be fine even if the previous points in the timeline are not signaled.
ok, will remove that checking.
Quoted 10 lines
After all this can happen on the device side as well (out of order signaling).
I thought the thing we didn't want is out of order submission.
Just checking the last chain node seqno against the host signal point should be enough.
What about simply returning
-EPERM, we can warn the application from userspace?OK, will add that.
Quoted 53 lines
Quoted 42 lines
+ }
+ }
+ }
+ }drivers/gpu/drm/drm_syncobj.c +21
-0+ + points = kmalloc_array(args->count_handles, sizeof(*points), + GFP_KERNEL); + if (!points) { + ret = -ENOMEM; + goto out; + } + if (!u64_to_user_ptr(args->points)) { + memset(points, 0, args->count_handles * sizeof(uint64_t)); + } else if (copy_from_user(points, u64_to_user_ptr(args->points), + sizeof(uint64_t) * args->count_handles)) { + ret = -EFAULT; + goto err_points; + } + + + for (i = 0; i < args->count_handles; i++) { + if (points[i]) + timeline_count++; + } + chains = kmalloc_array(timeline_count, sizeof(void *),
GFP_KERNEL);
+ if (!chains) {
+ ret =-ENOMEM;
+ gotoerr_points;
+ }
+ for (i = 0; i <timeline_count; i++) {
+ chains[i] =kzalloc(sizeof(struct dma_fence_chain), GFP_KERNEL);
+ if (!chains[i]) {
+ for (j = 0; j < i; j++)
+kfree(chains[j]);
+ ret =-ENOMEM;
+ gotoerr_chains;
+ }
+ }drivers/gpu/drm/drm_syncobj.c drm_syncobj_signal_ioctl(struct drm_device *dev, void *data, · line 1273
Quoted 6 lines
drivers/gpu/drm/drm_syncobj.c +6
-0+ + for (i = 0, j = 0; i < args->count_handles; i++) { + if (points[i]) { + struct dma_fence *fence = dma_fence_get_stub(); + + drm_syncobj_add_point(syncobjs[i], chains[j++],Isn't this breaking with j++ ?, it should be part of the
for()loop expression : for (i = 0, j = 0; i <arrags->count_handles; i++, j++)
Quoted 4 lines
Quoted 1 line
Otherwise j will not increment at the same pace as i.
I think that is intentional, because syncobj array could contain both binary and timeline. j is for
timelien_countin this context.-David
To be fair, I think it would be easier for applications to supply 0 for binary syncobjs.
It also copies count_handles points from userspace, so it would also be more consistent.
Sorry for not spotting this earlier.
-Lionel
Quoted 26 lines
Quoted 26 lines
Quoted 26 lines
+ fence, points[i]);
+dma_fence_put(fence);
+ } else
+drm_syncobj_assign_null_handle(syncobjs[i]); + }drivers/gpu/drm/drm_syncobj.c +10
-0+err_chains: + kfree(chains); +err_points: + kfree(points); +out: + drm_syncobj_array_free(syncobjs, args->count_handles); + + return ret; +} +int
drm_syncobj_query_ioctl(struct drm_device *dev, void *data, struct drm_file *file_private)
{include/uapi/drm/drm.h +0
-0@@ -943,6 +943,7 @@ extern "C" { #define DRM_IOCTL_SYNCOBJ_TIMELINE_WAIT DRM_IOWR(0xCA, struct drm_syncobj_timeline_wait)
Quoted 10 lines
Quoted 8 lines
include/uapi/drm/drm.h extern "C" { · line 949
Quoted 6 lines
include/uapi/drm/drm.h +1
-0#define DRM_IOCTL_SYNCOBJ_QUERY DRM_IOWR(0xCB, struct drm_syncobj_timeline_array) #define DRM_IOCTL_SYNCOBJ_TRANSFER DRM_IOWR(0xCC, struct drm_syncobj_transfer) +#define DRM_IOCTL_SYNCOBJ_TIMELINE_SIGNAL DRM_IOWR(0xCD, struct drm_syncobj_timeline_array) /*** Device specific ioctls should only be in their respective headers
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 8/9] drm/syncobj: add timeline signal ioctl for syncobj v3
In reply to a message not in the archiveQuoted 110 lines · On 20/03/2019 03:53, zhoucm1 wrote:
Quoted 100 lines · Lionel Landwerlin
Quoted 91 lines · Chunming Zhou
v2: individually allocate chain array, since chain node is free independently.
v3: all existing points must be already signaled before cpu perform signal operation, so add check condition for that.Signed-off-by Chunming Zhou <[email protected]>---
drivers/gpu/drm/drm_internal.h| 2 +
drivers/gpu/drm/drm_ioctl.c | 2 +
drivers/gpu/drm/drm_syncobj.c | 103
+++++++++++++++++++++++++++++++++
include/uapi/drm/drm.h | 1 +4 files changed, 108 insertions(+)drivers/gpu/drm/drm_internal.h +2
-0@@ -190,6 +190,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_timeline_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);
diff --gita/drivers/gpu/drm/drm_ioctl.cb/drivers/gpu/drm/drm_ioctl.cindex92b3b7b2fd81..d337f161909c100644drivers/gpu/drm/drm_ioctl.c +2
-0@@ -696,6 +696,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_TIMELINE_SIGNAL, drm_syncobj_timeline_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),drivers/gpu/drm/drm_syncobj.c +0
-0@@ -1183,6 +1183,109 @@ drm_syncobj_signal_ioctl(struct drm_device *dev, void *data, return ret; }+int
drivers/gpu/drm/drm_syncobj.c +41
-0+drm_syncobj_timeline_signal_ioctl(struct drm_device *dev, void *data, + struct drm_file *file_private) +{ + struct drm_syncobj_timeline_array *args = data; + struct drm_syncobj **syncobjs; + struct dma_fence_chain **chains; + uint64_t *points; + uint32_t i, j, timeline_count = 0; + int ret; + + if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ)) + return -EOPNOTSUPP; + + if (args->pad != 0) + 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; + + for (i = 0; i < args->count_handles; i++) { + struct dma_fence_chain *chain; + struct dma_fence *fence; + + fence = drm_syncobj_fence_get(syncobjs[i]); + chain = to_dma_fence_chain(fence); + if (chain) { + struct dma_fence *iter; + + dma_fence_chain_for_each(iter, fence) { + if (!iter) + break; + if (!dma_fence_is_signaled(iter)) { + dma_fence_put(iter); + DRM_ERROR("Client must guarantee all existingQuoted 3 lines
timeline points signaled before performing host signal operation!"); + ret =
-EPERM;
+ goto out;Sorry if I'm failing to remember whether we discussed this before.
Quoted 1 line
Signaling a point from the host should be fine even if the previous points in the timeline are not signaled.
ok, will remove that checking.
Quoted 4 lines
After all this can happen on the device side as well (out of order signaling).
Quoted 7 lines
Quoted 6 lines
I thought the thing we didn't want is out of order submission.
Just checking the last chain node seqno against the host signal point should be enough.
What about simply returning
-EPERM, we can warn the application from userspace?OK, will add that.
Sorry for coming back to this again, but we probably ought to drop this check completely.
This is allowed on the device signaling side, so I'm not quite sure what that protects us from.
Also we do the check at this point in the signal_timeline_ioctl() function but there is nothing that says that when we later call the add_point() function this condition still holds.
-Lionel
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 9/9 drm/amdgpu: update version for timeline syncobj support in amdgpu
In reply to a message not in the archive--- 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
@@ -74,9 +74,10 @@* - 3.28.0 - Add AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES * - 3.29.0 - Add AMDGPU_IB_FLAG_RESET_GDS_MAX_WAVE_ID * - 3.30.0 - Add AMDGPU_SCHED_OP_CONTEXT_PRIORITY_OVERRIDE. +* - 3.31.0 - Add syncobj timeline support to AMDGPU_CS. */ #define KMS_DRIVER_MAJOR 3 -#define KMS_DRIVER_MINOR 30 +#define KMS_DRIVER_MINOR 31#define KMS_DRIVER_PATCHLEVEL 0int amdgpu_vram_limit =0 ;
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 311 lines · Chunming Zhou
From: Christian König <[email protected]>
Lockless container implementation similar to a
dma_fence_array, but with only two elements per node and automatic garbage collection.v2: properly document
dma_fence_chain_for_each, adddma_fence_chain_find_seqno,
drop prev reference during garbage collection if it's not a chain fence.
v3: use head and iterator fordma_fence_chain_for_each
v4: fix reference count indma_fence_chain_enable_signaling
v5: fix iteration when walking each chain nodeSigned-off-by Christian König <[email protected]>--- drivers/dma-buf/Makefile | 3 +- drivers/dma-buf/dma-fence-chain.c | 241 ++++++++++++++++++++++++++++++ include/linux/dma-fence-chain.h | 81 ++++++++++ 3 files changed, 324 insertions(+), 1 deletion(-)create mode 100644
drivers/dma-buf/dma-fence-chain.ccreate mode 100644include/linux/dma-fence-chain.hdrivers/dma-buf/Makefile +2
-1@@ -1,4 +1,5 @@ -obj-y := dma-buf.o dma-fence.o dma-fence-array.o reservation.o seqno-fence.o +obj-y := dma-buf.o dma-fence.o dma-fence-array.o dma-fence-chain.o \ + reservation.o seqno-fence.o obj-$(CONFIG_SYNC_FILE) += sync_file.o obj-$(CONFIG_SW_SYNC) += sw_sync.o sync_debug.o obj-$(CONFIG_UDMABUF) += udmabuf.odrivers/dma-buf/dma-fence-chain.c new file +241
-0@@ -0,0 +1,241 @@ +/* +* fence-chain: chain fences together in a timeline +* +* Copyright (C) 2018 Advanced Micro Devices, Inc. +* Authors: +* Christian König <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License version 2 as published by +* the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +*/ + +#include <linux/dma-fence-chain.h> + +static bool dma_fence_chain_enable_signaling (struct dma_fence *fence); + +/** +* dma_fence_chain_get_prev - use RCU to get a reference to the previous fence +* @chain: chain node to get the previous node from +* +* Use dma_fence_get_rcu_safe to get a reference to the previous fence of the +* chain node. +*/ +static struct dma_fence *dma_fence_chain_get_prev (struct dma_fence_chain *chain) +{ +struct dma_fence *prev; + +rcu_read_lock (); + prev =dma_fence_get_rcu_safe (&chain->prev); +rcu_read_unlock (); +return prev; +} + +/** +* dma_fence_chain_walk - chain walking function +* @fence: current chain node +* +* Walk the chain to the next node. Returns the next fence or NULL if we are at +* the end of the chain. Garbage collects chain nodes which are already +* signaled. +*/ +struct dma_fence *dma_fence_chain_walk (struct dma_fence *fence) +{ +struct dma_fence_chain *chain, *prev_chain; +struct dma_fence *prev, *replacement, *tmp; + + chain =to_dma_fence_chain (fence); +if (!chain) { +dma_fence_put (fence); +return NULL ; + } + +while ((prev =dma_fence_chain_get_prev (chain))) { + + prev_chain =to_dma_fence_chain (prev); +if (prev_chain) { +if (!dma_fence_is_signaled (prev_chain->fence)) +break ; + + replacement =dma_fence_chain_get_prev (prev_chain); + }else { +if (!dma_fence_is_signaled (prev)) +break ; + + replacement =NULL ; + } + + tmp =cmpxchg (&chain->prev, prev, replacement); +if (tmp == prev) +dma_fence_put (tmp); +else +dma_fence_put (replacement); +dma_fence_put (prev); + } + +dma_fence_put (fence); +return prev; +} +EXPORT_SYMBOL (dma_fence_chain_walk); + +/** +* dma_fence_chain_find_seqno - find fence chain node by seqno +* @pfence: pointer to the chain node where to start +* @seqno: the sequence number to search for +* +* Advance the fence pointer to the chain node which will signal this sequence +* number. If no sequence number is provided then this is a no-op. +* +* Returns EINVAL if the fence is not a chain node or the sequence number has +* not yet advanced far enough. +*/ +int dma_fence_chain_find_seqno (struct dma_fence **pfence,uint64_t seqno) +{ +struct dma_fence_chain *chain; + +if (!seqno) +return 0 ; + + chain =to_dma_fence_chain (*pfence); +if (!chain || chain->base.seqno < seqno) +return -EINVAL ; + +dma_fence_chain_for_each (*pfence, &chain->base) { +if ((*pfence)->context != chain->base.context || +to_dma_fence_chain (*pfence)->prev_seqno < seqno) +break ; + } +dma_fence_put (&chain->base); + +return 0 ; +} +EXPORT_SYMBOL (dma_fence_chain_find_seqno); + +static const char *dma_fence_chain_get_driver_name (struct dma_fence *fence) +{ +return "dma_fence_chain" ; +} + +static const char *dma_fence_chain_get_timeline_name (struct dma_fence *fence) +{ +return "unbound" ; +} + +static void dma_fence_chain_irq_work (struct irq_work *work) +{ +struct dma_fence_chain *chain; + + chain =container_of (work,typeof (*chain), work); + +/* Try to rearm the callback */ +if (!dma_fence_chain_enable_signaling (&chain->base)) +/* Ok, we are done. No more unsignaled fences left */ +dma_fence_signal (&chain->base); +dma_fence_put (&chain->base); +} + +static void dma_fence_chain_cb (struct dma_fence *f,struct dma_fence_cb *cb) +{ +struct dma_fence_chain *chain; + + chain =container_of (cb,typeof (*chain), cb); +irq_work_queue (&chain->work); +dma_fence_put (f); +} + +static bool dma_fence_chain_enable_signaling (struct dma_fence *fence) +{ +struct dma_fence_chain *head =to_dma_fence_chain (fence); + +dma_fence_get (&head->base); +dma_fence_chain_for_each (fence, &head->base) { +struct dma_fence_chain *chain =to_dma_fence_chain (fence); +struct dma_fence *f = chain ? chain->fence : fence; + +dma_fence_get (f); +if (!dma_fence_add_callback (f, &head->cb, dma_fence_chain_cb)) { +dma_fence_put (fence); +return true; + } +dma_fence_put (f); + } +dma_fence_put (&head->base); +return false; +} + +static bool dma_fence_chain_signaled (struct dma_fence *fence) +{ +dma_fence_chain_for_each (fence, fence) { +struct dma_fence_chain *chain =to_dma_fence_chain (fence); +struct dma_fence *f = chain ? chain->fence : fence; + +if (!dma_fence_is_signaled (f)) { +dma_fence_put (fence); +return false; + } + } + +return true; +} + +static void dma_fence_chain_release (struct dma_fence *fence) +{ +struct dma_fence_chain *chain =to_dma_fence_chain (fence); + +dma_fence_put (chain->prev); +dma_fence_put (chain->fence); +dma_fence_free (fence); +} + +const struct dma_fence_ops dma_fence_chain_ops = { + .get_driver_name = dma_fence_chain_get_driver_name, + .get_timeline_name = dma_fence_chain_get_timeline_name, + .enable_signaling = dma_fence_chain_enable_signaling, + .signaled = dma_fence_chain_signaled, + .release = dma_fence_chain_release, +}; +EXPORT_SYMBOL (dma_fence_chain_ops); + +/** +* dma_fence_chain_init - initialize a fence chain +* @chain: the chain node to initialize +* @prev: the previous fence +* @fence: the current fence +* +* Initialize a new chain node and either start a new chain or add the node to +* the existing chain of the previous fence. +*/ +void dma_fence_chain_init (struct dma_fence_chain *chain, +struct dma_fence *prev, +struct dma_fence *fence, +uint64_t seqno) +{ +struct dma_fence_chain *prev_chain =to_dma_fence_chain (prev); +uint64_t context; + +spin_lock_init (&chain->lock); + chain->prev = prev; + chain->fence = fence; + chain->prev_seqno =0 ; +init_irq_work (&chain->work, dma_fence_chain_irq_work); + +/* Try to reuse the context of the previous chain node. */ +if (prev_chain &&__dma_fence_is_later (seqno, prev->seqno)) { + context = prev->context; + chain->prev_seqno = prev->seqno; + }else { + context =dma_fence_context_alloc (1 ); +/* Make sure that we always have a valid sequence number. */ +if (prev_chain) + seqno =max (prev->seqno, seqno); + } + +dma_fence_init (&chain->base, &dma_fence_chain_ops, + &chain->lock, context, seqno); +} +EXPORT_SYMBOL (dma_fence_chain_init);include/linux/dma-fence-chain.h new file +27
-0@@ -0,0 +1,81 @@ +/* +* fence-chain: chain fences together in a timeline +* +* Copyright (C) 2018 Advanced Micro Devices, Inc. +* Authors: +* Christian König <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License version 2 as published by +* the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +*/ + +#ifndef __LINUX_DMA_FENCE_CHAIN_H +#define __LINUX_DMA_FENCE_CHAIN_H + +#include <linux/dma-fence.h> +#include <linux/irq_work.h> + +/** +* struct dma_fence_chain - fence to represent an node of a fence chain +* @base: fence base class +* @lock: spinlock for fence handling
include/linux/dma-fence-chain.h line 37
Quoted 10 lines
include/linux/dma-fence-chain.h new file +10
-0+* @prev: previous fence of the chain +* @prev_seqno: original previous seqno before garbage collection +* @fence: encapsulated fence +* @cb: callback structure for signaling +* @work: irq work item for signaling +*/ +struct dma_fence_chain { +struct dma_fence base; +spinlock_t lock; +struct dma_fence *prev;
Not an expert on the rcu thing, but drm_syncobj has a __rcu on its fence field.
Should this be? :
struct dma_fence __rcu *prev;
Quoted 34 lines
include/linux/dma-fence-chain.h new file +34
-0+u64 prev_seqno; +struct dma_fence *fence; +struct dma_fence_cb cb; +struct irq_work work; +}; + +extern const struct dma_fence_ops dma_fence_chain_ops; + +/** +* to_dma_fence_chain - cast a fence to a dma_fence_chain +* @fence: fence to cast to a dma_fence_array +* +* Returns NULL if the fence is not a dma_fence_chain, +* or the dma_fence_chain otherwise. +*/ +static inline struct dma_fence_chain * +to_dma_fence_chain (struct dma_fence *fence) +{ +if (!fence || fence->ops != &dma_fence_chain_ops) +return NULL ; + + return container_of(fence, struct dma_fence_chain, base); +} + +/** +* dma_fence_chain_for_each - iterate over all fences in chain +* @iter: current fence +* @head: starting point +* +* Iterate over all fences in the chain. We keep a reference to the current +* fence while inside the loop which must be dropped when breaking out. +*/ +#define dma_fence_chain_for_each (iter, head) \ + for (iter = dma_fence_get(head); iter; \
include/linux/dma-fence-chain.h line 81
Quoted 10 lines
include/linux/dma-fence-chain.h new file +10
-0+ iter = dma_fence_chain_walk(iter)) + +struct dma_fence *dma_fence_chain_walk (struct dma_fence *fence); +int dma_fence_chain_find_seqno (struct dma_fence **pfence,uint64_t seqno); +void dma_fence_chain_init (struct dma_fence_chain *chain, +struct dma_fence *prev, +struct dma_fence *fence, +uint64_t seqno); + +#endif /* __LINUX_DMA_FENCE_CHAIN_H */
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 946e2cc2-eda7-7e7f-80ad-fa7161942930-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
Am 19.03.19 um 13:27 schrieb Lionel Landwerlin:
Quoted 20 lines · Chunming Zhou
Quoted 5 lines
[SNIP]
include/linux/dma-fence-chain.h new file +4
-0+/** +* struct dma_fence_chain - fence to represent an node of a fence chain +* @base: fence base class +* @lock: spinlock for fence handling include/linux/dma-fence-chain.h line 37
Quoted 10 lines
include/linux/dma-fence-chain.h new file +10
-0+* @prev: previous fence of the chain +* @prev_seqno: original previous seqno before garbage collection +* @fence: encapsulated fence +* @cb: callback structure for signaling +* @work: irq work item for signaling +*/ +struct dma_fence_chain { + struct dma_fence base; + spinlock_t lock; + struct dma_fence *prev;Not an expert on the rcu thing, but
drm_syncobjhas a__rcuon its fence field.
Quoted 4 lines
Should this be? :
struct
dma_fence__rcu*prev;
Yeah, the kbuild robot has already complained about this as well.
Needs to be fixed before pushed, but its only a minor change.
Christian.
Quoted 40 lines
Quoted 40 lines
+ u64
prev_seqno;
+ structdma_fence*fence;
+ structdma_fence_cbcb;
+ structirq_workwork;include/linux/dma-fence-chain.h new file +26
-0+}; + +extern const struct dma_fence_ops dma_fence_chain_ops; + +/** +* to_dma_fence_chain - cast a fence to a dma_fence_chain +* @fence: fence to cast to a dma_fence_array +* +* Returns NULL if the fence is not a dma_fence_chain, +* or the dma_fence_chain otherwise. +*/ +static inline struct dma_fence_chain * +to_dma_fence_chain (struct dma_fence *fence) +{ + if (!fence || fence->ops != &dma_fence_chain_ops) + return NULL; + + return container_of(fence, struct dma_fence_chain, base); +} + +/** +* dma_fence_chain_for_each - iterate over all fences in chain +* @iter: current fence +* @head: starting point +* +* Iterate over all fences in the chain. We keep a reference to the current
+ * fence while inside the loop which must be dropped when breaking out.
+ */include/linux/dma-fence-chain.h new file +5
-0+#define dma_fence_chain_for_each (iter, head) \ + for (iter = dma_fence_get(head); iter; \ + iter = dma_fence_chain_walk(iter)) + +struct dma_fence *dma_fence_chain_walk (struct dma_fence *fence);
Quoted 10 lines
include/linux/dma-fence-chain.h line 81
Quoted 8 lines
+int
dma_fence_chain_find_seqno(struct dma_fence **pfence, uint64_t seqno);include/linux/dma-fence-chain.h new file +6
-0+void dma_fence_chain_init (struct dma_fence_chain *chain, + struct dma_fence *prev, + struct dma_fence *fence, + uint64_t seqno); + +#endif /* __LINUX_DMA_FENCE_CHAIN_H */
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 6/9 drm/amdgpu: add timeline support in amdgpu CS v3
In reply to Chunming Zhousyncobj wait/signal operation is appending in command submission.
v2: separate to two kinds in/out_deps functions
v3: fix checking for timeline syncobj
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 10 +- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 152 +++++++++++++++++++++---- include/uapi/drm/amdgpu_drm.h | 8 ++ 3 files changed, 144 insertions(+), 26 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +8 -2
@@ -433,6 +433,12 @@ struct amdgpu_cs_chunk {void *kdata; }; +struct amdgpu_cs_post_dep { +struct drm_syncobj *syncobj; +struct dma_fence_chain *chain; +u64 point; +}; +struct amdgpu_cs_parser {struct amdgpu_device *adev;struct drm_file *filp;
@@ -462,8 +468,8 @@ struct amdgpu_cs_parser {/* user fence */ struct amdgpu_bo_list_entry uf_entry; -unsigned num_post_dep_syncobjs; -struct drm_syncobj **post_dep_syncobjs; +unsigned num_post_deps; +struct amdgpu_cs_post_dep *post_deps; }; static inline u32 amdgpu_get_ib_value(struct amdgpu_cs_parser *p,
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +128 -24
229 lines not on this page · raw message
include/uapi/drm/amdgpu_drm.h +8 -0
@@ -525,6 +525,8 @@ struct drm_amdgpu_gem_va {#define AMDGPU_CHUNK_ID_SYNCOBJ_OUT 0x05#define AMDGPU_CHUNK_ID_BO_HANDLES 0x06#define AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES 0x07 +#define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_WAIT 0x08 +#define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_SIGNAL 0x09struct drm_amdgpu_cs_chunk {__u32 chunk_id;
@@ -605,6 +607,12 @@ 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