From: Daniel Vetter <daniel@ffwll.ch>
To: "Christian König" <ckoenig.leichtzumerken@gmail.com>
Cc: linaro-mm-sig@lists.linaro.org,
"Christian König" <christian.koenig@amd.com>,
dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org
Subject: Re: [PATCH 3/5] dma-buf: return only unsignaled fences in dma_fence_unwrap_for_each
Date: Thu, 5 May 2022 16:08:42 +0200 [thread overview]
Message-ID: <YnPaapZfMZuwW1h7@phenom.ffwll.local> (raw)
In-Reply-To: <20220504122256.1654-3-christian.koenig@amd.com>
On Wed, May 04, 2022 at 02:22:54PM +0200, Christian König wrote:
> dma_fence_chain containers cleanup signaled fences automatically, so
> filter those out from arrays as well.
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
> drivers/dma-buf/dma-fence-unwrap.c | 23 ++++++++++++++++-------
> include/linux/dma-fence-unwrap.h | 4 ++--
> 2 files changed, 18 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/dma-buf/dma-fence-unwrap.c b/drivers/dma-buf/dma-fence-unwrap.c
> index 711be125428c..7b0b91086ded 100644
> --- a/drivers/dma-buf/dma-fence-unwrap.c
> +++ b/drivers/dma-buf/dma-fence-unwrap.c
> @@ -32,8 +32,13 @@ __dma_fence_unwrap_array(struct dma_fence_unwrap *cursor)
> struct dma_fence *dma_fence_unwrap_first(struct dma_fence *head,
> struct dma_fence_unwrap *cursor)
> {
> + struct dma_fence *tmp;
> +
> cursor->chain = dma_fence_get(head);
> - return __dma_fence_unwrap_array(cursor);
> + tmp = __dma_fence_unwrap_array(cursor);
> + if (tmp && dma_fence_is_signaled(tmp))
> + tmp = dma_fence_unwrap_next(cursor);
> + return tmp;
> }
> EXPORT_SYMBOL_GPL(dma_fence_unwrap_first);
>
> @@ -48,12 +53,16 @@ struct dma_fence *dma_fence_unwrap_next(struct dma_fence_unwrap *cursor)
> {
> struct dma_fence *tmp;
>
> - ++cursor->index;
> - tmp = dma_fence_array_next(cursor->array, cursor->index);
> - if (tmp)
> - return tmp;
> + do {
> + ++cursor->index;
> + tmp = dma_fence_array_next(cursor->array, cursor->index);
> + if (tmp && !dma_fence_is_signaled(tmp))
> + return tmp;
Don't do need a do {} while here too to first walk through the array
before going to the next one in the chain? Maybe add a testcase for this?
> +
> + cursor->chain = dma_fence_chain_walk(cursor->chain);
> + tmp = __dma_fence_unwrap_array(cursor);
> + } while (tmp && dma_fence_is_signaled(tmp));
>
> - cursor->chain = dma_fence_chain_walk(cursor->chain);
> - return __dma_fence_unwrap_array(cursor);
> + return tmp;
> }
> EXPORT_SYMBOL_GPL(dma_fence_unwrap_next);
> diff --git a/include/linux/dma-fence-unwrap.h b/include/linux/dma-fence-unwrap.h
> index e7c219da4ed7..e9d114637294 100644
> --- a/include/linux/dma-fence-unwrap.h
> +++ b/include/linux/dma-fence-unwrap.h
> @@ -41,8 +41,8 @@ struct dma_fence *dma_fence_unwrap_next(struct dma_fence_unwrap *cursor);
> * @head: starting point for the iterator
> *
> * Unwrap dma_fence_chain and dma_fence_array containers and deep dive into all
> - * potential fences in them. If @head is just a normal fence only that one is
> - * returned.
> + * potential none signaled fences in them. If @head is just a normal fence only
> + * that one is returned.
I think I get what you want to say, but it reads garbled. What about
leaving the current text as-is and adding something like
"Note that signalled fences are opportunistically filtered out, which
means the iteration is potentially over no fence at all"
Or something like that? I think smashing this all into one sentence
doesn't work well.
Then please also add this same sentence to unwrap_first/next() for
completeness.
-Daniel
> */
> #define dma_fence_unwrap_for_each(fence, cursor, head) \
> for (fence = dma_fence_unwrap_first(head, cursor); fence; \
> --
> 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: daniel@ffwll.ch, dri-devel@lists.freedesktop.org,
linaro-mm-sig@lists.linaro.org, linux-media@vger.kernel.org,
"Christian König" <christian.koenig@amd.com>
Subject: Re: [PATCH 3/5] dma-buf: return only unsignaled fences in dma_fence_unwrap_for_each
Date: Thu, 5 May 2022 16:08:42 +0200 [thread overview]
Message-ID: <YnPaapZfMZuwW1h7@phenom.ffwll.local> (raw)
In-Reply-To: <20220504122256.1654-3-christian.koenig@amd.com>
On Wed, May 04, 2022 at 02:22:54PM +0200, Christian König wrote:
> dma_fence_chain containers cleanup signaled fences automatically, so
> filter those out from arrays as well.
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
> drivers/dma-buf/dma-fence-unwrap.c | 23 ++++++++++++++++-------
> include/linux/dma-fence-unwrap.h | 4 ++--
> 2 files changed, 18 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/dma-buf/dma-fence-unwrap.c b/drivers/dma-buf/dma-fence-unwrap.c
> index 711be125428c..7b0b91086ded 100644
> --- a/drivers/dma-buf/dma-fence-unwrap.c
> +++ b/drivers/dma-buf/dma-fence-unwrap.c
> @@ -32,8 +32,13 @@ __dma_fence_unwrap_array(struct dma_fence_unwrap *cursor)
> struct dma_fence *dma_fence_unwrap_first(struct dma_fence *head,
> struct dma_fence_unwrap *cursor)
> {
> + struct dma_fence *tmp;
> +
> cursor->chain = dma_fence_get(head);
> - return __dma_fence_unwrap_array(cursor);
> + tmp = __dma_fence_unwrap_array(cursor);
> + if (tmp && dma_fence_is_signaled(tmp))
> + tmp = dma_fence_unwrap_next(cursor);
> + return tmp;
> }
> EXPORT_SYMBOL_GPL(dma_fence_unwrap_first);
>
> @@ -48,12 +53,16 @@ struct dma_fence *dma_fence_unwrap_next(struct dma_fence_unwrap *cursor)
> {
> struct dma_fence *tmp;
>
> - ++cursor->index;
> - tmp = dma_fence_array_next(cursor->array, cursor->index);
> - if (tmp)
> - return tmp;
> + do {
> + ++cursor->index;
> + tmp = dma_fence_array_next(cursor->array, cursor->index);
> + if (tmp && !dma_fence_is_signaled(tmp))
> + return tmp;
Don't do need a do {} while here too to first walk through the array
before going to the next one in the chain? Maybe add a testcase for this?
> +
> + cursor->chain = dma_fence_chain_walk(cursor->chain);
> + tmp = __dma_fence_unwrap_array(cursor);
> + } while (tmp && dma_fence_is_signaled(tmp));
>
> - cursor->chain = dma_fence_chain_walk(cursor->chain);
> - return __dma_fence_unwrap_array(cursor);
> + return tmp;
> }
> EXPORT_SYMBOL_GPL(dma_fence_unwrap_next);
> diff --git a/include/linux/dma-fence-unwrap.h b/include/linux/dma-fence-unwrap.h
> index e7c219da4ed7..e9d114637294 100644
> --- a/include/linux/dma-fence-unwrap.h
> +++ b/include/linux/dma-fence-unwrap.h
> @@ -41,8 +41,8 @@ struct dma_fence *dma_fence_unwrap_next(struct dma_fence_unwrap *cursor);
> * @head: starting point for the iterator
> *
> * Unwrap dma_fence_chain and dma_fence_array containers and deep dive into all
> - * potential fences in them. If @head is just a normal fence only that one is
> - * returned.
> + * potential none signaled fences in them. If @head is just a normal fence only
> + * that one is returned.
I think I get what you want to say, but it reads garbled. What about
leaving the current text as-is and adding something like
"Note that signalled fences are opportunistically filtered out, which
means the iteration is potentially over no fence at all"
Or something like that? I think smashing this all into one sentence
doesn't work well.
Then please also add this same sentence to unwrap_first/next() for
completeness.
-Daniel
> */
> #define dma_fence_unwrap_for_each(fence, cursor, head) \
> for (fence = dma_fence_unwrap_first(head, cursor); fence; \
> --
> 2.25.1
>
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
next prev parent reply other threads:[~2022-05-05 14:08 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-04 12:22 [PATCH 1/5] dma-buf: cleanup dma_fence_unwrap selftest Christian König
2022-05-04 12:22 ` [PATCH 2/5] dma-buf: cleanup dma_fence_unwrap implementation Christian König
2022-05-05 13:44 ` Daniel Vetter
2022-05-05 13:44 ` Daniel Vetter
2022-05-04 12:22 ` [PATCH 3/5] dma-buf: return only unsignaled fences in dma_fence_unwrap_for_each Christian König
2022-05-05 14:08 ` Daniel Vetter [this message]
2022-05-05 14:08 ` Daniel Vetter
2022-05-04 12:22 ` [PATCH 4/5] dma-buf: generalize dma_fence unwrap & merging v2 Christian König
2022-05-05 14:11 ` Daniel Vetter
2022-05-05 14:11 ` Daniel Vetter
2022-05-04 12:22 ` [PATCH 5/5] drm: use dma_fence_unwrap_merge() in drm_syncobj Christian König
2022-05-05 14:12 ` Daniel Vetter
2022-05-05 14:12 ` Daniel Vetter
2022-05-05 13:29 ` [PATCH 1/5] dma-buf: cleanup dma_fence_unwrap selftest Daniel Vetter
2022-05-05 13:29 ` Daniel Vetter
2022-05-05 17:46 ` Christian König
2022-05-05 17:46 ` Christian König
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=YnPaapZfMZuwW1h7@phenom.ffwll.local \
--to=daniel@ffwll.ch \
--cc=christian.koenig@amd.com \
--cc=ckoenig.leichtzumerken@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-media@vger.kernel.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: link
Be 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.