[RFC 2/5] dma-buf/fence-array: add fence_array_teardown()
Gustavo Padovan
gustavo at padovan.org
Thu Jun 23 15:29:47 UTC 2016
From: Gustavo Padovan <gustavo.padovan at collabora.co.uk>
When using fences in sync files we need to clean up everything when
the sync file needs to be freed, thus we need to teardown fence_array,
by removing the callback of its fences and putting extra references to the
fence_array base fence.
Signed-off-by: Gustavo Padovan <gustavo.padovan at collabora.co.uk>
---
drivers/dma-buf/fence-array.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/drivers/dma-buf/fence-array.c b/drivers/dma-buf/fence-array.c
index a8731c8..601448a 100644
--- a/drivers/dma-buf/fence-array.c
+++ b/drivers/dma-buf/fence-array.c
@@ -79,6 +79,21 @@ static bool fence_array_signaled(struct fence *fence)
return atomic_read(&array->num_pending) <= 0;
}
+static void fence_array_teardown(struct fence *fence)
+{
+ struct fence_array *array = to_fence_array(fence);
+ struct fence_array_cb *cb = (void *)(&array[1]);
+ int i;
+
+ for (i = 0; i < array->num_fences; i++) {
+ if (fence_is_signaled(array->fences[i]))
+ continue;
+
+ fence_remove_callback(array->fences[i], &cb[i].cb);
+ fence_put(&array->base);
+ }
+}
+
static void fence_array_release(struct fence *fence)
{
struct fence_array *array = to_fence_array(fence);
@@ -97,6 +112,7 @@ const struct fence_ops fence_array_ops = {
.enable_signaling = fence_array_enable_signaling,
.signaled = fence_array_signaled,
.wait = fence_default_wait,
+ .teardown = fence_array_teardown,
.release = fence_array_release,
};
--
2.5.5
More information about the dri-devel
mailing list