[PATCH 18/19] drm/i915/ringbuffer: Force restore of mm after failed context switch

Chris Wilson chris at chris-wilson.co.uk
Tue Jun 5 23:27:33 UTC 2018


If we interrupt the context switch and unwind, we leave the to_mm
believing that we have cleared the dirty bit for this engine (but the
LRI will never take place). Just in case we immediately reload the same
context, mark this engine as dirty so that we force the LRI to reload
the PD.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
Cc: Joonas Lahtinen <joonas.lahtinen at linux.intel.com>
Cc: Mika Kuoppala <mika.kuoppala at linux.intel.com>
Cc: Matthew Auld <matthew.william.auld at gmail.com>
---
 drivers/gpu/drm/i915/intel_ringbuffer.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index fb8d6217b03c..991187e1864a 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -1598,6 +1598,7 @@ static int switch_context(struct i915_request *rq)
 		to_gen6_ppgtt(to_ctx->ppgtt ?: rq->i915->mm.aliasing_ppgtt);
 	struct i915_gem_context *from_ctx = engine->legacy_active_context;
 	struct gen6_hw_ppgtt *from_mm = engine->legacy_active_ppgtt;
+	unsigned int unwind_mm = 0;
 	u32 hw_flags = 0;
 	int ret, i;
 
@@ -1611,8 +1612,13 @@ static int switch_context(struct i915_request *rq)
 		if (ret)
 			goto err;
 
-		to_mm->base.pd_dirty_rings &= ~intel_engine_flag(engine);
+		if (to_mm->base.pd_dirty_rings & intel_engine_flag(engine)) {
+			unwind_mm = intel_engine_flag(engine);
+			to_mm->base.pd_dirty_rings &= ~unwind_mm;
+		}
+
 		engine->legacy_active_ppgtt = to_mm;
+
 		hw_flags = MI_FORCE_RESTORE;
 	}
 
@@ -1655,6 +1661,8 @@ static int switch_context(struct i915_request *rq)
 err_ctx:
 	engine->legacy_active_context = from_ctx;
 err_mm:
+	if (unwind_mm)
+		to_mm->base.pd_dirty_rings |= unwind_mm;
 	engine->legacy_active_ppgtt = from_mm;
 err:
 	return ret;
-- 
2.17.1



More information about the Intel-gfx-trybot mailing list