From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 8/9] drm/i915: Track the previous pinned context inside the request
Date: Tue, 19 Apr 2016 13:02:26 +0100 [thread overview]
Message-ID: <57161E52.60505@linux.intel.com> (raw)
In-Reply-To: <1461048560-31983-9-git-send-email-chris@chris-wilson.co.uk>
On 19/04/16 07:49, Chris Wilson wrote:
> As the contexts are accessed by the hardware until the switch is completed
> to a new context, the hardware may still be writing to the context object
> after the breadcrumb is visible. We must not unpin/unbind/prune that
> object whilst still active and so we keep the previous context pinned until
> the following request. If we move this tracking onto the request, we can
> simplify the code and enable freeing of the request without the
> struct_mutex in subsequent patches.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> ---
> drivers/gpu/drm/i915/i915_gem_request.c | 8 ++++----
> drivers/gpu/drm/i915/i915_gem_request.h | 11 +++++++++++
> drivers/gpu/drm/i915/intel_lrc.c | 12 +++++-------
> 3 files changed, 20 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_gem_request.c b/drivers/gpu/drm/i915/i915_gem_request.c
> index 33aacf1725dd..8d7c415f1896 100644
> --- a/drivers/gpu/drm/i915/i915_gem_request.c
> +++ b/drivers/gpu/drm/i915/i915_gem_request.c
> @@ -643,12 +643,12 @@ void i915_gem_request_free(struct kref *req_ref)
> if (req->file_priv)
> i915_gem_request_remove_from_client(req);
>
> - if (ctx) {
> + if (req->pinned_context) {
> if (i915.enable_execlists)
> - intel_lr_context_unpin(ctx, req->engine);
> -
> - i915_gem_context_unreference(ctx);
> + intel_lr_context_unpin(req->pinned_context,
> + req->engine);
> }
>
> + i915_gem_context_unreference(ctx);
> kmem_cache_free(to_i915(req)->requests, req);
> }
> diff --git a/drivers/gpu/drm/i915/i915_gem_request.h b/drivers/gpu/drm/i915/i915_gem_request.h
> index 69a4d4e2c97b..389813cbc19a 100644
> --- a/drivers/gpu/drm/i915/i915_gem_request.h
> +++ b/drivers/gpu/drm/i915/i915_gem_request.h
> @@ -85,6 +85,17 @@ struct drm_i915_gem_request {
> struct intel_context *ctx;
> struct intel_ringbuffer *ringbuf;
>
> + /**
> + * Context related to the previous request.
> + * As the contexts are accessed by the hardware until the switch is
> + * completed to a new context, the hardware may still be writing
> + * to the context object after the breadcrumb is visible. We must
> + * not unpin/unbind/prune that object whilst still active and so
> + * we keep the previous context pinned until the following (this)
> + * request is retired.
> + */
> + struct intel_context *pinned_context;
> +
> /** Batch buffer related to this request if any (used for
> error state dump only) */
> struct drm_i915_gem_object *batch_obj;
> diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
> index b0d20af38574..0e55f206e592 100644
> --- a/drivers/gpu/drm/i915/intel_lrc.c
> +++ b/drivers/gpu/drm/i915/intel_lrc.c
> @@ -708,6 +708,7 @@ int intel_logical_ring_alloc_request_extras(struct drm_i915_gem_request *request
> request->ctx->engine[engine->id].initialised = true;
> }
>
> + request->pinned_context = request->ctx;
Add a little bit of comment to the big one above explaining the
possibility of pinned_context being, not the previous, but the current
one before submission?
> return 0;
> }
>
> @@ -782,12 +783,8 @@ intel_logical_ring_advance_and_submit(struct drm_i915_gem_request *request)
> intel_logical_ring_emit(ringbuf, MI_NOOP);
> intel_logical_ring_advance(ringbuf);
>
> - if (engine->last_context != request->ctx) {
> - if (engine->last_context)
> - intel_lr_context_unpin(engine->last_context, engine);
> - intel_lr_context_pin(request->ctx, engine);
> - engine->last_context = request->ctx;
> - }
> + request->pinned_context = engine->last_context;
> + engine->last_context = request->ctx;
I am not sure if this is very complicated or just very different from my
approach. Either way after thinking long and hard I cannot fault it.
Looks like it will work.
>
> if (dev_priv->guc.execbuf_client)
> i915_guc_submit(dev_priv->guc.execbuf_client, request);
> @@ -1009,7 +1006,8 @@ void intel_execlists_retire_requests(struct intel_engine_cs *engine)
> spin_unlock_bh(&engine->execlist_lock);
>
> list_for_each_entry_safe(req, tmp, &retired_list, execlist_link) {
> - intel_lr_context_unpin(req->ctx, engine);
> + if (req->pinned_context)
> + intel_lr_context_unpin(req->pinned_context, engine);
>
> list_del(&req->execlist_link);
> i915_gem_request_unreference(req);
>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
I suppose you did not see any performance effect since you decided to
turn it on for both GuC and execlists? (Assuming vma iomap is in place.)
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:[~2016-04-19 12:02 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-15 11:54 [PATCH 0/3] GuC premature LRC unpin Tvrtko Ursulin
2016-04-15 11:54 ` [PATCH 1/3] drm/i915: Refactor execlists default context pinning Tvrtko Ursulin
2016-04-15 12:16 ` Chris Wilson
2016-04-15 13:21 ` Tvrtko Ursulin
2016-04-15 11:54 ` [PATCH 2/3] drm/i915/guc: Keep the previous context pinned until the next one has been completed Tvrtko Ursulin
2016-04-15 12:12 ` Chris Wilson
2016-04-15 13:16 ` Tvrtko Ursulin
2016-04-15 11:54 ` [PATCH 3/3] DO NOT MERGE: drm/i915: Enable GuC submission Tvrtko Ursulin
2016-04-15 15:24 ` ✗ Fi.CI.BAT: warning for GuC premature LRC unpin Patchwork
2016-04-19 6:49 ` Premature " Chris Wilson
2016-04-19 6:49 ` [PATCH 1/9] drm/i915: Assign every HW context a unique ID Chris Wilson
2016-04-19 8:57 ` Tvrtko Ursulin
2016-04-19 9:04 ` Chris Wilson
2016-04-19 9:20 ` Tvrtko Ursulin
2016-04-19 6:49 ` [PATCH 2/9] drm/i915: Replace the pinned context address with its " Chris Wilson
2016-04-19 9:03 ` Tvrtko Ursulin
2016-04-19 6:49 ` [PATCH 3/9] drm/i915: Refactor execlists default context pinning Chris Wilson
2016-04-19 9:16 ` Tvrtko Ursulin
2016-04-19 9:55 ` [PATCH] " Chris Wilson
2016-04-19 6:49 ` [PATCH 4/9] drm/i915: Remove early l3-remap Chris Wilson
2016-04-19 9:41 ` Tvrtko Ursulin
2016-04-19 10:07 ` [PATCH 1/3] drm/i915: L3 cache remapping is part of context switching Chris Wilson
2016-04-19 10:07 ` [PATCH 2/3] drm/i915: Consolidate L3 remapping LRI Chris Wilson
2016-04-19 10:21 ` Tvrtko Ursulin
2016-04-19 10:07 ` [PATCH 3/3] drm/i915: Remove early l3-remap Chris Wilson
2016-04-19 10:23 ` Tvrtko Ursulin
2016-04-19 10:20 ` [PATCH 1/3] drm/i915: L3 cache remapping is part of context switching Tvrtko Ursulin
2016-04-19 6:49 ` [PATCH 5/9] drm/i915: Rearrange switch_context to load the aliasing ppgtt on first use Chris Wilson
2016-04-19 9:52 ` Tvrtko Ursulin
2016-04-19 6:49 ` [PATCH 6/9] drm/i915: Move context initialisation to first-use Chris Wilson
2016-04-19 9:57 ` Tvrtko Ursulin
2016-04-19 10:15 ` Tvrtko Ursulin
2016-04-19 10:55 ` Chris Wilson
2016-04-19 6:49 ` [PATCH 7/9] drm/i915: Move the magical deferred context allocation into the request Chris Wilson
2016-04-19 10:28 ` Tvrtko Ursulin
2016-04-19 6:49 ` [PATCH 8/9] drm/i915: Track the previous pinned context inside " Chris Wilson
2016-04-19 12:02 ` Tvrtko Ursulin [this message]
2016-04-19 12:14 ` Chris Wilson
2016-04-19 6:49 ` [PATCH 9/9] drm/i915: Move releasing of the GEM request from free to retire/cancel Chris Wilson
2016-04-19 12:16 ` Tvrtko Ursulin
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=57161E52.60505@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.