[RFC 28/29] staging/android: use .cleanup() to interrupt any sync_fence waiter

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

 



From: Gustavo Padovan <gustavo.padovan@xxxxxxxxxxxxxxx>

When the timeline is being destroyed all the waiters waiting for the
sync_fence to signal need to be woken up and finished as well.

Signed-off-by: Gustavo Padovan <gustavo.padovan@xxxxxxxxxxxxxxx>
---
 drivers/staging/android/sw_sync.c | 8 ++++++++
 drivers/staging/android/sync.c    | 9 +++++++++
 drivers/staging/android/sync.h    | 2 ++
 3 files changed, 19 insertions(+)

diff --git a/drivers/staging/android/sw_sync.c b/drivers/staging/android/sw_sync.c
index ee7a942..8c83bad 100644
--- a/drivers/staging/android/sw_sync.c
+++ b/drivers/staging/android/sw_sync.c
@@ -25,6 +25,13 @@
 
 #include "sw_sync.h"
 
+static void sw_sync_cleanup(struct fence *fence, void *user_data)
+{
+	struct sync_fence *sync_fence = user_data;
+
+	sync_fence_cleanup(sync_fence);
+}
+
 static const struct fence_ops sw_sync_fence_ops = {
 	.get_driver_name = fence_default_get_driver_name,
 	.get_timeline_name = fence_default_get_timeline_name,
@@ -32,6 +39,7 @@ static const struct fence_ops sw_sync_fence_ops = {
 	.signaled = fence_default_signaled,
 	.wait = fence_default_wait,
 	.release = fence_default_release,
+	.cleanup = sw_sync_cleanup,
 	.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/drivers/staging/android/sync.c b/drivers/staging/android/sync.c
index 956b4e9..aafecf4 100644
--- a/drivers/staging/android/sync.c
+++ b/drivers/staging/android/sync.c
@@ -91,6 +91,8 @@ struct sync_fence *sync_fence_create_dma(const char *name, struct fence *fence)
 
 	sync_fence_debug_add(sync_fence);
 
+	fence_add_user_data(fence, sync_fence);
+
 	return sync_fence;
 }
 EXPORT_SYMBOL(sync_fence_create_dma);
@@ -101,6 +103,13 @@ struct sync_fence *sync_fence_create(const char *name, struct fence *fence)
 }
 EXPORT_SYMBOL(sync_fence_create);
 
+void sync_fence_cleanup(struct sync_fence *sync_fence)
+{
+	atomic_set(&sync_fence->status, -ENOENT);
+	wake_up_all(&sync_fence->wq);
+}
+EXPORT_SYMBOL(sync_fence_cleanup);
+
 struct sync_fence *sync_fence_fdget(int fd)
 {
 	struct file *file = fget(fd);
diff --git a/drivers/staging/android/sync.h b/drivers/staging/android/sync.h
index 8e6827b..d60d9c2 100644
--- a/drivers/staging/android/sync.h
+++ b/drivers/staging/android/sync.h
@@ -98,6 +98,8 @@ struct sync_fence *sync_fence_create(const char *name, struct fence *fence);
  */
 struct sync_fence *sync_fence_create_dma(const char *name, struct fence *pt);
 
+void sync_fence_cleanup(struct sync_fence *sync_fence);
+
 /*
  * API for sync_fence consumers
  */
-- 
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