dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: "Christian König" <ckoenig.leichtzumerken@gmail.com>
To: Jason Ekstrand <jason@jlekstrand.net>, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 1/4] dma-buf: add dma_fence_array_for_each (v2)
Date: Fri, 21 May 2021 09:51:41 +0200	[thread overview]
Message-ID: <5698cfc1-471b-5e13-bf3f-1c7025dc9a2c@gmail.com> (raw)
In-Reply-To: <20210520190007.534046-2-jason@jlekstrand.net>

Am 20.05.21 um 21:00 schrieb Jason Ekstrand:
> From: Christian König <ckoenig.leichtzumerken@gmail.com>
>
> Add a helper to iterate over all fences in a dma_fence_array object.
>
> v2 (Jason Ekstrand)
>   - Return NULL from dma_fence_array_first if head == NULL.  This matches
>     the iterator behavior of dma_fence_chain_for_each in that it iterates
>     zero times if head == NULL.
>   - Return NULL from dma_fence_array_next if index > array->num_fences.
>
> Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>

Reviewed-by: Christian König <christian.koenig@amd.com>

BTW: I'm only seeing this patch from the series. Looks like somehow the 
rest didn't made it into my inbox.

> ---
>   drivers/dma-buf/dma-fence-array.c | 27 +++++++++++++++++++++++++++
>   include/linux/dma-fence-array.h   | 17 +++++++++++++++++
>   2 files changed, 44 insertions(+)
>
> diff --git a/drivers/dma-buf/dma-fence-array.c b/drivers/dma-buf/dma-fence-array.c
> index d3fbd950be944..2ac1afc697d0f 100644
> --- a/drivers/dma-buf/dma-fence-array.c
> +++ b/drivers/dma-buf/dma-fence-array.c
> @@ -201,3 +201,30 @@ bool dma_fence_match_context(struct dma_fence *fence, u64 context)
>   	return true;
>   }
>   EXPORT_SYMBOL(dma_fence_match_context);
> +
> +struct dma_fence *dma_fence_array_first(struct dma_fence *head)
> +{
> +	struct dma_fence_array *array;
> +
> +	if (!head)
> +		return NULL;
> +
> +	array = to_dma_fence_array(head);
> +	if (!array)
> +		return head;
> +
> +	return array->fences[0];
> +}
> +EXPORT_SYMBOL(dma_fence_array_first);
> +
> +struct dma_fence *dma_fence_array_next(struct dma_fence *head,
> +				       unsigned int index)
> +{
> +	struct dma_fence_array *array = to_dma_fence_array(head);
> +
> +	if (!array || index >= array->num_fences)
> +		return NULL;
> +
> +	return array->fences[index];
> +}
> +EXPORT_SYMBOL(dma_fence_array_next);
> diff --git a/include/linux/dma-fence-array.h b/include/linux/dma-fence-array.h
> index 303dd712220fd..588ac8089dd61 100644
> --- a/include/linux/dma-fence-array.h
> +++ b/include/linux/dma-fence-array.h
> @@ -74,6 +74,19 @@ to_dma_fence_array(struct dma_fence *fence)
>   	return container_of(fence, struct dma_fence_array, base);
>   }
>   
> +/**
> + * dma_fence_array_for_each - iterate over all fences in array
> + * @fence: current fence
> + * @index: index into the array
> + * @head: potential dma_fence_array object
> + *
> + * Test if @array is a dma_fence_array object and if yes iterate over all fences
> + * in the array. If not just iterate over the fence in @array itself.
> + */
> +#define dma_fence_array_for_each(fence, index, head)			\
> +	for (index = 0, fence = dma_fence_array_first(head); fence;	\
> +	     ++(index), fence = dma_fence_array_next(head, index))
> +
>   struct dma_fence_array *dma_fence_array_create(int num_fences,
>   					       struct dma_fence **fences,
>   					       u64 context, unsigned seqno,
> @@ -81,4 +94,8 @@ struct dma_fence_array *dma_fence_array_create(int num_fences,
>   
>   bool dma_fence_match_context(struct dma_fence *fence, u64 context);
>   
> +struct dma_fence *dma_fence_array_first(struct dma_fence *head);
> +struct dma_fence *dma_fence_array_next(struct dma_fence *head,
> +				       unsigned int index);
> +
>   #endif /* __LINUX_DMA_FENCE_ARRAY_H */


  reply	other threads:[~2021-05-21  7:51 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-20 19:00 [PATCH 0/4] dma-buf: Add an API for exporting sync files (v8) Jason Ekstrand
2021-05-20 19:00 ` [PATCH 1/4] dma-buf: add dma_fence_array_for_each (v2) Jason Ekstrand
2021-05-21  7:51   ` Christian König [this message]
2021-05-21 16:27     ` Jason Ekstrand
2021-05-21 18:11       ` Christian König
2021-05-20 19:00 ` [PATCH 2/4] dma-buf: add dma_resv_get_singleton_rcu (v4) Jason Ekstrand
2021-05-21 17:48   ` Daniel Vetter
2021-05-24 20:04     ` Jason Ekstrand
2021-05-25 12:38       ` Daniel Vetter
2021-05-25 15:50         ` Christian König
2021-05-22 14:38   ` kernel test robot
2021-05-22 18:59   ` kernel test robot
2021-05-20 19:00 ` [PATCH 3/4] dma-buf: Add an API for exporting sync files (v9) Jason Ekstrand
2021-05-20 19:00 ` [PATCH 4/4] RFC: dma-buf: Add an API for importing sync files (v6) Jason Ekstrand
2021-05-22 20:05   ` Daniel Stone
2021-05-23 17:15     ` EPOLL for drm_syncfile (was Re: [PATCH 4/4] RFC: dma-buf: Add an API for importing sync files (v6)) Christian König
2021-05-23 21:34       ` Daniel Stone
2021-05-25  5:55         ` Daniel Vetter
2021-05-26  9:45         ` Simon Ser
2021-05-24 17:11     ` [PATCH 4/4] RFC: dma-buf: Add an API for importing sync files (v6) Jason Ekstrand
2021-05-25  6:27       ` Daniel Vetter
2021-05-26 11:08       ` Daniel Stone
2021-05-26 12:35         ` Daniel Vetter
2021-05-26 13:08           ` Daniel Stone
2021-05-26 13:44             ` Daniel Vetter
2021-05-26 15:13               ` Daniel Stone
2021-05-26 16:52                 ` Daniel Vetter
2021-05-26 18:01                   ` Daniel Stone
2021-05-27  7:21                   ` Christian König
2021-05-26 13:52         ` Daniel Stone
2021-05-26 15:24         ` Jason Ekstrand
2021-05-26 18:14           ` Daniel Stone
2021-05-27  4:32             ` Jason Ekstrand
2021-05-27 10:19               ` Daniel Vetter
2021-05-27 10:39                 ` Christian König
2021-05-26 12:21       ` Vlad Zahorodnii
2021-05-21 21:32 ` [PATCH 0/4] dma-buf: Add an API for exporting sync files (v8) Jason Ekstrand

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=5698cfc1-471b-5e13-bf3f-1c7025dc9a2c@gmail.com \
    --to=ckoenig.leichtzumerken@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jason@jlekstrand.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).