From: Jason Ekstrand <jason@jlekstrand.net>
To: unlisted-recipients:; (no To-header on input)
Cc: airlied@redhat.com, christian.koenig@amd.com,
jessehall@google.com, jajones@nvidia.com, daniels@collabora.com,
hoegsberg@google.com, daniel.vetter@ffwll.ch,
bas@basnieuwenhuizen.nl,
"Christian König" <ckoenig.leichtzumerken@gmail.com>,
"Jason Ekstrand" <jason@jlekstrand.net>,
"Sumit Semwal" <sumit.semwal@linaro.org>,
"Gustavo Padovan" <gustavo@padovan.org>,
"Kate Stewart" <kstewart@linuxfoundation.org>,
"Richard Fontana" <rfontana@redhat.com>,
"Allison Randal" <allison@lohutok.net>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Greg Hackmann" <ghackmann@google.com>,
"Chenbo Feng" <fengc@google.com>,
linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org,
linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/3] dma-buf: add dma_fence_array_for_each (v2)
Date: Tue, 10 Mar 2020 22:43:46 -0500 [thread overview]
Message-ID: <20200311034351.1275197-1-jason@jlekstrand.net> (raw)
In-Reply-To: <20200303190318.522103-1-jason@jlekstrand.net>
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>
---
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 d3fbd950be94..2ac1afc697d0 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 303dd712220f..588ac8089dd6 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 */
--
2.24.1
next prev parent reply other threads:[~2020-03-11 3:44 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-25 23:58 [PATCH] RFC: dma-buf: Add an API for importing and exporting sync files Jason Ekstrand
2020-02-26 9:16 ` Christian König
2020-02-26 10:05 ` Daniel Vetter
2020-02-26 15:28 ` Jason Ekstrand
2020-02-26 16:46 ` Bas Nieuwenhuizen
2020-02-27 8:28 ` Christian König
2020-03-03 19:10 ` Jason Ekstrand
2020-03-04 8:34 ` Christian König
2020-03-04 16:27 ` Jason Ekstrand
2020-03-04 16:41 ` Jason Ekstrand
2020-03-05 13:06 ` Christian König
2020-03-05 15:54 ` Jason Ekstrand
2020-03-09 16:21 ` Christian König
2020-03-11 3:43 ` Jason Ekstrand
2020-02-26 18:09 ` [PATCH] RFC: dma-buf: Add an API for importing and exporting sync files (v2) Jason Ekstrand
2020-03-03 19:03 ` [PATCH] RFC: dma-buf: Add an API for importing and exporting sync files (v3) Jason Ekstrand
2020-03-03 19:05 ` Jason Ekstrand
2020-03-11 3:43 ` Jason Ekstrand [this message]
2020-03-11 3:43 ` [PATCH 2/3] dma-buf: add dma_resv_get_singleton (v2) Jason Ekstrand
2020-03-11 3:43 ` [PATCH 3/3] RFC: dma-buf: Add an API for importing and exporting sync files (v4) Jason Ekstrand
2020-03-11 13:18 ` Christian König
2020-03-12 15:57 ` Jason Ekstrand
2020-03-13 10:33 ` Christian König
2020-03-17 21:21 ` [PATCH 3/3] RFC: dma-buf: Add an API for importing and exporting sync files (v5) Jason Ekstrand
2020-09-30 9:39 ` Michel Dänzer
2020-09-30 9:55 ` Daniel Vetter
2021-03-15 21:11 ` Jason Ekstrand
2021-03-15 21:30 ` 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=20200311034351.1275197-1-jason@jlekstrand.net \
--to=jason@jlekstrand.net \
--cc=airlied@redhat.com \
--cc=allison@lohutok.net \
--cc=bas@basnieuwenhuizen.nl \
--cc=christian.koenig@amd.com \
--cc=ckoenig.leichtzumerken@gmail.com \
--cc=daniel.vetter@ffwll.ch \
--cc=daniels@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=fengc@google.com \
--cc=ghackmann@google.com \
--cc=gustavo@padovan.org \
--cc=hoegsberg@google.com \
--cc=jajones@nvidia.com \
--cc=jessehall@google.com \
--cc=kstewart@linuxfoundation.org \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=rfontana@redhat.com \
--cc=sumit.semwal@linaro.org \
--cc=tglx@linutronix.de \
/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).