All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH 15/71] drm/i915: Stop parking the signaler around reset
Date: Thu,  3 May 2018 07:37:01 +0100	[thread overview]
Message-ID: <20180503063757.22238-15-chris@chris-wilson.co.uk> (raw)
In-Reply-To: <20180503063757.22238-1-chris@chris-wilson.co.uk>

We cannot call kthread_park() from softirq context, so let's avoid it
entirely during the reset. We wanted to suspend the signaler so that it
would not mark a request as complete at the same time as we marked it as
being in error. Instead of parking the signaling, stop the engine from
advancing so that the GPU doesn't emit the breadcrumb for our chosen
"guilty" request.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Cc: Michał Winiarski <michal.winiarski@intel.com>
CC: Michel Thierry <michel.thierry@intel.com>
Cc: Jeff McGee <jeff.mcgee@intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 drivers/gpu/drm/i915/i915_gem.c         | 14 --------------
 drivers/gpu/drm/i915/intel_lrc.c        | 21 +++++++++++++++++++++
 drivers/gpu/drm/i915/intel_ringbuffer.c | 18 ++++++++++++++++++
 3 files changed, 39 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 694471fba777..022a84ac0c74 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -3013,18 +3013,6 @@ i915_gem_reset_prepare_engine(struct intel_engine_cs *engine)
 	 */
 	intel_uncore_forcewake_get(engine->i915, FORCEWAKE_ALL);
 
-	/*
-	 * Prevent the signaler thread from updating the request
-	 * state (by calling dma_fence_signal) as we are processing
-	 * the reset. The write from the GPU of the seqno is
-	 * asynchronous and the signaler thread may see a different
-	 * value to us and declare the request complete, even though
-	 * the reset routine have picked that request as the active
-	 * (incomplete) request. This conflict is not handled
-	 * gracefully!
-	 */
-	kthread_park(engine->breadcrumbs.signaler);
-
 	request = engine->reset.prepare(engine);
 	if (request && request->fence.error == -EIO)
 		request = ERR_PTR(-EIO); /* Previous reset failed! */
@@ -3227,8 +3215,6 @@ void i915_gem_reset_finish_engine(struct intel_engine_cs *engine)
 {
 	engine->reset.finish(engine);
 
-	kthread_unpark(engine->breadcrumbs.signaler);
-
 	intel_uncore_forcewake_put(engine->i915, FORCEWAKE_ALL);
 }
 
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index a60c3afd0adb..bcebcd6f2848 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -1852,6 +1852,21 @@ static void tasklet_kill_and_disable(struct tasklet_struct *t)
 	smp_mb();
 }
 
+static void set_stop_engine(struct intel_engine_cs *engine)
+{
+	struct drm_i915_private *dev_priv = engine->i915;
+	const u32 base = engine->mmio_base;
+	const i915_reg_t mode = RING_MI_MODE(base);
+
+	GEM_TRACE("%s\n", engine->name);
+	I915_WRITE_FW(mode, _MASKED_BIT_ENABLE(STOP_RING));
+	if (__intel_wait_for_register_fw(dev_priv,
+					 mode, MODE_IDLE, MODE_IDLE,
+					 1000, 0,
+					 NULL))
+		GEM_TRACE("%s: timed out on STOP_RING -> IDLE\n", engine->name);
+}
+
 static struct i915_request *
 execlists_reset_prepare(struct intel_engine_cs *engine)
 {
@@ -1898,6 +1913,12 @@ execlists_reset_prepare(struct intel_engine_cs *engine)
 	if (request) {
 		unsigned long flags;
 
+		/*
+		 * Prevent the breadcrumb from advancing before we decide
+		 * which request is currently active.
+		 */
+		set_stop_engine(engine);
+
 		spin_lock_irqsave(&engine->timeline.lock, flags);
 		list_for_each_entry_from_reverse(request,
 						 &engine->timeline.requests,
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index 1e37e1be16c2..166901cbfa88 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -531,8 +531,26 @@ static int init_ring_common(struct intel_engine_cs *engine)
 	return ret;
 }
 
+static void set_stop_engine(struct intel_engine_cs *engine)
+{
+	struct drm_i915_private *dev_priv = engine->i915;
+	const u32 base = engine->mmio_base;
+	const i915_reg_t mode = RING_MI_MODE(base);
+
+	I915_WRITE_FW(mode, _MASKED_BIT_ENABLE(STOP_RING));
+	if (__intel_wait_for_register_fw(dev_priv,
+					 mode, MODE_IDLE, MODE_IDLE,
+					 1000, 0,
+					 NULL))
+		DRM_DEBUG_DRIVER("%s: timed out on STOP_RING\n",
+				 engine->name);
+}
+
 static struct i915_request *reset_prepare(struct intel_engine_cs *engine)
 {
+	if (INTEL_GEN(engine->i915) >= 3)
+		set_stop_engine(engine);
+
 	if (engine->irq_seqno_barrier)
 		engine->irq_seqno_barrier(engine);
 
-- 
2.17.0

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

  parent reply	other threads:[~2018-05-03  6:38 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-03  6:36 [PATCH 01/71] drm/i915/execlists: Drop preemption arbitrations points along the ring Chris Wilson
2018-05-03  6:36 ` [PATCH 02/71] drm/i915/execlists: Emit i915_trace_request_out for preemption Chris Wilson
2018-05-03  6:36 ` [PATCH 03/71] drm/i915: Lazily unbind vma on close Chris Wilson
2018-05-03 16:59   ` Tvrtko Ursulin
2018-05-03  6:36 ` [PATCH 04/71] drm/i915: Keep one request in our ring_list Chris Wilson
2018-05-03 17:04   ` Tvrtko Ursulin
2018-05-03  6:36 ` [PATCH 05/71] drm/i915/execlists: Disable submission tasklets when rescheduling Chris Wilson
2018-05-03 17:49   ` Tvrtko Ursulin
2018-05-03 19:50     ` Chris Wilson
2018-05-04  9:15       ` Tvrtko Ursulin
2018-05-04  9:31         ` Chris Wilson
2018-05-03  6:36 ` [PATCH 06/71] drm/i915: Detect if we missed kicking the execlists tasklet Chris Wilson
2018-05-03 13:08   ` Chris Wilson
2018-05-03  6:36 ` [PATCH 07/71] drm/i915: Move request->ctx aside Chris Wilson
2018-05-03  6:36 ` [PATCH 08/71] drm/i915: Move fiddling with engine->last_retired_context Chris Wilson
2018-05-03  6:36 ` [PATCH 09/71] drm/i915: Store a pointer to intel_context in i915_request Chris Wilson
2018-05-04 10:31   ` Tvrtko Ursulin
2018-05-03  6:36 ` [PATCH 10/71] drm/i915/execlists: Refactor out complete_preempt_context() Chris Wilson
2018-05-03  6:36 ` [PATCH 11/71] drm/i915: Move engine reset prepare/finish to backends Chris Wilson
2018-05-03  6:36 ` [PATCH 12/71] drm/i915: Split execlists/guc reset preparations Chris Wilson
2018-05-03  6:36 ` [PATCH 13/71] drm/i915/execlists: Flush pending preemption events during reset Chris Wilson
2018-05-03  6:37 ` [PATCH 14/71] drm/i915: Combine tasklet_kill and tasklet_disable Chris Wilson
2018-05-03  6:37 ` Chris Wilson [this message]
2018-05-03  6:37 ` [PATCH 16/71] drm/i915: Be irqsafe inside reset Chris Wilson
2018-05-03  6:37 ` [PATCH 17/71] drm/i915/execlists: Make submission tasklet hardirq safe Chris Wilson
2018-05-03  6:37 ` [PATCH 18/71] drm/i915/guc: " Chris Wilson
2018-05-03  6:37 ` [PATCH 19/71] drm/i915: Allow init_breadcrumbs to be used from irq context Chris Wilson
2018-05-03  6:37 ` [PATCH 20/71] drm/i915/execlists: Force preemption via reset on timeout Chris Wilson
2018-05-03  6:37 ` [PATCH 21/71] drm/i915/execlists: Try preempt-reset from hardirq timer context Chris Wilson
2018-05-03  6:37 ` [PATCH 22/71] drm/i915/preemption: Select timeout when scheduling Chris Wilson
2018-05-03  6:37 ` [PATCH 23/71] drm/i915: Use a preemption timeout to enforce interactivity Chris Wilson
2018-05-03  6:37 ` [PATCH 24/71] drm/i915: Allow user control over preempt timeout on their important context Chris Wilson
2018-05-03  6:37 ` [PATCH 25/71] drm/i915: Disable preemption and sleeping while using the punit sideband Chris Wilson
2018-05-03  6:37 ` [PATCH 26/71] drm/i915: Lift acquiring the vlv punit magic to a common sb-get Chris Wilson
2018-05-03  6:37 ` [PATCH 27/71] drm/i915: Lift sideband locking for vlv_punit_(read|write) Chris Wilson
2018-05-03  6:37 ` [PATCH 28/71] drm/i915: Reduce RPS update frequency on Valleyview/Cherryview Chris Wilson
2018-05-03  6:37 ` [PATCH 29/71] Revert "drm/i915: Avoid tweaking evaluation thresholds on Baytrail v3" Chris Wilson
2018-05-03  6:37 ` [PATCH 30/71] drm/i915: Replace pcu_lock with sb_lock Chris Wilson
2018-05-03  6:37 ` [PATCH 31/71] drm/i915: Separate sideband declarations to intel_sideband.h Chris Wilson
2018-05-03  6:37 ` [PATCH 32/71] drm/i915: Merge sbi read/write into a single accessor Chris Wilson
2018-05-03  6:37 ` [PATCH 33/71] drm/i915: Merge sandybridge_pcode_(read|write) Chris Wilson
2018-05-03  6:37 ` [PATCH 34/71] drm/i915: Move sandybride pcode access to intel_sideband.c Chris Wilson
2018-05-03  6:37 ` [PATCH 35/71] drm/i915: Mark up Ironlake ips with rpm wakerefs Chris Wilson
2018-05-03  6:37 ` [PATCH 36/71] drm/i915: Record logical context support in driver caps Chris Wilson
2018-05-03  6:37 ` [PATCH 37/71] drm/i915: Generalize i915_gem_sanitize() to reset contexts Chris Wilson
2018-05-03  6:37 ` [PATCH 38/71] drm/i915: Enable render context support for Ironlake (gen5) Chris Wilson
2018-05-03  8:47   ` Chris Wilson
2018-05-03  6:37 ` [PATCH 39/71] drm/i915: Enable render context support for gen4 (Broadwater to Cantiga) Chris Wilson
2018-05-03  6:37 ` [PATCH 40/71] drm/i915: Split GT powermanagement functions to intel_gt_pm.c Chris Wilson
2018-05-03  6:37 ` [PATCH 41/71] drm/i915: Move rps worker " Chris Wilson
2018-05-03  6:37 ` [PATCH 42/71] drm/i915: Move all the RPS irq handlers to intel_gt_pm Chris Wilson
2018-05-03  6:37 ` [PATCH 43/71] drm/i915: Track HAS_RPS alongside HAS_RC6 in the device info Chris Wilson
2018-05-03  6:37 ` [PATCH 44/71] drm/i915: Remove defunct intel_suspend_gt_powersave() Chris Wilson
2018-05-03  6:37 ` [PATCH 45/71] drm/i915: Reorder GT interface code Chris Wilson
2018-05-03  6:37 ` [PATCH 46/71] drm/i915: Split control of rps and rc6 Chris Wilson
2018-05-03  6:37 ` [PATCH 47/71] drm/i915: Enabling rc6 and rps have different requirements, so separate them Chris Wilson
2018-05-03  6:37 ` [PATCH 48/71] drm/i915: Simplify rc6/rps enabling Chris Wilson
2018-05-03  6:37 ` [PATCH 49/71] drm/i915: Refactor frequency bounds computation Chris Wilson
2018-05-03  6:37 ` [PATCH 50/71] drm/i915: Rename rps min/max frequencies Chris Wilson
2018-05-03  6:37 ` [PATCH 51/71] drm/i915: Pull IPS into GT power management Chris Wilson
2018-05-03 10:13 ` [PATCH 01/71] drm/i915/execlists: Drop preemption arbitrations points along the ring Lionel Landwerlin
2018-05-03 10:18   ` Chris Wilson
2018-05-03 10:28     ` Lionel Landwerlin
2018-05-03 10:38       ` Chris Wilson
2018-05-03 16:37 ` 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=20180503063757.22238-15-chris@chris-wilson.co.uk \
    --to=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.