lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 23 Mar 2016 15:47:24 -0300
From:	Gustavo Padovan <gustavo@...ovan.org>
To:	dri-devel@...ts.freedesktop.org
Cc:	linux-kernel@...r.kernel.org, Daniel Stone <daniels@...labora.com>,
	Arve Hjønnevåg <arve@...roid.com>,
	Riley Andrews <riandrews@...roid.com>,
	Daniel Vetter <daniel.vetter@...ll.ch>,
	Rob Clark <robdclark@...il.com>,
	Greg Hackmann <ghackmann@...gle.com>,
	John Harrison <John.C.Harrison@...el.com>,
	Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
	Gustavo Padovan <gustavo.padovan@...labora.co.uk>
Subject: [RFC 3/6] dma-buf/sync_file: add sync_file_fences_get()

From: Gustavo Padovan <gustavo.padovan@...labora.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@...labora.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ