From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 11/13] drm/i915: Extend execution fence to support a callback
Date: Mon, 11 Mar 2019 13:09:11 +0000 [thread overview]
Message-ID: <7c1bce56-47c6-7cae-f939-57db4993bc86@linux.intel.com> (raw)
In-Reply-To: <20190308141244.16837-12-chris@chris-wilson.co.uk>
On 08/03/2019 14:12, Chris Wilson wrote:
> In the next patch, we will want to configure the slave request
> depending on which physical engine the master request is executed on.
> For this, we introduce a callback from the execute fence to convey this
> information.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> ---
> drivers/gpu/drm/i915/i915_request.c | 84 +++++++++++++++++++++++++++--
> drivers/gpu/drm/i915/i915_request.h | 4 ++
> 2 files changed, 83 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_request.c b/drivers/gpu/drm/i915/i915_request.c
> index 09046a15d218..5527ab22dbf2 100644
> --- a/drivers/gpu/drm/i915/i915_request.c
> +++ b/drivers/gpu/drm/i915/i915_request.c
> @@ -38,6 +38,8 @@ struct execute_cb {
> struct list_head link;
> struct irq_work work;
> struct i915_sw_fence *fence;
> + void (*hook)(struct i915_request *rq, struct dma_fence *signal);
> + struct i915_request *signal;
> };
>
> static struct i915_global_request {
> @@ -343,6 +345,17 @@ static void irq_execute_cb(struct irq_work *wrk)
> kmem_cache_free(global.slab_execute_cbs, cb);
> }
>
> +static void irq_execute_cb_hook(struct irq_work *wrk)
> +{
> + struct execute_cb *cb = container_of(wrk, typeof(*cb), work);
> +
> + cb->hook(container_of(cb->fence, struct i915_request, submit),
> + &cb->signal->fence);
> + i915_request_put(cb->signal);
> +
> + irq_execute_cb(wrk);
> +}
> +
> static void __notify_execute_cb(struct i915_request *rq)
> {
> struct execute_cb *cb;
> @@ -369,14 +382,19 @@ static void __notify_execute_cb(struct i915_request *rq)
> }
>
> static int
> -i915_request_await_execution(struct i915_request *rq,
> - struct i915_request *signal,
> - gfp_t gfp)
> +__i915_request_await_execution(struct i915_request *rq,
> + struct i915_request *signal,
> + void (*hook)(struct i915_request *rq,
> + struct dma_fence *signal),
> + gfp_t gfp)
> {
> struct execute_cb *cb;
>
> - if (i915_request_is_active(signal))
> + if (i915_request_is_active(signal)) {
> + if (hook)
> + hook(rq, &signal->fence);
> return 0;
> + }
>
> cb = kmem_cache_alloc(global.slab_execute_cbs, gfp);
> if (!cb)
> @@ -386,8 +404,18 @@ i915_request_await_execution(struct i915_request *rq,
> i915_sw_fence_await(cb->fence);
> init_irq_work(&cb->work, irq_execute_cb);
>
> + if (hook) {
> + cb->hook = hook;
> + cb->signal = i915_request_get(signal);
> + cb->work.func = irq_execute_cb_hook;
> + }
> +
> spin_lock_irq(&signal->lock);
> if (i915_request_is_active(signal)) {
> + if (hook) {
> + hook(rq, &signal->fence);
> + i915_request_put(signal);
> + }
> i915_sw_fence_complete(cb->fence);
> kmem_cache_free(global.slab_execute_cbs, cb);
> } else {
> @@ -790,7 +818,7 @@ emit_semaphore_wait(struct i915_request *to,
> return err;
>
> /* Only submit our spinner after the signaler is running! */
> - err = i915_request_await_execution(to, from, gfp);
> + err = __i915_request_await_execution(to, from, NULL, gfp);
> if (err)
> return err;
>
> @@ -910,6 +938,52 @@ i915_request_await_dma_fence(struct i915_request *rq, struct dma_fence *fence)
> return 0;
> }
>
> +int
> +i915_request_await_execution(struct i915_request *rq,
> + struct dma_fence *fence,
> + void (*hook)(struct i915_request *rq,
> + struct dma_fence *signal))
> +{
> + struct dma_fence **child = &fence;
> + unsigned int nchild = 1;
> + int ret;
> +
> + if (dma_fence_is_array(fence)) {
> + struct dma_fence_array *array = to_dma_fence_array(fence);
> +
> + /* XXX Error for signal-on-any fence arrays */
Unfinished?
> +
> + child = array->fences;
> + nchild = array->num_fences;
> + GEM_BUG_ON(!nchild);
> + }
> +
> + do {
> + fence = *child++;
> + if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags))
> + continue;
> +
> + /*
> + * We don't squash repeated fence dependencies here as we
> + * want to run our callback in all cases.
> + */
> +
> + if (dma_fence_is_i915(fence))
> + ret = __i915_request_await_execution(rq,
> + to_request(fence),
> + hook,
> + I915_FENCE_GFP);
> + else
> + ret = i915_sw_fence_await_dma_fence(&rq->submit, fence,
> + I915_FENCE_TIMEOUT,
> + GFP_KERNEL);
> + if (ret < 0)
> + return ret;
> + } while (--nchild);
> +
> + return 0;
> +}
> +
> /**
> * i915_request_await_object - set this request to (async) wait upon a bo
> * @to: request we are wishing to use
> diff --git a/drivers/gpu/drm/i915/i915_request.h b/drivers/gpu/drm/i915/i915_request.h
> index cd6c130964cd..d4f6b2940130 100644
> --- a/drivers/gpu/drm/i915/i915_request.h
> +++ b/drivers/gpu/drm/i915/i915_request.h
> @@ -265,6 +265,10 @@ int i915_request_await_object(struct i915_request *to,
> bool write);
> int i915_request_await_dma_fence(struct i915_request *rq,
> struct dma_fence *fence);
> +int i915_request_await_execution(struct i915_request *rq,
> + struct dma_fence *fence,
> + void (*hook)(struct i915_request *rq,
> + struct dma_fence *signal));
>
> void i915_request_add(struct i915_request *rq);
>
>
Regards,
Tvrtko
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2019-03-11 13:09 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-08 14:12 Home straight for veng, the uAPI wars Chris Wilson
2019-03-08 14:12 ` [PATCH 01/13] drm/i915: Suppress the "Failed to idle" warning for gem_eio Chris Wilson
2019-03-08 14:12 ` [PATCH 02/13] drm/i915: Introduce the i915_user_extension_method Chris Wilson
2019-03-08 14:33 ` Tvrtko Ursulin
2019-03-13 10:50 ` Chris Wilson
2019-03-13 11:13 ` Tvrtko Ursulin
2019-03-13 11:21 ` Chris Wilson
2019-03-13 11:35 ` Tvrtko Ursulin
2019-03-13 11:46 ` Chris Wilson
2019-03-13 13:11 ` Tvrtko Ursulin
2019-03-13 13:14 ` Chris Wilson
2019-03-08 14:12 ` [PATCH 03/13] drm/i915: Introduce a context barrier callback Chris Wilson
2019-03-08 14:12 ` [PATCH 04/13] drm/i915: Create/destroy VM (ppGTT) for use with contexts Chris Wilson
2019-03-08 15:03 ` Tvrtko Ursulin
2019-03-08 15:35 ` Chris Wilson
2019-03-08 15:41 ` [PATCH v2] " Chris Wilson
2019-03-08 14:12 ` [PATCH 05/13] drm/i915: Extend CONTEXT_CREATE to set parameters upon construction Chris Wilson
2019-03-08 14:12 ` [PATCH 06/13] drm/i915: Allow contexts to share a single timeline across all engines Chris Wilson
2019-03-08 15:56 ` Tvrtko Ursulin
2019-03-08 14:12 ` [PATCH 07/13] drm/i915: Allow userspace to clone contexts on creation Chris Wilson
2019-03-08 16:13 ` Tvrtko Ursulin
2019-03-08 16:34 ` Chris Wilson
2019-03-08 14:12 ` [PATCH 08/13] drm/i915: Allow a context to define its set of engines Chris Wilson
2019-03-08 16:27 ` Tvrtko Ursulin
2019-03-08 16:47 ` Chris Wilson
2019-03-11 9:23 ` Tvrtko Ursulin
2019-03-11 9:45 ` Chris Wilson
2019-03-11 10:12 ` Tvrtko Ursulin
2019-03-11 14:45 ` Chris Wilson
2019-03-11 16:16 ` Tvrtko Ursulin
2019-03-11 16:22 ` Chris Wilson
2019-03-11 16:34 ` Tvrtko Ursulin
2019-03-11 16:52 ` Chris Wilson
2019-03-08 14:12 ` [PATCH 09/13] drm/i915: Extend I915_CONTEXT_PARAM_SSEU to support local ctx->engine[] Chris Wilson
2019-03-08 16:31 ` Tvrtko Ursulin
2019-03-08 16:57 ` Chris Wilson
2019-03-11 7:14 ` Tvrtko Ursulin
2019-03-11 10:33 ` Chris Wilson
2019-03-08 17:11 ` Chris Wilson
2019-03-11 7:16 ` Tvrtko Ursulin
2019-03-11 10:31 ` Chris Wilson
2019-03-08 14:12 ` [PATCH 10/13] drm/i915: Load balancing across a virtual engine Chris Wilson
2019-03-11 12:47 ` Tvrtko Ursulin
2019-03-11 13:43 ` Chris Wilson
2019-03-12 7:52 ` Tvrtko Ursulin
2019-03-12 8:56 ` Chris Wilson
2019-03-08 14:12 ` [PATCH 11/13] drm/i915: Extend execution fence to support a callback Chris Wilson
2019-03-11 13:09 ` Tvrtko Ursulin [this message]
2019-03-11 14:22 ` Chris Wilson
2019-03-08 14:12 ` [PATCH 12/13] drm/i915/execlists: Virtual engine bonding Chris Wilson
2019-03-11 13:38 ` Tvrtko Ursulin
2019-03-11 14:30 ` Chris Wilson
2019-03-08 14:12 ` [PATCH 13/13] drm/i915: Allow specification of parallel execbuf Chris Wilson
2019-03-11 13:40 ` Tvrtko Ursulin
2019-03-08 14:58 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [01/13] drm/i915: Suppress the "Failed to idle" warning for gem_eio Patchwork
2019-03-08 15:05 ` ✗ Fi.CI.SPARSE: " Patchwork
2019-03-08 15:19 ` ✗ Fi.CI.BAT: failure " Patchwork
2019-03-08 16:47 ` ✗ Fi.CI.BAT: failure for series starting with [01/13] drm/i915: Suppress the "Failed to idle" warning for gem_eio (rev2) 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=7c1bce56-47c6-7cae-f939-57db4993bc86@linux.intel.com \
--to=tvrtko.ursulin@linux.intel.com \
--cc=chris@chris-wilson.co.uk \
--cc=intel-gfx@lists.freedesktop.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