From: Gustavo Padovan <gustavo@padovan.org>
To: dri-devel@lists.freedesktop.org
Cc: linux-kernel@vger.kernel.org,
"Daniel Stone" <daniels@collabora.com>,
"Arve Hjønnevåg" <arve@android.com>,
"Riley Andrews" <riandrews@android.com>,
"Daniel Vetter" <daniel.vetter@ffwll.ch>,
"Rob Clark" <robdclark@gmail.com>,
"Greg Hackmann" <ghackmann@google.com>,
"John Harrison" <John.C.Harrison@Intel.com>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Gustavo Padovan" <gustavo.padovan@collabora.co.uk>
Subject: [RFC 3/6] dma-buf/sync_file: add sync_file_fences_get()
Date: Wed, 23 Mar 2016 15:47:24 -0300 [thread overview]
Message-ID: <1458758847-21170-4-git-send-email-gustavo@padovan.org> (raw)
In-Reply-To: <1458758847-21170-1-git-send-email-gustavo@padovan.org>
From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Creates a function that given an sync file descriptor returns a
fence_collection containing all fences in the sync_file.
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
---
drivers/dma-buf/sync_file.c | 36 ++++++++++++++++++++++++++++++++++++
include/linux/sync_file.h | 8 ++++++++
2 files changed, 44 insertions(+)
diff --git a/drivers/dma-buf/sync_file.c b/drivers/dma-buf/sync_file.c
index b67876b..16a3ef7 100644
--- a/drivers/dma-buf/sync_file.c
+++ b/drivers/dma-buf/sync_file.c
@@ -122,6 +122,42 @@ void sync_file_install(struct sync_file *sync_file, int fd)
}
EXPORT_SYMBOL(sync_file_install);
+static void sync_file_fence_collection_put(void *data)
+{
+ struct sync_file *sync_file = data;
+
+ sync_file_put(sync_file);
+}
+
+struct fence_collection *sync_file_fences_get(int fd)
+{
+ struct fence_collection *collection;
+ struct sync_file *sync_file;
+ int i;
+
+ sync_file = sync_file_fdget(fd);
+ if (!sync_file)
+ return NULL;
+
+ collection = kzalloc(offsetof(struct fence_collection,
+ fences[sync_file->num_fences]),
+ GFP_KERNEL);
+ if (!collection)
+ return NULL;
+
+ collection->num_fences = sync_file->num_fences;
+ collection->user_data = sync_file;
+ collection->func = sync_file_fence_collection_put;
+
+ for (i = 0; i < sync_file->num_fences; ++i) {
+ collection->fences[i] = sync_file->cbs[i].fence;
+ fence_get(collection->fences[i]);
+ }
+
+ return collection;
+}
+EXPORT_SYMBOL(sync_file_fences_get);
+
static void sync_file_add_pt(struct sync_file *sync_file, int *i,
struct fence *fence)
{
diff --git a/include/linux/sync_file.h b/include/linux/sync_file.h
index 7b7a89d..1b9386a 100644
--- a/include/linux/sync_file.h
+++ b/include/linux/sync_file.h
@@ -103,4 +103,12 @@ void sync_file_put(struct sync_file *sync_file);
*/
void sync_file_install(struct sync_file *sync_file, int fd);
+/**
+ * sync_file_fences_get - get the fence collection related to the fd
+ * @fd: file descriptor to look for a fence collection
+ *
+ * Ensures @fd references a valid sync_file, increments the refcount of the
+ * backing file. Returns the fence_collection or NULL in case of error.
+ */
+struct fence_collection *sync_file_fences_get(int fd);
#endif /* _LINUX_SYNC_H */
--
2.5.0
next prev parent reply other threads:[~2016-03-23 18:47 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-23 18:47 [RFC 0/6] drm/fences: add in-fences to DRM Gustavo Padovan
2016-03-23 18:47 ` [RFC 1/6] drm/fence: add FENCE_FD property to planes Gustavo Padovan
2016-04-05 12:36 ` Rob Clark
2016-04-05 12:57 ` Daniel Stone
2016-04-05 14:04 ` Rob Clark
2016-04-05 14:19 ` Daniel Stone
2016-04-05 15:23 ` Rob Clark
2016-03-23 18:47 ` [RFC 2/6] dma-buf/fence: add struct fence_collection Gustavo Padovan
2016-03-23 18:47 ` Gustavo Padovan [this message]
2016-03-23 18:47 ` [RFC 4/6] dma-buf/fence: add fence_collection_put() Gustavo Padovan
2016-03-23 18:47 ` [RFC 5/6] dma-buf/fence: add fence_collection_wait() Gustavo Padovan
2016-03-23 18:47 ` [RFC 6/6] drm/fence: support fence_collection on atomic commit Gustavo Padovan
2016-03-24 7:20 ` [RFC 0/6] drm/fences: add in-fences to DRM Maarten Lankhorst
2016-03-24 14:31 ` Gustavo Padovan
2016-03-24 8:18 ` Inki Dae
2016-03-24 14:39 ` Gustavo Padovan
2016-03-24 23:03 ` Inki Dae
2016-03-24 15:40 ` Rob Clark
2016-03-24 23:49 ` Inki Dae
2016-03-25 11:58 ` Rob Clark
2016-03-25 12:10 ` Daniel Stone
2016-03-28 1:26 ` Inki Dae
2016-03-28 13:26 ` Daniel Stone
2016-03-29 2:18 ` Inki Dae
2016-03-29 13:23 ` Rob Clark
2016-03-31 7:45 ` Inki Dae
2016-03-31 9:35 ` Daniel Stone
2016-03-31 10:04 ` Daniel Vetter
2016-03-31 11:40 ` Inki Dae
2016-03-31 10:05 ` Inki Dae
2016-03-31 10:56 ` Daniel Stone
2016-03-31 11:26 ` Inki Dae
2016-03-31 11:41 ` Daniel Stone
2016-03-31 14:10 ` Rob Clark
2016-04-04 0:14 ` Inki Dae
2016-04-04 15:41 ` Rob Clark
2016-04-04 15:46 ` Rob Clark
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=1458758847-21170-4-git-send-email-gustavo@padovan.org \
--to=gustavo@padovan.org \
--cc=John.C.Harrison@Intel.com \
--cc=arve@android.com \
--cc=daniel.vetter@ffwll.ch \
--cc=daniels@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=ghackmann@google.com \
--cc=gustavo.padovan@collabora.co.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=riandrews@android.com \
--cc=robdclark@gmail.com \
/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
all inboxes | Powered by JetHome®