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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1452869739-3304-22-git-send-email-gustavo@padovan.org>
Date:	Fri, 15 Jan 2016 12:55:31 -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 21/29] dma-buf/fence: add fence_create_on_timeline()

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

This functions in intended to replace sync_pt_create() and it does
exactly the same thing sync_pt_create() did.

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

diff --git a/drivers/dma-buf/fence.c b/drivers/dma-buf/fence.c
index ec51146..0a07fcb 100644
--- a/drivers/dma-buf/fence.c
+++ b/drivers/dma-buf/fence.c
@@ -768,6 +768,44 @@ err_free_cb:
 EXPORT_SYMBOL(fence_wait_any_timeout);
 
 /**
+ * fence_create_on_timeline - create a fence and add it to the timeline
+ * or until timeout elapses
+ * @obj:	[in]	timeline object
+ * @ops:	[in]	fence_ops to use
+ * @size:	[in]	size to allocate struct fence
+ * @value:	[in]	value of this fence
+ *
+ * This function allocates a new fence and initialize it as a child of the
+ * fence_timeline provided. The value received is the seqno used to know
+ * when the fence is signaled.
+ *
+ * Returns NULL if fails to allocate memory or size is too small.
+ */
+struct fence *fence_create_on_timeline(struct fence_timeline *obj,
+				       const struct fence_ops *ops, int size,
+				       unsigned int value)
+{
+	unsigned long flags;
+	struct fence *fence;
+
+	if (size < sizeof(*fence))
+		return NULL;
+
+	fence = kzalloc(size, GFP_KERNEL);
+	if (!fence)
+		return NULL;
+
+	spin_lock_irqsave(&obj->lock, flags);
+	fence_timeline_get(obj);
+	fence_init(fence, ops, &obj->lock, obj->context, value);
+	list_add_tail(&fence->child_list, &obj->child_list_head);
+	INIT_LIST_HEAD(&fence->active_list);
+	spin_unlock_irqrestore(&obj->lock, flags);
+	return fence;
+}
+EXPORT_SYMBOL(fence_create_on_timeline);
+
+/**
  * fence_init - Initialize a custom fence.
  * @fence:	[in]	the fence to initialize
  * @ops:	[in]	the fence_ops for operations on this fence
diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c
index a275108..2365db7 100644
--- a/drivers/staging/android/sync.c
+++ b/drivers/staging/android/sync.c
@@ -36,24 +36,8 @@ static const struct file_operations sync_fence_fops;
 
 struct fence *sync_pt_create(struct fence_timeline *obj, int size, u32 value)
 {
-	unsigned long flags;
-	struct fence *fence;
-
-	if (size < sizeof(*fence))
-		return NULL;
-
-	fence = kzalloc(size, GFP_KERNEL);
-	if (!fence)
-		return NULL;
-
-	spin_lock_irqsave(&obj->lock, flags);
-	fence_timeline_get(obj);
-	fence_init(fence, &sync_fence_ops, &obj->lock,
-		   obj->context, value);
-	list_add_tail(&fence->child_list, &obj->child_list_head);
-	INIT_LIST_HEAD(&fence->active_list);
-	spin_unlock_irqrestore(&obj->lock, flags);
-	return fence;
+	return fence_create_on_timeline(obj, &sync_fence_ops,
+					sizeof(struct fence), value);
 }
 EXPORT_SYMBOL(sync_pt_create);
 
diff --git a/include/linux/fence.h b/include/linux/fence.h
index 8908433..adece43 100644
--- a/include/linux/fence.h
+++ b/include/linux/fence.h
@@ -212,6 +212,9 @@ struct fence_ops {
 	void (*timeline_value_str)(struct fence *fence, char *str, int size);
 };
 
+struct fence *fence_create_on_timeline(struct fence_timeline *obj,
+				       const struct fence_ops *ops, int size,
+				       unsigned int value);
 void fence_init(struct fence *fence, const struct fence_ops *ops,
 		spinlock_t *lock, unsigned context, unsigned seqno);
 
-- 
2.5.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ