[Intel-gfx] [PATCH] RFT drm/i915: Try setting the engine wa_list from the ring

Chris Wilson chris at chris-wilson.co.uk
Sat Apr 13 07:29:12 UTC 2019


All for trying to make b118 stick.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/intel_lrc.c         |  5 ++-
 drivers/gpu/drm/i915/intel_workarounds.c | 52 +++++++++++++++++++++++-
 drivers/gpu/drm/i915/intel_workarounds.h |  2 +-
 3 files changed, 55 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index 4e0a351bfbca..ceebbb423b6e 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -1789,7 +1789,6 @@ static bool unexpected_starting_state(struct intel_engine_cs *engine)
 
 static int gen8_init_common_ring(struct intel_engine_cs *engine)
 {
-	intel_engine_apply_workarounds(engine);
 	intel_engine_apply_whitelist(engine);
 
 	intel_mocs_init_engine(engine);
@@ -2314,6 +2313,10 @@ static int gen8_init_rcs_context(struct i915_request *rq)
 {
 	int ret;
 
+	ret = intel_engine_apply_workarounds(rq);
+	if (ret)
+		return ret;
+
 	ret = intel_engine_emit_ctx_wa(rq);
 	if (ret)
 		return ret;
diff --git a/drivers/gpu/drm/i915/intel_workarounds.c b/drivers/gpu/drm/i915/intel_workarounds.c
index ccaf63679435..0b7f6fe36e37 100644
--- a/drivers/gpu/drm/i915/intel_workarounds.c
+++ b/drivers/gpu/drm/i915/intel_workarounds.c
@@ -1250,9 +1250,57 @@ void intel_engine_init_workarounds(struct intel_engine_cs *engine)
 	wa_init_finish(wal);
 }
 
-void intel_engine_apply_workarounds(struct intel_engine_cs *engine)
+static int
+wa_list_lri(struct i915_request *rq, const struct i915_wa_list *wal)
 {
-	wa_list_apply(engine->uncore, &engine->wa_list);
+	struct intel_uncore *uncore = rq->engine->uncore;
+	struct i915_wa *wa = wal->list;
+	unsigned int rem = wal->count;
+	enum forcewake_domains fw;
+	unsigned long flags;
+
+	if (!rem)
+		return 0;
+
+	fw = wal_get_fw_for_rmw(uncore, wal);
+
+	intel_uncore_forcewake_get__locked(uncore, fw);
+	spin_lock_irqsave(&uncore->lock, flags);
+
+	do {
+		unsigned int count;
+		u32 *cs;
+
+		count = min(rem, 100u);
+		rem -= count;
+
+		cs = intel_ring_begin(rq, 2 * count + 2);
+		if (IS_ERR(cs))
+			return PTR_ERR(cs);
+
+		*cs++ = MI_LOAD_REGISTER_IMM(count);
+		while (count--) {
+			u32 val = intel_uncore_read_fw(uncore, wa->reg);
+
+			*cs++ = i915_mmio_reg_offset(wa->reg);
+			*cs++ = (val & ~wa->mask) | wa->val;
+
+			wa++;
+		}
+		*cs++ = MI_NOOP;
+
+		intel_ring_advance(rq, cs);
+	} while (rem);
+
+	intel_uncore_forcewake_put__locked(uncore, fw);
+	spin_unlock_irqrestore(&uncore->lock, flags);
+
+	return 0;
+}
+
+int intel_engine_apply_workarounds(struct i915_request *rq)
+{
+	return wa_list_lri(rq, &rq->engine->wa_list);
 }
 
 #if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
diff --git a/drivers/gpu/drm/i915/intel_workarounds.h b/drivers/gpu/drm/i915/intel_workarounds.h
index 34eee5ec511e..bb6c628f0c65 100644
--- a/drivers/gpu/drm/i915/intel_workarounds.h
+++ b/drivers/gpu/drm/i915/intel_workarounds.h
@@ -29,6 +29,6 @@ void intel_engine_init_whitelist(struct intel_engine_cs *engine);
 void intel_engine_apply_whitelist(struct intel_engine_cs *engine);
 
 void intel_engine_init_workarounds(struct intel_engine_cs *engine);
-void intel_engine_apply_workarounds(struct intel_engine_cs *engine);
+int intel_engine_apply_workarounds(struct i915_request *rq);
 
 #endif
-- 
2.20.1



More information about the Intel-gfx mailing list