[PATCH 3/3] dma-buf/fence: add signal_on_any to the fence array
Chris Wilson
chris at chris-wilson.co.uk
Mon May 23 11:49:25 UTC 2016
On Mon, May 23, 2016 at 01:25:22PM +0200, Christian König wrote:
> From: Christian König <christian.koenig at amd.com>
>
> If @signal_on_any is true the fence array signals if any fence in the array
> signals, otherwise it signals when all fences in the array signal.
>
> Signed-off-by: Christian König <christian.koenig at amd.com>
> ---
> drivers/dma-buf/fence-array.c | 23 ++++++++++++++++-------
> include/linux/fence-array.h | 3 ++-
> 2 files changed, 18 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/dma-buf/fence-array.c b/drivers/dma-buf/fence-array.c
> index bbcf79f..726e840 100644
> --- a/drivers/dma-buf/fence-array.c
> +++ b/drivers/dma-buf/fence-array.c
> @@ -41,6 +41,7 @@ static void fence_array_cb_func(struct fence *f, struct fence_cb *cb)
>
> if (atomic_dec_and_test(&array->num_pending))
> fence_signal(&array->base);
> + fence_put(&array->base);
> }
>
> static bool fence_array_enable_signaling(struct fence *fence)
> @@ -51,10 +52,13 @@ static bool fence_array_enable_signaling(struct fence *fence)
>
> for (i = 0; i < array->num_fences; ++i) {
> cb[i].array = array;
> + fence_get(&array->base);
> if (!fence_add_callback(array->fences[i], &cb[i].cb,
> - fence_array_cb_func))
> + fence_array_cb_func)) {
> + fence_put(&array->base);
Ok, yes, that is an artifact of reporting signaled before all cb are
complete.
/* As we may report that the fence is signaled before all callbacks are
* complete, we need to take an additional reference count on the array
* so that we do not free it too early. The core fence handling will
* only hold the reference until we signal the array as complete (but
* that is now insufficient).
*/
fence_array_signaled() should now be
return atomic_read(&array->num_pending) <= 0;
-Chris
--
Chris Wilson, Intel Open Source Technology Centre
More information about the dri-devel
mailing list