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]
Message-Id: <1452869739-3304-14-git-send-email-gustavo@padovan.org>
Date:	Fri, 15 Jan 2016 12:55:23 -0200
From:	Gustavo Padovan <gustavo@...ovan.org>
To:	Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc:	linux-kernel@...r.kernel.org, devel@...verdev.osuosl.org,
	dri-devel@...ts.freedesktop.org, 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@...onical.com>,
	Gustavo Padovan <gustavo.padovan@...labora.co.uk>
Subject: [RFC 13/29] dma-buf/fence: create fence_default_enable_signaling()

From: Gustavo Padovan <gustavo.padovan@...labora.co.uk>

Add a default .enable_signaling() op to be used on fence_ops vtable.
fence_default_enable_signaling() checks if the was not signaled yet
and adds it to the active_list.

Signed-off-by: Gustavo Padovan <gustavo.padovan@...labora.co.uk>
---
 drivers/dma-buf/fence.c        | 22 ++++++++++++++++++++++
 drivers/staging/android/sync.c | 13 +------------
 include/linux/fence.h          |  1 +
 3 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/drivers/dma-buf/fence.c b/drivers/dma-buf/fence.c
index 5dcb94c..51b77ed 100644
--- a/drivers/dma-buf/fence.c
+++ b/drivers/dma-buf/fence.c
@@ -438,6 +438,28 @@ fence_remove_callback(struct fence *fence, struct fence_cb *cb)
 }
 EXPORT_SYMBOL(fence_remove_callback);
 
+/**
+ * fence_default_enable_signaling - default op for .enable_signaling
+ * @fence:	[in]	the fence to enable signaling
+ *
+ * This function checks if the fence was already signaled and if not
+ * adds it to the list of active fences.
+ */
+bool fence_default_enable_signaling(struct fence *fence)
+{
+	struct fence_timeline *timeline = fence_parent(fence);
+
+	if (!timeline)
+		return false;
+
+	if (fence->ops->signaled && fence->ops->signaled(fence))
+		return false;
+
+	list_add_tail(&fence->active_list, &timeline->active_list_head);
+	return true;
+}
+EXPORT_SYMBOL(fence_default_enable_signaling);
+
 struct default_wait_cb {
 	struct fence_cb base;
 	struct task_struct *task;
diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c
index 417cf9f..87fb93c 100644
--- a/drivers/staging/android/sync.c
+++ b/drivers/staging/android/sync.c
@@ -362,17 +362,6 @@ static bool sync_fence_signaled(struct fence *fence)
 	return ret;
 }
 
-static bool sync_fence_enable_signaling(struct fence *fence)
-{
-	struct fence_timeline *parent = fence_parent(fence);
-
-	if (sync_fence_signaled(fence))
-		return false;
-
-	list_add_tail(&fence->active_list, &parent->active_list_head);
-	return true;
-}
-
 static int sync_fence_fill_driver_data(struct fence *fence,
 					  void *data, int size)
 {
@@ -412,7 +401,7 @@ static void sync_fence_timeline_value_str(struct fence *fence,
 static const struct fence_ops sync_fence_ops = {
 	.get_driver_name = sync_fence_get_driver_name,
 	.get_timeline_name = sync_fence_get_timeline_name,
-	.enable_signaling = sync_fence_enable_signaling,
+	.enable_signaling = fence_default_enable_signaling,
 	.signaled = sync_fence_signaled,
 	.wait = fence_default_wait,
 	.release = sync_fence_release,
diff --git a/include/linux/fence.h b/include/linux/fence.h
index a333bf37..73b8c9f 100644
--- a/include/linux/fence.h
+++ b/include/linux/fence.h
@@ -295,6 +295,7 @@ static inline void fence_put(struct fence *fence)
 
 int fence_signal(struct fence *fence);
 int fence_signal_locked(struct fence *fence);
+bool fence_default_enable_signaling(struct fence *fence);
 signed long fence_default_wait(struct fence *fence, bool intr, signed long timeout);
 int fence_add_callback(struct fence *fence, struct fence_cb *cb,
 		       fence_func_t func);
-- 
2.5.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ