[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1466695790-2833-3-git-send-email-gustavo@padovan.org>
Date: Thu, 23 Jun 2016 12:29:47 -0300
From: Gustavo Padovan <gustavo@...ovan.org>
To: dri-devel@...ts.freedesktop.org
Cc: linux-kernel@...r.kernel.org, Daniel Stone <daniels@...labora.com>,
Daniel Vetter <daniel.vetter@...ll.ch>,
Rob Clark <robdclark@...il.com>,
Greg Hackmann <ghackmann@...gle.com>,
John Harrison <John.C.Harrison@...el.com>,
laurent.pinchart@...asonboard.com, seanpaul@...gle.com,
marcheu@...gle.com, m.chehab@...sung.com,
Sumit Semwal <sumit.semwal@...aro.org>,
Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Gustavo Padovan <gustavo.padovan@...labora.co.uk>
Subject: [RFC 2/5] dma-buf/fence-array: add fence_array_teardown()
From: Gustavo Padovan <gustavo.padovan@...labora.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@...labora.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
Powered by blists - more mailing lists