diff mbox

[47/50] drm/i915/bdw: Make sure gpu reset still works with Execlists

Message ID 1399637360-4277-48-git-send-email-oscar.mateo@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

oscar.mateo@intel.com May 9, 2014, 12:09 p.m. UTC
From: Oscar Mateo <oscar.mateo@intel.com>

If we reset a ring after a hang, we have to make sure that we clear
out all queued Execlists requests and that we re-program the ring for
execution. Also, reset the hangcheck counters.

Signed-off-by: Oscar Mateo <oscar.mateo@intel.com>
---
 drivers/gpu/drm/i915/i915_gem.c         | 13 +++++++++++++
 drivers/gpu/drm/i915/intel_lrc.c        | 10 +---------
 drivers/gpu/drm/i915/intel_ringbuffer.c |  8 ++++++++
 3 files changed, 22 insertions(+), 9 deletions(-)
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index e2d2edb..4f1bb46 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -2400,6 +2400,19 @@  static void i915_gem_reset_ring_cleanup(struct drm_i915_private *dev_priv,
 		i915_gem_free_request(request);
 	}
 
+	if (dev_priv->lrc_enabled) {
+		while (!list_empty(&ring->execlist_queue)) {
+			struct drm_i915_gem_request *request;
+
+			request = list_first_entry(&ring->execlist_queue,
+						   struct drm_i915_gem_request,
+						   execlist_link);
+			list_del(&request->execlist_link);
+			i915_gem_context_unreference(request->ctx);
+			kfree(request);
+		}
+	}
+
 	/* These may not have been flush before the reset, do so now */
 	kfree(ring->preallocated_lazy_request);
 	ring->preallocated_lazy_request = NULL;
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index a13a570..d9edd10 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -700,17 +700,9 @@  int gen8_gem_context_init(struct drm_device *dev)
 		goto err_out;
 	}
 
-	for_each_ring(ring, dev_priv, ring_id) {
+	for_each_ring(ring, dev_priv, ring_id)
 		ring->default_context = ctx;
 
-		I915_WRITE(RING_MODE_GEN7(ring),
-			_MASKED_BIT_DISABLE(GFX_REPLAY_MODE) |
-			_MASKED_BIT_ENABLE(GFX_RUN_LIST_ENABLE));
-		POSTING_READ(RING_MODE_GEN7(ring));
-		DRM_DEBUG_DRIVER("Execlists enabled for %s\n",
-				ring->name);
-	}
-
 	DRM_DEBUG_DRIVER("LR context support initialized\n");
 	return 0;
 
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index 94c1716..9c0deb2 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -573,6 +573,14 @@  static int init_ring_common_lrc(struct intel_engine *ring)
 	struct drm_device *dev = ring->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 
+	I915_WRITE(RING_MODE_GEN7(ring),
+		_MASKED_BIT_DISABLE(GFX_REPLAY_MODE) |
+		_MASKED_BIT_ENABLE(GFX_RUN_LIST_ENABLE));
+	POSTING_READ(RING_MODE_GEN7(ring));
+	DRM_DEBUG_DRIVER("Execlists enabled for %s\n", ring->name);
+
+	memset(&ring->hangcheck, 0, sizeof(ring->hangcheck));
+
 	I915_WRITE_IMR(ring, ~(ring->irq_enable_mask | ring->irq_keep_mask));
 	I915_WRITE(RING_HWSTAM(ring->mmio_base), 0xffffffff);