[PATCH 2/2] unicast read all

Tvrtko Ursulin tvrtko.ursulin at linux.intel.com
Mon Jul 22 12:59:03 UTC 2019


From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
---
 drivers/gpu/drm/i915/gt/intel_workarounds.c | 83 ++++++++++++++-------
 1 file changed, 56 insertions(+), 27 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/intel_workarounds.c b/drivers/gpu/drm/i915/gt/intel_workarounds.c
index 54e364c08e32..f437803c0889 100644
--- a/drivers/gpu/drm/i915/gt/intel_workarounds.c
+++ b/drivers/gpu/drm/i915/gt/intel_workarounds.c
@@ -927,31 +927,70 @@ void intel_gt_init_workarounds(struct drm_i915_private *i915)
 	wa_init_finish(wal);
 }
 
-static enum forcewake_domains
-wal_get_fw_for_rmw(struct intel_uncore *uncore, const struct i915_wa_list *wal)
+static void read_all(struct intel_uncore *uncore, i915_reg_t reg)
 {
-	enum forcewake_domains fw = 0;
-	struct i915_wa *wa;
-	unsigned int i;
+	struct drm_i915_private *i915 = uncore->i915;
+	const struct sseu_dev_info *sseu = &RUNTIME_INFO(i915)->sseu;
+	unsigned int slice, subslice;
+	u32 l3_en, mcr, mcr_mask, common, old_mcr;
 
-	for (i = 0, wa = wal->list; i < wal->count; i++, wa++)
-		fw |= intel_uncore_forcewake_for_reg(uncore,
-						     wa->reg,
-						     FW_REG_READ |
-						     FW_REG_WRITE);
+	if (!uncore)
+		return;
+
+	if (INTEL_GEN(i915) < 10)
+		return;
+
+	if (is_power_of_2(sseu->slice_mask)) {
+		u32 l3_fuse =
+			intel_uncore_read(&i915->uncore, GEN10_MIRROR_FUSE3) &
+			GEN10_L3BANK_MASK;
+
+		l3_en = ~(l3_fuse << GEN10_L3BANK_PAIR_COUNT | l3_fuse);
+	} else {
+		l3_en = ~0;
+	}
+
+	slice = ffs(sseu->slice_mask) - 1;
+	GEM_BUG_ON(slice >= ARRAY_SIZE(sseu->subslice_mask));
+	common = l3_en & sseu->subslice_mask[slice];
+	DRM_DEBUG_DRIVER("l3_en=%x ss_en=%x common=%x\n",
+			 l3_en, sseu->subslice_mask[slice], common);
+
+	old_mcr = intel_uncore_read(uncore, GEN8_MCR_SELECTOR);
+
+	for (subslice = 0; subslice < 8; subslice++) {
+		u32 val;
+
+		if (!(common & BIT(subslice)))
+			continue;
+
+		if (INTEL_GEN(i915) >= 11) {
+			mcr = GEN11_MCR_SLICE(slice) | GEN11_MCR_SUBSLICE(subslice);
+			mcr_mask = GEN11_MCR_SLICE_MASK | GEN11_MCR_SUBSLICE_MASK;
+		} else {
+			mcr = GEN8_MCR_SLICE(slice) | GEN8_MCR_SUBSLICE(subslice);
+			mcr_mask = GEN8_MCR_SLICE_MASK | GEN8_MCR_SUBSLICE_MASK;
+		}
+
+		mcr |= old_mcr & ~(BIT(31) | mcr_mask);
+		intel_uncore_write(uncore, GEN8_MCR_SELECTOR, mcr);
+		val = intel_uncore_read(uncore, reg);
+		DRM_DEBUG_DRIVER("subslice=%u reg=%x val=%x old_mcr=%x mcr=%x\n",
+				 subslice, i915_mmio_reg_offset(reg), val, old_mcr, mcr);
+	}
 
-	return fw;
+	intel_uncore_write(uncore, GEN8_MCR_SELECTOR, old_mcr);
 }
 
 static bool
-wa_verify(const struct i915_wa *wa, u32 cur, const char *name, const char *from)
+wa_verify(struct intel_uncore *uncore, const struct i915_wa *wa, u32 cur, const char *name, const char *from)
 {
 	if ((cur ^ wa->val) & wa->read) {
 		DRM_ERROR("%s workaround lost on %s! (%x=%x/%x, expected %x, mask=%x)\n",
 			  name, from, i915_mmio_reg_offset(wa->reg),
 			  cur, cur & wa->read,
 			  wa->val, wa->mask);
-
+		read_all(uncore, wa->reg);
 		return false;
 	}
 
@@ -961,29 +1000,19 @@ wa_verify(const struct i915_wa *wa, u32 cur, const char *name, const char *from)
 static void
 wa_list_apply(struct intel_uncore *uncore, const struct i915_wa_list *wal)
 {
-	enum forcewake_domains fw;
-	unsigned long flags;
 	struct i915_wa *wa;
 	unsigned int i;
 
 	if (!wal->count)
 		return;
 
-	fw = wal_get_fw_for_rmw(uncore, wal);
-
-	spin_lock_irqsave(&uncore->lock, flags);
-	intel_uncore_forcewake_get__locked(uncore, fw);
-
 	for (i = 0, wa = wal->list; i < wal->count; i++, wa++) {
-		intel_uncore_rmw_fw(uncore, wa->reg, wa->mask, wa->val);
+		intel_uncore_rmw(uncore, wa->reg, wa->mask, wa->val);
 		if (IS_ENABLED(CONFIG_DRM_I915_DEBUG_GEM))
-			wa_verify(wa,
+			wa_verify(uncore, wa,
 				  intel_uncore_read_fw(uncore, wa->reg),
 				  wal->name, "application");
 	}
-
-	intel_uncore_forcewake_put__locked(uncore, fw);
-	spin_unlock_irqrestore(&uncore->lock, flags);
 }
 
 void intel_gt_apply_workarounds(struct intel_gt *gt)
@@ -1000,7 +1029,7 @@ static bool wa_list_verify(struct intel_uncore *uncore,
 	bool ok = true;
 
 	for (i = 0, wa = wal->list; i < wal->count; i++, wa++)
-		ok &= wa_verify(wa,
+		ok &= wa_verify(uncore, wa,
 				intel_uncore_read(uncore, wa->reg),
 				wal->name, from);
 
@@ -1529,7 +1558,7 @@ static int engine_wa_list_verify(struct intel_context *ce,
 		if (mcr_range(rq->i915, i915_mmio_reg_offset(wa->reg)))
 			continue;
 
-		if (!wa_verify(wa, results[i], wal->name, from))
+		if (!wa_verify(NULL, wa, results[i], wal->name, from))
 			err = -ENXIO;
 	}
 
-- 
2.20.1



More information about the Intel-gfx-trybot mailing list