[RFC 19/29] dma-buf/fence: create fence_default_fill_driver_data()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Gustavo Padovan <gustavo.padovan@xxxxxxxxxxxxxxx>

The value needed by sw_sync is now inside struct fence so we create a
default ops to reply that value for us.
---
 drivers/dma-buf/fence.c        | 21 +++++++++++++++++++++
 drivers/staging/android/sync.c | 12 +-----------
 include/linux/fence.h          |  1 +
 3 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/drivers/dma-buf/fence.c b/drivers/dma-buf/fence.c
index 9fdeae8..d9089a0 100644
--- a/drivers/dma-buf/fence.c
+++ b/drivers/dma-buf/fence.c
@@ -621,6 +621,27 @@ void fence_default_release(struct fence *fence)
 EXPORT_SYMBOL(fence_default_release);
 
 /**
+ * fence_default_fill_driver_data - fence default .fill_driver_data ops
+ * @fence:	[in]	the fence to get the data from
+ * @data:	[out]	the data pointer to write the data
+ * @size:	[in]	the size of the allocated data
+ *
+ * This function return a driver data. In the case the fence seqno value.
+ * It is used at least by the sw_sync to send fence information to the
+ * userspace.
+ */
+int fence_default_fill_driver_data(struct fence *fence, void *data, int size)
+{
+	if (size < sizeof(fence->seqno))
+		return -ENOMEM;
+
+	memcpy(data, &fence->seqno, sizeof(fence->seqno));
+
+	return sizeof(fence->seqno);
+}
+EXPORT_SYMBOL(fence_default_fill_driver_data);
+
+/**
  * fence_default_value_str - default .fence_value_str fence ops
  * @fence:	[in]	the fence to get the value from
  * @str:	[out]	the string pointer to write the value
diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c
index 147a494..a275108 100644
--- a/drivers/staging/android/sync.c
+++ b/drivers/staging/android/sync.c
@@ -321,16 +321,6 @@ int sync_fence_wait(struct sync_fence *sync_fence, long timeout)
 }
 EXPORT_SYMBOL(sync_fence_wait);
 
-static int sync_fence_fill_driver_data(struct fence *fence,
-					  void *data, int size)
-{
-	struct fence_timeline *parent = fence_parent(fence);
-
-	if (!parent->ops->fill_driver_data)
-		return 0;
-	return parent->ops->fill_driver_data(fence, data, size);
-}
-
 static const struct fence_ops sync_fence_ops = {
 	.get_driver_name = fence_default_get_driver_name,
 	.get_timeline_name = fence_default_get_timeline_name,
@@ -338,7 +328,7 @@ static const struct fence_ops sync_fence_ops = {
 	.signaled = fence_default_signaled,
 	.wait = fence_default_wait,
 	.release = fence_default_release,
-	.fill_driver_data = sync_fence_fill_driver_data,
+	.fill_driver_data = fence_default_fill_driver_data,
 	.fence_value_str = fence_default_value_str,
 	.timeline_value_str = fence_default_timeline_value_str,
 };
diff --git a/include/linux/fence.h b/include/linux/fence.h
index 5371beb..04438c3 100644
--- a/include/linux/fence.h
+++ b/include/linux/fence.h
@@ -285,6 +285,7 @@ bool fence_default_signaled(struct fence *fence);
 bool fence_default_enable_signaling(struct fence *fence);
 signed long fence_default_wait(struct fence *fence, bool intr, signed long timeout);
 void fence_default_release(struct fence *fence);
+int fence_default_fill_driver_data(struct fence *fence, void *data, int size);
 void fence_default_value_str(struct fence *fence, char *str, int size);
 void fence_default_timeline_value_str(struct fence *fence, char *str, int size);
 int fence_add_callback(struct fence *fence, struct fence_cb *cb,
-- 
2.5.0

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux