From: Gustavo Padovan <gustavo.padovan@xxxxxxxxxxxxxxx> 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@xxxxxxxxxxxxxxx> --- 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 _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel