Re: [PATCH 1/4] dma-fence: Propagate errors to dma-fence-array container

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

 



Am 10.08.19 um 17:34 schrieb Chris Wilson:
> When one of the array of fences is signaled, propagate its errors to the
> parent fence-array (keeping the first error to be raised).
>
> v2: Opencode cmpxchg_local to avoid compiler freakout.
>
> Signed-off-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>
> Cc: Sumit Semwal <sumit.semwal@xxxxxxxxxx>
> Cc: Gustavo Padovan <gustavo@xxxxxxxxxxx>
> ---
>   drivers/dma-buf/dma-fence-array.c | 15 +++++++++++++++
>   1 file changed, 15 insertions(+)
>
> diff --git a/drivers/dma-buf/dma-fence-array.c b/drivers/dma-buf/dma-fence-array.c
> index 12c6f64c0bc2..d90675bb4fcc 100644
> --- a/drivers/dma-buf/dma-fence-array.c
> +++ b/drivers/dma-buf/dma-fence-array.c
> @@ -13,6 +13,12 @@
>   #include <linux/slab.h>
>   #include <linux/dma-fence-array.h>
>   
> +static void fence_set_error_once(struct dma_fence *fence, int error)

I would use a dma_fence_array prefix for all names in the file.

> +{
> +	if (!fence->error && error)
> +		dma_fence_set_error(fence, error);
> +}
> +
>   static const char *dma_fence_array_get_driver_name(struct dma_fence *fence)
>   {
>   	return "dma_fence_array";
> @@ -38,6 +44,13 @@ static void dma_fence_array_cb_func(struct dma_fence *f,
>   		container_of(cb, struct dma_fence_array_cb, cb);
>   	struct dma_fence_array *array = array_cb->array;
>   
> +	/*
> +	 * Propagate the first error reported by any of our fences, but only
> +	 * before we ourselves are signaled.
> +	 */
> +	if (atomic_read(&array->num_pending) > 0)
> +		fence_set_error_once(&array->base, f->error);

That is racy even if you check the atomic because num_pending can be 
initialized to 1 for signal any arrays as well.

I suggest to rather test in dma_fence_array_set_error_once if we got an 
error and if yes grab the sequence lock and test if we are already 
signaled or not.

Christian.

> +
>   	if (atomic_dec_and_test(&array->num_pending))
>   		irq_work_queue(&array->work);
>   	else
> @@ -63,6 +76,8 @@ static bool dma_fence_array_enable_signaling(struct dma_fence *fence)
>   		dma_fence_get(&array->base);
>   		if (dma_fence_add_callback(array->fences[i], &cb[i].cb,
>   					   dma_fence_array_cb_func)) {
> +			fence_set_error_once(&array->base,
> +					     array->fences[i]->error);
>   			dma_fence_put(&array->base);
>   			if (atomic_dec_and_test(&array->num_pending))
>   				return false;

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux