From: "Koenig, Christian" <Christian.Koenig@amd.com>
To: Chris Wilson <chris@chris-wilson.co.uk>,
"dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>
Cc: Gustavo Padovan <gustavo@padovan.org>,
"intel-gfx@lists.freedesktop.org"
<intel-gfx@lists.freedesktop.org>,
Sumit Semwal <sumit.semwal@linaro.org>
Subject: Re: [PATCH v4] dma-fence: Propagate errors to dma-fence-array container
Date: Sun, 11 Aug 2019 16:08:47 +0000 [thread overview]
Message-ID: <61c7693c-497f-5d89-362f-b37c30c7a8da@amd.com> (raw)
In-Reply-To: <20190811122134.21419-1-chris@chris-wilson.co.uk>
How about this instead:
Setting array->base.error = 1 during initialization.
Then cmpxchg(array->base.error, 1, error) whenever a fence in the array
signals.
And then finally cmpxchg(array->base.error, 1, 0) when the array itself
signals.
Christian.
Am 11.08.19 um 14:21 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.
> v3: Be careful not to flag an error if we race against signal-on-any.
> v4: Same applies to installing the signal cb.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Sumit Semwal <sumit.semwal@linaro.org>
> Cc: Gustavo Padovan <gustavo@padovan.org>
> Cc: Christian König <christian.koenig@amd.com>
> ---
> drivers/dma-buf/dma-fence-array.c | 37 ++++++++++++++++++++++++++++++-
> include/linux/dma-fence-array.h | 2 ++
> 2 files changed, 38 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/dma-buf/dma-fence-array.c b/drivers/dma-buf/dma-fence-array.c
> index 12c6f64c0bc2..4d574dff0ba9 100644
> --- a/drivers/dma-buf/dma-fence-array.c
> +++ b/drivers/dma-buf/dma-fence-array.c
> @@ -23,10 +23,37 @@ static const char *dma_fence_array_get_timeline_name(struct dma_fence *fence)
> return "unbound";
> }
>
> +static void dma_fence_array_set_error(struct dma_fence_array *array)
> +{
> + int error = READ_ONCE(array->pending_error);
> +
> + if (!array->base.error && error)
> + dma_fence_set_error(&array->base, error);
> +}
> +
> +static void dma_fence_array_set_pending_error(struct dma_fence_array *array,
> + int error)
> +{
> + /*
> + * Propagate the first error reported by any of our fences, but only
> + * before we ourselves are signaled.
> + *
> + * Note that this may race with multiple fences completing
> + * simultaneously in error, but only one error will be kept, not
> + * necessarily the first. So long as we propagate an error if any
> + * fences were in error before we are signaled we should be telling
> + * an acceptable truth.
> + */
> + if (error && !array->pending_error)
> + WRITE_ONCE(array->pending_error, error);
> +}
> +
> static void irq_dma_fence_array_work(struct irq_work *wrk)
> {
> struct dma_fence_array *array = container_of(wrk, typeof(*array), work);
>
> + dma_fence_array_set_error(array);
> +
> dma_fence_signal(&array->base);
> dma_fence_put(&array->base);
> }
> @@ -38,6 +65,8 @@ 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;
>
> + dma_fence_array_set_pending_error(array, f->error);
> +
> if (atomic_dec_and_test(&array->num_pending))
> irq_work_queue(&array->work);
> else
> @@ -63,9 +92,14 @@ 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)) {
> + int error = array->fences[i]->error;
> +
> + dma_fence_array_set_pending_error(array, error);
> dma_fence_put(&array->base);
> - if (atomic_dec_and_test(&array->num_pending))
> + if (atomic_dec_and_test(&array->num_pending)) {
> + dma_fence_array_set_error(array);
> return false;
> + }
> }
> }
>
> @@ -141,6 +175,7 @@ struct dma_fence_array *dma_fence_array_create(int num_fences,
> array->num_fences = num_fences;
> atomic_set(&array->num_pending, signal_on_any ? 1 : num_fences);
> array->fences = fences;
> + array->pending_error = 0;
>
> return array;
> }
> diff --git a/include/linux/dma-fence-array.h b/include/linux/dma-fence-array.h
> index 303dd712220f..faaf70c524ae 100644
> --- a/include/linux/dma-fence-array.h
> +++ b/include/linux/dma-fence-array.h
> @@ -42,6 +42,8 @@ struct dma_fence_array {
> atomic_t num_pending;
> struct dma_fence **fences;
>
> + int pending_error;
> +
> struct irq_work work;
> };
>
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2019-08-11 16:08 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-10 15:34 [PATCH 1/4] dma-fence: Propagate errors to dma-fence-array container Chris Wilson
2019-08-10 15:34 ` [PATCH 2/4] dma-fence: Report the composite sync_file status Chris Wilson
2019-08-12 9:05 ` [Intel-gfx] " Matthew Auld
2019-08-10 15:34 ` [PATCH 3/4] dma-fence: Refactor signaling for manual invocation Chris Wilson
2019-08-12 14:34 ` Koenig, Christian
2019-08-12 14:43 ` Chris Wilson
2019-08-12 14:50 ` Koenig, Christian
2019-08-12 14:53 ` Chris Wilson
2019-08-13 6:59 ` Koenig, Christian
2019-08-13 8:25 ` Chris Wilson
2019-08-13 8:49 ` Koenig, Christian
2019-08-10 15:34 ` [PATCH 4/4] dma-fence: Always execute signal callbacks Chris Wilson
2019-08-11 9:01 ` Koenig, Christian
2019-08-11 9:15 ` [PATCH 5/4] dma-fence: Have dma_fence_signal call signal_locked Chris Wilson
2019-08-11 16:09 ` Koenig, Christian
2019-08-14 17:20 ` Daniel Vetter
2019-08-15 18:45 ` Chris Wilson
2019-08-15 18:48 ` Daniel Vetter
2019-08-15 19:03 ` Chris Wilson
2019-08-15 19:29 ` Chris Wilson
2019-08-16 7:58 ` Koenig, Christian
2019-08-10 15:56 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [1/4] dma-fence: Propagate errors to dma-fence-array container Patchwork
2019-08-10 16:20 ` ✓ Fi.CI.BAT: success " Patchwork
2019-08-11 8:34 ` ✓ Fi.CI.IGT: " Patchwork
2019-08-11 8:58 ` [PATCH 1/4] " Koenig, Christian
2019-08-11 11:56 ` Chris Wilson
2019-08-11 9:21 ` ✗ Fi.CI.BAT: failure for series starting with [1/4] dma-fence: Propagate errors to dma-fence-array container (rev2) Patchwork
2019-08-11 12:02 ` ✗ Fi.CI.BAT: failure for series starting with [1/4] dma-fence: Propagate errors to dma-fence-array container (rev3) Patchwork
2019-08-11 12:09 ` [PATCH v3] dma-fence: Propagate errors to dma-fence-array container Chris Wilson
2019-08-11 12:20 ` ✗ Fi.CI.BAT: failure for series starting with [v3] dma-fence: Propagate errors to dma-fence-array container (rev4) Patchwork
2019-08-11 12:21 ` [PATCH v4] dma-fence: Propagate errors to dma-fence-array container Chris Wilson
2019-08-11 16:08 ` Koenig, Christian [this message]
2019-08-11 16:25 ` [PATCH v5] " Chris Wilson
2019-08-11 16:28 ` Koenig, Christian
2019-08-11 19:33 ` [PATCH v4] " kbuild test robot
2019-08-11 13:08 ` ✗ Fi.CI.BAT: failure for series starting with [v4] dma-fence: Propagate errors to dma-fence-array container (rev5) Patchwork
2019-08-11 16:38 ` ✗ Fi.CI.BAT: failure for series starting with [v5] dma-fence: Propagate errors to dma-fence-array container (rev6) Patchwork
2019-08-15 19:22 ` ✗ Fi.CI.BAT: failure for series starting with [v5] dma-fence: Propagate errors to dma-fence-array container (rev7) Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=61c7693c-497f-5d89-362f-b37c30c7a8da@amd.com \
--to=christian.koenig@amd.com \
--cc=chris@chris-wilson.co.uk \
--cc=dri-devel@lists.freedesktop.org \
--cc=gustavo@padovan.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=sumit.semwal@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox