Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: jeff.mcgee@intel.com
To: intel-gfx@lists.freedesktop.org
Cc: ben@bwidawsk.net, kalyan.kondapally@intel.com
Subject: [RFC 6/8] drm/i915: Repair the preemption context if hit by reset
Date: Fri, 16 Mar 2018 11:31:03 -0700	[thread overview]
Message-ID: <20180316183105.16027-7-jeff.mcgee@intel.com> (raw)
In-Reply-To: <20180316183105.16027-1-jeff.mcgee@intel.com>

From: Jeff McGee <jeff.mcgee@intel.com>

It is possible for the preemption context to be active on an engine
when the engine is reset. The preemption context is not tracked via
the request mechanism, so the normal reset handling will not detect
this scenario and will not be able to fixup possible context
corruption. So add some extra logic to do this.

This patch is required to support the force preemption feature.

Test: Run IGT gem_exec_fpreempt repeatedly.
Change-Id: Ifd0f17726111f3b702dd900064b7f375bbb42808
Signed-off-by: Jeff McGee <jeff.mcgee@intel.com>
---
 drivers/gpu/drm/i915/intel_lrc.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index b2f838c484b0..581483886153 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -1619,6 +1619,25 @@ static void reset_common_ring(struct intel_engine_cs *engine,
 
 	spin_unlock_irqrestore(&engine->timeline->lock, flags);
 
+	/* If a preemption was pending when the reset occurred, and no
+	 * active request was found when the reset completed, it is
+	 * possible that the preemption context was hit by the reset.
+	 * We must assume that the context is corrupted so repair it.
+	 */
+	if (execlists_is_active(execlists, EXECLISTS_ACTIVE_PREEMPT) &&
+	    !request) {
+		struct i915_gem_context *ctx = engine->i915->preempt_context;
+		ce = &ctx->engine[engine->id];
+
+		execlists_init_reg_state(ce->lrc_reg_state,
+					 ctx, engine, ce->ring);
+		ce->lrc_reg_state[CTX_RING_BUFFER_START+1] =
+			i915_ggtt_offset(ce->ring->vma);
+		ce->lrc_reg_state[CTX_RING_HEAD+1] = ce->ring->tail;
+
+		return;
+	}
+
 	/* If the request was innocent, we leave the request in the ELSP
 	 * and will try to replay it on restarting. The context image may
 	 * have been corrupted by the reset, in which case we may have
-- 
2.16.2

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2018-03-16 18:45 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-16 18:30 [RFC 0/8] Force preemption jeff.mcgee
2018-03-16 18:30 ` [RFC 1/8] drm/i915: Downgrade tasklet GEM_BUG_ON for request not completed jeff.mcgee
2018-03-16 20:30   ` Chris Wilson
2018-03-16 18:30 ` [RFC 2/8] drm/i915: Skip CSB processing on invalid CSB tail jeff.mcgee
2018-03-16 20:30   ` Chris Wilson
2018-03-16 18:31 ` [RFC 3/8] drm/i915: Execlists to mark the HWSP upon preemption finished jeff.mcgee
2018-03-16 18:31 ` [RFC 4/8] drm/i915: Add a wait_for routine with more exact timeout jeff.mcgee
2018-03-16 18:31 ` [RFC 5/8] drm/i915: Consider preemption when finding the active request jeff.mcgee
2018-03-16 18:31 ` jeff.mcgee [this message]
2018-03-16 18:31 ` [RFC 7/8] drm/i915: Allow reset without error capture jeff.mcgee
2018-03-16 20:33   ` Chris Wilson
2018-03-16 18:31 ` [RFC 8/8] drm/i915: Force preemption to complete via engine reset jeff.mcgee
2018-03-16 20:39   ` Chris Wilson
2018-03-16 20:44   ` Chris Wilson
2018-03-16 18:59 ` ✗ Fi.CI.BAT: failure for Force preemption Patchwork
2018-03-16 20:53 ` [RFC 0/8] " Chris Wilson
2018-03-16 21:03   ` Chris Wilson
2018-03-16 23:04     ` [PATCH] force-preempt-reset Chris Wilson
2018-03-16 23:45     ` ✗ Fi.CI.BAT: failure for force-preempt-reset Patchwork
2018-03-16 22:34 ` [RFC 0/8] Force preemption 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=20180316183105.16027-7-jeff.mcgee@intel.com \
    --to=jeff.mcgee@intel.com \
    --cc=ben@bwidawsk.net \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=kalyan.kondapally@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox