From: Daniel Vetter <daniel@ffwll.ch> To: "Christian König" <ckoenig.leichtzumerken@gmail.com> Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: Re: [PATCH 1/5] dma-buf: fix dma_resv_test_signaled test_all handling Date: Fri, 11 Jun 2021 16:47:58 +0200 [thread overview] Message-ID: <YMN3nr1mTj09p8lT@phenom.ffwll.local> (raw) In-Reply-To: <20210611120301.10595-1-christian.koenig@amd.com> On Fri, Jun 11, 2021 at 02:02:57PM +0200, Christian König wrote: > As the name implies if testing all fences is requested we > should indeed test all fences and not skip the exclusive > one because we see shared ones. > > Signed-off-by: Christian König <christian.koenig@amd.com> Hm I thought we've had the rule that when both fences exist, then collectively the shared ones must signale no earlier than the exclusive one. That's at least the contract we've implemented in dma_resv.h. But I've also found a bunch of drivers who are a lot more yolo on this. I think there's a solid case here to just always take all the fences if we ask for all the shared ones, but if we go that way then I'd say - clear kerneldoc patch to really hammer this in (currently we're not good at all in this regard) - going through drivers a bit to check for this (I have some of that done already in my earlier series, need to respin it and send it out) But I'm kinda not seeing why this needs to be in this patch series here. -Daniel > --- > drivers/dma-buf/dma-resv.c | 33 ++++++++++++--------------------- > 1 file changed, 12 insertions(+), 21 deletions(-) > > diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c > index f26c71747d43..c66bfdde9454 100644 > --- a/drivers/dma-buf/dma-resv.c > +++ b/drivers/dma-buf/dma-resv.c > @@ -615,25 +615,21 @@ static inline int dma_resv_test_signaled_single(struct dma_fence *passed_fence) > */ > bool dma_resv_test_signaled(struct dma_resv *obj, bool test_all) > { > - unsigned int seq, shared_count; > + struct dma_fence *fence; > + unsigned int seq; > int ret; > > rcu_read_lock(); > retry: > ret = true; > - shared_count = 0; > seq = read_seqcount_begin(&obj->seq); > > if (test_all) { > struct dma_resv_list *fobj = dma_resv_shared_list(obj); > - unsigned int i; > - > - if (fobj) > - shared_count = fobj->shared_count; > + unsigned int i, shared_count; > > + shared_count = fobj ? fobj->shared_count : 0; > for (i = 0; i < shared_count; ++i) { > - struct dma_fence *fence; > - > fence = rcu_dereference(fobj->shared[i]); > ret = dma_resv_test_signaled_single(fence); > if (ret < 0) > @@ -641,24 +637,19 @@ bool dma_resv_test_signaled(struct dma_resv *obj, bool test_all) > else if (!ret) > break; > } > - > - if (read_seqcount_retry(&obj->seq, seq)) > - goto retry; > } > > - if (!shared_count) { > - struct dma_fence *fence_excl = dma_resv_excl_fence(obj); > - > - if (fence_excl) { > - ret = dma_resv_test_signaled_single(fence_excl); > - if (ret < 0) > - goto retry; > + fence = dma_resv_excl_fence(obj); > + if (fence) { > + ret = dma_resv_test_signaled_single(fence); > + if (ret < 0) > + goto retry; > > - if (read_seqcount_retry(&obj->seq, seq)) > - goto retry; > - } > } > > + if (read_seqcount_retry(&obj->seq, seq)) > + goto retry; > + > rcu_read_unlock(); > return ret; > } > -- > 2.25.1 > -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
WARNING: multiple messages have this Message-ID (diff)
From: Daniel Vetter <daniel@ffwll.ch> To: "Christian König" <ckoenig.leichtzumerken@gmail.com> Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, daniel@ffwll.ch Subject: Re: [PATCH 1/5] dma-buf: fix dma_resv_test_signaled test_all handling Date: Fri, 11 Jun 2021 16:47:58 +0200 [thread overview] Message-ID: <YMN3nr1mTj09p8lT@phenom.ffwll.local> (raw) In-Reply-To: <20210611120301.10595-1-christian.koenig@amd.com> On Fri, Jun 11, 2021 at 02:02:57PM +0200, Christian König wrote: > As the name implies if testing all fences is requested we > should indeed test all fences and not skip the exclusive > one because we see shared ones. > > Signed-off-by: Christian König <christian.koenig@amd.com> Hm I thought we've had the rule that when both fences exist, then collectively the shared ones must signale no earlier than the exclusive one. That's at least the contract we've implemented in dma_resv.h. But I've also found a bunch of drivers who are a lot more yolo on this. I think there's a solid case here to just always take all the fences if we ask for all the shared ones, but if we go that way then I'd say - clear kerneldoc patch to really hammer this in (currently we're not good at all in this regard) - going through drivers a bit to check for this (I have some of that done already in my earlier series, need to respin it and send it out) But I'm kinda not seeing why this needs to be in this patch series here. -Daniel > --- > drivers/dma-buf/dma-resv.c | 33 ++++++++++++--------------------- > 1 file changed, 12 insertions(+), 21 deletions(-) > > diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c > index f26c71747d43..c66bfdde9454 100644 > --- a/drivers/dma-buf/dma-resv.c > +++ b/drivers/dma-buf/dma-resv.c > @@ -615,25 +615,21 @@ static inline int dma_resv_test_signaled_single(struct dma_fence *passed_fence) > */ > bool dma_resv_test_signaled(struct dma_resv *obj, bool test_all) > { > - unsigned int seq, shared_count; > + struct dma_fence *fence; > + unsigned int seq; > int ret; > > rcu_read_lock(); > retry: > ret = true; > - shared_count = 0; > seq = read_seqcount_begin(&obj->seq); > > if (test_all) { > struct dma_resv_list *fobj = dma_resv_shared_list(obj); > - unsigned int i; > - > - if (fobj) > - shared_count = fobj->shared_count; > + unsigned int i, shared_count; > > + shared_count = fobj ? fobj->shared_count : 0; > for (i = 0; i < shared_count; ++i) { > - struct dma_fence *fence; > - > fence = rcu_dereference(fobj->shared[i]); > ret = dma_resv_test_signaled_single(fence); > if (ret < 0) > @@ -641,24 +637,19 @@ bool dma_resv_test_signaled(struct dma_resv *obj, bool test_all) > else if (!ret) > break; > } > - > - if (read_seqcount_retry(&obj->seq, seq)) > - goto retry; > } > > - if (!shared_count) { > - struct dma_fence *fence_excl = dma_resv_excl_fence(obj); > - > - if (fence_excl) { > - ret = dma_resv_test_signaled_single(fence_excl); > - if (ret < 0) > - goto retry; > + fence = dma_resv_excl_fence(obj); > + if (fence) { > + ret = dma_resv_test_signaled_single(fence); > + if (ret < 0) > + goto retry; > > - if (read_seqcount_retry(&obj->seq, seq)) > - goto retry; > - } > } > > + if (read_seqcount_retry(&obj->seq, seq)) > + goto retry; > + > rcu_read_unlock(); > return ret; > } > -- > 2.25.1 > -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ amd-gfx mailing list amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx
next prev parent reply other threads:[~2021-06-11 14:48 UTC|newest] Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-06-11 12:02 [PATCH 1/5] dma-buf: fix dma_resv_test_signaled test_all handling Christian König 2021-06-11 12:02 ` Christian König 2021-06-11 12:02 ` [PATCH 2/5] dma-buf: some dma_fence_chain improvements Christian König 2021-06-11 12:02 ` Christian König 2021-06-11 12:02 ` [PATCH 3/5] dma-buf: add dma_fence_chain_alloc/free v2 Christian König 2021-06-11 12:02 ` Christian König 2021-06-11 14:52 ` Daniel Vetter 2021-06-11 14:52 ` Daniel Vetter 2021-06-11 14:54 ` Christian König 2021-06-11 14:54 ` Christian König 2021-06-11 12:03 ` [PATCH 4/5] drm/amdgpu: unwrap fence chains in the explicit sync fence Christian König 2021-06-11 12:03 ` Christian König 2021-06-11 12:03 ` [PATCH 5/5] drm/amdgpu: rework dma_resv handling v2 Christian König 2021-06-11 12:03 ` Christian König 2021-06-11 14:56 ` Daniel Vetter 2021-06-11 14:56 ` Daniel Vetter 2021-06-11 15:10 ` Christian König 2021-06-11 15:10 ` Christian König 2021-06-11 14:47 ` Daniel Vetter [this message] 2021-06-11 14:47 ` [PATCH 1/5] dma-buf: fix dma_resv_test_signaled test_all handling Daniel Vetter 2021-06-11 14:53 ` Christian König 2021-06-11 14:53 ` Christian König 2021-06-11 14:55 ` Daniel Vetter 2021-06-11 14:55 ` Daniel Vetter 2021-06-14 17:15 ` Christian König 2021-06-14 17:15 ` Christian König 2021-06-17 16:58 ` Daniel Vetter 2021-06-17 16:58 ` Daniel Vetter
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=YMN3nr1mTj09p8lT@phenom.ffwll.local \ --to=daniel@ffwll.ch \ --cc=amd-gfx@lists.freedesktop.org \ --cc=ckoenig.leichtzumerken@gmail.com \ --cc=dri-devel@lists.freedesktop.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.