From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Intel-gfx@lists.freedesktop.org
Cc: Tvrtko Ursulin <tvrtko@ursulin.net>
Subject: [RFC 2/4] drm/i915/guc: Keep the previous context pinned until the next one has been completed
Date: Fri, 8 Apr 2016 14:54:56 +0100 [thread overview]
Message-ID: <1460123698-16832-3-git-send-email-tvrtko.ursulin@linux.intel.com> (raw)
In-Reply-To: <1460123698-16832-1-git-send-email-tvrtko.ursulin@linux.intel.com>
From: Tvrtko Ursulin <tvrtko@ursulin.net>
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.
Signed-off-by: Tvrtko Ursulin <tvrtko@ursulin.net>
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 | 17 +++++++++++++++++
3 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index fa199b7e51b5..216b2297ae3e 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -2283,6 +2283,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;
@@ -2318,7 +2321,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 c1df696f9002..118911ce7231 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -1445,6 +1445,11 @@ static void i915_gem_request_retire(struct drm_i915_gem_request *request)
*/
request->ringbuf->last_retired_head = request->postfix;
+ if (request->prev_ctx) {
+ intel_lr_context_unpin(request->prev_ctx, request->engine);
+ request->prev_ctx = NULL;
+ }
+
__i915_gem_request_release(request);
}
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index 31445aa3429b..3d08dac0a9b0 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -798,6 +798,23 @@ 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 (engine->last_context) {
+ if (engine->last_context != request->i915->kernel_context) {
+ intel_lr_context_pin(engine->last_context, engine);
+ request->prev_ctx = engine->last_context;
+ }
+ }
+
+ /*
+ * Track and pin the last context submitted on an engine.
+ */
if (engine->last_context != request->ctx) {
if (engine->last_context)
intel_lr_context_unpin(engine->last_context, engine);
--
1.9.1
_______________________________________________
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-08 13:55 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-08 13:54 [RFC 0/4] Eliminating the execlist retired request queue Tvrtko Ursulin
2016-04-08 13:54 ` [RFC 1/4] drm/i915: Move releasing of the GEM request from free to retire/cancel Tvrtko Ursulin
2016-04-08 15:01 ` Chris Wilson
2016-04-11 9:19 ` Tvrtko Ursulin
2016-04-08 13:54 ` Tvrtko Ursulin [this message]
2016-04-08 14:37 ` [RFC 2/4] drm/i915/guc: Keep the previous context pinned until the next one has been completed Chris Wilson
2016-04-11 8:58 ` Tvrtko Ursulin
2016-04-08 13:54 ` [RFC 3/4] drm/i915: Use new i915_gem_object_pin_map for LRC Tvrtko Ursulin
2016-04-08 14:40 ` Chris Wilson
2016-04-11 9:05 ` Tvrtko Ursulin
2016-04-11 9:18 ` Chris Wilson
2016-04-08 13:54 ` [RFC 4/4] drm/i915: Stop tracking execlists retired requests Tvrtko Ursulin
2016-04-08 14:57 ` Chris Wilson
2016-04-11 9:10 ` Tvrtko Ursulin
2016-04-11 9:23 ` Chris Wilson
2016-04-11 9:26 ` Chris Wilson
2016-04-08 14:08 ` ✗ Fi.CI.BAT: failure for Eliminating the execlist retired request queue Patchwork
2016-04-09 8:03 ` [RFC 0/4] " Chris Wilson
2016-04-11 9:19 ` Tvrtko Ursulin
2016-04-11 10:20 ` Chris Wilson
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=1460123698-16832-3-git-send-email-tvrtko.ursulin@linux.intel.com \
--to=tvrtko.ursulin@linux.intel.com \
--cc=Intel-gfx@lists.freedesktop.org \
--cc=tvrtko@ursulin.net \
/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