From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>,
Intel-gfx@lists.freedesktop.org,
Tvrtko Ursulin <tvrtko.ursulin@intel.com>,
Alex Dai <yu.dai@intel.com>,
Dave Gordon <david.s.gordon@intel.com>,
Nick Hoath <nicholas.hoath@intel.com>
Subject: Re: [PATCH 2/3] drm/i915/guc: Keep the previous context pinned until the next one has been completed
Date: Fri, 15 Apr 2016 14:16:58 +0100 [thread overview]
Message-ID: <5710E9CA.10603@linux.intel.com> (raw)
In-Reply-To: <20160415121246.GO19990@nuc-i3427.alporthouse.com>
On 15/04/16 13:12, Chris Wilson wrote:
> On Fri, Apr 15, 2016 at 12:54:34PM +0100, Tvrtko Ursulin wrote:
>> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>>
>> In GuC mode submitting requests is only putting them into the
>> GuC queue with the actual submission to hardware following at
>> some future point. This makes the per engine last context
>> tracking insufficient for closing the premature context
>> unpin race.
>>
>> Instead we need to make requests track and pin the previous
>> context on the same engine, and only unpin them when they
>> themselves are retired. This will ensure contexts remain pinned
>> in all cases until the are fully saved by the GPU.
>>
>> v2: Only track contexts.
>> v3: Limit to GuC for now.
>>
>> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>> Cc: Alex Dai <yu.dai@intel.com>
>> Cc: Dave Gordon <david.s.gordon@intel.com>
>> Cc: Nick Hoath <nicholas.hoath@intel.com>
>> Cc: Chris Wilson <chris@chris-wilson.co.uk>
>> ---
>> drivers/gpu/drm/i915/i915_drv.h | 4 +++-
>> drivers/gpu/drm/i915/i915_gem.c | 5 +++++
>> drivers/gpu/drm/i915/intel_lrc.c | 15 +++++++++++++++
>> 3 files changed, 23 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
>> index b9ed1b305beb..80f2d959ed7b 100644
>> --- a/drivers/gpu/drm/i915/i915_drv.h
>> +++ b/drivers/gpu/drm/i915/i915_drv.h
>> @@ -2290,6 +2290,9 @@ struct drm_i915_gem_request {
>> struct intel_context *ctx;
>> struct intel_ringbuffer *ringbuf;
>>
>> + /** Context preceding this one on the same engine. Can be NULL. */
>> + struct intel_context *prev_ctx;
>> +
>> /** Batch buffer related to this request if any (used for
>> error state dump only) */
>> struct drm_i915_gem_object *batch_obj;
>> @@ -2325,7 +2328,6 @@ struct drm_i915_gem_request {
>>
>> /** Execlists no. of times this request has been sent to the ELSP */
>> int elsp_submitted;
>> -
>> };
>>
>> struct drm_i915_gem_request * __must_check
>> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
>> index e9db56c7a31f..18e747132ce5 100644
>> --- a/drivers/gpu/drm/i915/i915_gem.c
>> +++ b/drivers/gpu/drm/i915/i915_gem.c
>> @@ -1413,6 +1413,11 @@ static void i915_gem_request_retire(struct drm_i915_gem_request *request)
>> list_del_init(&request->list);
>> i915_gem_request_remove_from_client(request);
>>
>> + if (request->prev_ctx) {
>> + intel_lr_context_unpin(request->prev_ctx, request->engine);
>> + request->prev_ctx = NULL;
>> + }
>> +
>> i915_gem_request_unreference(request);
>> }
>>
>> diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
>> index 2f49dfae5560..73be9eac8ecc 100644
>> --- a/drivers/gpu/drm/i915/intel_lrc.c
>> +++ b/drivers/gpu/drm/i915/intel_lrc.c
>> @@ -791,6 +791,21 @@ intel_logical_ring_advance_and_submit(struct drm_i915_gem_request *request)
>> if (intel_engine_stopped(engine))
>> return 0;
>>
>> + /*
>> + * Pin the previous context on this engine to ensure it is not
>> + * prematurely unpinned in GuC mode.
>> + * Previous context will be unpinned when this request is retired,
>> + * ensuring the GPU has switched out from the previous context and
>> + * into a new context at that point.
>> + */
>> + if (dev_priv->guc.execbuf_client && engine->last_context) {
>> + intel_lr_context_pin(engine->last_context, engine);
>> + request->prev_ctx = engine->last_context;
>> + }
>
> Nak.
>
> We just want,
>
> request->pinned_ctx = engine->last_context;
> engine->last_context = request->ctx;
>
> as that works for everyone (and replaces the current last_context dance)
Not sure if you are against the implementation or the idea.
It is deliberately limited to GuC for now, until the lazy ringbuffer
unpin happens for all platforms.
Then - engine needs to hold the pin on the last context in case there
are no subsequent requests to keep it pinned.
In your snippet where do you pin it before assigning to any object?
I could optimize my implementation by not doing the pin-unpin in the
case when the context changes between current and last, but other than
that it looks correct to me.
And I don't think pinned_ctx is a good name. Previous context is
descriptive and self documenting so wins easily IMHO.
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-15 13:17 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 [this message]
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
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=5710E9CA.10603@linux.intel.com \
--to=tvrtko.ursulin@linux.intel.com \
--cc=Intel-gfx@lists.freedesktop.org \
--cc=chris@chris-wilson.co.uk \
--cc=david.s.gordon@intel.com \
--cc=nicholas.hoath@intel.com \
--cc=tvrtko.ursulin@intel.com \
--cc=yu.dai@intel.com \
/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.