All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] drm/i915/selftests: Verify the LRC register layout between init and HW
@ 2019-09-23 23:02 Chris Wilson
  2019-09-23 23:02 ` [PATCH 2/2] drm/i915/tgl: Swap engines for rps (gpu reclocking) Chris Wilson
                   ` (11 more replies)
  0 siblings, 12 replies; 22+ messages in thread
From: Chris Wilson @ 2019-09-23 23:02 UTC (permalink / raw)
  To: intel-gfx

Before we submit the first context to HW, we need to construct a valid
image of the register state. This layout is defined by the HW and should
match the layout generated by HW when it saves the context image.
Asserting that this should be equivalent should help avoid any undefined
behaviour and verify that we haven't missed anything important!

Of course, having insisted that the initial register state within the
LRC should match that returned by HW, we need to ensure that it does.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
---
 drivers/gpu/drm/i915/gem/i915_gem_context.c   |   2 +-
 drivers/gpu/drm/i915/gt/intel_lrc.c           | 669 ++++++++++++------
 drivers/gpu/drm/i915/gt/intel_lrc_reg.h       |  62 +-
 drivers/gpu/drm/i915/gt/selftest_lrc.c        | 142 ++++
 drivers/gpu/drm/i915/i915_perf.c              |  35 +-
 drivers/gpu/drm/i915/i915_perf.h              |   5 +-
 .../drm/i915/selftests/i915_live_selftests.h  |   1 +
 7 files changed, 649 insertions(+), 267 deletions(-)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c
index 4a34c4f62065..f7ba0935ed67 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
@@ -1115,7 +1115,7 @@ static int gen8_emit_rpcs_config(struct i915_request *rq,
 
 	offset = i915_ggtt_offset(ce->state) +
 		 LRC_STATE_PN * PAGE_SIZE +
-		 (CTX_R_PWR_CLK_STATE + 1) * 4;
+		 CTX_R_PWR_CLK_STATE * 4;
 
 	*cs++ = MI_STORE_DWORD_IMM_GEN4 | MI_USE_GGTT;
 	*cs++ = lower_32_bits(offset);
diff --git a/drivers/gpu/drm/i915/gt/intel_lrc.c b/drivers/gpu/drm/i915/gt/intel_lrc.c
index 6cfdc0f9f2b9..c2c3e574af3a 100644
--- a/drivers/gpu/drm/i915/gt/intel_lrc.c
+++ b/drivers/gpu/drm/i915/gt/intel_lrc.c
@@ -230,9 +230,10 @@ static int __execlists_context_alloc(struct intel_context *ce,
 				     struct intel_engine_cs *engine);
 
 static void execlists_init_reg_state(u32 *reg_state,
-				     struct intel_context *ce,
-				     struct intel_engine_cs *engine,
-				     struct intel_ring *ring);
+				     const struct intel_context *ce,
+				     const struct intel_engine_cs *engine,
+				     const struct intel_ring *ring,
+				     bool close);
 
 static void mark_eio(struct i915_request *rq)
 {
@@ -471,6 +472,411 @@ lrc_descriptor(struct intel_context *ce, struct intel_engine_cs *engine)
 	return desc;
 }
 
+static u32 *set_offsets(u32 *regs,
+			const u8 *data,
+			const struct intel_engine_cs *engine)
+#define NOP(x) (BIT(7) | (x))
+#define LRI(count, flags) ((flags) << 6 | (count))
+#define POSTED BIT(0)
+#define REG(x) (((x) >> 2) | BUILD_BUG_ON_ZERO(x >= 0x200))
+#define REG16(x) \
+	(((x) >> 9) | BIT(7) | BUILD_BUG_ON_ZERO(x >= 0x10000)), \
+	(((x) >> 2) & 0x7f)
+#define END() 0
+{
+	const u32 base = engine->mmio_base;
+
+	while (*data) {
+		u8 count, flags;
+
+		if (*data & BIT(7)) { /* skip */
+			regs += *data++ & ~BIT(7);
+			continue;
+		}
+
+		count = *data & 0x3f;
+		flags = *data >> 6;
+		data++;
+
+		*regs = MI_LOAD_REGISTER_IMM(count);
+		if (flags & POSTED)
+			*regs |= MI_LRI_FORCE_POSTED;
+		if (INTEL_GEN(engine->i915) >= 11)
+			*regs |= MI_LRI_CS_MMIO;
+		regs++;
+
+		GEM_BUG_ON(!count);
+		do {
+			u32 offset = 0;
+			u8 v;
+
+			do {
+				v = *data++;
+				offset <<= 7;
+				offset |= v & ~BIT(7);
+			} while (v & BIT(7));
+
+			*regs = base + (offset << 2);
+			regs += 2;
+		} while (--count);
+	}
+
+	return regs;
+}
+
+static const u8 gen8_xcs_offsets[] = {
+	NOP(1),
+	LRI(11, 0),
+	REG16(0x244),
+	REG(0x034),
+	REG(0x030),
+	REG(0x038),
+	REG(0x03c),
+	REG(0x168),
+	REG(0x140),
+	REG(0x110),
+	REG(0x11c),
+	REG(0x114),
+	REG(0x118),
+
+	NOP(9),
+	LRI(9, 0),
+	REG16(0x3a8),
+	REG16(0x28c),
+	REG16(0x288),
+	REG16(0x284),
+	REG16(0x280),
+	REG16(0x27c),
+	REG16(0x278),
+	REG16(0x274),
+	REG16(0x270),
+
+	NOP(13),
+	LRI(2, 0),
+	REG16(0x200),
+	REG(0x028),
+
+	END(),
+};
+
+static const u8 gen9_xcs_offsets[] = {
+	NOP(1),
+	LRI(14, POSTED),
+	REG16(0x244),
+	REG(0x034),
+	REG(0x030),
+	REG(0x038),
+	REG(0x03c),
+	REG(0x168),
+	REG(0x140),
+	REG(0x110),
+	REG(0x11c),
+	REG(0x114),
+	REG(0x118),
+	REG(0x1c0),
+	REG(0x1c4),
+	REG(0x1c8),
+
+	NOP(3),
+	LRI(9, POSTED),
+	REG16(0x3a8),
+	REG16(0x28c),
+	REG16(0x288),
+	REG16(0x284),
+	REG16(0x280),
+	REG16(0x27c),
+	REG16(0x278),
+	REG16(0x274),
+	REG16(0x270),
+
+	NOP(13),
+	LRI(1, POSTED),
+	REG16(0x200),
+
+	NOP(13),
+	LRI(44, POSTED),
+	REG(0x028),
+	REG(0x09c),
+	REG(0x0c0),
+	REG(0x178),
+	REG(0x17c),
+	REG16(0x358),
+	REG(0x170),
+	REG(0x150),
+	REG(0x154),
+	REG(0x158),
+	REG16(0x41c),
+	REG16(0x600),
+	REG16(0x604),
+	REG16(0x608),
+	REG16(0x60c),
+	REG16(0x610),
+	REG16(0x614),
+	REG16(0x618),
+	REG16(0x61c),
+	REG16(0x620),
+	REG16(0x624),
+	REG16(0x628),
+	REG16(0x62c),
+	REG16(0x630),
+	REG16(0x634),
+	REG16(0x638),
+	REG16(0x63c),
+	REG16(0x640),
+	REG16(0x644),
+	REG16(0x648),
+	REG16(0x64c),
+	REG16(0x650),
+	REG16(0x654),
+	REG16(0x658),
+	REG16(0x65c),
+	REG16(0x660),
+	REG16(0x664),
+	REG16(0x668),
+	REG16(0x66c),
+	REG16(0x670),
+	REG16(0x674),
+	REG16(0x678),
+	REG16(0x67c),
+	REG(0x068),
+
+	END(),
+};
+
+static const u8 gen12_xcs_offsets[] = {
+	NOP(1),
+	LRI(13, POSTED),
+	REG16(0x244),
+	REG(0x034),
+	REG(0x030),
+	REG(0x038),
+	REG(0x03c),
+	REG(0x168),
+	REG(0x140),
+	REG(0x110),
+	REG(0x1c0),
+	REG(0x1c4),
+	REG(0x1c8),
+	REG(0x180),
+	REG16(0x2b4),
+
+	NOP(5),
+	LRI(9, POSTED),
+	REG16(0x3a8),
+	REG16(0x28c),
+	REG16(0x288),
+	REG16(0x284),
+	REG16(0x280),
+	REG16(0x27c),
+	REG16(0x278),
+	REG16(0x274),
+	REG16(0x270),
+
+	NOP(13),
+	LRI(2, POSTED),
+	REG16(0x200),
+	REG16(0x204),
+
+	NOP(11),
+	LRI(50, POSTED),
+	REG16(0x588),
+	REG16(0x588),
+	REG16(0x588),
+	REG16(0x588),
+	REG16(0x588),
+	REG16(0x588),
+	REG(0x028),
+	REG(0x09c),
+	REG(0x0c0),
+	REG(0x178),
+	REG(0x17c),
+	REG16(0x358),
+	REG(0x170),
+	REG(0x150),
+	REG(0x154),
+	REG(0x158),
+	REG16(0x41c),
+	REG16(0x600),
+	REG16(0x604),
+	REG16(0x608),
+	REG16(0x60c),
+	REG16(0x610),
+	REG16(0x614),
+	REG16(0x618),
+	REG16(0x61c),
+	REG16(0x620),
+	REG16(0x624),
+	REG16(0x628),
+	REG16(0x62c),
+	REG16(0x630),
+	REG16(0x634),
+	REG16(0x638),
+	REG16(0x63c),
+	REG16(0x640),
+	REG16(0x644),
+	REG16(0x648),
+	REG16(0x64c),
+	REG16(0x650),
+	REG16(0x654),
+	REG16(0x658),
+	REG16(0x65c),
+	REG16(0x660),
+	REG16(0x664),
+	REG16(0x668),
+	REG16(0x66c),
+	REG16(0x670),
+	REG16(0x674),
+	REG16(0x678),
+	REG16(0x67c),
+	REG(0x068),
+
+	END(),
+};
+
+static const u8 gen8_rcs_offsets[] = {
+	NOP(1),
+	LRI(14, POSTED),
+	REG16(0x244),
+	REG(0x034),
+	REG(0x030),
+	REG(0x038),
+	REG(0x03c),
+	REG(0x168),
+	REG(0x140),
+	REG(0x110),
+	REG(0x11c),
+	REG(0x114),
+	REG(0x118),
+	REG(0x1c0),
+	REG(0x1c4),
+	REG(0x1c8),
+
+	NOP(3),
+	LRI(9, POSTED),
+	REG16(0x3a8),
+	REG16(0x28c),
+	REG16(0x288),
+	REG16(0x284),
+	REG16(0x280),
+	REG16(0x27c),
+	REG16(0x278),
+	REG16(0x274),
+	REG16(0x270),
+
+	NOP(13),
+	LRI(1, 0),
+	REG(0x0c8),
+
+	END(),
+};
+
+static const u8 gen11_rcs_offsets[] = {
+	NOP(1),
+	LRI(15, POSTED),
+	REG16(0x244),
+	REG(0x034),
+	REG(0x030),
+	REG(0x038),
+	REG(0x03c),
+	REG(0x168),
+	REG(0x140),
+	REG(0x110),
+	REG(0x11c),
+	REG(0x114),
+	REG(0x118),
+	REG(0x1c0),
+	REG(0x1c4),
+	REG(0x1c8),
+	REG(0x180),
+
+	NOP(1),
+	LRI(9, POSTED),
+	REG16(0x3a8),
+	REG16(0x28c),
+	REG16(0x288),
+	REG16(0x284),
+	REG16(0x280),
+	REG16(0x27c),
+	REG16(0x278),
+	REG16(0x274),
+	REG16(0x270),
+
+	LRI(1, POSTED),
+	REG(0x1b0),
+
+	NOP(10),
+	LRI(1, 0),
+	REG(0x0c8),
+
+	END(),
+};
+
+static const u8 gen12_rcs_offsets[] = {
+	NOP(1),
+	LRI(13, POSTED),
+	REG16(0x244),
+	REG(0x034),
+	REG(0x030),
+	REG(0x038),
+	REG(0x03c),
+	REG(0x168),
+	REG(0x140),
+	REG(0x110),
+	REG(0x1c0),
+	REG(0x1c4),
+	REG(0x1c8),
+	REG(0x180),
+	REG16(0x2b4),
+
+	NOP(5),
+	LRI(9, POSTED),
+	REG16(0x3a8),
+	REG16(0x28c),
+	REG16(0x288),
+	REG16(0x284),
+	REG16(0x280),
+	REG16(0x27c),
+	REG16(0x278),
+	REG16(0x274),
+	REG16(0x270),
+
+	LRI(3, POSTED),
+	REG(0x1b0),
+	REG16(0x5a8),
+	REG16(0x5ac),
+
+	NOP(6),
+	LRI(1, 0),
+	REG(0x0c8),
+
+	END(),
+};
+
+#undef END
+#undef REG16
+#undef REG
+#undef LRI
+#undef NOP
+
+static const u8 *reg_offsets(const struct intel_engine_cs *engine)
+{
+	if (engine->class == RENDER_CLASS) {
+		if (INTEL_GEN(engine->i915) >= 12)
+			return gen12_rcs_offsets;
+		else if (INTEL_GEN(engine->i915) >= 11)
+			return gen11_rcs_offsets;
+		else
+			return gen8_rcs_offsets;
+	} else {
+		if (INTEL_GEN(engine->i915) >= 12)
+			return gen12_xcs_offsets;
+		else if (INTEL_GEN(engine->i915) >= 9)
+			return gen9_xcs_offsets;
+		else
+			return gen8_xcs_offsets;
+	}
+}
+
 static void unwind_wa_tail(struct i915_request *rq)
 {
 	rq->tail = intel_ring_wrap(rq->ring, rq->wa_tail - WA_TAIL_BYTES);
@@ -654,7 +1060,7 @@ static u64 execlists_update_context(const struct i915_request *rq)
 	struct intel_context *ce = rq->hw_context;
 	u64 desc;
 
-	ce->lrc_reg_state[CTX_RING_TAIL + 1] =
+	ce->lrc_reg_state[CTX_RING_TAIL] =
 		intel_ring_set_tail(rq->ring, rq->tail);
 
 	/*
@@ -826,54 +1232,7 @@ static bool can_merge_rq(const struct i915_request *prev,
 static void virtual_update_register_offsets(u32 *regs,
 					    struct intel_engine_cs *engine)
 {
-	u32 base = engine->mmio_base;
-
-	/* Refactor so that we only have one place that knows all the offsets! */
-	GEM_WARN_ON(INTEL_GEN(engine->i915) >= 12);
-
-	/* Must match execlists_init_reg_state()! */
-
-	/* Common part */
-	regs[CTX_CONTEXT_CONTROL] =
-		i915_mmio_reg_offset(RING_CONTEXT_CONTROL(base));
-	regs[CTX_RING_HEAD] = i915_mmio_reg_offset(RING_HEAD(base));
-	regs[CTX_RING_TAIL] = i915_mmio_reg_offset(RING_TAIL(base));
-	regs[CTX_RING_BUFFER_START] = i915_mmio_reg_offset(RING_START(base));
-	regs[CTX_RING_BUFFER_CONTROL] = i915_mmio_reg_offset(RING_CTL(base));
-
-	regs[CTX_BB_HEAD_U] = i915_mmio_reg_offset(RING_BBADDR_UDW(base));
-	regs[CTX_BB_HEAD_L] = i915_mmio_reg_offset(RING_BBADDR(base));
-	regs[CTX_BB_STATE] = i915_mmio_reg_offset(RING_BBSTATE(base));
-
-	regs[CTX_SECOND_BB_HEAD_U] =
-		i915_mmio_reg_offset(RING_SBBADDR_UDW(base));
-	regs[CTX_SECOND_BB_HEAD_L] = i915_mmio_reg_offset(RING_SBBADDR(base));
-	regs[CTX_SECOND_BB_STATE] = i915_mmio_reg_offset(RING_SBBSTATE(base));
-
-	/* PPGTT part */
-	regs[CTX_CTX_TIMESTAMP] =
-		i915_mmio_reg_offset(RING_CTX_TIMESTAMP(base));
-
-	regs[CTX_PDP3_UDW] = i915_mmio_reg_offset(GEN8_RING_PDP_UDW(base, 3));
-	regs[CTX_PDP3_LDW] = i915_mmio_reg_offset(GEN8_RING_PDP_LDW(base, 3));
-	regs[CTX_PDP2_UDW] = i915_mmio_reg_offset(GEN8_RING_PDP_UDW(base, 2));
-	regs[CTX_PDP2_LDW] = i915_mmio_reg_offset(GEN8_RING_PDP_LDW(base, 2));
-	regs[CTX_PDP1_UDW] = i915_mmio_reg_offset(GEN8_RING_PDP_UDW(base, 1));
-	regs[CTX_PDP1_LDW] = i915_mmio_reg_offset(GEN8_RING_PDP_LDW(base, 1));
-	regs[CTX_PDP0_UDW] = i915_mmio_reg_offset(GEN8_RING_PDP_UDW(base, 0));
-	regs[CTX_PDP0_LDW] = i915_mmio_reg_offset(GEN8_RING_PDP_LDW(base, 0));
-
-	if (engine->class == RENDER_CLASS) {
-		regs[CTX_RCS_INDIRECT_CTX] =
-			i915_mmio_reg_offset(RING_INDIRECT_CTX(base));
-		regs[CTX_RCS_INDIRECT_CTX_OFFSET] =
-			i915_mmio_reg_offset(RING_INDIRECT_CTX_OFFSET(base));
-		regs[CTX_BB_PER_CTX_PTR] =
-			i915_mmio_reg_offset(RING_BB_PER_CTX_PTR(base));
-
-		regs[CTX_R_PWR_CLK_STATE] =
-			i915_mmio_reg_offset(GEN8_R_PWR_CLK_STATE);
-	}
+	set_offsets(regs, reg_offsets(engine), engine);
 }
 
 static bool virtual_matches(const struct virtual_engine *ve,
@@ -1738,8 +2097,8 @@ static void execlists_context_unpin(struct intel_context *ce)
 }
 
 static void
-__execlists_update_reg_state(struct intel_context *ce,
-			     struct intel_engine_cs *engine)
+__execlists_update_reg_state(const struct intel_context *ce,
+			     const struct intel_engine_cs *engine)
 {
 	struct intel_ring *ring = ce->ring;
 	u32 *regs = ce->lrc_reg_state;
@@ -1747,16 +2106,16 @@ __execlists_update_reg_state(struct intel_context *ce,
 	GEM_BUG_ON(!intel_ring_offset_valid(ring, ring->head));
 	GEM_BUG_ON(!intel_ring_offset_valid(ring, ring->tail));
 
-	regs[CTX_RING_BUFFER_START + 1] = i915_ggtt_offset(ring->vma);
-	regs[CTX_RING_HEAD + 1] = ring->head;
-	regs[CTX_RING_TAIL + 1] = ring->tail;
+	regs[CTX_RING_BUFFER_START] = i915_ggtt_offset(ring->vma);
+	regs[CTX_RING_HEAD] = ring->head;
+	regs[CTX_RING_TAIL] = ring->tail;
 
 	/* RPCS */
 	if (engine->class == RENDER_CLASS) {
-		regs[CTX_R_PWR_CLK_STATE + 1] =
+		regs[CTX_R_PWR_CLK_STATE] =
 			intel_sseu_make_rpcs(engine->i915, &ce->sseu);
 
-		i915_oa_init_reg_state(engine, ce, regs);
+		i915_oa_init_reg_state(ce, engine);
 	}
 }
 
@@ -2465,7 +2824,7 @@ static void __execlists_reset(struct intel_engine_cs *engine, bool stalled)
 		       engine->pinned_default_state + LRC_STATE_PN * PAGE_SIZE,
 		       engine->context_size - PAGE_SIZE);
 	}
-	execlists_init_reg_state(regs, ce, engine, ce->ring);
+	execlists_init_reg_state(regs, ce, engine, ce->ring, false);
 
 out_replay:
 	GEM_TRACE("%s replay {head:%04x, tail:%04x\n",
@@ -3092,7 +3451,7 @@ void intel_execlists_set_default_submission(struct intel_engine_cs *engine)
 			engine->flags |= I915_ENGINE_HAS_PREEMPTION;
 	}
 
-	if (engine->class != COPY_ENGINE_CLASS && INTEL_GEN(engine->i915) >= 12)
+	if (engine->class != COPY_ENGINE_CLASS && INTEL_GEN(engine->i915) >= 11)
 		engine->flags |= I915_ENGINE_HAS_RELATIVE_MMIO;
 }
 
@@ -3243,7 +3602,7 @@ int intel_execlists_submission_init(struct intel_engine_cs *engine)
 	return 0;
 }
 
-static u32 intel_lr_indirect_ctx_offset(struct intel_engine_cs *engine)
+static u32 intel_lr_indirect_ctx_offset(const struct intel_engine_cs *engine)
 {
 	u32 indirect_ctx_offset;
 
@@ -3278,75 +3637,48 @@ static u32 intel_lr_indirect_ctx_offset(struct intel_engine_cs *engine)
 
 
 static void init_common_reg_state(u32 * const regs,
-				  struct i915_ppgtt * const ppgtt,
-				  struct intel_engine_cs *engine,
-				  struct intel_ring *ring)
+				  const struct intel_engine_cs *engine,
+				  const struct intel_ring *ring)
 {
-	const u32 base = engine->mmio_base;
-
-	CTX_REG(regs, CTX_CONTEXT_CONTROL, RING_CONTEXT_CONTROL(base),
+	regs[CTX_CONTEXT_CONTROL] =
 		_MASKED_BIT_DISABLE(CTX_CTRL_ENGINE_CTX_RESTORE_INHIBIT) |
-		_MASKED_BIT_ENABLE(CTX_CTRL_INHIBIT_SYN_CTX_SWITCH));
-	if (INTEL_GEN(engine->i915) < 11) {
-		regs[CTX_CONTEXT_CONTROL + 1] |=
+		_MASKED_BIT_ENABLE(CTX_CTRL_INHIBIT_SYN_CTX_SWITCH);
+	if (INTEL_GEN(engine->i915) < 11)
+		regs[CTX_CONTEXT_CONTROL] |=
 			_MASKED_BIT_DISABLE(CTX_CTRL_ENGINE_CTX_SAVE_INHIBIT |
 					    CTX_CTRL_RS_CTX_ENABLE);
-	}
-	CTX_REG(regs, CTX_RING_HEAD, RING_HEAD(base), 0);
-	CTX_REG(regs, CTX_RING_TAIL, RING_TAIL(base), 0);
-	CTX_REG(regs, CTX_RING_BUFFER_START, RING_START(base), 0);
-	CTX_REG(regs, CTX_RING_BUFFER_CONTROL, RING_CTL(base),
-		RING_CTL_SIZE(ring->size) | RING_VALID);
-	CTX_REG(regs, CTX_BB_HEAD_U, RING_BBADDR_UDW(base), 0);
-	CTX_REG(regs, CTX_BB_HEAD_L, RING_BBADDR(base), 0);
-	CTX_REG(regs, CTX_BB_STATE, RING_BBSTATE(base), RING_BB_PPGTT);
+
+	regs[CTX_RING_BUFFER_CONTROL] = RING_CTL_SIZE(ring->size) | RING_VALID;
+	regs[CTX_BB_STATE] = RING_BB_PPGTT;
 }
 
 static void init_wa_bb_reg_state(u32 * const regs,
-				 struct intel_engine_cs *engine,
+				 const struct intel_engine_cs *engine,
 				 u32 pos_bb_per_ctx)
 {
-	struct i915_ctx_workarounds * const wa_ctx = &engine->wa_ctx;
-	const u32 base = engine->mmio_base;
-	const u32 pos_indirect_ctx = pos_bb_per_ctx + 2;
-	const u32 pos_indirect_ctx_offset = pos_indirect_ctx + 2;
+	const struct i915_ctx_workarounds * const wa_ctx = &engine->wa_ctx;
+
+	if (wa_ctx->per_ctx.size) {
+		const u32 ggtt_offset = i915_ggtt_offset(wa_ctx->vma);
+
+		regs[pos_bb_per_ctx] =
+			(ggtt_offset + wa_ctx->per_ctx.offset) | 0x01;
+	}
 
-	CTX_REG(regs, pos_indirect_ctx, RING_INDIRECT_CTX(base), 0);
-	CTX_REG(regs, pos_indirect_ctx_offset,
-		RING_INDIRECT_CTX_OFFSET(base), 0);
 	if (wa_ctx->indirect_ctx.size) {
 		const u32 ggtt_offset = i915_ggtt_offset(wa_ctx->vma);
 
-		regs[pos_indirect_ctx + 1] =
+		regs[pos_bb_per_ctx + 2] =
 			(ggtt_offset + wa_ctx->indirect_ctx.offset) |
 			(wa_ctx->indirect_ctx.size / CACHELINE_BYTES);
 
-		regs[pos_indirect_ctx_offset + 1] =
+		regs[pos_bb_per_ctx + 4] =
 			intel_lr_indirect_ctx_offset(engine) << 6;
 	}
-
-	CTX_REG(regs, pos_bb_per_ctx, RING_BB_PER_CTX_PTR(base), 0);
-	if (wa_ctx->per_ctx.size) {
-		const u32 ggtt_offset = i915_ggtt_offset(wa_ctx->vma);
-
-		regs[pos_bb_per_ctx + 1] =
-			(ggtt_offset + wa_ctx->per_ctx.offset) | 0x01;
-	}
 }
 
-static void init_ppgtt_reg_state(u32 *regs, u32 base,
-				 struct i915_ppgtt *ppgtt)
+static void init_ppgtt_reg_state(u32 *regs, const struct i915_ppgtt *ppgtt)
 {
-	/* PDP values well be assigned later if needed */
-	CTX_REG(regs, CTX_PDP3_UDW, GEN8_RING_PDP_UDW(base, 3), 0);
-	CTX_REG(regs, CTX_PDP3_LDW, GEN8_RING_PDP_LDW(base, 3), 0);
-	CTX_REG(regs, CTX_PDP2_UDW, GEN8_RING_PDP_UDW(base, 2), 0);
-	CTX_REG(regs, CTX_PDP2_LDW, GEN8_RING_PDP_LDW(base, 2), 0);
-	CTX_REG(regs, CTX_PDP1_UDW, GEN8_RING_PDP_UDW(base, 1), 0);
-	CTX_REG(regs, CTX_PDP1_LDW, GEN8_RING_PDP_LDW(base, 1), 0);
-	CTX_REG(regs, CTX_PDP0_UDW, GEN8_RING_PDP_UDW(base, 0), 0);
-	CTX_REG(regs, CTX_PDP0_LDW, GEN8_RING_PDP_LDW(base, 0), 0);
-
 	if (i915_vm_is_4lvl(&ppgtt->vm)) {
 		/* 64b PPGTT (48bit canonical)
 		 * PDP0_DESCRIPTOR contains the base address to PML4 and
@@ -3369,91 +3701,11 @@ static struct i915_ppgtt *vm_alias(struct i915_address_space *vm)
 		return i915_vm_to_ppgtt(vm);
 }
 
-static void gen8_init_reg_state(u32 * const regs,
-				struct intel_context *ce,
-				struct intel_engine_cs *engine,
-				struct intel_ring *ring)
-{
-	struct i915_ppgtt * const ppgtt = vm_alias(ce->vm);
-	const bool rcs = engine->class == RENDER_CLASS;
-	const u32 base = engine->mmio_base;
-	const u32 lri_base =
-		intel_engine_has_relative_mmio(engine) ? MI_LRI_CS_MMIO : 0;
-
-	regs[CTX_LRI_HEADER_0] =
-		MI_LOAD_REGISTER_IMM(rcs ? 14 : 11) |
-		MI_LRI_FORCE_POSTED |
-		lri_base;
-
-	init_common_reg_state(regs, ppgtt, engine, ring);
-	CTX_REG(regs, CTX_SECOND_BB_HEAD_U, RING_SBBADDR_UDW(base), 0);
-	CTX_REG(regs, CTX_SECOND_BB_HEAD_L, RING_SBBADDR(base), 0);
-	CTX_REG(regs, CTX_SECOND_BB_STATE, RING_SBBSTATE(base), 0);
-	if (rcs)
-		init_wa_bb_reg_state(regs, engine, CTX_BB_PER_CTX_PTR);
-
-	regs[CTX_LRI_HEADER_1] =
-		MI_LOAD_REGISTER_IMM(9) |
-		MI_LRI_FORCE_POSTED |
-		lri_base;
-
-	CTX_REG(regs, CTX_CTX_TIMESTAMP, RING_CTX_TIMESTAMP(base), 0);
-
-	init_ppgtt_reg_state(regs, base, ppgtt);
-
-	if (rcs) {
-		regs[CTX_LRI_HEADER_2] = MI_LOAD_REGISTER_IMM(1) | lri_base;
-		CTX_REG(regs, CTX_R_PWR_CLK_STATE, GEN8_R_PWR_CLK_STATE, 0);
-	}
-
-	regs[CTX_END] = MI_BATCH_BUFFER_END;
-	if (INTEL_GEN(engine->i915) >= 10)
-		regs[CTX_END] |= BIT(0);
-}
-
-static void gen12_init_reg_state(u32 * const regs,
-				 struct intel_context *ce,
-				 struct intel_engine_cs *engine,
-				 struct intel_ring *ring)
-{
-	struct i915_ppgtt * const ppgtt = i915_vm_to_ppgtt(ce->vm);
-	const bool rcs = engine->class == RENDER_CLASS;
-	const u32 base = engine->mmio_base;
-	const u32 lri_base =
-		intel_engine_has_relative_mmio(engine) ? MI_LRI_CS_MMIO : 0;
-
-	regs[CTX_LRI_HEADER_0] =
-		MI_LOAD_REGISTER_IMM(rcs ? 11 : 9) |
-		MI_LRI_FORCE_POSTED |
-		lri_base;
-
-	init_common_reg_state(regs, ppgtt, engine, ring);
-
-	/* We want ctx_ptr for all engines to be set */
-	init_wa_bb_reg_state(regs, engine, GEN12_CTX_BB_PER_CTX_PTR);
-
-	regs[CTX_LRI_HEADER_1] =
-		MI_LOAD_REGISTER_IMM(9) |
-		MI_LRI_FORCE_POSTED |
-		lri_base;
-
-	CTX_REG(regs, CTX_CTX_TIMESTAMP, RING_CTX_TIMESTAMP(base), 0);
-
-	init_ppgtt_reg_state(regs, base, ppgtt);
-
-	if (rcs) {
-		regs[GEN12_CTX_LRI_HEADER_3] =
-			MI_LOAD_REGISTER_IMM(1) | lri_base;
-		CTX_REG(regs, CTX_R_PWR_CLK_STATE, GEN8_R_PWR_CLK_STATE, 0);
-
-		/* TODO: oa_init_reg_state ? */
-	}
-}
-
 static void execlists_init_reg_state(u32 *regs,
-				     struct intel_context *ce,
-				     struct intel_engine_cs *engine,
-				     struct intel_ring *ring)
+				     const struct intel_context *ce,
+				     const struct intel_engine_cs *engine,
+				     const struct intel_ring *ring,
+				     bool close)
 {
 	/*
 	 * A context is actually a big batch buffer with several
@@ -3465,10 +3717,21 @@ static void execlists_init_reg_state(u32 *regs,
 	 *
 	 * Must keep consistent with virtual_update_register_offsets().
 	 */
-	if (INTEL_GEN(engine->i915) >= 12)
-		gen12_init_reg_state(regs, ce, engine, ring);
-	else
-		gen8_init_reg_state(regs, ce, engine, ring);
+	u32 *bbe = set_offsets(regs, reg_offsets(engine), engine);
+
+	if (close) { /* Close the batch; used mainly by live_lrc_layout() */
+		*bbe = MI_BATCH_BUFFER_END;
+		if (INTEL_GEN(engine->i915) >= 10)
+			*bbe |= BIT(0);
+	}
+
+	init_common_reg_state(regs, engine, ring);
+	init_ppgtt_reg_state(regs, vm_alias(ce->vm));
+
+	init_wa_bb_reg_state(regs, engine,
+			     INTEL_GEN(engine->i915) >= 12 ?
+			     GEN12_CTX_BB_PER_CTX_PTR :
+			     CTX_BB_PER_CTX_PTR);
 }
 
 static int
@@ -3477,6 +3740,7 @@ populate_lr_context(struct intel_context *ce,
 		    struct intel_engine_cs *engine,
 		    struct intel_ring *ring)
 {
+	bool inhibit = true;
 	void *vaddr;
 	u32 *regs;
 	int ret;
@@ -3508,14 +3772,15 @@ populate_lr_context(struct intel_context *ce,
 
 		memcpy(vaddr + start, defaults + start, engine->context_size);
 		i915_gem_object_unpin_map(engine->default_state);
+		inhibit = false;
 	}
 
 	/* The second page of the context object contains some fields which must
 	 * be set up prior to the first execution. */
 	regs = vaddr + LRC_STATE_PN * PAGE_SIZE;
-	execlists_init_reg_state(regs, ce, engine, ring);
-	if (!engine->default_state)
-		regs[CTX_CONTEXT_CONTROL + 1] |=
+	execlists_init_reg_state(regs, ce, engine, ring, inhibit);
+	if (inhibit)
+		regs[CTX_CONTEXT_CONTROL] |=
 			_MASKED_BIT_ENABLE(CTX_CTRL_ENGINE_CTX_RESTORE_INHIBIT);
 
 	ret = 0;
@@ -4212,7 +4477,7 @@ void intel_lr_context_reset(struct intel_engine_cs *engine,
 			       engine->pinned_default_state + LRC_STATE_PN * PAGE_SIZE,
 			       engine->context_size - PAGE_SIZE);
 		}
-		execlists_init_reg_state(regs, ce, engine, ce->ring);
+		execlists_init_reg_state(regs, ce, engine, ce->ring, false);
 	}
 
 	/* Rerun the request; its payload has been neutered (if guilty). */
diff --git a/drivers/gpu/drm/i915/gt/intel_lrc_reg.h b/drivers/gpu/drm/i915/gt/intel_lrc_reg.h
index 7e773e74a3fe..06ab0276e10e 100644
--- a/drivers/gpu/drm/i915/gt/intel_lrc_reg.h
+++ b/drivers/gpu/drm/i915/gt/intel_lrc_reg.h
@@ -10,60 +10,40 @@
 #include <linux/types.h>
 
 /* GEN8 to GEN11 Reg State Context */
-#define CTX_LRI_HEADER_0		0x01
-#define CTX_CONTEXT_CONTROL		0x02
-#define CTX_RING_HEAD			0x04
-#define CTX_RING_TAIL			0x06
-#define CTX_RING_BUFFER_START		0x08
-#define CTX_RING_BUFFER_CONTROL		0x0a
-#define CTX_BB_HEAD_U			0x0c
-#define CTX_BB_HEAD_L			0x0e
-#define CTX_BB_STATE			0x10
-#define CTX_SECOND_BB_HEAD_U		0x12
-#define CTX_SECOND_BB_HEAD_L		0x14
-#define CTX_SECOND_BB_STATE		0x16
-#define CTX_BB_PER_CTX_PTR		0x18
-#define CTX_RCS_INDIRECT_CTX		0x1a
-#define CTX_RCS_INDIRECT_CTX_OFFSET	0x1c
-#define CTX_LRI_HEADER_1		0x21
-#define CTX_CTX_TIMESTAMP		0x22
-#define CTX_PDP3_UDW			0x24
-#define CTX_PDP3_LDW			0x26
-#define CTX_PDP2_UDW			0x28
-#define CTX_PDP2_LDW			0x2a
-#define CTX_PDP1_UDW			0x2c
-#define CTX_PDP1_LDW			0x2e
-#define CTX_PDP0_UDW			0x30
-#define CTX_PDP0_LDW			0x32
-#define CTX_LRI_HEADER_2		0x41
-#define CTX_R_PWR_CLK_STATE		0x42
-#define CTX_END				0x44
+#define CTX_CONTEXT_CONTROL		(0x02 + 1)
+#define CTX_RING_HEAD			(0x04 + 1)
+#define CTX_RING_TAIL			(0x06 + 1)
+#define CTX_RING_BUFFER_START		(0x08 + 1)
+#define CTX_RING_BUFFER_CONTROL		(0x0a + 1)
+#define CTX_BB_STATE			(0x10 + 1)
+#define CTX_BB_PER_CTX_PTR		(0x18 + 1)
+#define CTX_PDP3_UDW			(0x24 + 1)
+#define CTX_PDP3_LDW			(0x26 + 1)
+#define CTX_PDP2_UDW			(0x28 + 1)
+#define CTX_PDP2_LDW			(0x2a + 1)
+#define CTX_PDP1_UDW			(0x2c + 1)
+#define CTX_PDP1_LDW			(0x2e + 1)
+#define CTX_PDP0_UDW			(0x30 + 1)
+#define CTX_PDP0_LDW			(0x32 + 1)
+#define CTX_R_PWR_CLK_STATE		(0x42 + 1)
 
 #define GEN9_CTX_RING_MI_MODE		0x54
 
 /* GEN12+ Reg State Context */
-#define GEN12_CTX_BB_PER_CTX_PTR		0x12
-#define GEN12_CTX_LRI_HEADER_3			0x41
-
-#define CTX_REG(reg_state, pos, reg, val) do { \
-	u32 *reg_state__ = (reg_state); \
-	const u32 pos__ = (pos); \
-	(reg_state__)[(pos__) + 0] = i915_mmio_reg_offset(reg); \
-	(reg_state__)[(pos__) + 1] = (val); \
-} while (0)
+#define GEN12_CTX_BB_PER_CTX_PTR		(0x12 + 1)
 
 #define ASSIGN_CTX_PDP(ppgtt, reg_state, n) do { \
 	u32 *reg_state__ = (reg_state); \
 	const u64 addr__ = i915_page_dir_dma_addr((ppgtt), (n)); \
-	(reg_state__)[CTX_PDP ## n ## _UDW + 1] = upper_32_bits(addr__); \
-	(reg_state__)[CTX_PDP ## n ## _LDW + 1] = lower_32_bits(addr__); \
+	(reg_state__)[CTX_PDP ## n ## _UDW] = upper_32_bits(addr__); \
+	(reg_state__)[CTX_PDP ## n ## _LDW] = lower_32_bits(addr__); \
 } while (0)
 
 #define ASSIGN_CTX_PML4(ppgtt, reg_state) do { \
 	u32 *reg_state__ = (reg_state); \
 	const u64 addr__ = px_dma(ppgtt->pd); \
-	(reg_state__)[CTX_PDP0_UDW + 1] = upper_32_bits(addr__); \
-	(reg_state__)[CTX_PDP0_LDW + 1] = lower_32_bits(addr__); \
+	(reg_state__)[CTX_PDP0_UDW] = upper_32_bits(addr__); \
+	(reg_state__)[CTX_PDP0_LDW] = lower_32_bits(addr__); \
 } while (0)
 
 #define GEN8_CTX_RCS_INDIRECT_CTX_OFFSET_DEFAULT	0x17
diff --git a/drivers/gpu/drm/i915/gt/selftest_lrc.c b/drivers/gpu/drm/i915/gt/selftest_lrc.c
index 93a871bfd95d..22ea2e747064 100644
--- a/drivers/gpu/drm/i915/gt/selftest_lrc.c
+++ b/drivers/gpu/drm/i915/gt/selftest_lrc.c
@@ -2201,3 +2201,145 @@ int intel_execlists_live_selftests(struct drm_i915_private *i915)
 
 	return i915_live_subtests(tests, i915);
 }
+
+static void hexdump(const void *buf, size_t len)
+{
+	const size_t rowsize = 8 * sizeof(u32);
+	const void *prev = NULL;
+	bool skip = false;
+	size_t pos;
+
+	for (pos = 0; pos < len; pos += rowsize) {
+		char line[128];
+
+		if (prev && !memcmp(prev, buf + pos, rowsize)) {
+			if (!skip) {
+				pr_info("*\n");
+				skip = true;
+			}
+			continue;
+		}
+
+		WARN_ON_ONCE(hex_dump_to_buffer(buf + pos, len - pos,
+						rowsize, sizeof(u32),
+						line, sizeof(line),
+						false) >= sizeof(line));
+		pr_info("[%04zx] %s\n", pos, line);
+
+		prev = buf + pos;
+		skip = false;
+	}
+}
+
+static int live_lrc_layout(void *arg)
+{
+	struct intel_gt *gt = arg;
+	struct intel_engine_cs *engine;
+	enum intel_engine_id id;
+	u32 *mem;
+	int err;
+
+	/*
+	 * Check the registers offsets we use to create the initial reg state
+	 * match the layout saved by HW.
+	 */
+
+	mem = kmalloc(PAGE_SIZE, GFP_KERNEL);
+	if (!mem)
+		return -ENOMEM;
+
+	err = 0;
+	for_each_engine(engine, gt->i915, id) {
+		u32 *hw, *lrc;
+		int dw;
+
+		if (!engine->default_state)
+			continue;
+
+		hw = i915_gem_object_pin_map(engine->default_state,
+					     I915_MAP_WB);
+		if (IS_ERR(hw)) {
+			err = PTR_ERR(hw);
+			break;
+		}
+		hw += LRC_STATE_PN * PAGE_SIZE / sizeof(*hw);
+
+		lrc = memset(mem, 0, PAGE_SIZE);
+		execlists_init_reg_state(lrc,
+					 engine->kernel_context,
+					 engine,
+					 engine->kernel_context->ring,
+					 true);
+
+		dw = 0;
+		do {
+			u32 lri = hw[dw];
+
+			if (lri == 0) {
+				dw++;
+				continue;
+			}
+
+			if ((lri & GENMASK(31, 23)) != MI_INSTR(0x22, 0)) {
+				pr_err("%s: Expected LRI command at dword %d, found %08x\n",
+				       engine->name, dw, lri);
+				err = -EINVAL;
+				break;
+			}
+
+			if (lrc[dw] != lri) {
+				pr_err("%s: LRI command mismatch at dword %d, expected %08x found %08x\n",
+				       engine->name, dw, lri, lrc[dw]);
+				err = -EINVAL;
+				break;
+			}
+
+			lri &= 0x7f;
+			lri++;
+			dw++;
+
+			while (lri) {
+				if (hw[dw] != lrc[dw]) {
+					pr_err("%s: Different registers found at dword %d, expected %x, found %x\n",
+					       engine->name, dw, hw[dw], lrc[dw]);
+					err = -EINVAL;
+					break;
+				}
+
+				/*
+				 * Skip over the actual register value as we
+				 * expect that to differ.
+				 */
+				dw += 2;
+				lri -= 2;
+			}
+		} while ((lrc[dw] & ~BIT(0)) != MI_BATCH_BUFFER_END);
+
+		if (err) {
+			pr_info("%s: HW register image:\n", engine->name);
+			hexdump(hw, PAGE_SIZE);
+
+			pr_info("%s: SW register image:\n", engine->name);
+			hexdump(lrc, PAGE_SIZE);
+		}
+
+		i915_gem_object_unpin_map(engine->default_state);
+		if (err)
+			break;
+	}
+
+	kfree(mem);
+	return err;
+}
+
+int intel_lrc_live_selftests(struct drm_i915_private *i915)
+{
+	static const struct i915_subtest tests[] = {
+		SUBTEST(live_lrc_layout),
+	};
+
+	if (!HAS_LOGICAL_RING_CONTEXTS(i915))
+		return 0;
+
+	return intel_gt_live_subtests(tests, &i915->gt);
+}
diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c
index c1b764233761..524f6710b7aa 100644
--- a/drivers/gpu/drm/i915/i915_perf.c
+++ b/drivers/gpu/drm/i915/i915_perf.c
@@ -1673,10 +1673,8 @@ static u32 oa_config_flex_reg(const struct i915_oa_config *oa_config,
  * in the case that the OA unit has been disabled.
  */
 static void
-gen8_update_reg_state_unlocked(struct i915_perf_stream *stream,
-			       struct intel_context *ce,
-			       u32 *reg_state,
-			       const struct i915_oa_config *oa_config)
+gen8_update_reg_state_unlocked(const struct intel_context *ce,
+			       const struct i915_perf_stream *stream)
 {
 	struct drm_i915_private *i915 = ce->engine->i915;
 	u32 ctx_oactxctrl = i915->perf.ctx_oactxctrl_offset;
@@ -1691,21 +1689,19 @@ gen8_update_reg_state_unlocked(struct i915_perf_stream *stream,
 		EU_PERF_CNTL5,
 		EU_PERF_CNTL6,
 	};
+	u32 *reg_state = ce->lrc_reg_state;
 	int i;
 
-	CTX_REG(reg_state, ctx_oactxctrl, GEN8_OACTXCONTROL,
+	reg_state[ctx_oactxctrl + 1] =
 		(stream->period_exponent << GEN8_OA_TIMER_PERIOD_SHIFT) |
 		(stream->periodic ? GEN8_OA_TIMER_ENABLE : 0) |
-		GEN8_OA_COUNTER_RESUME);
+		GEN8_OA_COUNTER_RESUME;
 
-	for (i = 0; i < ARRAY_SIZE(flex_regs); i++) {
-		CTX_REG(reg_state, ctx_flexeu0 + i * 2, flex_regs[i],
-			oa_config_flex_reg(oa_config, flex_regs[i]));
-	}
+	for (i = 0; i < ARRAY_SIZE(flex_regs); i++)
+		reg_state[ctx_flexeu0 + i * 2 + 1] =
+			oa_config_flex_reg(stream->oa_config, flex_regs[i]);
 
-	CTX_REG(reg_state,
-		CTX_R_PWR_CLK_STATE, GEN8_R_PWR_CLK_STATE,
-		intel_sseu_make_rpcs(i915, &ce->sseu));
+	reg_state[CTX_R_PWR_CLK_STATE] = intel_sseu_make_rpcs(i915, &ce->sseu);
 }
 
 struct flex {
@@ -1729,7 +1725,7 @@ gen8_store_flex(struct i915_request *rq,
 	offset = i915_ggtt_offset(ce->state) + LRC_STATE_PN * PAGE_SIZE;
 	do {
 		*cs++ = MI_STORE_DWORD_IMM_GEN4 | MI_USE_GGTT;
-		*cs++ = offset + (flex->offset + 1) * sizeof(u32);
+		*cs++ = offset + flex->offset * sizeof(u32);
 		*cs++ = 0;
 		*cs++ = flex->value;
 	} while (flex++, --count);
@@ -1863,7 +1859,7 @@ static int gen8_configure_all_contexts(struct i915_perf_stream *stream,
 	struct drm_i915_private *i915 = stream->dev_priv;
 	/* The MMIO offsets for Flex EU registers aren't contiguous */
 	const u32 ctx_flexeu0 = i915->perf.ctx_flexeu0_offset;
-#define ctx_flexeuN(N) (ctx_flexeu0 + 2 * (N))
+#define ctx_flexeuN(N) (ctx_flexeu0 + 2 * (N) + 1)
 	struct flex regs[] = {
 		{
 			GEN8_R_PWR_CLK_STATE,
@@ -1871,7 +1867,7 @@ static int gen8_configure_all_contexts(struct i915_perf_stream *stream,
 		},
 		{
 			GEN8_OACTXCONTROL,
-			i915->perf.ctx_oactxctrl_offset,
+			i915->perf.ctx_oactxctrl_offset + 1,
 			((stream->period_exponent << GEN8_OA_TIMER_PERIOD_SHIFT) |
 			 (stream->periodic ? GEN8_OA_TIMER_ENABLE : 0) |
 			 GEN8_OA_COUNTER_RESUME)
@@ -2299,9 +2295,8 @@ static int i915_oa_stream_init(struct i915_perf_stream *stream,
 	return ret;
 }
 
-void i915_oa_init_reg_state(struct intel_engine_cs *engine,
-			    struct intel_context *ce,
-			    u32 *regs)
+void i915_oa_init_reg_state(const struct intel_context *ce,
+			    const struct intel_engine_cs *engine)
 {
 	struct i915_perf_stream *stream;
 
@@ -2313,7 +2308,7 @@ void i915_oa_init_reg_state(struct intel_engine_cs *engine,
 
 	stream = engine->i915->perf.exclusive_stream;
 	if (stream)
-		gen8_update_reg_state_unlocked(stream, ce, regs, stream->oa_config);
+		gen8_update_reg_state_unlocked(ce, stream);
 }
 
 /**
diff --git a/drivers/gpu/drm/i915/i915_perf.h b/drivers/gpu/drm/i915/i915_perf.h
index a412b16d9ffc..f4fb311184b1 100644
--- a/drivers/gpu/drm/i915/i915_perf.h
+++ b/drivers/gpu/drm/i915/i915_perf.h
@@ -25,8 +25,7 @@ int i915_perf_add_config_ioctl(struct drm_device *dev, void *data,
 			       struct drm_file *file);
 int i915_perf_remove_config_ioctl(struct drm_device *dev, void *data,
 				  struct drm_file *file);
-void i915_oa_init_reg_state(struct intel_engine_cs *engine,
-			    struct intel_context *ce,
-			    u32 *reg_state);
+void i915_oa_init_reg_state(const struct intel_context *ce,
+			    const struct intel_engine_cs *engine);
 
 #endif /* __I915_PERF_H__ */
diff --git a/drivers/gpu/drm/i915/selftests/i915_live_selftests.h b/drivers/gpu/drm/i915/selftests/i915_live_selftests.h
index 1ccf0f731ac0..66d83c1390c1 100644
--- a/drivers/gpu/drm/i915/selftests/i915_live_selftests.h
+++ b/drivers/gpu/drm/i915/selftests/i915_live_selftests.h
@@ -15,6 +15,7 @@ selftest(workarounds, intel_workarounds_live_selftests)
 selftest(gt_engines, intel_engine_live_selftests)
 selftest(gt_timelines, intel_timeline_live_selftests)
 selftest(gt_contexts, intel_context_live_selftests)
+selftest(gt_lrc, intel_lrc_live_selftests)
 selftest(requests, i915_request_live_selftests)
 selftest(active, i915_active_live_selftests)
 selftest(objects, i915_gem_object_live_selftests)
-- 
2.23.0

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

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 2/2] drm/i915/tgl: Swap engines for rps (gpu reclocking)
  2019-09-23 23:02 [PATCH 1/2] drm/i915/selftests: Verify the LRC register layout between init and HW Chris Wilson
@ 2019-09-23 23:02 ` Chris Wilson
  2019-09-24  7:09   ` [PATCH] drm/i915/tgl: Swap engines for no rc6/rps (gpu powersave and reclocking) Chris Wilson
  2019-09-23 23:08 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [1/2] drm/i915/selftests: Verify the LRC register layout between init and HW Patchwork
                   ` (10 subsequent siblings)
  11 siblings, 1 reply; 22+ messages in thread
From: Chris Wilson @ 2019-09-23 23:02 UTC (permalink / raw)
  To: intel-gfx

If we disable rps, it appears the Tigerlake is stable enough to run
multiple engines simultaneously in CI. As disabling rps should only
cause the execution being slow, whereas many features depend on the
different engines, we would prefer to have the engines enabled while the
hangs are being debugged.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=111714
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
---
 drivers/gpu/drm/i915/i915_pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c
index c2faa679658c..796a31ee63ea 100644
--- a/drivers/gpu/drm/i915/i915_pci.c
+++ b/drivers/gpu/drm/i915/i915_pci.c
@@ -798,7 +798,7 @@ static const struct intel_device_info intel_tigerlake_12_info = {
 	.display.has_modular_fia = 1,
 	.engine_mask =
 		BIT(RCS0) | BIT(BCS0) | BIT(VECS0) | BIT(VCS0) | BIT(VCS2),
-	.engine_mask = BIT(RCS0), /* XXX reduced for debugging */
+	.has_rps = false, /* XXX disabled for debugging */
 };
 
 #undef GEN
-- 
2.23.0

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

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* ✗ Fi.CI.CHECKPATCH: warning for series starting with [1/2] drm/i915/selftests: Verify the LRC register layout between init and HW
  2019-09-23 23:02 [PATCH 1/2] drm/i915/selftests: Verify the LRC register layout between init and HW Chris Wilson
  2019-09-23 23:02 ` [PATCH 2/2] drm/i915/tgl: Swap engines for rps (gpu reclocking) Chris Wilson
@ 2019-09-23 23:08 ` Patchwork
  2019-09-23 23:31 ` ✓ Fi.CI.BAT: success " Patchwork
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 22+ messages in thread
From: Patchwork @ 2019-09-23 23:08 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: series starting with [1/2] drm/i915/selftests: Verify the LRC register layout between init and HW
URL   : https://patchwork.freedesktop.org/series/67135/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
eaf8d924c5d1 drm/i915/selftests: Verify the LRC register layout between init and HW
-:61: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'x' - possible side-effects?
#61: FILE: drivers/gpu/drm/i915/gt/intel_lrc.c:481:
+#define REG(x) (((x) >> 2) | BUILD_BUG_ON_ZERO(x >= 0x200))

-:62: ERROR:COMPLEX_MACRO: Macros with complex values should be enclosed in parentheses
#62: FILE: drivers/gpu/drm/i915/gt/intel_lrc.c:482:
+#define REG16(x) \
+	(((x) >> 9) | BIT(7) | BUILD_BUG_ON_ZERO(x >= 0x10000)), \
+	(((x) >> 2) & 0x7f)

-:62: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'x' - possible side-effects?
#62: FILE: drivers/gpu/drm/i915/gt/intel_lrc.c:482:
+#define REG16(x) \
+	(((x) >> 9) | BIT(7) | BUILD_BUG_ON_ZERO(x >= 0x10000)), \
+	(((x) >> 2) & 0x7f)

total: 1 errors, 0 warnings, 2 checks, 1125 lines checked
3477ed35e9be drm/i915/tgl: Swap engines for rps (gpu reclocking)

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

^ permalink raw reply	[flat|nested] 22+ messages in thread

* ✓ Fi.CI.BAT: success for series starting with [1/2] drm/i915/selftests: Verify the LRC register layout between init and HW
  2019-09-23 23:02 [PATCH 1/2] drm/i915/selftests: Verify the LRC register layout between init and HW Chris Wilson
  2019-09-23 23:02 ` [PATCH 2/2] drm/i915/tgl: Swap engines for rps (gpu reclocking) Chris Wilson
  2019-09-23 23:08 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [1/2] drm/i915/selftests: Verify the LRC register layout between init and HW Patchwork
@ 2019-09-23 23:31 ` Patchwork
  2019-09-24  7:17 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [1/2] drm/i915/selftests: Verify the LRC register layout between init and HW (rev2) Patchwork
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 22+ messages in thread
From: Patchwork @ 2019-09-23 23:31 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: series starting with [1/2] drm/i915/selftests: Verify the LRC register layout between init and HW
URL   : https://patchwork.freedesktop.org/series/67135/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_6945 -> Patchwork_14508
====================================================

Summary
-------

  **SUCCESS**

  No regressions found.

  External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14508/

New tests
---------

  New tests have been introduced between CI_DRM_6945 and Patchwork_14508:

### New IGT tests (1) ###

  * igt@i915_selftest@live_gt_lrc:
    - Statuses : 46 pass(s)
    - Exec time: [0.39, 2.17] s

  

Known issues
------------

  Here are the changes found in Patchwork_14508 that come from known issues:

### IGT changes ###

#### Issues hit ####

  * igt@i915_selftest@live_gtt:
    - fi-glk-dsi:         [PASS][1] -> [INCOMPLETE][2] ([fdo#103359] / [k.org#198133])
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6945/fi-glk-dsi/igt@i915_selftest@live_gtt.html
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14508/fi-glk-dsi/igt@i915_selftest@live_gtt.html

  * igt@prime_busy@basic-wait-before-default:
    - fi-icl-u3:          [PASS][3] -> [DMESG-WARN][4] ([fdo#107724]) +2 similar issues
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6945/fi-icl-u3/igt@prime_busy@basic-wait-before-default.html
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14508/fi-icl-u3/igt@prime_busy@basic-wait-before-default.html

  
#### Possible fixes ####

  * igt@gem_linear_blits@basic:
    - {fi-tgl-u}:         [SKIP][5] ([fdo#111714]) -> [PASS][6]
   [5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6945/fi-tgl-u/igt@gem_linear_blits@basic.html
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14508/fi-tgl-u/igt@gem_linear_blits@basic.html

  * igt@gem_mmap_gtt@basic-read-write-distinct:
    - fi-icl-u3:          [DMESG-WARN][7] ([fdo#107724]) -> [PASS][8] +1 similar issue
   [7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6945/fi-icl-u3/igt@gem_mmap_gtt@basic-read-write-distinct.html
   [8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14508/fi-icl-u3/igt@gem_mmap_gtt@basic-read-write-distinct.html

  * igt@gem_tiled_fence_blits@basic:
    - {fi-tgl-u2}:        [SKIP][9] ([fdo#111714]) -> [PASS][10] +2 similar issues
   [9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6945/fi-tgl-u2/igt@gem_tiled_fence_blits@basic.html
   [10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14508/fi-tgl-u2/igt@gem_tiled_fence_blits@basic.html

  * igt@i915_module_load@reload:
    - fi-icl-u3:          [DMESG-WARN][11] ([fdo#107724] / [fdo#111214]) -> [PASS][12]
   [11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6945/fi-icl-u3/igt@i915_module_load@reload.html
   [12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14508/fi-icl-u3/igt@i915_module_load@reload.html

  * igt@i915_selftest@live_execlists:
    - fi-icl-u2:          [DMESG-FAIL][13] ([fdo#111108]) -> [PASS][14]
   [13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6945/fi-icl-u2/igt@i915_selftest@live_execlists.html
   [14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14508/fi-icl-u2/igt@i915_selftest@live_execlists.html

  * igt@i915_selftest@live_hangcheck:
    - fi-kbl-7500u:       [INCOMPLETE][15] ([fdo#108744]) -> [PASS][16]
   [15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6945/fi-kbl-7500u/igt@i915_selftest@live_hangcheck.html
   [16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14508/fi-kbl-7500u/igt@i915_selftest@live_hangcheck.html

  * igt@kms_chamelium@hdmi-hpd-fast:
    - fi-kbl-7500u:       [FAIL][17] ([fdo#111407]) -> [PASS][18]
   [17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6945/fi-kbl-7500u/igt@kms_chamelium@hdmi-hpd-fast.html
   [18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14508/fi-kbl-7500u/igt@kms_chamelium@hdmi-hpd-fast.html

  * igt@kms_frontbuffer_tracking@basic:
    - {fi-tgl-u2}:        [FAIL][19] ([fdo#111604]) -> [PASS][20]
   [19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6945/fi-tgl-u2/igt@kms_frontbuffer_tracking@basic.html
   [20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14508/fi-tgl-u2/igt@kms_frontbuffer_tracking@basic.html

  * igt@kms_pipe_crc_basic@suspend-read-crc-pipe-a:
    - fi-blb-e6850:       [INCOMPLETE][21] ([fdo#107718]) -> [PASS][22]
   [21]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6945/fi-blb-e6850/igt@kms_pipe_crc_basic@suspend-read-crc-pipe-a.html
   [22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14508/fi-blb-e6850/igt@kms_pipe_crc_basic@suspend-read-crc-pipe-a.html

  
  {name}: This element is suppressed. This means it is ignored when computing
          the status of the difference (SUCCESS, WARNING, or FAILURE).

  [fdo#103359]: https://bugs.freedesktop.org/show_bug.cgi?id=103359
  [fdo#106107]: https://bugs.freedesktop.org/show_bug.cgi?id=106107
  [fdo#107718]: https://bugs.freedesktop.org/show_bug.cgi?id=107718
  [fdo#107724]: https://bugs.freedesktop.org/show_bug.cgi?id=107724
  [fdo#108744]: https://bugs.freedesktop.org/show_bug.cgi?id=108744
  [fdo#111045]: https://bugs.freedesktop.org/show_bug.cgi?id=111045
  [fdo#111096]: https://bugs.freedesktop.org/show_bug.cgi?id=111096
  [fdo#111108]: https://bugs.freedesktop.org/show_bug.cgi?id=111108
  [fdo#111214]: https://bugs.freedesktop.org/show_bug.cgi?id=111214
  [fdo#111407]: https://bugs.freedesktop.org/show_bug.cgi?id=111407
  [fdo#111604]: https://bugs.freedesktop.org/show_bug.cgi?id=111604
  [fdo#111647]: https://bugs.freedesktop.org/show_bug.cgi?id=111647
  [fdo#111714]: https://bugs.freedesktop.org/show_bug.cgi?id=111714
  [k.org#198133]: https://bugzilla.kernel.org/show_bug.cgi?id=198133


Participating hosts (54 -> 47)
------------------------------

  Missing    (7): fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-icl-y fi-byt-clapper fi-bdw-samus 


Build changes
-------------

  * CI: CI-20190529 -> None
  * Linux: CI_DRM_6945 -> Patchwork_14508

  CI-20190529: 20190529
  CI_DRM_6945: f11d819264a3fab210498a4920ef34a891da39e0 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGT_5197: aa534ff47fd2f455c8be9e59eae807695b87fcdd @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_14508: 3477ed35e9bed50d62fd98b5aeaf62db23ce02b7 @ git://anongit.freedesktop.org/gfx-ci/linux


== Linux commits ==

3477ed35e9be drm/i915/tgl: Swap engines for rps (gpu reclocking)
eaf8d924c5d1 drm/i915/selftests: Verify the LRC register layout between init and HW

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14508/index.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH] drm/i915/tgl: Swap engines for no rc6/rps (gpu powersave and reclocking)
  2019-09-23 23:02 ` [PATCH 2/2] drm/i915/tgl: Swap engines for rps (gpu reclocking) Chris Wilson
@ 2019-09-24  7:09   ` Chris Wilson
  0 siblings, 0 replies; 22+ messages in thread
From: Chris Wilson @ 2019-09-24  7:09 UTC (permalink / raw)
  To: intel-gfx

If we disable rps, it appears the Tigerlake is stable enough to run
multiple engines simultaneously in CI. As disabling rps should only
cause the execution being slow, whereas many features depend on the
different engines, we would prefer to have the engines enabled while the
hangs are being debugged.

RPS was almost enough for CI, through in a bonus no RC6 as well!

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=111714
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
---
 drivers/gpu/drm/i915/i915_pci.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c
index c2faa679658c..a180acb2e83b 100644
--- a/drivers/gpu/drm/i915/i915_pci.c
+++ b/drivers/gpu/drm/i915/i915_pci.c
@@ -798,7 +798,8 @@ static const struct intel_device_info intel_tigerlake_12_info = {
 	.display.has_modular_fia = 1,
 	.engine_mask =
 		BIT(RCS0) | BIT(BCS0) | BIT(VECS0) | BIT(VCS0) | BIT(VCS2),
-	.engine_mask = BIT(RCS0), /* XXX reduced for debugging */
+	.has_rc6 = false, /* XXX disabled for debugging */
+	.has_rps = false, /* XXX disabled for debugging */
 };
 
 #undef GEN
-- 
2.23.0

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

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* ✗ Fi.CI.CHECKPATCH: warning for series starting with [1/2] drm/i915/selftests: Verify the LRC register layout between init and HW (rev2)
  2019-09-23 23:02 [PATCH 1/2] drm/i915/selftests: Verify the LRC register layout between init and HW Chris Wilson
                   ` (2 preceding siblings ...)
  2019-09-23 23:31 ` ✓ Fi.CI.BAT: success " Patchwork
@ 2019-09-24  7:17 ` Patchwork
  2019-09-24  7:43 ` ✓ Fi.CI.BAT: success " Patchwork
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 22+ messages in thread
From: Patchwork @ 2019-09-24  7:17 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: series starting with [1/2] drm/i915/selftests: Verify the LRC register layout between init and HW (rev2)
URL   : https://patchwork.freedesktop.org/series/67135/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
b188840c0465 drm/i915/selftests: Verify the LRC register layout between init and HW
-:61: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'x' - possible side-effects?
#61: FILE: drivers/gpu/drm/i915/gt/intel_lrc.c:481:
+#define REG(x) (((x) >> 2) | BUILD_BUG_ON_ZERO(x >= 0x200))

-:62: ERROR:COMPLEX_MACRO: Macros with complex values should be enclosed in parentheses
#62: FILE: drivers/gpu/drm/i915/gt/intel_lrc.c:482:
+#define REG16(x) \
+	(((x) >> 9) | BIT(7) | BUILD_BUG_ON_ZERO(x >= 0x10000)), \
+	(((x) >> 2) & 0x7f)

-:62: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'x' - possible side-effects?
#62: FILE: drivers/gpu/drm/i915/gt/intel_lrc.c:482:
+#define REG16(x) \
+	(((x) >> 9) | BIT(7) | BUILD_BUG_ON_ZERO(x >= 0x10000)), \
+	(((x) >> 2) & 0x7f)

total: 1 errors, 0 warnings, 2 checks, 1125 lines checked
701593b193cc drm/i915/tgl: Swap engines for no rc6/rps (gpu powersave and reclocking)

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

^ permalink raw reply	[flat|nested] 22+ messages in thread

* ✓ Fi.CI.BAT: success for series starting with [1/2] drm/i915/selftests: Verify the LRC register layout between init and HW (rev2)
  2019-09-23 23:02 [PATCH 1/2] drm/i915/selftests: Verify the LRC register layout between init and HW Chris Wilson
                   ` (3 preceding siblings ...)
  2019-09-24  7:17 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [1/2] drm/i915/selftests: Verify the LRC register layout between init and HW (rev2) Patchwork
@ 2019-09-24  7:43 ` Patchwork
  2019-09-24  7:59   ` Chris Wilson
  2019-09-24 10:21 ` [PATCH 1/2] drm/i915/selftests: Verify the LRC register layout between init and HW Mika Kuoppala
                   ` (6 subsequent siblings)
  11 siblings, 1 reply; 22+ messages in thread
From: Patchwork @ 2019-09-24  7:43 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: series starting with [1/2] drm/i915/selftests: Verify the LRC register layout between init and HW (rev2)
URL   : https://patchwork.freedesktop.org/series/67135/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_6945 -> Patchwork_14512
====================================================

Summary
-------

  **SUCCESS**

  No regressions found.

  External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14512/

Possible new issues
-------------------

  Here are the unknown changes that may have been introduced in Patchwork_14512:

### IGT changes ###

#### Suppressed ####

  The following results come from untrusted machines, tests, or statuses.
  They do not affect the overall result.

  * igt@i915_selftest@live_hugepages:
    - {fi-tgl-u2}:        [PASS][1] -> [INCOMPLETE][2]
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6945/fi-tgl-u2/igt@i915_selftest@live_hugepages.html
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14512/fi-tgl-u2/igt@i915_selftest@live_hugepages.html

  
New tests
---------

  New tests have been introduced between CI_DRM_6945 and Patchwork_14512:

### New IGT tests (1) ###

  * igt@i915_selftest@live_gt_lrc:
    - Statuses : 41 pass(s)
    - Exec time: [0.33, 2.13] s

  

Known issues
------------

  Here are the changes found in Patchwork_14512 that come from known issues:

### IGT changes ###

#### Issues hit ####

  * igt@gem_ctx_create@basic-files:
    - fi-icl-u2:          [PASS][3] -> [INCOMPLETE][4] ([fdo#107713] / [fdo#109100])
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6945/fi-icl-u2/igt@gem_ctx_create@basic-files.html
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14512/fi-icl-u2/igt@gem_ctx_create@basic-files.html

  * igt@gem_exec_suspend@basic-s3:
    - fi-blb-e6850:       [PASS][5] -> [INCOMPLETE][6] ([fdo#107718])
   [5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6945/fi-blb-e6850/igt@gem_exec_suspend@basic-s3.html
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14512/fi-blb-e6850/igt@gem_exec_suspend@basic-s3.html

  * igt@kms_frontbuffer_tracking@basic:
    - fi-hsw-peppy:       [PASS][7] -> [DMESG-WARN][8] ([fdo#102614])
   [7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6945/fi-hsw-peppy/igt@kms_frontbuffer_tracking@basic.html
   [8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14512/fi-hsw-peppy/igt@kms_frontbuffer_tracking@basic.html

  
#### Possible fixes ####

  * igt@gem_linear_blits@basic:
    - {fi-tgl-u}:         [SKIP][9] ([fdo#111714]) -> [PASS][10]
   [9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6945/fi-tgl-u/igt@gem_linear_blits@basic.html
   [10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14512/fi-tgl-u/igt@gem_linear_blits@basic.html

  * igt@gem_tiled_fence_blits@basic:
    - {fi-tgl-u2}:        [SKIP][11] ([fdo#111714]) -> [PASS][12] +2 similar issues
   [11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6945/fi-tgl-u2/igt@gem_tiled_fence_blits@basic.html
   [12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14512/fi-tgl-u2/igt@gem_tiled_fence_blits@basic.html

  * igt@i915_selftest@live_hangcheck:
    - fi-kbl-7500u:       [INCOMPLETE][13] ([fdo#108744]) -> [PASS][14]
   [13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6945/fi-kbl-7500u/igt@i915_selftest@live_hangcheck.html
   [14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14512/fi-kbl-7500u/igt@i915_selftest@live_hangcheck.html

  * igt@kms_chamelium@hdmi-hpd-fast:
    - fi-kbl-7500u:       [FAIL][15] ([fdo#111407]) -> [PASS][16]
   [15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6945/fi-kbl-7500u/igt@kms_chamelium@hdmi-hpd-fast.html
   [16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14512/fi-kbl-7500u/igt@kms_chamelium@hdmi-hpd-fast.html

  
  {name}: This element is suppressed. This means it is ignored when computing
          the status of the difference (SUCCESS, WARNING, or FAILURE).

  [fdo#102614]: https://bugs.freedesktop.org/show_bug.cgi?id=102614
  [fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
  [fdo#107713]: https://bugs.freedesktop.org/show_bug.cgi?id=107713
  [fdo#107718]: https://bugs.freedesktop.org/show_bug.cgi?id=107718
  [fdo#108744]: https://bugs.freedesktop.org/show_bug.cgi?id=108744
  [fdo#109100]: https://bugs.freedesktop.org/show_bug.cgi?id=109100
  [fdo#111045]: https://bugs.freedesktop.org/show_bug.cgi?id=111045
  [fdo#111096]: https://bugs.freedesktop.org/show_bug.cgi?id=111096
  [fdo#111407]: https://bugs.freedesktop.org/show_bug.cgi?id=111407
  [fdo#111600]: https://bugs.freedesktop.org/show_bug.cgi?id=111600
  [fdo#111604]: https://bugs.freedesktop.org/show_bug.cgi?id=111604
  [fdo#111647]: https://bugs.freedesktop.org/show_bug.cgi?id=111647
  [fdo#111714]: https://bugs.freedesktop.org/show_bug.cgi?id=111714
  [fdo#111718]: https://bugs.freedesktop.org/show_bug.cgi?id=111718


Participating hosts (54 -> 45)
------------------------------

  Missing    (9): fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-kbl-x1275 fi-icl-u3 fi-icl-y fi-byt-clapper fi-bdw-samus 


Build changes
-------------

  * CI: CI-20190529 -> None
  * Linux: CI_DRM_6945 -> Patchwork_14512

  CI-20190529: 20190529
  CI_DRM_6945: f11d819264a3fab210498a4920ef34a891da39e0 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGT_5197: aa534ff47fd2f455c8be9e59eae807695b87fcdd @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_14512: 701593b193cc6c5eae55692f0bf472e7a6d7d657 @ git://anongit.freedesktop.org/gfx-ci/linux


== Linux commits ==

701593b193cc drm/i915/tgl: Swap engines for no rc6/rps (gpu powersave and reclocking)
b188840c0465 drm/i915/selftests: Verify the LRC register layout between init and HW

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14512/index.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: ✓ Fi.CI.BAT: success for series starting with [1/2] drm/i915/selftests: Verify the LRC register layout between init and HW (rev2)
  2019-09-24  7:43 ` ✓ Fi.CI.BAT: success " Patchwork
@ 2019-09-24  7:59   ` Chris Wilson
  0 siblings, 0 replies; 22+ messages in thread
From: Chris Wilson @ 2019-09-24  7:59 UTC (permalink / raw)
  To: Patchwork; +Cc: intel-gfx

Quoting Patchwork (2019-09-24 08:43:47)
> == Series Details ==
> 
> Series: series starting with [1/2] drm/i915/selftests: Verify the LRC register layout between init and HW (rev2)
> URL   : https://patchwork.freedesktop.org/series/67135/
> State : success
> 
> == Summary ==
> 
> CI Bug Log - changes from CI_DRM_6945 -> Patchwork_14512
> ====================================================
> 
> Summary
> -------
> 
>   **SUCCESS**
> 
>   No regressions found.
> 
>   External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14512/

No, fi-tgl-u is still dying on gem_sync. fi-tgl-u2 is happy, I dare say
rps is its kryptonite (without disabling rps both die in
gem_exec_gttfill).
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 1/2] drm/i915/selftests: Verify the LRC register layout between init and HW
  2019-09-23 23:02 [PATCH 1/2] drm/i915/selftests: Verify the LRC register layout between init and HW Chris Wilson
                   ` (4 preceding siblings ...)
  2019-09-24  7:43 ` ✓ Fi.CI.BAT: success " Patchwork
@ 2019-09-24 10:21 ` Mika Kuoppala
  2019-09-24 10:43   ` Chris Wilson
  2019-09-24 11:00   ` Chris Wilson
  2019-09-24 13:23 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [1/2] drm/i915/selftests: Verify the LRC register layout between init and HW (rev3) Patchwork
                   ` (5 subsequent siblings)
  11 siblings, 2 replies; 22+ messages in thread
From: Mika Kuoppala @ 2019-09-24 10:21 UTC (permalink / raw)
  To: Chris Wilson, intel-gfx

Chris Wilson <chris@chris-wilson.co.uk> writes:

> Before we submit the first context to HW, we need to construct a valid
> image of the register state. This layout is defined by the HW and should
> match the layout generated by HW when it saves the context image.
> Asserting that this should be equivalent should help avoid any undefined
> behaviour and verify that we haven't missed anything important!
>
> Of course, having insisted that the initial register state within the
> LRC should match that returned by HW, we need to ensure that it does.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
> Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
> ---
>  drivers/gpu/drm/i915/gem/i915_gem_context.c   |   2 +-
>  drivers/gpu/drm/i915/gt/intel_lrc.c           | 669 ++++++++++++------
>  drivers/gpu/drm/i915/gt/intel_lrc_reg.h       |  62 +-
>  drivers/gpu/drm/i915/gt/selftest_lrc.c        | 142 ++++
>  drivers/gpu/drm/i915/i915_perf.c              |  35 +-
>  drivers/gpu/drm/i915/i915_perf.h              |   5 +-
>  .../drm/i915/selftests/i915_live_selftests.h  |   1 +
>  7 files changed, 649 insertions(+), 267 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c
> index 4a34c4f62065..f7ba0935ed67 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
> @@ -1115,7 +1115,7 @@ static int gen8_emit_rpcs_config(struct i915_request *rq,
>  
>  	offset = i915_ggtt_offset(ce->state) +
>  		 LRC_STATE_PN * PAGE_SIZE +
> -		 (CTX_R_PWR_CLK_STATE + 1) * 4;
> +		 CTX_R_PWR_CLK_STATE * 4;
>  
>  	*cs++ = MI_STORE_DWORD_IMM_GEN4 | MI_USE_GGTT;
>  	*cs++ = lower_32_bits(offset);
> diff --git a/drivers/gpu/drm/i915/gt/intel_lrc.c b/drivers/gpu/drm/i915/gt/intel_lrc.c
> index 6cfdc0f9f2b9..c2c3e574af3a 100644
> --- a/drivers/gpu/drm/i915/gt/intel_lrc.c
> +++ b/drivers/gpu/drm/i915/gt/intel_lrc.c
> @@ -230,9 +230,10 @@ static int __execlists_context_alloc(struct intel_context *ce,
>  				     struct intel_engine_cs *engine);
>  
>  static void execlists_init_reg_state(u32 *reg_state,
> -				     struct intel_context *ce,
> -				     struct intel_engine_cs *engine,
> -				     struct intel_ring *ring);
> +				     const struct intel_context *ce,
> +				     const struct intel_engine_cs *engine,
> +				     const struct intel_ring *ring,
> +				     bool close);
>  
>  static void mark_eio(struct i915_request *rq)
>  {
> @@ -471,6 +472,411 @@ lrc_descriptor(struct intel_context *ce, struct intel_engine_cs *engine)
>  	return desc;
>  }
>  
> +static u32 *set_offsets(u32 *regs,
> +			const u8 *data,
> +			const struct intel_engine_cs *engine)
> +#define NOP(x) (BIT(7) | (x))
> +#define LRI(count, flags) ((flags) << 6 | (count))
> +#define POSTED BIT(0)
> +#define REG(x) (((x) >> 2) | BUILD_BUG_ON_ZERO(x >= 0x200))
> +#define REG16(x) \
> +	(((x) >> 9) | BIT(7) | BUILD_BUG_ON_ZERO(x >= 0x10000)), \
> +	(((x) >> 2) & 0x7f)

I am still not sure if the actual saving are worth the complexity.

> +#define END() 0
> +{
> +	const u32 base = engine->mmio_base;
> +
> +	while (*data) {
> +		u8 count, flags;
> +
> +		if (*data & BIT(7)) { /* skip */
> +			regs += *data++ & ~BIT(7);
> +			continue;
> +		}
> +
> +		count = *data & 0x3f;
> +		flags = *data >> 6;
> +		data++;
> +
> +		*regs = MI_LOAD_REGISTER_IMM(count);
> +		if (flags & POSTED)
> +			*regs |= MI_LRI_FORCE_POSTED;
> +		if (INTEL_GEN(engine->i915) >= 11)
> +			*regs |= MI_LRI_CS_MMIO;
> +		regs++;
> +
> +		GEM_BUG_ON(!count);
> +		do {
> +			u32 offset = 0;
> +			u8 v;
> +
> +			do {
> +				v = *data++;
> +				offset <<= 7;
> +				offset |= v & ~BIT(7);
> +			} while (v & BIT(7));

...but perhaps this amount of extra can be tolerated.

Did you check how this would play out with just REG being wide enough?

> +
> +			*regs = base + (offset << 2);

In here reader is yearning for an asserts of not trampling
on wrong territory.

But I would guess that you want this part to be like
oiled lightning and test the machinery with selftest..as the
subject seems to promise.

> +			regs += 2;
> +		} while (--count);
> +	}
> +
> +	return regs;
> +}
> +
> +static const u8 gen8_xcs_offsets[] = {
> +	NOP(1),
> +	LRI(11, 0),
> +	REG16(0x244),
> +	REG(0x034),
> +	REG(0x030),
> +	REG(0x038),
> +	REG(0x03c),
> +	REG(0x168),
> +	REG(0x140),
> +	REG(0x110),
> +	REG(0x11c),
> +	REG(0x114),
> +	REG(0x118),
> +
> +	NOP(9),
> +	LRI(9, 0),
> +	REG16(0x3a8),
> +	REG16(0x28c),
> +	REG16(0x288),
> +	REG16(0x284),
> +	REG16(0x280),
> +	REG16(0x27c),
> +	REG16(0x278),
> +	REG16(0x274),
> +	REG16(0x270),
> +
> +	NOP(13),
> +	LRI(2, 0),
> +	REG16(0x200),
> +	REG(0x028),
> +
> +	END(),
> +};
> +
> +static const u8 gen9_xcs_offsets[] = {
> +	NOP(1),
> +	LRI(14, POSTED),
> +	REG16(0x244),
> +	REG(0x034),
> +	REG(0x030),
> +	REG(0x038),
> +	REG(0x03c),
> +	REG(0x168),
> +	REG(0x140),
> +	REG(0x110),
> +	REG(0x11c),
> +	REG(0x114),
> +	REG(0x118),
> +	REG(0x1c0),
> +	REG(0x1c4),
> +	REG(0x1c8),
> +
> +	NOP(3),
> +	LRI(9, POSTED),
> +	REG16(0x3a8),
> +	REG16(0x28c),
> +	REG16(0x288),
> +	REG16(0x284),
> +	REG16(0x280),
> +	REG16(0x27c),
> +	REG16(0x278),
> +	REG16(0x274),
> +	REG16(0x270),
> +
> +	NOP(13),
> +	LRI(1, POSTED),
> +	REG16(0x200),
> +
> +	NOP(13),
> +	LRI(44, POSTED),
> +	REG(0x028),
> +	REG(0x09c),
> +	REG(0x0c0),
> +	REG(0x178),
> +	REG(0x17c),
> +	REG16(0x358),
> +	REG(0x170),
> +	REG(0x150),
> +	REG(0x154),
> +	REG(0x158),
> +	REG16(0x41c),
> +	REG16(0x600),
> +	REG16(0x604),
> +	REG16(0x608),
> +	REG16(0x60c),
> +	REG16(0x610),
> +	REG16(0x614),
> +	REG16(0x618),
> +	REG16(0x61c),
> +	REG16(0x620),
> +	REG16(0x624),
> +	REG16(0x628),
> +	REG16(0x62c),
> +	REG16(0x630),
> +	REG16(0x634),
> +	REG16(0x638),
> +	REG16(0x63c),
> +	REG16(0x640),
> +	REG16(0x644),
> +	REG16(0x648),
> +	REG16(0x64c),
> +	REG16(0x650),
> +	REG16(0x654),
> +	REG16(0x658),
> +	REG16(0x65c),
> +	REG16(0x660),
> +	REG16(0x664),
> +	REG16(0x668),
> +	REG16(0x66c),
> +	REG16(0x670),
> +	REG16(0x674),
> +	REG16(0x678),
> +	REG16(0x67c),
> +	REG(0x068),
> +
> +	END(),
> +};
> +
> +static const u8 gen12_xcs_offsets[] = {
> +	NOP(1),
> +	LRI(13, POSTED),
> +	REG16(0x244),
> +	REG(0x034),
> +	REG(0x030),
> +	REG(0x038),
> +	REG(0x03c),
> +	REG(0x168),
> +	REG(0x140),
> +	REG(0x110),
> +	REG(0x1c0),
> +	REG(0x1c4),
> +	REG(0x1c8),
> +	REG(0x180),
> +	REG16(0x2b4),
> +
> +	NOP(5),
> +	LRI(9, POSTED),
> +	REG16(0x3a8),
> +	REG16(0x28c),
> +	REG16(0x288),
> +	REG16(0x284),
> +	REG16(0x280),
> +	REG16(0x27c),
> +	REG16(0x278),
> +	REG16(0x274),
> +	REG16(0x270),
> +
> +	NOP(13),
> +	LRI(2, POSTED),
> +	REG16(0x200),
> +	REG16(0x204),
> +
> +	NOP(11),
> +	LRI(50, POSTED),
> +	REG16(0x588),
> +	REG16(0x588),
> +	REG16(0x588),
> +	REG16(0x588),
> +	REG16(0x588),
> +	REG16(0x588),
> +	REG(0x028),
> +	REG(0x09c),
> +	REG(0x0c0),
> +	REG(0x178),
> +	REG(0x17c),
> +	REG16(0x358),
> +	REG(0x170),
> +	REG(0x150),
> +	REG(0x154),
> +	REG(0x158),
> +	REG16(0x41c),
> +	REG16(0x600),
> +	REG16(0x604),
> +	REG16(0x608),
> +	REG16(0x60c),
> +	REG16(0x610),
> +	REG16(0x614),
> +	REG16(0x618),
> +	REG16(0x61c),
> +	REG16(0x620),
> +	REG16(0x624),
> +	REG16(0x628),
> +	REG16(0x62c),
> +	REG16(0x630),
> +	REG16(0x634),
> +	REG16(0x638),
> +	REG16(0x63c),
> +	REG16(0x640),
> +	REG16(0x644),
> +	REG16(0x648),
> +	REG16(0x64c),
> +	REG16(0x650),
> +	REG16(0x654),
> +	REG16(0x658),
> +	REG16(0x65c),
> +	REG16(0x660),
> +	REG16(0x664),
> +	REG16(0x668),
> +	REG16(0x66c),
> +	REG16(0x670),
> +	REG16(0x674),
> +	REG16(0x678),
> +	REG16(0x67c),
> +	REG(0x068),
> +
> +	END(),
> +};
> +
> +static const u8 gen8_rcs_offsets[] = {
> +	NOP(1),
> +	LRI(14, POSTED),
> +	REG16(0x244),
> +	REG(0x034),
> +	REG(0x030),
> +	REG(0x038),
> +	REG(0x03c),
> +	REG(0x168),
> +	REG(0x140),
> +	REG(0x110),
> +	REG(0x11c),
> +	REG(0x114),
> +	REG(0x118),
> +	REG(0x1c0),
> +	REG(0x1c4),
> +	REG(0x1c8),
> +
> +	NOP(3),
> +	LRI(9, POSTED),
> +	REG16(0x3a8),
> +	REG16(0x28c),
> +	REG16(0x288),
> +	REG16(0x284),
> +	REG16(0x280),
> +	REG16(0x27c),
> +	REG16(0x278),
> +	REG16(0x274),
> +	REG16(0x270),
> +
> +	NOP(13),
> +	LRI(1, 0),
> +	REG(0x0c8),
> +
> +	END(),
> +};
> +
> +static const u8 gen11_rcs_offsets[] = {
> +	NOP(1),
> +	LRI(15, POSTED),
> +	REG16(0x244),
> +	REG(0x034),
> +	REG(0x030),
> +	REG(0x038),
> +	REG(0x03c),
> +	REG(0x168),
> +	REG(0x140),
> +	REG(0x110),
> +	REG(0x11c),
> +	REG(0x114),
> +	REG(0x118),
> +	REG(0x1c0),
> +	REG(0x1c4),
> +	REG(0x1c8),
> +	REG(0x180),
> +
> +	NOP(1),
> +	LRI(9, POSTED),
> +	REG16(0x3a8),
> +	REG16(0x28c),
> +	REG16(0x288),
> +	REG16(0x284),
> +	REG16(0x280),
> +	REG16(0x27c),
> +	REG16(0x278),
> +	REG16(0x274),
> +	REG16(0x270),
> +
> +	LRI(1, POSTED),
> +	REG(0x1b0),
> +
> +	NOP(10),
> +	LRI(1, 0),
> +	REG(0x0c8),
> +
> +	END(),
> +};
> +
> +static const u8 gen12_rcs_offsets[] = {
> +	NOP(1),
> +	LRI(13, POSTED),
> +	REG16(0x244),
> +	REG(0x034),
> +	REG(0x030),
> +	REG(0x038),
> +	REG(0x03c),
> +	REG(0x168),
> +	REG(0x140),
> +	REG(0x110),
> +	REG(0x1c0),
> +	REG(0x1c4),
> +	REG(0x1c8),
> +	REG(0x180),
> +	REG16(0x2b4),
> +
> +	NOP(5),
> +	LRI(9, POSTED),
> +	REG16(0x3a8),
> +	REG16(0x28c),
> +	REG16(0x288),
> +	REG16(0x284),
> +	REG16(0x280),
> +	REG16(0x27c),
> +	REG16(0x278),
> +	REG16(0x274),
> +	REG16(0x270),
> +
> +	LRI(3, POSTED),
> +	REG(0x1b0),
> +	REG16(0x5a8),
> +	REG16(0x5ac),
> +
> +	NOP(6),
> +	LRI(1, 0),
> +	REG(0x0c8),
> +
> +	END(),
> +};
> +
> +#undef END
> +#undef REG16
> +#undef REG
> +#undef LRI
> +#undef NOP
> +
> +static const u8 *reg_offsets(const struct intel_engine_cs *engine)
> +{
> +	if (engine->class == RENDER_CLASS) {
> +		if (INTEL_GEN(engine->i915) >= 12)
> +			return gen12_rcs_offsets;
> +		else if (INTEL_GEN(engine->i915) >= 11)
> +			return gen11_rcs_offsets;
> +		else
> +			return gen8_rcs_offsets;
> +	} else {
> +		if (INTEL_GEN(engine->i915) >= 12)
> +			return gen12_xcs_offsets;
> +		else if (INTEL_GEN(engine->i915) >= 9)
> +			return gen9_xcs_offsets;
> +		else
> +			return gen8_xcs_offsets;
> +	}
> +}
> +
>  static void unwind_wa_tail(struct i915_request *rq)
>  {
>  	rq->tail = intel_ring_wrap(rq->ring, rq->wa_tail - WA_TAIL_BYTES);
> @@ -654,7 +1060,7 @@ static u64 execlists_update_context(const struct i915_request *rq)
>  	struct intel_context *ce = rq->hw_context;
>  	u64 desc;
>  
> -	ce->lrc_reg_state[CTX_RING_TAIL + 1] =
> +	ce->lrc_reg_state[CTX_RING_TAIL] =
>  		intel_ring_set_tail(rq->ring, rq->tail);
>  
>  	/*
> @@ -826,54 +1232,7 @@ static bool can_merge_rq(const struct i915_request *prev,
>  static void virtual_update_register_offsets(u32 *regs,
>  					    struct intel_engine_cs *engine)
>  {
> -	u32 base = engine->mmio_base;
> -
> -	/* Refactor so that we only have one place that knows all the offsets! */
> -	GEM_WARN_ON(INTEL_GEN(engine->i915) >= 12);
> -
> -	/* Must match execlists_init_reg_state()! */
> -
> -	/* Common part */
> -	regs[CTX_CONTEXT_CONTROL] =
> -		i915_mmio_reg_offset(RING_CONTEXT_CONTROL(base));
> -	regs[CTX_RING_HEAD] = i915_mmio_reg_offset(RING_HEAD(base));
> -	regs[CTX_RING_TAIL] = i915_mmio_reg_offset(RING_TAIL(base));
> -	regs[CTX_RING_BUFFER_START] = i915_mmio_reg_offset(RING_START(base));
> -	regs[CTX_RING_BUFFER_CONTROL] = i915_mmio_reg_offset(RING_CTL(base));
> -
> -	regs[CTX_BB_HEAD_U] = i915_mmio_reg_offset(RING_BBADDR_UDW(base));
> -	regs[CTX_BB_HEAD_L] = i915_mmio_reg_offset(RING_BBADDR(base));
> -	regs[CTX_BB_STATE] = i915_mmio_reg_offset(RING_BBSTATE(base));
> -
> -	regs[CTX_SECOND_BB_HEAD_U] =
> -		i915_mmio_reg_offset(RING_SBBADDR_UDW(base));
> -	regs[CTX_SECOND_BB_HEAD_L] = i915_mmio_reg_offset(RING_SBBADDR(base));
> -	regs[CTX_SECOND_BB_STATE] = i915_mmio_reg_offset(RING_SBBSTATE(base));
> -
> -	/* PPGTT part */
> -	regs[CTX_CTX_TIMESTAMP] =
> -		i915_mmio_reg_offset(RING_CTX_TIMESTAMP(base));
> -
> -	regs[CTX_PDP3_UDW] = i915_mmio_reg_offset(GEN8_RING_PDP_UDW(base, 3));
> -	regs[CTX_PDP3_LDW] = i915_mmio_reg_offset(GEN8_RING_PDP_LDW(base, 3));
> -	regs[CTX_PDP2_UDW] = i915_mmio_reg_offset(GEN8_RING_PDP_UDW(base, 2));
> -	regs[CTX_PDP2_LDW] = i915_mmio_reg_offset(GEN8_RING_PDP_LDW(base, 2));
> -	regs[CTX_PDP1_UDW] = i915_mmio_reg_offset(GEN8_RING_PDP_UDW(base, 1));
> -	regs[CTX_PDP1_LDW] = i915_mmio_reg_offset(GEN8_RING_PDP_LDW(base, 1));
> -	regs[CTX_PDP0_UDW] = i915_mmio_reg_offset(GEN8_RING_PDP_UDW(base, 0));
> -	regs[CTX_PDP0_LDW] = i915_mmio_reg_offset(GEN8_RING_PDP_LDW(base, 0));
> -
> -	if (engine->class == RENDER_CLASS) {
> -		regs[CTX_RCS_INDIRECT_CTX] =
> -			i915_mmio_reg_offset(RING_INDIRECT_CTX(base));
> -		regs[CTX_RCS_INDIRECT_CTX_OFFSET] =
> -			i915_mmio_reg_offset(RING_INDIRECT_CTX_OFFSET(base));
> -		regs[CTX_BB_PER_CTX_PTR] =
> -			i915_mmio_reg_offset(RING_BB_PER_CTX_PTR(base));
> -
> -		regs[CTX_R_PWR_CLK_STATE] =
> -			i915_mmio_reg_offset(GEN8_R_PWR_CLK_STATE);
> -	}
> +	set_offsets(regs, reg_offsets(engine), engine);
>  }
>  
>  static bool virtual_matches(const struct virtual_engine *ve,
> @@ -1738,8 +2097,8 @@ static void execlists_context_unpin(struct intel_context *ce)
>  }
>  
>  static void
> -__execlists_update_reg_state(struct intel_context *ce,
> -			     struct intel_engine_cs *engine)
> +__execlists_update_reg_state(const struct intel_context *ce,
> +			     const struct intel_engine_cs *engine)
>  {
>  	struct intel_ring *ring = ce->ring;
>  	u32 *regs = ce->lrc_reg_state;
> @@ -1747,16 +2106,16 @@ __execlists_update_reg_state(struct intel_context *ce,
>  	GEM_BUG_ON(!intel_ring_offset_valid(ring, ring->head));
>  	GEM_BUG_ON(!intel_ring_offset_valid(ring, ring->tail));
>  
> -	regs[CTX_RING_BUFFER_START + 1] = i915_ggtt_offset(ring->vma);
> -	regs[CTX_RING_HEAD + 1] = ring->head;
> -	regs[CTX_RING_TAIL + 1] = ring->tail;
> +	regs[CTX_RING_BUFFER_START] = i915_ggtt_offset(ring->vma);
> +	regs[CTX_RING_HEAD] = ring->head;
> +	regs[CTX_RING_TAIL] = ring->tail;
>  
>  	/* RPCS */
>  	if (engine->class == RENDER_CLASS) {
> -		regs[CTX_R_PWR_CLK_STATE + 1] =
> +		regs[CTX_R_PWR_CLK_STATE] =
>  			intel_sseu_make_rpcs(engine->i915, &ce->sseu);
>  
> -		i915_oa_init_reg_state(engine, ce, regs);
> +		i915_oa_init_reg_state(ce, engine);
>  	}
>  }
>  
> @@ -2465,7 +2824,7 @@ static void __execlists_reset(struct intel_engine_cs *engine, bool stalled)
>  		       engine->pinned_default_state + LRC_STATE_PN * PAGE_SIZE,
>  		       engine->context_size - PAGE_SIZE);
>  	}
> -	execlists_init_reg_state(regs, ce, engine, ce->ring);
> +	execlists_init_reg_state(regs, ce, engine, ce->ring, false);
>  
>  out_replay:
>  	GEM_TRACE("%s replay {head:%04x, tail:%04x\n",
> @@ -3092,7 +3451,7 @@ void intel_execlists_set_default_submission(struct intel_engine_cs *engine)
>  			engine->flags |= I915_ENGINE_HAS_PREEMPTION;
>  	}
>  
> -	if (engine->class != COPY_ENGINE_CLASS && INTEL_GEN(engine->i915) >= 12)
> +	if (engine->class != COPY_ENGINE_CLASS && INTEL_GEN(engine->i915) >= 11)
>  		engine->flags |= I915_ENGINE_HAS_RELATIVE_MMIO;

Ok, first I thought this was unintentional. But prolly not.
Do you need it for the verifier to work?

Could we still rip it out to be a first in the series.
Just would want to differiante possible icl hickups apart
from this patch.

>  }
>  
> @@ -3243,7 +3602,7 @@ int intel_execlists_submission_init(struct intel_engine_cs *engine)
>  	return 0;
>  }
>  
> -static u32 intel_lr_indirect_ctx_offset(struct intel_engine_cs *engine)
> +static u32 intel_lr_indirect_ctx_offset(const struct intel_engine_cs *engine)
>  {
>  	u32 indirect_ctx_offset;
>  
> @@ -3278,75 +3637,48 @@ static u32 intel_lr_indirect_ctx_offset(struct intel_engine_cs *engine)
>  
>  
>  static void init_common_reg_state(u32 * const regs,
> -				  struct i915_ppgtt * const ppgtt,
> -				  struct intel_engine_cs *engine,
> -				  struct intel_ring *ring)
> +				  const struct intel_engine_cs *engine,
> +				  const struct intel_ring *ring)
>  {
> -	const u32 base = engine->mmio_base;
> -
> -	CTX_REG(regs, CTX_CONTEXT_CONTROL, RING_CONTEXT_CONTROL(base),
> +	regs[CTX_CONTEXT_CONTROL] =
>  		_MASKED_BIT_DISABLE(CTX_CTRL_ENGINE_CTX_RESTORE_INHIBIT) |
> -		_MASKED_BIT_ENABLE(CTX_CTRL_INHIBIT_SYN_CTX_SWITCH));
> -	if (INTEL_GEN(engine->i915) < 11) {
> -		regs[CTX_CONTEXT_CONTROL + 1] |=
> +		_MASKED_BIT_ENABLE(CTX_CTRL_INHIBIT_SYN_CTX_SWITCH);
> +	if (INTEL_GEN(engine->i915) < 11)
> +		regs[CTX_CONTEXT_CONTROL] |=
>  			_MASKED_BIT_DISABLE(CTX_CTRL_ENGINE_CTX_SAVE_INHIBIT |
>  					    CTX_CTRL_RS_CTX_ENABLE);
> -	}
> -	CTX_REG(regs, CTX_RING_HEAD, RING_HEAD(base), 0);
> -	CTX_REG(regs, CTX_RING_TAIL, RING_TAIL(base), 0);
> -	CTX_REG(regs, CTX_RING_BUFFER_START, RING_START(base), 0);
> -	CTX_REG(regs, CTX_RING_BUFFER_CONTROL, RING_CTL(base),
> -		RING_CTL_SIZE(ring->size) | RING_VALID);
> -	CTX_REG(regs, CTX_BB_HEAD_U, RING_BBADDR_UDW(base), 0);
> -	CTX_REG(regs, CTX_BB_HEAD_L, RING_BBADDR(base), 0);
> -	CTX_REG(regs, CTX_BB_STATE, RING_BBSTATE(base), RING_BB_PPGTT);
> +
> +	regs[CTX_RING_BUFFER_CONTROL] = RING_CTL_SIZE(ring->size) | RING_VALID;
> +	regs[CTX_BB_STATE] = RING_BB_PPGTT;
>  }
>  
>  static void init_wa_bb_reg_state(u32 * const regs,
> -				 struct intel_engine_cs *engine,
> +				 const struct intel_engine_cs *engine,
>  				 u32 pos_bb_per_ctx)
>  {
> -	struct i915_ctx_workarounds * const wa_ctx = &engine->wa_ctx;
> -	const u32 base = engine->mmio_base;
> -	const u32 pos_indirect_ctx = pos_bb_per_ctx + 2;
> -	const u32 pos_indirect_ctx_offset = pos_indirect_ctx + 2;
> +	const struct i915_ctx_workarounds * const wa_ctx = &engine->wa_ctx;
> +
> +	if (wa_ctx->per_ctx.size) {
> +		const u32 ggtt_offset = i915_ggtt_offset(wa_ctx->vma);
> +
> +		regs[pos_bb_per_ctx] =
> +			(ggtt_offset + wa_ctx->per_ctx.offset) | 0x01;
> +	}
>  
> -	CTX_REG(regs, pos_indirect_ctx, RING_INDIRECT_CTX(base), 0);
> -	CTX_REG(regs, pos_indirect_ctx_offset,
> -		RING_INDIRECT_CTX_OFFSET(base), 0);
>  	if (wa_ctx->indirect_ctx.size) {
>  		const u32 ggtt_offset = i915_ggtt_offset(wa_ctx->vma);
>  
> -		regs[pos_indirect_ctx + 1] =
> +		regs[pos_bb_per_ctx + 2] =
>  			(ggtt_offset + wa_ctx->indirect_ctx.offset) |
>  			(wa_ctx->indirect_ctx.size / CACHELINE_BYTES);
>  
> -		regs[pos_indirect_ctx_offset + 1] =
> +		regs[pos_bb_per_ctx + 4] =
>  			intel_lr_indirect_ctx_offset(engine) << 6;
>  	}
> -
> -	CTX_REG(regs, pos_bb_per_ctx, RING_BB_PER_CTX_PTR(base), 0);
> -	if (wa_ctx->per_ctx.size) {
> -		const u32 ggtt_offset = i915_ggtt_offset(wa_ctx->vma);
> -
> -		regs[pos_bb_per_ctx + 1] =
> -			(ggtt_offset + wa_ctx->per_ctx.offset) | 0x01;
> -	}
>  }
>  
> -static void init_ppgtt_reg_state(u32 *regs, u32 base,
> -				 struct i915_ppgtt *ppgtt)
> +static void init_ppgtt_reg_state(u32 *regs, const struct i915_ppgtt *ppgtt)
>  {
> -	/* PDP values well be assigned later if needed */
> -	CTX_REG(regs, CTX_PDP3_UDW, GEN8_RING_PDP_UDW(base, 3), 0);
> -	CTX_REG(regs, CTX_PDP3_LDW, GEN8_RING_PDP_LDW(base, 3), 0);
> -	CTX_REG(regs, CTX_PDP2_UDW, GEN8_RING_PDP_UDW(base, 2), 0);
> -	CTX_REG(regs, CTX_PDP2_LDW, GEN8_RING_PDP_LDW(base, 2), 0);
> -	CTX_REG(regs, CTX_PDP1_UDW, GEN8_RING_PDP_UDW(base, 1), 0);
> -	CTX_REG(regs, CTX_PDP1_LDW, GEN8_RING_PDP_LDW(base, 1), 0);
> -	CTX_REG(regs, CTX_PDP0_UDW, GEN8_RING_PDP_UDW(base, 0), 0);
> -	CTX_REG(regs, CTX_PDP0_LDW, GEN8_RING_PDP_LDW(base, 0), 0);
> -
>  	if (i915_vm_is_4lvl(&ppgtt->vm)) {
>  		/* 64b PPGTT (48bit canonical)
>  		 * PDP0_DESCRIPTOR contains the base address to PML4 and
> @@ -3369,91 +3701,11 @@ static struct i915_ppgtt *vm_alias(struct i915_address_space *vm)
>  		return i915_vm_to_ppgtt(vm);
>  }
>  
> -static void gen8_init_reg_state(u32 * const regs,
> -				struct intel_context *ce,
> -				struct intel_engine_cs *engine,
> -				struct intel_ring *ring)
> -{
> -	struct i915_ppgtt * const ppgtt = vm_alias(ce->vm);
> -	const bool rcs = engine->class == RENDER_CLASS;
> -	const u32 base = engine->mmio_base;
> -	const u32 lri_base =
> -		intel_engine_has_relative_mmio(engine) ? MI_LRI_CS_MMIO : 0;
> -
> -	regs[CTX_LRI_HEADER_0] =
> -		MI_LOAD_REGISTER_IMM(rcs ? 14 : 11) |
> -		MI_LRI_FORCE_POSTED |
> -		lri_base;
> -
> -	init_common_reg_state(regs, ppgtt, engine, ring);
> -	CTX_REG(regs, CTX_SECOND_BB_HEAD_U, RING_SBBADDR_UDW(base), 0);
> -	CTX_REG(regs, CTX_SECOND_BB_HEAD_L, RING_SBBADDR(base), 0);
> -	CTX_REG(regs, CTX_SECOND_BB_STATE, RING_SBBSTATE(base), 0);
> -	if (rcs)
> -		init_wa_bb_reg_state(regs, engine, CTX_BB_PER_CTX_PTR);
> -
> -	regs[CTX_LRI_HEADER_1] =
> -		MI_LOAD_REGISTER_IMM(9) |
> -		MI_LRI_FORCE_POSTED |
> -		lri_base;
> -
> -	CTX_REG(regs, CTX_CTX_TIMESTAMP, RING_CTX_TIMESTAMP(base), 0);
> -
> -	init_ppgtt_reg_state(regs, base, ppgtt);
> -
> -	if (rcs) {
> -		regs[CTX_LRI_HEADER_2] = MI_LOAD_REGISTER_IMM(1) | lri_base;
> -		CTX_REG(regs, CTX_R_PWR_CLK_STATE, GEN8_R_PWR_CLK_STATE, 0);
> -	}
> -
> -	regs[CTX_END] = MI_BATCH_BUFFER_END;
> -	if (INTEL_GEN(engine->i915) >= 10)
> -		regs[CTX_END] |= BIT(0);
> -}
> -
> -static void gen12_init_reg_state(u32 * const regs,
> -				 struct intel_context *ce,
> -				 struct intel_engine_cs *engine,
> -				 struct intel_ring *ring)
> -{
> -	struct i915_ppgtt * const ppgtt = i915_vm_to_ppgtt(ce->vm);
> -	const bool rcs = engine->class == RENDER_CLASS;
> -	const u32 base = engine->mmio_base;
> -	const u32 lri_base =
> -		intel_engine_has_relative_mmio(engine) ? MI_LRI_CS_MMIO : 0;
> -
> -	regs[CTX_LRI_HEADER_0] =
> -		MI_LOAD_REGISTER_IMM(rcs ? 11 : 9) |
> -		MI_LRI_FORCE_POSTED |
> -		lri_base;
> -
> -	init_common_reg_state(regs, ppgtt, engine, ring);
> -
> -	/* We want ctx_ptr for all engines to be set */
> -	init_wa_bb_reg_state(regs, engine, GEN12_CTX_BB_PER_CTX_PTR);
> -
> -	regs[CTX_LRI_HEADER_1] =
> -		MI_LOAD_REGISTER_IMM(9) |
> -		MI_LRI_FORCE_POSTED |
> -		lri_base;
> -
> -	CTX_REG(regs, CTX_CTX_TIMESTAMP, RING_CTX_TIMESTAMP(base), 0);
> -
> -	init_ppgtt_reg_state(regs, base, ppgtt);
> -
> -	if (rcs) {
> -		regs[GEN12_CTX_LRI_HEADER_3] =
> -			MI_LOAD_REGISTER_IMM(1) | lri_base;
> -		CTX_REG(regs, CTX_R_PWR_CLK_STATE, GEN8_R_PWR_CLK_STATE, 0);
> -
> -		/* TODO: oa_init_reg_state ? */
> -	}
> -}
> -
>  static void execlists_init_reg_state(u32 *regs,
> -				     struct intel_context *ce,
> -				     struct intel_engine_cs *engine,
> -				     struct intel_ring *ring)
> +				     const struct intel_context *ce,
> +				     const struct intel_engine_cs *engine,
> +				     const struct intel_ring *ring,
> +				     bool close)
>  {
>  	/*
>  	 * A context is actually a big batch buffer with several
> @@ -3465,10 +3717,21 @@ static void execlists_init_reg_state(u32 *regs,
>  	 *
>  	 * Must keep consistent with virtual_update_register_offsets().
>  	 */
> -	if (INTEL_GEN(engine->i915) >= 12)
> -		gen12_init_reg_state(regs, ce, engine, ring);
> -	else
> -		gen8_init_reg_state(regs, ce, engine, ring);
> +	u32 *bbe = set_offsets(regs, reg_offsets(engine), engine);
> +
> +	if (close) { /* Close the batch; used mainly by live_lrc_layout() */
> +		*bbe = MI_BATCH_BUFFER_END;
> +		if (INTEL_GEN(engine->i915) >= 10)
> +			*bbe |= BIT(0);
> +	}
> +
> +	init_common_reg_state(regs, engine, ring);
> +	init_ppgtt_reg_state(regs, vm_alias(ce->vm));
> +
> +	init_wa_bb_reg_state(regs, engine,
> +			     INTEL_GEN(engine->i915) >= 12 ?
> +			     GEN12_CTX_BB_PER_CTX_PTR :
> +			     CTX_BB_PER_CTX_PTR);
>  }
>  
>  static int
> @@ -3477,6 +3740,7 @@ populate_lr_context(struct intel_context *ce,
>  		    struct intel_engine_cs *engine,
>  		    struct intel_ring *ring)
>  {
> +	bool inhibit = true;
>  	void *vaddr;
>  	u32 *regs;
>  	int ret;
> @@ -3508,14 +3772,15 @@ populate_lr_context(struct intel_context *ce,
>  
>  		memcpy(vaddr + start, defaults + start, engine->context_size);
>  		i915_gem_object_unpin_map(engine->default_state);
> +		inhibit = false;
>  	}
>  
>  	/* The second page of the context object contains some fields which must
>  	 * be set up prior to the first execution. */
>  	regs = vaddr + LRC_STATE_PN * PAGE_SIZE;
> -	execlists_init_reg_state(regs, ce, engine, ring);
> -	if (!engine->default_state)
> -		regs[CTX_CONTEXT_CONTROL + 1] |=
> +	execlists_init_reg_state(regs, ce, engine, ring, inhibit);
> +	if (inhibit)
> +		regs[CTX_CONTEXT_CONTROL] |=
>  			_MASKED_BIT_ENABLE(CTX_CTRL_ENGINE_CTX_RESTORE_INHIBIT);
>  
>  	ret = 0;
> @@ -4212,7 +4477,7 @@ void intel_lr_context_reset(struct intel_engine_cs *engine,
>  			       engine->pinned_default_state + LRC_STATE_PN * PAGE_SIZE,
>  			       engine->context_size - PAGE_SIZE);
>  		}
> -		execlists_init_reg_state(regs, ce, engine, ce->ring);
> +		execlists_init_reg_state(regs, ce, engine, ce->ring, false);
>  	}
>  
>  	/* Rerun the request; its payload has been neutered (if guilty). */
> diff --git a/drivers/gpu/drm/i915/gt/intel_lrc_reg.h b/drivers/gpu/drm/i915/gt/intel_lrc_reg.h
> index 7e773e74a3fe..06ab0276e10e 100644
> --- a/drivers/gpu/drm/i915/gt/intel_lrc_reg.h
> +++ b/drivers/gpu/drm/i915/gt/intel_lrc_reg.h
> @@ -10,60 +10,40 @@
>  #include <linux/types.h>
>  
>  /* GEN8 to GEN11 Reg State Context */
> -#define CTX_LRI_HEADER_0		0x01
> -#define CTX_CONTEXT_CONTROL		0x02
> -#define CTX_RING_HEAD			0x04
> -#define CTX_RING_TAIL			0x06
> -#define CTX_RING_BUFFER_START		0x08
> -#define CTX_RING_BUFFER_CONTROL		0x0a
> -#define CTX_BB_HEAD_U			0x0c
> -#define CTX_BB_HEAD_L			0x0e
> -#define CTX_BB_STATE			0x10
> -#define CTX_SECOND_BB_HEAD_U		0x12
> -#define CTX_SECOND_BB_HEAD_L		0x14
> -#define CTX_SECOND_BB_STATE		0x16
> -#define CTX_BB_PER_CTX_PTR		0x18
> -#define CTX_RCS_INDIRECT_CTX		0x1a
> -#define CTX_RCS_INDIRECT_CTX_OFFSET	0x1c
> -#define CTX_LRI_HEADER_1		0x21
> -#define CTX_CTX_TIMESTAMP		0x22
> -#define CTX_PDP3_UDW			0x24
> -#define CTX_PDP3_LDW			0x26
> -#define CTX_PDP2_UDW			0x28
> -#define CTX_PDP2_LDW			0x2a
> -#define CTX_PDP1_UDW			0x2c
> -#define CTX_PDP1_LDW			0x2e
> -#define CTX_PDP0_UDW			0x30
> -#define CTX_PDP0_LDW			0x32
> -#define CTX_LRI_HEADER_2		0x41
> -#define CTX_R_PWR_CLK_STATE		0x42
> -#define CTX_END				0x44
> +#define CTX_CONTEXT_CONTROL		(0x02 + 1)
> +#define CTX_RING_HEAD			(0x04 + 1)
> +#define CTX_RING_TAIL			(0x06 + 1)
> +#define CTX_RING_BUFFER_START		(0x08 + 1)
> +#define CTX_RING_BUFFER_CONTROL		(0x0a + 1)
> +#define CTX_BB_STATE			(0x10 + 1)
> +#define CTX_BB_PER_CTX_PTR		(0x18 + 1)
> +#define CTX_PDP3_UDW			(0x24 + 1)
> +#define CTX_PDP3_LDW			(0x26 + 1)
> +#define CTX_PDP2_UDW			(0x28 + 1)
> +#define CTX_PDP2_LDW			(0x2a + 1)
> +#define CTX_PDP1_UDW			(0x2c + 1)
> +#define CTX_PDP1_LDW			(0x2e + 1)
> +#define CTX_PDP0_UDW			(0x30 + 1)
> +#define CTX_PDP0_LDW			(0x32 + 1)
> +#define CTX_R_PWR_CLK_STATE		(0x42 + 1)
>  
>  #define GEN9_CTX_RING_MI_MODE		0x54
>  
>  /* GEN12+ Reg State Context */
> -#define GEN12_CTX_BB_PER_CTX_PTR		0x12
> -#define GEN12_CTX_LRI_HEADER_3			0x41
> -
> -#define CTX_REG(reg_state, pos, reg, val) do { \
> -	u32 *reg_state__ = (reg_state); \
> -	const u32 pos__ = (pos); \
> -	(reg_state__)[(pos__) + 0] = i915_mmio_reg_offset(reg); \
> -	(reg_state__)[(pos__) + 1] = (val); \
> -} while (0)
> +#define GEN12_CTX_BB_PER_CTX_PTR		(0x12 + 1)
>  
>  #define ASSIGN_CTX_PDP(ppgtt, reg_state, n) do { \
>  	u32 *reg_state__ = (reg_state); \
>  	const u64 addr__ = i915_page_dir_dma_addr((ppgtt), (n)); \
> -	(reg_state__)[CTX_PDP ## n ## _UDW + 1] = upper_32_bits(addr__); \
> -	(reg_state__)[CTX_PDP ## n ## _LDW + 1] = lower_32_bits(addr__); \
> +	(reg_state__)[CTX_PDP ## n ## _UDW] = upper_32_bits(addr__); \
> +	(reg_state__)[CTX_PDP ## n ## _LDW] = lower_32_bits(addr__); \
>  } while (0)
>  
>  #define ASSIGN_CTX_PML4(ppgtt, reg_state) do { \
>  	u32 *reg_state__ = (reg_state); \
>  	const u64 addr__ = px_dma(ppgtt->pd); \
> -	(reg_state__)[CTX_PDP0_UDW + 1] = upper_32_bits(addr__); \
> -	(reg_state__)[CTX_PDP0_LDW + 1] = lower_32_bits(addr__); \
> +	(reg_state__)[CTX_PDP0_UDW] = upper_32_bits(addr__); \
> +	(reg_state__)[CTX_PDP0_LDW] = lower_32_bits(addr__); \
>  } while (0)
>  
>  #define GEN8_CTX_RCS_INDIRECT_CTX_OFFSET_DEFAULT	0x17
> diff --git a/drivers/gpu/drm/i915/gt/selftest_lrc.c b/drivers/gpu/drm/i915/gt/selftest_lrc.c
> index 93a871bfd95d..22ea2e747064 100644
> --- a/drivers/gpu/drm/i915/gt/selftest_lrc.c
> +++ b/drivers/gpu/drm/i915/gt/selftest_lrc.c
> @@ -2201,3 +2201,145 @@ int intel_execlists_live_selftests(struct drm_i915_private *i915)
>  
>  	return i915_live_subtests(tests, i915);
>  }
> +
> +static void hexdump(const void *buf, size_t len)
> +{
> +	const size_t rowsize = 8 * sizeof(u32);
> +	const void *prev = NULL;
> +	bool skip = false;
> +	size_t pos;
> +
> +	for (pos = 0; pos < len; pos += rowsize) {
> +		char line[128];
> +
> +		if (prev && !memcmp(prev, buf + pos, rowsize)) {
> +			if (!skip) {
> +				pr_info("*\n");
> +				skip = true;
> +			}
> +			continue;
> +		}
> +
> +		WARN_ON_ONCE(hex_dump_to_buffer(buf + pos, len - pos,
> +						rowsize, sizeof(u32),
> +						line, sizeof(line),
> +						false) >= sizeof(line));
> +		pr_info("[%04zx] %s\n", pos, line);
> +
> +		prev = buf + pos;
> +		skip = false;
> +	}
> +}
> +
> +static int live_lrc_layout(void *arg)
> +{
> +	struct intel_gt *gt = arg;
> +	struct intel_engine_cs *engine;
> +	enum intel_engine_id id;
> +	u32 *mem;
> +	int err;
> +
> +	/*
> +	 * Check the registers offsets we use to create the initial reg state
> +	 * match the layout saved by HW.
> +	 */
> +
> +	mem = kmalloc(PAGE_SIZE, GFP_KERNEL);
> +	if (!mem)
> +		return -ENOMEM;
> +
> +	err = 0;
> +	for_each_engine(engine, gt->i915, id) {
> +		u32 *hw, *lrc;
> +		int dw;
> +
> +		if (!engine->default_state)
> +			continue;
> +
> +		hw = i915_gem_object_pin_map(engine->default_state,
> +					     I915_MAP_WB);

This default state is not pristine as we have trampled
it with our first submission, right?

But being succeeded at doing so, the next context
save should overwrite our trampling and it would
then represent the hw accurate context save
state.

Against which we will compare of our reg state
writer.



> +		if (IS_ERR(hw)) {
> +			err = PTR_ERR(hw);
> +			break;
> +		}
> +		hw += LRC_STATE_PN * PAGE_SIZE / sizeof(*hw);
> +
> +		lrc = memset(mem, 0, PAGE_SIZE);
> +		execlists_init_reg_state(lrc,
> +					 engine->kernel_context,
> +					 engine,
> +					 engine->kernel_context->ring,
> +					 true);
> +
> +		dw = 0;
> +		do {
> +			u32 lri = hw[dw];
> +
> +			if (lri == 0) {
> +				dw++;
> +				continue;
> +			}
> +
> +			if ((lri & GENMASK(31, 23)) != MI_INSTR(0x22, 0)) {
> +				pr_err("%s: Expected LRI command at dword %d, found %08x\n",
> +				       engine->name, dw, lri);
> +				err = -EINVAL;
> +				break;
> +			}
> +
> +			if (lrc[dw] != lri) {
> +				pr_err("%s: LRI command mismatch at dword %d, expected %08x found %08x\n",
> +				       engine->name, dw, lri, lrc[dw]);
> +				err = -EINVAL;
> +				break;
> +			}
> +
> +			lri &= 0x7f;
> +			lri++;
> +			dw++;
> +
> +			while (lri) {
> +				if (hw[dw] != lrc[dw]) {
> +					pr_err("%s: Different registers found at dword %d, expected %x, found %x\n",
> +					       engine->name, dw, hw[dw], lrc[dw]);
> +					err = -EINVAL;
> +					break;
> +				}
> +
> +				/*
> +				 * Skip over the actual register value as we
> +				 * expect that to differ.
> +				 */
> +				dw += 2;
> +				lri -= 2;

This makes me wonder if we could use this machinery post hang. Just to
get a little more triage data out, ie 'your context looks corrupted at
offset %x'...

> +			}
> +		} while ((lrc[dw] & ~BIT(0)) != MI_BATCH_BUFFER_END);

Ok, you tie up always the generate image. For future work add the hw batch
endpoint be a part of checker?

-Mika

> +
> +		if (err) {
> +			pr_info("%s: HW register image:\n", engine->name);
> +			hexdump(hw, PAGE_SIZE);
> +
> +			pr_info("%s: SW register image:\n", engine->name);
> +			hexdump(lrc, PAGE_SIZE);
> +		}
> +
> +		i915_gem_object_unpin_map(engine->default_state);
> +		if (err)
> +			break;
> +	}
> +
> +	kfree(mem);
> +	return err;
> +}
> +
> +int intel_lrc_live_selftests(struct drm_i915_private *i915)
> +{
> +	static const struct i915_subtest tests[] = {
> +		SUBTEST(live_lrc_layout),
> +	};
> +
> +	if (!HAS_LOGICAL_RING_CONTEXTS(i915))
> +		return 0;
> +
> +	return intel_gt_live_subtests(tests, &i915->gt);
> +}
> diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c
> index c1b764233761..524f6710b7aa 100644
> --- a/drivers/gpu/drm/i915/i915_perf.c
> +++ b/drivers/gpu/drm/i915/i915_perf.c
> @@ -1673,10 +1673,8 @@ static u32 oa_config_flex_reg(const struct i915_oa_config *oa_config,
>   * in the case that the OA unit has been disabled.
>   */
>  static void
> -gen8_update_reg_state_unlocked(struct i915_perf_stream *stream,
> -			       struct intel_context *ce,
> -			       u32 *reg_state,
> -			       const struct i915_oa_config *oa_config)
> +gen8_update_reg_state_unlocked(const struct intel_context *ce,
> +			       const struct i915_perf_stream *stream)
>  {
>  	struct drm_i915_private *i915 = ce->engine->i915;
>  	u32 ctx_oactxctrl = i915->perf.ctx_oactxctrl_offset;
> @@ -1691,21 +1689,19 @@ gen8_update_reg_state_unlocked(struct i915_perf_stream *stream,
>  		EU_PERF_CNTL5,
>  		EU_PERF_CNTL6,
>  	};
> +	u32 *reg_state = ce->lrc_reg_state;
>  	int i;
>  
> -	CTX_REG(reg_state, ctx_oactxctrl, GEN8_OACTXCONTROL,
> +	reg_state[ctx_oactxctrl + 1] =
>  		(stream->period_exponent << GEN8_OA_TIMER_PERIOD_SHIFT) |
>  		(stream->periodic ? GEN8_OA_TIMER_ENABLE : 0) |
> -		GEN8_OA_COUNTER_RESUME);
> +		GEN8_OA_COUNTER_RESUME;
>  
> -	for (i = 0; i < ARRAY_SIZE(flex_regs); i++) {
> -		CTX_REG(reg_state, ctx_flexeu0 + i * 2, flex_regs[i],
> -			oa_config_flex_reg(oa_config, flex_regs[i]));
> -	}
> +	for (i = 0; i < ARRAY_SIZE(flex_regs); i++)
> +		reg_state[ctx_flexeu0 + i * 2 + 1] =
> +			oa_config_flex_reg(stream->oa_config, flex_regs[i]);
>  
> -	CTX_REG(reg_state,
> -		CTX_R_PWR_CLK_STATE, GEN8_R_PWR_CLK_STATE,
> -		intel_sseu_make_rpcs(i915, &ce->sseu));
> +	reg_state[CTX_R_PWR_CLK_STATE] = intel_sseu_make_rpcs(i915, &ce->sseu);
>  }
>  
>  struct flex {
> @@ -1729,7 +1725,7 @@ gen8_store_flex(struct i915_request *rq,
>  	offset = i915_ggtt_offset(ce->state) + LRC_STATE_PN * PAGE_SIZE;
>  	do {
>  		*cs++ = MI_STORE_DWORD_IMM_GEN4 | MI_USE_GGTT;
> -		*cs++ = offset + (flex->offset + 1) * sizeof(u32);
> +		*cs++ = offset + flex->offset * sizeof(u32);
>  		*cs++ = 0;
>  		*cs++ = flex->value;
>  	} while (flex++, --count);
> @@ -1863,7 +1859,7 @@ static int gen8_configure_all_contexts(struct i915_perf_stream *stream,
>  	struct drm_i915_private *i915 = stream->dev_priv;
>  	/* The MMIO offsets for Flex EU registers aren't contiguous */
>  	const u32 ctx_flexeu0 = i915->perf.ctx_flexeu0_offset;
> -#define ctx_flexeuN(N) (ctx_flexeu0 + 2 * (N))
> +#define ctx_flexeuN(N) (ctx_flexeu0 + 2 * (N) + 1)
>  	struct flex regs[] = {
>  		{
>  			GEN8_R_PWR_CLK_STATE,
> @@ -1871,7 +1867,7 @@ static int gen8_configure_all_contexts(struct i915_perf_stream *stream,
>  		},
>  		{
>  			GEN8_OACTXCONTROL,
> -			i915->perf.ctx_oactxctrl_offset,
> +			i915->perf.ctx_oactxctrl_offset + 1,
>  			((stream->period_exponent << GEN8_OA_TIMER_PERIOD_SHIFT) |
>  			 (stream->periodic ? GEN8_OA_TIMER_ENABLE : 0) |
>  			 GEN8_OA_COUNTER_RESUME)
> @@ -2299,9 +2295,8 @@ static int i915_oa_stream_init(struct i915_perf_stream *stream,
>  	return ret;
>  }
>  
> -void i915_oa_init_reg_state(struct intel_engine_cs *engine,
> -			    struct intel_context *ce,
> -			    u32 *regs)
> +void i915_oa_init_reg_state(const struct intel_context *ce,
> +			    const struct intel_engine_cs *engine)
>  {
>  	struct i915_perf_stream *stream;
>  
> @@ -2313,7 +2308,7 @@ void i915_oa_init_reg_state(struct intel_engine_cs *engine,
>  
>  	stream = engine->i915->perf.exclusive_stream;
>  	if (stream)
> -		gen8_update_reg_state_unlocked(stream, ce, regs, stream->oa_config);
> +		gen8_update_reg_state_unlocked(ce, stream);
>  }
>  
>  /**
> diff --git a/drivers/gpu/drm/i915/i915_perf.h b/drivers/gpu/drm/i915/i915_perf.h
> index a412b16d9ffc..f4fb311184b1 100644
> --- a/drivers/gpu/drm/i915/i915_perf.h
> +++ b/drivers/gpu/drm/i915/i915_perf.h
> @@ -25,8 +25,7 @@ int i915_perf_add_config_ioctl(struct drm_device *dev, void *data,
>  			       struct drm_file *file);
>  int i915_perf_remove_config_ioctl(struct drm_device *dev, void *data,
>  				  struct drm_file *file);
> -void i915_oa_init_reg_state(struct intel_engine_cs *engine,
> -			    struct intel_context *ce,
> -			    u32 *reg_state);
> +void i915_oa_init_reg_state(const struct intel_context *ce,
> +			    const struct intel_engine_cs *engine);
>  
>  #endif /* __I915_PERF_H__ */
> diff --git a/drivers/gpu/drm/i915/selftests/i915_live_selftests.h b/drivers/gpu/drm/i915/selftests/i915_live_selftests.h
> index 1ccf0f731ac0..66d83c1390c1 100644
> --- a/drivers/gpu/drm/i915/selftests/i915_live_selftests.h
> +++ b/drivers/gpu/drm/i915/selftests/i915_live_selftests.h
> @@ -15,6 +15,7 @@ selftest(workarounds, intel_workarounds_live_selftests)
>  selftest(gt_engines, intel_engine_live_selftests)
>  selftest(gt_timelines, intel_timeline_live_selftests)
>  selftest(gt_contexts, intel_context_live_selftests)
> +selftest(gt_lrc, intel_lrc_live_selftests)
>  selftest(requests, i915_request_live_selftests)
>  selftest(active, i915_active_live_selftests)
>  selftest(objects, i915_gem_object_live_selftests)
> -- 
> 2.23.0
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 1/2] drm/i915/selftests: Verify the LRC register layout between init and HW
  2019-09-24 10:21 ` [PATCH 1/2] drm/i915/selftests: Verify the LRC register layout between init and HW Mika Kuoppala
@ 2019-09-24 10:43   ` Chris Wilson
  2019-09-24 15:07     ` Mika Kuoppala
  2019-09-24 11:00   ` Chris Wilson
  1 sibling, 1 reply; 22+ messages in thread
From: Chris Wilson @ 2019-09-24 10:43 UTC (permalink / raw)
  To: Mika Kuoppala, intel-gfx

Quoting Mika Kuoppala (2019-09-24 11:21:38)
> Chris Wilson <chris@chris-wilson.co.uk> writes:
> 
> > Before we submit the first context to HW, we need to construct a valid
> > image of the register state. This layout is defined by the HW and should
> > match the layout generated by HW when it saves the context image.
> > Asserting that this should be equivalent should help avoid any undefined
> > behaviour and verify that we haven't missed anything important!
> >
> > Of course, having insisted that the initial register state within the
> > LRC should match that returned by HW, we need to ensure that it does.
> >
> > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> > Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
> > Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>

> > +static u32 *set_offsets(u32 *regs,
> > +                     const u8 *data,
> > +                     const struct intel_engine_cs *engine)
> > +#define NOP(x) (BIT(7) | (x))
> > +#define LRI(count, flags) ((flags) << 6 | (count))
> > +#define POSTED BIT(0)
> > +#define REG(x) (((x) >> 2) | BUILD_BUG_ON_ZERO(x >= 0x200))
> > +#define REG16(x) \
> > +     (((x) >> 9) | BIT(7) | BUILD_BUG_ON_ZERO(x >= 0x10000)), \
> > +     (((x) >> 2) & 0x7f)
> 
> I am still not sure if the actual saving are worth the complexity.
> 
> > +#define END() 0
> > +{
> > +     const u32 base = engine->mmio_base;
> > +
> > +     while (*data) {
> > +             u8 count, flags;
> > +
> > +             if (*data & BIT(7)) { /* skip */
> > +                     regs += *data++ & ~BIT(7);
> > +                     continue;
> > +             }
> > +
> > +             count = *data & 0x3f;
> > +             flags = *data >> 6;
> > +             data++;
> > +
> > +             *regs = MI_LOAD_REGISTER_IMM(count);
> > +             if (flags & POSTED)
> > +                     *regs |= MI_LRI_FORCE_POSTED;
> > +             if (INTEL_GEN(engine->i915) >= 11)
> > +                     *regs |= MI_LRI_CS_MMIO;
> > +             regs++;
> > +
> > +             GEM_BUG_ON(!count);
> > +             do {
> > +                     u32 offset = 0;
> > +                     u8 v;
> > +
> > +                     do {
> > +                             v = *data++;
> > +                             offset <<= 7;
> > +                             offset |= v & ~BIT(7);
> > +                     } while (v & BIT(7));
> 
> ...but perhaps this amount of extra can be tolerated.
> 
> Did you check how this would play out with just REG being wide enough?

When I started, I thought we could get away with only one REG16. Looking
at the context image I think we might want a few non engine->mmio_base
regs in there (if I read it right, some of the 0x4000 range are per
engine). That will need a slightly different encoding as well :|

No, I haven't but since you ask, I shall.

> > +
> > +                     *regs = base + (offset << 2);
> 
> In here reader is yearning for an asserts of not trampling
> on wrong territory.

If you have an idea for a good assert, go for it :)

What range should be checked. offset < 0x1000 ?

> But I would guess that you want this part to be like
> oiled lightning and test the machinery with selftest..as the
> subject seems to promise.

The importance is certainly placed on having a selftest and the
confidence in keeping our offsets in line with the HW. The goal was to
have a compact description for the register offsets, in terms of
readability I think the emphasis should be on the tables
(gen8_xcs_offsets[]).

> > @@ -3092,7 +3451,7 @@ void intel_execlists_set_default_submission(struct intel_engine_cs *engine)
> >                       engine->flags |= I915_ENGINE_HAS_PREEMPTION;
> >       }
> >  
> > -     if (engine->class != COPY_ENGINE_CLASS && INTEL_GEN(engine->i915) >= 12)
> > +     if (engine->class != COPY_ENGINE_CLASS && INTEL_GEN(engine->i915) >= 11)
> >               engine->flags |= I915_ENGINE_HAS_RELATIVE_MMIO;
> 
> Ok, first I thought this was unintentional. But prolly not.
> Do you need it for the verifier to work?

No, I ended up completely ignoring this flag as the HW does not
differentiate between engines. On gen11+, it sets the LRI flag everywhere
in the context image.

> Could we still rip it out to be a first in the series.
> Just would want to differiante possible icl hickups apart
> from this patch.

Sure.

> > +static int live_lrc_layout(void *arg)
> > +{
> > +     struct intel_gt *gt = arg;
> > +     struct intel_engine_cs *engine;
> > +     enum intel_engine_id id;
> > +     u32 *mem;
> > +     int err;
> > +
> > +     /*
> > +      * Check the registers offsets we use to create the initial reg state
> > +      * match the layout saved by HW.
> > +      */
> > +
> > +     mem = kmalloc(PAGE_SIZE, GFP_KERNEL);
> > +     if (!mem)
> > +             return -ENOMEM;
> > +
> > +     err = 0;
> > +     for_each_engine(engine, gt->i915, id) {
> > +             u32 *hw, *lrc;
> > +             int dw;
> > +
> > +             if (!engine->default_state)
> > +                     continue;
> > +
> > +             hw = i915_gem_object_pin_map(engine->default_state,
> > +                                          I915_MAP_WB);
> 
> This default state is not pristine as we have trampled
> it with our first submission, right?

It is the context image saved after the first request.
 
> But being succeeded at doing so, the next context
> save should overwrite our trampling and it would
> then represent the hw accurate context save
> state.
> 
> Against which we will compare of our reg state
> writer.

Right, default_state is the HW version of our init_reg_state.

> > +             if (IS_ERR(hw)) {
> > +                     err = PTR_ERR(hw);
> > +                     break;
> > +             }
> > +             hw += LRC_STATE_PN * PAGE_SIZE / sizeof(*hw);
> > +
> > +             lrc = memset(mem, 0, PAGE_SIZE);
> > +             execlists_init_reg_state(lrc,
> > +                                      engine->kernel_context,
> > +                                      engine,
> > +                                      engine->kernel_context->ring,
> > +                                      true);
> > +
> > +             dw = 0;
> > +             do {
> > +                     u32 lri = hw[dw];
> > +
> > +                     if (lri == 0) {
> > +                             dw++;
> > +                             continue;
> > +                     }
> > +
> > +                     if ((lri & GENMASK(31, 23)) != MI_INSTR(0x22, 0)) {
> > +                             pr_err("%s: Expected LRI command at dword %d, found %08x\n",
> > +                                    engine->name, dw, lri);
> > +                             err = -EINVAL;
> > +                             break;
> > +                     }
> > +
> > +                     if (lrc[dw] != lri) {
> > +                             pr_err("%s: LRI command mismatch at dword %d, expected %08x found %08x\n",
> > +                                    engine->name, dw, lri, lrc[dw]);
> > +                             err = -EINVAL;
> > +                             break;
> > +                     }
> > +
> > +                     lri &= 0x7f;
> > +                     lri++;
> > +                     dw++;
> > +
> > +                     while (lri) {
> > +                             if (hw[dw] != lrc[dw]) {
> > +                                     pr_err("%s: Different registers found at dword %d, expected %x, found %x\n",
> > +                                            engine->name, dw, hw[dw], lrc[dw]);
> > +                                     err = -EINVAL;
> > +                                     break;
> > +                             }
> > +
> > +                             /*
> > +                              * Skip over the actual register value as we
> > +                              * expect that to differ.
> > +                              */
> > +                             dw += 2;
> > +                             lri -= 2;
> 
> This makes me wonder if we could use this machinery post hang. Just to
> get a little more triage data out, ie 'your context looks corrupted at
> offset %x'...

Certainly possible, but what we check here is _mostly_ the privileged
registers that are not really meant to be changed by the user -- and we
are only checking the offsets, so unlikely there to be just one wrong.

The general principle was that we should provide raw information and
have the smarts in userspace (so that we could always enhance our
processing and reanalyse existing dumps). But at the end of the day,
whatever allows us to prevent bugs or fix bugs is paramount.

But I'm not yet sold this helps. Maybe if we find an example where it
proves useful...

> > +                     }
> > +             } while ((lrc[dw] & ~BIT(0)) != MI_BATCH_BUFFER_END);
> 
> Ok, you tie up always the generate image. For future work add the hw batch
> endpoint be a part of checker?

It's not always in the first page, I'm not even sure if a BB_END is
always included in the older gen. (I have a feeling the HW definitely
started including it ~gen10.)
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 1/2] drm/i915/selftests: Verify the LRC register layout between init and HW
  2019-09-24 10:21 ` [PATCH 1/2] drm/i915/selftests: Verify the LRC register layout between init and HW Mika Kuoppala
  2019-09-24 10:43   ` Chris Wilson
@ 2019-09-24 11:00   ` Chris Wilson
  2019-09-24 11:58     ` Mika Kuoppala
  1 sibling, 1 reply; 22+ messages in thread
From: Chris Wilson @ 2019-09-24 11:00 UTC (permalink / raw)
  To: Mika Kuoppala, intel-gfx

Quoting Mika Kuoppala (2019-09-24 11:21:38)
> Chris Wilson <chris@chris-wilson.co.uk> writes:
> > +static u32 *set_offsets(u32 *regs,
> > +                     const u8 *data,
> > +                     const struct intel_engine_cs *engine)
> > +#define NOP(x) (BIT(7) | (x))
> > +#define LRI(count, flags) ((flags) << 6 | (count))
> > +#define POSTED BIT(0)
> > +#define REG(x) (((x) >> 2) | BUILD_BUG_ON_ZERO(x >= 0x200))
> > +#define REG16(x) \
> > +     (((x) >> 9) | BIT(7) | BUILD_BUG_ON_ZERO(x >= 0x10000)), \
> > +     (((x) >> 2) & 0x7f)
> 
> I am still not sure if the actual saving are worth the complexity.
> 
> > +#define END() 0
> > +{
> > +     const u32 base = engine->mmio_base;
> > +
> > +     while (*data) {
> > +             u8 count, flags;
> > +
> > +             if (*data & BIT(7)) { /* skip */
> > +                     regs += *data++ & ~BIT(7);
> > +                     continue;
> > +             }
> > +
> > +             count = *data & 0x3f;
> > +             flags = *data >> 6;
> > +             data++;
> > +
> > +             *regs = MI_LOAD_REGISTER_IMM(count);
> > +             if (flags & POSTED)
> > +                     *regs |= MI_LRI_FORCE_POSTED;
> > +             if (INTEL_GEN(engine->i915) >= 11)
> > +                     *regs |= MI_LRI_CS_MMIO;
> > +             regs++;
> > +
> > +             GEM_BUG_ON(!count);
> > +             do {
> > +                     u32 offset = 0;
> > +                     u8 v;
> > +
> > +                     do {
> > +                             v = *data++;
> > +                             offset <<= 7;
> > +                             offset |= v & ~BIT(7);
> > +                     } while (v & BIT(7));
> 
> ...but perhaps this amount of extra can be tolerated.
> 
> Did you check how this would play out with just REG being wide enough?

Function                                     old     new   delta
gen9_xcs_offsets                             122     145     +23
gen12_xcs_offsets                            136     157     +21
gen11_rcs_offsets                             44      60     +16
gen8_rcs_offsets                              41      55     +14
gen12_rcs_offsets                             47      60     +13
gen8_xcs_offsets                              40      51     +11
set_offsets.isra                             215     179     -36
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 1/2] drm/i915/selftests: Verify the LRC register layout between init and HW
  2019-09-24 11:00   ` Chris Wilson
@ 2019-09-24 11:58     ` Mika Kuoppala
  0 siblings, 0 replies; 22+ messages in thread
From: Mika Kuoppala @ 2019-09-24 11:58 UTC (permalink / raw)
  To: Chris Wilson, intel-gfx

Chris Wilson <chris@chris-wilson.co.uk> writes:

> Quoting Mika Kuoppala (2019-09-24 11:21:38)
>> Did you check how this would play out with just REG being wide enough?
> Function                                     old     new   delta
> gen9_xcs_offsets                             122     145     +23
> gen12_xcs_offsets                            136     157     +21
> gen11_rcs_offsets                             44      60     +16
> gen8_rcs_offsets                              41      55     +14
> gen12_rcs_offsets                             47      60     +13
> gen8_xcs_offsets                              40      51     +11
> set_offsets.isra                             215     179     -36
> -Chris

Thanks for getting the numbers,
-Mika
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 22+ messages in thread

* ✗ Fi.CI.CHECKPATCH: warning for series starting with [1/2] drm/i915/selftests: Verify the LRC register layout between init and HW (rev3)
  2019-09-23 23:02 [PATCH 1/2] drm/i915/selftests: Verify the LRC register layout between init and HW Chris Wilson
                   ` (5 preceding siblings ...)
  2019-09-24 10:21 ` [PATCH 1/2] drm/i915/selftests: Verify the LRC register layout between init and HW Mika Kuoppala
@ 2019-09-24 13:23 ` Patchwork
  2019-09-24 13:48 ` ✓ Fi.CI.BAT: success " Patchwork
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 22+ messages in thread
From: Patchwork @ 2019-09-24 13:23 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: series starting with [1/2] drm/i915/selftests: Verify the LRC register layout between init and HW (rev3)
URL   : https://patchwork.freedesktop.org/series/67135/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
04c615713c10 drm/i915/selftests: Verify the LRC register layout between init and HW
-:61: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'x' - possible side-effects?
#61: FILE: drivers/gpu/drm/i915/gt/intel_lrc.c:481:
+#define REG(x) (((x) >> 2) | BUILD_BUG_ON_ZERO(x >= 0x200))

-:62: ERROR:COMPLEX_MACRO: Macros with complex values should be enclosed in parentheses
#62: FILE: drivers/gpu/drm/i915/gt/intel_lrc.c:482:
+#define REG16(x) \
+	(((x) >> 9) | BIT(7) | BUILD_BUG_ON_ZERO(x >= 0x10000)), \
+	(((x) >> 2) & 0x7f)

-:62: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'x' - possible side-effects?
#62: FILE: drivers/gpu/drm/i915/gt/intel_lrc.c:482:
+#define REG16(x) \
+	(((x) >> 9) | BIT(7) | BUILD_BUG_ON_ZERO(x >= 0x10000)), \
+	(((x) >> 2) & 0x7f)

total: 1 errors, 0 warnings, 2 checks, 1125 lines checked
210943331ffe drm/i915/tgl: Swap engines for no rc6/rps (gpu powersave and reclocking)

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

^ permalink raw reply	[flat|nested] 22+ messages in thread

* ✓ Fi.CI.BAT: success for series starting with [1/2] drm/i915/selftests: Verify the LRC register layout between init and HW (rev3)
  2019-09-23 23:02 [PATCH 1/2] drm/i915/selftests: Verify the LRC register layout between init and HW Chris Wilson
                   ` (6 preceding siblings ...)
  2019-09-24 13:23 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [1/2] drm/i915/selftests: Verify the LRC register layout between init and HW (rev3) Patchwork
@ 2019-09-24 13:48 ` Patchwork
  2019-09-24 13:58   ` Chris Wilson
  2019-09-24 14:59 ` [PATCH v2] drm/i915/selftests: Verify the LRC register layout between init and HW Chris Wilson
                   ` (3 subsequent siblings)
  11 siblings, 1 reply; 22+ messages in thread
From: Patchwork @ 2019-09-24 13:48 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: series starting with [1/2] drm/i915/selftests: Verify the LRC register layout between init and HW (rev3)
URL   : https://patchwork.freedesktop.org/series/67135/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_6948 -> Patchwork_14514
====================================================

Summary
-------

  **SUCCESS**

  No regressions found.

  External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14514/

New tests
---------

  New tests have been introduced between CI_DRM_6948 and Patchwork_14514:

### New IGT tests (1) ###

  * igt@i915_selftest@live_gt_lrc:
    - Statuses : 42 pass(s)
    - Exec time: [0.36, 2.17] s

  

Known issues
------------

  Here are the changes found in Patchwork_14514 that come from known issues:

### IGT changes ###

#### Issues hit ####

  * igt@gem_ctx_create@basic-files:
    - fi-bxt-dsi:         [PASS][1] -> [INCOMPLETE][2] ([fdo#103927])
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6948/fi-bxt-dsi/igt@gem_ctx_create@basic-files.html
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14514/fi-bxt-dsi/igt@gem_ctx_create@basic-files.html
    - fi-apl-guc:         [PASS][3] -> [INCOMPLETE][4] ([fdo#103927])
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6948/fi-apl-guc/igt@gem_ctx_create@basic-files.html
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14514/fi-apl-guc/igt@gem_ctx_create@basic-files.html

  * igt@kms_chamelium@hdmi-hpd-fast:
    - fi-kbl-7500u:       [PASS][5] -> [FAIL][6] ([fdo#111045] / [fdo#111096])
   [5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6948/fi-kbl-7500u/igt@kms_chamelium@hdmi-hpd-fast.html
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14514/fi-kbl-7500u/igt@kms_chamelium@hdmi-hpd-fast.html

  
#### Possible fixes ####

  * igt@gem_exec_suspend@basic-s4-devices:
    - fi-blb-e6850:       [INCOMPLETE][7] ([fdo#107718]) -> [PASS][8]
   [7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6948/fi-blb-e6850/igt@gem_exec_suspend@basic-s4-devices.html
   [8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14514/fi-blb-e6850/igt@gem_exec_suspend@basic-s4-devices.html

  * igt@gem_tiled_fence_blits@basic:
    - {fi-tgl-u}:         [SKIP][9] ([fdo#111714]) -> [PASS][10] +2 similar issues
   [9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6948/fi-tgl-u/igt@gem_tiled_fence_blits@basic.html
   [10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14514/fi-tgl-u/igt@gem_tiled_fence_blits@basic.html

  * igt@kms_frontbuffer_tracking@basic:
    - {fi-tgl-u}:         [FAIL][11] ([fdo#111604]) -> [PASS][12]
   [11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6948/fi-tgl-u/igt@kms_frontbuffer_tracking@basic.html
   [12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14514/fi-tgl-u/igt@kms_frontbuffer_tracking@basic.html

  
  {name}: This element is suppressed. This means it is ignored when computing
          the status of the difference (SUCCESS, WARNING, or FAILURE).

  [fdo#103927]: https://bugs.freedesktop.org/show_bug.cgi?id=103927
  [fdo#107713]: https://bugs.freedesktop.org/show_bug.cgi?id=107713
  [fdo#107718]: https://bugs.freedesktop.org/show_bug.cgi?id=107718
  [fdo#109100]: https://bugs.freedesktop.org/show_bug.cgi?id=109100
  [fdo#111045]: https://bugs.freedesktop.org/show_bug.cgi?id=111045
  [fdo#111096]: https://bugs.freedesktop.org/show_bug.cgi?id=111096
  [fdo#111604]: https://bugs.freedesktop.org/show_bug.cgi?id=111604
  [fdo#111714]: https://bugs.freedesktop.org/show_bug.cgi?id=111714
  [fdo#111718]: https://bugs.freedesktop.org/show_bug.cgi?id=111718


Participating hosts (52 -> 45)
------------------------------

  Additional (1): fi-icl-dsi 
  Missing    (8): fi-ilk-m540 fi-hsw-4200u fi-tgl-u2 fi-byt-squawks fi-bsw-cyan fi-icl-y fi-byt-clapper fi-bdw-samus 


Build changes
-------------

  * CI: CI-20190529 -> None
  * Linux: CI_DRM_6948 -> Patchwork_14514

  CI-20190529: 20190529
  CI_DRM_6948: 485ca160d8ffac7ffb5be5e76fa12ad46a7e5a19 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGT_5201: 3c1633abec14679300d52eeaf9fb7b63e435e51e @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_14514: 210943331ffe218976fe1680be9203b2a63c9f90 @ git://anongit.freedesktop.org/gfx-ci/linux


== Linux commits ==

210943331ffe drm/i915/tgl: Swap engines for no rc6/rps (gpu powersave and reclocking)
04c615713c10 drm/i915/selftests: Verify the LRC register layout between init and HW

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14514/index.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: ✓ Fi.CI.BAT: success for series starting with [1/2] drm/i915/selftests: Verify the LRC register layout between init and HW (rev3)
  2019-09-24 13:48 ` ✓ Fi.CI.BAT: success " Patchwork
@ 2019-09-24 13:58   ` Chris Wilson
  0 siblings, 0 replies; 22+ messages in thread
From: Chris Wilson @ 2019-09-24 13:58 UTC (permalink / raw)
  To: Patchwork; +Cc: intel-gfx

Quoting Patchwork (2019-09-24 14:48:50)
> == Series Details ==
> 
> Series: series starting with [1/2] drm/i915/selftests: Verify the LRC register layout between init and HW (rev3)
> URL   : https://patchwork.freedesktop.org/series/67135/
> State : success
> 
> == Summary ==
> 
> CI Bug Log - changes from CI_DRM_6948 -> Patchwork_14514
> ====================================================
> 
> Summary
> -------
> 
>   **SUCCESS**
> 
>   No regressions found.
> 
>   External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14514/

That time fi-tgl-u was happy. I've stolen its heart.
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH v2] drm/i915/selftests: Verify the LRC register layout between init and HW
  2019-09-23 23:02 [PATCH 1/2] drm/i915/selftests: Verify the LRC register layout between init and HW Chris Wilson
                   ` (7 preceding siblings ...)
  2019-09-24 13:48 ` ✓ Fi.CI.BAT: success " Patchwork
@ 2019-09-24 14:59 ` Chris Wilson
  2019-09-24 15:04   ` Chris Wilson
  2019-09-24 15:57 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [v2] drm/i915/selftests: Verify the LRC register layout between init and HW (rev5) Patchwork
                   ` (2 subsequent siblings)
  11 siblings, 1 reply; 22+ messages in thread
From: Chris Wilson @ 2019-09-24 14:59 UTC (permalink / raw)
  To: intel-gfx

Before we submit the first context to HW, we need to construct a valid
image of the register state. This layout is defined by the HW and should
match the layout generated by HW when it saves the context image.
Asserting that this should be equivalent should help avoid any undefined
behaviour and verify that we haven't missed anything important!

Of course, having insisted that the initial register state within the
LRC should match that returned by HW, we need to ensure that it does.

v2: Drop the RELATIVE_MMIO flag from gen11, we ignore it for
constructing the lrc image.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
---
 drivers/gpu/drm/i915/gem/i915_gem_context.c   |   2 +-
 drivers/gpu/drm/i915/gt/intel_lrc.c           | 667 ++++++++++++------
 drivers/gpu/drm/i915/gt/intel_lrc_reg.h       |  62 +-
 drivers/gpu/drm/i915/gt/selftest_lrc.c        | 142 ++++
 drivers/gpu/drm/i915/i915_perf.c              |  35 +-
 drivers/gpu/drm/i915/i915_perf.h              |   5 +-
 .../drm/i915/selftests/i915_live_selftests.h  |   1 +
 7 files changed, 648 insertions(+), 266 deletions(-)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c
index 4a34c4f62065..f7ba0935ed67 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
@@ -1115,7 +1115,7 @@ static int gen8_emit_rpcs_config(struct i915_request *rq,
 
 	offset = i915_ggtt_offset(ce->state) +
 		 LRC_STATE_PN * PAGE_SIZE +
-		 (CTX_R_PWR_CLK_STATE + 1) * 4;
+		 CTX_R_PWR_CLK_STATE * 4;
 
 	*cs++ = MI_STORE_DWORD_IMM_GEN4 | MI_USE_GGTT;
 	*cs++ = lower_32_bits(offset);
diff --git a/drivers/gpu/drm/i915/gt/intel_lrc.c b/drivers/gpu/drm/i915/gt/intel_lrc.c
index 6cfdc0f9f2b9..caac091b3eb9 100644
--- a/drivers/gpu/drm/i915/gt/intel_lrc.c
+++ b/drivers/gpu/drm/i915/gt/intel_lrc.c
@@ -230,9 +230,10 @@ static int __execlists_context_alloc(struct intel_context *ce,
 				     struct intel_engine_cs *engine);
 
 static void execlists_init_reg_state(u32 *reg_state,
-				     struct intel_context *ce,
-				     struct intel_engine_cs *engine,
-				     struct intel_ring *ring);
+				     const struct intel_context *ce,
+				     const struct intel_engine_cs *engine,
+				     const struct intel_ring *ring,
+				     bool close);
 
 static void mark_eio(struct i915_request *rq)
 {
@@ -471,6 +472,411 @@ lrc_descriptor(struct intel_context *ce, struct intel_engine_cs *engine)
 	return desc;
 }
 
+static u32 *set_offsets(u32 *regs,
+			const u8 *data,
+			const struct intel_engine_cs *engine)
+#define NOP(x) (BIT(7) | (x))
+#define LRI(count, flags) ((flags) << 6 | (count))
+#define POSTED BIT(0)
+#define REG(x) (((x) >> 2) | BUILD_BUG_ON_ZERO(x >= 0x200))
+#define REG16(x) \
+	(((x) >> 9) | BIT(7) | BUILD_BUG_ON_ZERO(x >= 0x10000)), \
+	(((x) >> 2) & 0x7f)
+#define END() 0
+{
+	const u32 base = engine->mmio_base;
+
+	while (*data) {
+		u8 count, flags;
+
+		if (*data & BIT(7)) { /* skip */
+			regs += *data++ & ~BIT(7);
+			continue;
+		}
+
+		count = *data & 0x3f;
+		flags = *data >> 6;
+		data++;
+
+		*regs = MI_LOAD_REGISTER_IMM(count);
+		if (flags & POSTED)
+			*regs |= MI_LRI_FORCE_POSTED;
+		if (INTEL_GEN(engine->i915) >= 11)
+			*regs |= MI_LRI_CS_MMIO;
+		regs++;
+
+		GEM_BUG_ON(!count);
+		do {
+			u32 offset = 0;
+			u8 v;
+
+			do {
+				v = *data++;
+				offset <<= 7;
+				offset |= v & ~BIT(7);
+			} while (v & BIT(7));
+
+			*regs = base + (offset << 2);
+			regs += 2;
+		} while (--count);
+	}
+
+	return regs;
+}
+
+static const u8 gen8_xcs_offsets[] = {
+	NOP(1),
+	LRI(11, 0),
+	REG16(0x244),
+	REG(0x034),
+	REG(0x030),
+	REG(0x038),
+	REG(0x03c),
+	REG(0x168),
+	REG(0x140),
+	REG(0x110),
+	REG(0x11c),
+	REG(0x114),
+	REG(0x118),
+
+	NOP(9),
+	LRI(9, 0),
+	REG16(0x3a8),
+	REG16(0x28c),
+	REG16(0x288),
+	REG16(0x284),
+	REG16(0x280),
+	REG16(0x27c),
+	REG16(0x278),
+	REG16(0x274),
+	REG16(0x270),
+
+	NOP(13),
+	LRI(2, 0),
+	REG16(0x200),
+	REG(0x028),
+
+	END(),
+};
+
+static const u8 gen9_xcs_offsets[] = {
+	NOP(1),
+	LRI(14, POSTED),
+	REG16(0x244),
+	REG(0x034),
+	REG(0x030),
+	REG(0x038),
+	REG(0x03c),
+	REG(0x168),
+	REG(0x140),
+	REG(0x110),
+	REG(0x11c),
+	REG(0x114),
+	REG(0x118),
+	REG(0x1c0),
+	REG(0x1c4),
+	REG(0x1c8),
+
+	NOP(3),
+	LRI(9, POSTED),
+	REG16(0x3a8),
+	REG16(0x28c),
+	REG16(0x288),
+	REG16(0x284),
+	REG16(0x280),
+	REG16(0x27c),
+	REG16(0x278),
+	REG16(0x274),
+	REG16(0x270),
+
+	NOP(13),
+	LRI(1, POSTED),
+	REG16(0x200),
+
+	NOP(13),
+	LRI(44, POSTED),
+	REG(0x028),
+	REG(0x09c),
+	REG(0x0c0),
+	REG(0x178),
+	REG(0x17c),
+	REG16(0x358),
+	REG(0x170),
+	REG(0x150),
+	REG(0x154),
+	REG(0x158),
+	REG16(0x41c),
+	REG16(0x600),
+	REG16(0x604),
+	REG16(0x608),
+	REG16(0x60c),
+	REG16(0x610),
+	REG16(0x614),
+	REG16(0x618),
+	REG16(0x61c),
+	REG16(0x620),
+	REG16(0x624),
+	REG16(0x628),
+	REG16(0x62c),
+	REG16(0x630),
+	REG16(0x634),
+	REG16(0x638),
+	REG16(0x63c),
+	REG16(0x640),
+	REG16(0x644),
+	REG16(0x648),
+	REG16(0x64c),
+	REG16(0x650),
+	REG16(0x654),
+	REG16(0x658),
+	REG16(0x65c),
+	REG16(0x660),
+	REG16(0x664),
+	REG16(0x668),
+	REG16(0x66c),
+	REG16(0x670),
+	REG16(0x674),
+	REG16(0x678),
+	REG16(0x67c),
+	REG(0x068),
+
+	END(),
+};
+
+static const u8 gen12_xcs_offsets[] = {
+	NOP(1),
+	LRI(13, POSTED),
+	REG16(0x244),
+	REG(0x034),
+	REG(0x030),
+	REG(0x038),
+	REG(0x03c),
+	REG(0x168),
+	REG(0x140),
+	REG(0x110),
+	REG(0x1c0),
+	REG(0x1c4),
+	REG(0x1c8),
+	REG(0x180),
+	REG16(0x2b4),
+
+	NOP(5),
+	LRI(9, POSTED),
+	REG16(0x3a8),
+	REG16(0x28c),
+	REG16(0x288),
+	REG16(0x284),
+	REG16(0x280),
+	REG16(0x27c),
+	REG16(0x278),
+	REG16(0x274),
+	REG16(0x270),
+
+	NOP(13),
+	LRI(2, POSTED),
+	REG16(0x200),
+	REG16(0x204),
+
+	NOP(11),
+	LRI(50, POSTED),
+	REG16(0x588),
+	REG16(0x588),
+	REG16(0x588),
+	REG16(0x588),
+	REG16(0x588),
+	REG16(0x588),
+	REG(0x028),
+	REG(0x09c),
+	REG(0x0c0),
+	REG(0x178),
+	REG(0x17c),
+	REG16(0x358),
+	REG(0x170),
+	REG(0x150),
+	REG(0x154),
+	REG(0x158),
+	REG16(0x41c),
+	REG16(0x600),
+	REG16(0x604),
+	REG16(0x608),
+	REG16(0x60c),
+	REG16(0x610),
+	REG16(0x614),
+	REG16(0x618),
+	REG16(0x61c),
+	REG16(0x620),
+	REG16(0x624),
+	REG16(0x628),
+	REG16(0x62c),
+	REG16(0x630),
+	REG16(0x634),
+	REG16(0x638),
+	REG16(0x63c),
+	REG16(0x640),
+	REG16(0x644),
+	REG16(0x648),
+	REG16(0x64c),
+	REG16(0x650),
+	REG16(0x654),
+	REG16(0x658),
+	REG16(0x65c),
+	REG16(0x660),
+	REG16(0x664),
+	REG16(0x668),
+	REG16(0x66c),
+	REG16(0x670),
+	REG16(0x674),
+	REG16(0x678),
+	REG16(0x67c),
+	REG(0x068),
+
+	END(),
+};
+
+static const u8 gen8_rcs_offsets[] = {
+	NOP(1),
+	LRI(14, POSTED),
+	REG16(0x244),
+	REG(0x034),
+	REG(0x030),
+	REG(0x038),
+	REG(0x03c),
+	REG(0x168),
+	REG(0x140),
+	REG(0x110),
+	REG(0x11c),
+	REG(0x114),
+	REG(0x118),
+	REG(0x1c0),
+	REG(0x1c4),
+	REG(0x1c8),
+
+	NOP(3),
+	LRI(9, POSTED),
+	REG16(0x3a8),
+	REG16(0x28c),
+	REG16(0x288),
+	REG16(0x284),
+	REG16(0x280),
+	REG16(0x27c),
+	REG16(0x278),
+	REG16(0x274),
+	REG16(0x270),
+
+	NOP(13),
+	LRI(1, 0),
+	REG(0x0c8),
+
+	END(),
+};
+
+static const u8 gen11_rcs_offsets[] = {
+	NOP(1),
+	LRI(15, POSTED),
+	REG16(0x244),
+	REG(0x034),
+	REG(0x030),
+	REG(0x038),
+	REG(0x03c),
+	REG(0x168),
+	REG(0x140),
+	REG(0x110),
+	REG(0x11c),
+	REG(0x114),
+	REG(0x118),
+	REG(0x1c0),
+	REG(0x1c4),
+	REG(0x1c8),
+	REG(0x180),
+
+	NOP(1),
+	LRI(9, POSTED),
+	REG16(0x3a8),
+	REG16(0x28c),
+	REG16(0x288),
+	REG16(0x284),
+	REG16(0x280),
+	REG16(0x27c),
+	REG16(0x278),
+	REG16(0x274),
+	REG16(0x270),
+
+	LRI(1, POSTED),
+	REG(0x1b0),
+
+	NOP(10),
+	LRI(1, 0),
+	REG(0x0c8),
+
+	END(),
+};
+
+static const u8 gen12_rcs_offsets[] = {
+	NOP(1),
+	LRI(13, POSTED),
+	REG16(0x244),
+	REG(0x034),
+	REG(0x030),
+	REG(0x038),
+	REG(0x03c),
+	REG(0x168),
+	REG(0x140),
+	REG(0x110),
+	REG(0x1c0),
+	REG(0x1c4),
+	REG(0x1c8),
+	REG(0x180),
+	REG16(0x2b4),
+
+	NOP(5),
+	LRI(9, POSTED),
+	REG16(0x3a8),
+	REG16(0x28c),
+	REG16(0x288),
+	REG16(0x284),
+	REG16(0x280),
+	REG16(0x27c),
+	REG16(0x278),
+	REG16(0x274),
+	REG16(0x270),
+
+	LRI(3, POSTED),
+	REG(0x1b0),
+	REG16(0x5a8),
+	REG16(0x5ac),
+
+	NOP(6),
+	LRI(1, 0),
+	REG(0x0c8),
+
+	END(),
+};
+
+#undef END
+#undef REG16
+#undef REG
+#undef LRI
+#undef NOP
+
+static const u8 *reg_offsets(const struct intel_engine_cs *engine)
+{
+	if (engine->class == RENDER_CLASS) {
+		if (INTEL_GEN(engine->i915) >= 12)
+			return gen12_rcs_offsets;
+		else if (INTEL_GEN(engine->i915) >= 11)
+			return gen11_rcs_offsets;
+		else
+			return gen8_rcs_offsets;
+	} else {
+		if (INTEL_GEN(engine->i915) >= 12)
+			return gen12_xcs_offsets;
+		else if (INTEL_GEN(engine->i915) >= 9)
+			return gen9_xcs_offsets;
+		else
+			return gen8_xcs_offsets;
+	}
+}
+
 static void unwind_wa_tail(struct i915_request *rq)
 {
 	rq->tail = intel_ring_wrap(rq->ring, rq->wa_tail - WA_TAIL_BYTES);
@@ -654,7 +1060,7 @@ static u64 execlists_update_context(const struct i915_request *rq)
 	struct intel_context *ce = rq->hw_context;
 	u64 desc;
 
-	ce->lrc_reg_state[CTX_RING_TAIL + 1] =
+	ce->lrc_reg_state[CTX_RING_TAIL] =
 		intel_ring_set_tail(rq->ring, rq->tail);
 
 	/*
@@ -826,54 +1232,7 @@ static bool can_merge_rq(const struct i915_request *prev,
 static void virtual_update_register_offsets(u32 *regs,
 					    struct intel_engine_cs *engine)
 {
-	u32 base = engine->mmio_base;
-
-	/* Refactor so that we only have one place that knows all the offsets! */
-	GEM_WARN_ON(INTEL_GEN(engine->i915) >= 12);
-
-	/* Must match execlists_init_reg_state()! */
-
-	/* Common part */
-	regs[CTX_CONTEXT_CONTROL] =
-		i915_mmio_reg_offset(RING_CONTEXT_CONTROL(base));
-	regs[CTX_RING_HEAD] = i915_mmio_reg_offset(RING_HEAD(base));
-	regs[CTX_RING_TAIL] = i915_mmio_reg_offset(RING_TAIL(base));
-	regs[CTX_RING_BUFFER_START] = i915_mmio_reg_offset(RING_START(base));
-	regs[CTX_RING_BUFFER_CONTROL] = i915_mmio_reg_offset(RING_CTL(base));
-
-	regs[CTX_BB_HEAD_U] = i915_mmio_reg_offset(RING_BBADDR_UDW(base));
-	regs[CTX_BB_HEAD_L] = i915_mmio_reg_offset(RING_BBADDR(base));
-	regs[CTX_BB_STATE] = i915_mmio_reg_offset(RING_BBSTATE(base));
-
-	regs[CTX_SECOND_BB_HEAD_U] =
-		i915_mmio_reg_offset(RING_SBBADDR_UDW(base));
-	regs[CTX_SECOND_BB_HEAD_L] = i915_mmio_reg_offset(RING_SBBADDR(base));
-	regs[CTX_SECOND_BB_STATE] = i915_mmio_reg_offset(RING_SBBSTATE(base));
-
-	/* PPGTT part */
-	regs[CTX_CTX_TIMESTAMP] =
-		i915_mmio_reg_offset(RING_CTX_TIMESTAMP(base));
-
-	regs[CTX_PDP3_UDW] = i915_mmio_reg_offset(GEN8_RING_PDP_UDW(base, 3));
-	regs[CTX_PDP3_LDW] = i915_mmio_reg_offset(GEN8_RING_PDP_LDW(base, 3));
-	regs[CTX_PDP2_UDW] = i915_mmio_reg_offset(GEN8_RING_PDP_UDW(base, 2));
-	regs[CTX_PDP2_LDW] = i915_mmio_reg_offset(GEN8_RING_PDP_LDW(base, 2));
-	regs[CTX_PDP1_UDW] = i915_mmio_reg_offset(GEN8_RING_PDP_UDW(base, 1));
-	regs[CTX_PDP1_LDW] = i915_mmio_reg_offset(GEN8_RING_PDP_LDW(base, 1));
-	regs[CTX_PDP0_UDW] = i915_mmio_reg_offset(GEN8_RING_PDP_UDW(base, 0));
-	regs[CTX_PDP0_LDW] = i915_mmio_reg_offset(GEN8_RING_PDP_LDW(base, 0));
-
-	if (engine->class == RENDER_CLASS) {
-		regs[CTX_RCS_INDIRECT_CTX] =
-			i915_mmio_reg_offset(RING_INDIRECT_CTX(base));
-		regs[CTX_RCS_INDIRECT_CTX_OFFSET] =
-			i915_mmio_reg_offset(RING_INDIRECT_CTX_OFFSET(base));
-		regs[CTX_BB_PER_CTX_PTR] =
-			i915_mmio_reg_offset(RING_BB_PER_CTX_PTR(base));
-
-		regs[CTX_R_PWR_CLK_STATE] =
-			i915_mmio_reg_offset(GEN8_R_PWR_CLK_STATE);
-	}
+	set_offsets(regs, reg_offsets(engine), engine);
 }
 
 static bool virtual_matches(const struct virtual_engine *ve,
@@ -1738,8 +2097,8 @@ static void execlists_context_unpin(struct intel_context *ce)
 }
 
 static void
-__execlists_update_reg_state(struct intel_context *ce,
-			     struct intel_engine_cs *engine)
+__execlists_update_reg_state(const struct intel_context *ce,
+			     const struct intel_engine_cs *engine)
 {
 	struct intel_ring *ring = ce->ring;
 	u32 *regs = ce->lrc_reg_state;
@@ -1747,16 +2106,16 @@ __execlists_update_reg_state(struct intel_context *ce,
 	GEM_BUG_ON(!intel_ring_offset_valid(ring, ring->head));
 	GEM_BUG_ON(!intel_ring_offset_valid(ring, ring->tail));
 
-	regs[CTX_RING_BUFFER_START + 1] = i915_ggtt_offset(ring->vma);
-	regs[CTX_RING_HEAD + 1] = ring->head;
-	regs[CTX_RING_TAIL + 1] = ring->tail;
+	regs[CTX_RING_BUFFER_START] = i915_ggtt_offset(ring->vma);
+	regs[CTX_RING_HEAD] = ring->head;
+	regs[CTX_RING_TAIL] = ring->tail;
 
 	/* RPCS */
 	if (engine->class == RENDER_CLASS) {
-		regs[CTX_R_PWR_CLK_STATE + 1] =
+		regs[CTX_R_PWR_CLK_STATE] =
 			intel_sseu_make_rpcs(engine->i915, &ce->sseu);
 
-		i915_oa_init_reg_state(engine, ce, regs);
+		i915_oa_init_reg_state(ce, engine);
 	}
 }
 
@@ -2465,7 +2824,7 @@ static void __execlists_reset(struct intel_engine_cs *engine, bool stalled)
 		       engine->pinned_default_state + LRC_STATE_PN * PAGE_SIZE,
 		       engine->context_size - PAGE_SIZE);
 	}
-	execlists_init_reg_state(regs, ce, engine, ce->ring);
+	execlists_init_reg_state(regs, ce, engine, ce->ring, false);
 
 out_replay:
 	GEM_TRACE("%s replay {head:%04x, tail:%04x\n",
@@ -3243,7 +3602,7 @@ int intel_execlists_submission_init(struct intel_engine_cs *engine)
 	return 0;
 }
 
-static u32 intel_lr_indirect_ctx_offset(struct intel_engine_cs *engine)
+static u32 intel_lr_indirect_ctx_offset(const struct intel_engine_cs *engine)
 {
 	u32 indirect_ctx_offset;
 
@@ -3278,75 +3637,48 @@ static u32 intel_lr_indirect_ctx_offset(struct intel_engine_cs *engine)
 
 
 static void init_common_reg_state(u32 * const regs,
-				  struct i915_ppgtt * const ppgtt,
-				  struct intel_engine_cs *engine,
-				  struct intel_ring *ring)
+				  const struct intel_engine_cs *engine,
+				  const struct intel_ring *ring)
 {
-	const u32 base = engine->mmio_base;
-
-	CTX_REG(regs, CTX_CONTEXT_CONTROL, RING_CONTEXT_CONTROL(base),
+	regs[CTX_CONTEXT_CONTROL] =
 		_MASKED_BIT_DISABLE(CTX_CTRL_ENGINE_CTX_RESTORE_INHIBIT) |
-		_MASKED_BIT_ENABLE(CTX_CTRL_INHIBIT_SYN_CTX_SWITCH));
-	if (INTEL_GEN(engine->i915) < 11) {
-		regs[CTX_CONTEXT_CONTROL + 1] |=
+		_MASKED_BIT_ENABLE(CTX_CTRL_INHIBIT_SYN_CTX_SWITCH);
+	if (INTEL_GEN(engine->i915) < 11)
+		regs[CTX_CONTEXT_CONTROL] |=
 			_MASKED_BIT_DISABLE(CTX_CTRL_ENGINE_CTX_SAVE_INHIBIT |
 					    CTX_CTRL_RS_CTX_ENABLE);
-	}
-	CTX_REG(regs, CTX_RING_HEAD, RING_HEAD(base), 0);
-	CTX_REG(regs, CTX_RING_TAIL, RING_TAIL(base), 0);
-	CTX_REG(regs, CTX_RING_BUFFER_START, RING_START(base), 0);
-	CTX_REG(regs, CTX_RING_BUFFER_CONTROL, RING_CTL(base),
-		RING_CTL_SIZE(ring->size) | RING_VALID);
-	CTX_REG(regs, CTX_BB_HEAD_U, RING_BBADDR_UDW(base), 0);
-	CTX_REG(regs, CTX_BB_HEAD_L, RING_BBADDR(base), 0);
-	CTX_REG(regs, CTX_BB_STATE, RING_BBSTATE(base), RING_BB_PPGTT);
+
+	regs[CTX_RING_BUFFER_CONTROL] = RING_CTL_SIZE(ring->size) | RING_VALID;
+	regs[CTX_BB_STATE] = RING_BB_PPGTT;
 }
 
 static void init_wa_bb_reg_state(u32 * const regs,
-				 struct intel_engine_cs *engine,
+				 const struct intel_engine_cs *engine,
 				 u32 pos_bb_per_ctx)
 {
-	struct i915_ctx_workarounds * const wa_ctx = &engine->wa_ctx;
-	const u32 base = engine->mmio_base;
-	const u32 pos_indirect_ctx = pos_bb_per_ctx + 2;
-	const u32 pos_indirect_ctx_offset = pos_indirect_ctx + 2;
+	const struct i915_ctx_workarounds * const wa_ctx = &engine->wa_ctx;
+
+	if (wa_ctx->per_ctx.size) {
+		const u32 ggtt_offset = i915_ggtt_offset(wa_ctx->vma);
+
+		regs[pos_bb_per_ctx] =
+			(ggtt_offset + wa_ctx->per_ctx.offset) | 0x01;
+	}
 
-	CTX_REG(regs, pos_indirect_ctx, RING_INDIRECT_CTX(base), 0);
-	CTX_REG(regs, pos_indirect_ctx_offset,
-		RING_INDIRECT_CTX_OFFSET(base), 0);
 	if (wa_ctx->indirect_ctx.size) {
 		const u32 ggtt_offset = i915_ggtt_offset(wa_ctx->vma);
 
-		regs[pos_indirect_ctx + 1] =
+		regs[pos_bb_per_ctx + 2] =
 			(ggtt_offset + wa_ctx->indirect_ctx.offset) |
 			(wa_ctx->indirect_ctx.size / CACHELINE_BYTES);
 
-		regs[pos_indirect_ctx_offset + 1] =
+		regs[pos_bb_per_ctx + 4] =
 			intel_lr_indirect_ctx_offset(engine) << 6;
 	}
-
-	CTX_REG(regs, pos_bb_per_ctx, RING_BB_PER_CTX_PTR(base), 0);
-	if (wa_ctx->per_ctx.size) {
-		const u32 ggtt_offset = i915_ggtt_offset(wa_ctx->vma);
-
-		regs[pos_bb_per_ctx + 1] =
-			(ggtt_offset + wa_ctx->per_ctx.offset) | 0x01;
-	}
 }
 
-static void init_ppgtt_reg_state(u32 *regs, u32 base,
-				 struct i915_ppgtt *ppgtt)
+static void init_ppgtt_reg_state(u32 *regs, const struct i915_ppgtt *ppgtt)
 {
-	/* PDP values well be assigned later if needed */
-	CTX_REG(regs, CTX_PDP3_UDW, GEN8_RING_PDP_UDW(base, 3), 0);
-	CTX_REG(regs, CTX_PDP3_LDW, GEN8_RING_PDP_LDW(base, 3), 0);
-	CTX_REG(regs, CTX_PDP2_UDW, GEN8_RING_PDP_UDW(base, 2), 0);
-	CTX_REG(regs, CTX_PDP2_LDW, GEN8_RING_PDP_LDW(base, 2), 0);
-	CTX_REG(regs, CTX_PDP1_UDW, GEN8_RING_PDP_UDW(base, 1), 0);
-	CTX_REG(regs, CTX_PDP1_LDW, GEN8_RING_PDP_LDW(base, 1), 0);
-	CTX_REG(regs, CTX_PDP0_UDW, GEN8_RING_PDP_UDW(base, 0), 0);
-	CTX_REG(regs, CTX_PDP0_LDW, GEN8_RING_PDP_LDW(base, 0), 0);
-
 	if (i915_vm_is_4lvl(&ppgtt->vm)) {
 		/* 64b PPGTT (48bit canonical)
 		 * PDP0_DESCRIPTOR contains the base address to PML4 and
@@ -3369,91 +3701,11 @@ static struct i915_ppgtt *vm_alias(struct i915_address_space *vm)
 		return i915_vm_to_ppgtt(vm);
 }
 
-static void gen8_init_reg_state(u32 * const regs,
-				struct intel_context *ce,
-				struct intel_engine_cs *engine,
-				struct intel_ring *ring)
-{
-	struct i915_ppgtt * const ppgtt = vm_alias(ce->vm);
-	const bool rcs = engine->class == RENDER_CLASS;
-	const u32 base = engine->mmio_base;
-	const u32 lri_base =
-		intel_engine_has_relative_mmio(engine) ? MI_LRI_CS_MMIO : 0;
-
-	regs[CTX_LRI_HEADER_0] =
-		MI_LOAD_REGISTER_IMM(rcs ? 14 : 11) |
-		MI_LRI_FORCE_POSTED |
-		lri_base;
-
-	init_common_reg_state(regs, ppgtt, engine, ring);
-	CTX_REG(regs, CTX_SECOND_BB_HEAD_U, RING_SBBADDR_UDW(base), 0);
-	CTX_REG(regs, CTX_SECOND_BB_HEAD_L, RING_SBBADDR(base), 0);
-	CTX_REG(regs, CTX_SECOND_BB_STATE, RING_SBBSTATE(base), 0);
-	if (rcs)
-		init_wa_bb_reg_state(regs, engine, CTX_BB_PER_CTX_PTR);
-
-	regs[CTX_LRI_HEADER_1] =
-		MI_LOAD_REGISTER_IMM(9) |
-		MI_LRI_FORCE_POSTED |
-		lri_base;
-
-	CTX_REG(regs, CTX_CTX_TIMESTAMP, RING_CTX_TIMESTAMP(base), 0);
-
-	init_ppgtt_reg_state(regs, base, ppgtt);
-
-	if (rcs) {
-		regs[CTX_LRI_HEADER_2] = MI_LOAD_REGISTER_IMM(1) | lri_base;
-		CTX_REG(regs, CTX_R_PWR_CLK_STATE, GEN8_R_PWR_CLK_STATE, 0);
-	}
-
-	regs[CTX_END] = MI_BATCH_BUFFER_END;
-	if (INTEL_GEN(engine->i915) >= 10)
-		regs[CTX_END] |= BIT(0);
-}
-
-static void gen12_init_reg_state(u32 * const regs,
-				 struct intel_context *ce,
-				 struct intel_engine_cs *engine,
-				 struct intel_ring *ring)
-{
-	struct i915_ppgtt * const ppgtt = i915_vm_to_ppgtt(ce->vm);
-	const bool rcs = engine->class == RENDER_CLASS;
-	const u32 base = engine->mmio_base;
-	const u32 lri_base =
-		intel_engine_has_relative_mmio(engine) ? MI_LRI_CS_MMIO : 0;
-
-	regs[CTX_LRI_HEADER_0] =
-		MI_LOAD_REGISTER_IMM(rcs ? 11 : 9) |
-		MI_LRI_FORCE_POSTED |
-		lri_base;
-
-	init_common_reg_state(regs, ppgtt, engine, ring);
-
-	/* We want ctx_ptr for all engines to be set */
-	init_wa_bb_reg_state(regs, engine, GEN12_CTX_BB_PER_CTX_PTR);
-
-	regs[CTX_LRI_HEADER_1] =
-		MI_LOAD_REGISTER_IMM(9) |
-		MI_LRI_FORCE_POSTED |
-		lri_base;
-
-	CTX_REG(regs, CTX_CTX_TIMESTAMP, RING_CTX_TIMESTAMP(base), 0);
-
-	init_ppgtt_reg_state(regs, base, ppgtt);
-
-	if (rcs) {
-		regs[GEN12_CTX_LRI_HEADER_3] =
-			MI_LOAD_REGISTER_IMM(1) | lri_base;
-		CTX_REG(regs, CTX_R_PWR_CLK_STATE, GEN8_R_PWR_CLK_STATE, 0);
-
-		/* TODO: oa_init_reg_state ? */
-	}
-}
-
 static void execlists_init_reg_state(u32 *regs,
-				     struct intel_context *ce,
-				     struct intel_engine_cs *engine,
-				     struct intel_ring *ring)
+				     const struct intel_context *ce,
+				     const struct intel_engine_cs *engine,
+				     const struct intel_ring *ring,
+				     bool close)
 {
 	/*
 	 * A context is actually a big batch buffer with several
@@ -3465,10 +3717,21 @@ static void execlists_init_reg_state(u32 *regs,
 	 *
 	 * Must keep consistent with virtual_update_register_offsets().
 	 */
-	if (INTEL_GEN(engine->i915) >= 12)
-		gen12_init_reg_state(regs, ce, engine, ring);
-	else
-		gen8_init_reg_state(regs, ce, engine, ring);
+	u32 *bbe = set_offsets(regs, reg_offsets(engine), engine);
+
+	if (close) { /* Close the batch; used mainly by live_lrc_layout() */
+		*bbe = MI_BATCH_BUFFER_END;
+		if (INTEL_GEN(engine->i915) >= 10)
+			*bbe |= BIT(0);
+	}
+
+	init_common_reg_state(regs, engine, ring);
+	init_ppgtt_reg_state(regs, vm_alias(ce->vm));
+
+	init_wa_bb_reg_state(regs, engine,
+			     INTEL_GEN(engine->i915) >= 12 ?
+			     GEN12_CTX_BB_PER_CTX_PTR :
+			     CTX_BB_PER_CTX_PTR);
 }
 
 static int
@@ -3477,6 +3740,7 @@ populate_lr_context(struct intel_context *ce,
 		    struct intel_engine_cs *engine,
 		    struct intel_ring *ring)
 {
+	bool inhibit = true;
 	void *vaddr;
 	u32 *regs;
 	int ret;
@@ -3508,14 +3772,15 @@ populate_lr_context(struct intel_context *ce,
 
 		memcpy(vaddr + start, defaults + start, engine->context_size);
 		i915_gem_object_unpin_map(engine->default_state);
+		inhibit = false;
 	}
 
 	/* The second page of the context object contains some fields which must
 	 * be set up prior to the first execution. */
 	regs = vaddr + LRC_STATE_PN * PAGE_SIZE;
-	execlists_init_reg_state(regs, ce, engine, ring);
-	if (!engine->default_state)
-		regs[CTX_CONTEXT_CONTROL + 1] |=
+	execlists_init_reg_state(regs, ce, engine, ring, inhibit);
+	if (inhibit)
+		regs[CTX_CONTEXT_CONTROL] |=
 			_MASKED_BIT_ENABLE(CTX_CTRL_ENGINE_CTX_RESTORE_INHIBIT);
 
 	ret = 0;
@@ -4212,7 +4477,7 @@ void intel_lr_context_reset(struct intel_engine_cs *engine,
 			       engine->pinned_default_state + LRC_STATE_PN * PAGE_SIZE,
 			       engine->context_size - PAGE_SIZE);
 		}
-		execlists_init_reg_state(regs, ce, engine, ce->ring);
+		execlists_init_reg_state(regs, ce, engine, ce->ring, false);
 	}
 
 	/* Rerun the request; its payload has been neutered (if guilty). */
diff --git a/drivers/gpu/drm/i915/gt/intel_lrc_reg.h b/drivers/gpu/drm/i915/gt/intel_lrc_reg.h
index 7e773e74a3fe..06ab0276e10e 100644
--- a/drivers/gpu/drm/i915/gt/intel_lrc_reg.h
+++ b/drivers/gpu/drm/i915/gt/intel_lrc_reg.h
@@ -10,60 +10,40 @@
 #include <linux/types.h>
 
 /* GEN8 to GEN11 Reg State Context */
-#define CTX_LRI_HEADER_0		0x01
-#define CTX_CONTEXT_CONTROL		0x02
-#define CTX_RING_HEAD			0x04
-#define CTX_RING_TAIL			0x06
-#define CTX_RING_BUFFER_START		0x08
-#define CTX_RING_BUFFER_CONTROL		0x0a
-#define CTX_BB_HEAD_U			0x0c
-#define CTX_BB_HEAD_L			0x0e
-#define CTX_BB_STATE			0x10
-#define CTX_SECOND_BB_HEAD_U		0x12
-#define CTX_SECOND_BB_HEAD_L		0x14
-#define CTX_SECOND_BB_STATE		0x16
-#define CTX_BB_PER_CTX_PTR		0x18
-#define CTX_RCS_INDIRECT_CTX		0x1a
-#define CTX_RCS_INDIRECT_CTX_OFFSET	0x1c
-#define CTX_LRI_HEADER_1		0x21
-#define CTX_CTX_TIMESTAMP		0x22
-#define CTX_PDP3_UDW			0x24
-#define CTX_PDP3_LDW			0x26
-#define CTX_PDP2_UDW			0x28
-#define CTX_PDP2_LDW			0x2a
-#define CTX_PDP1_UDW			0x2c
-#define CTX_PDP1_LDW			0x2e
-#define CTX_PDP0_UDW			0x30
-#define CTX_PDP0_LDW			0x32
-#define CTX_LRI_HEADER_2		0x41
-#define CTX_R_PWR_CLK_STATE		0x42
-#define CTX_END				0x44
+#define CTX_CONTEXT_CONTROL		(0x02 + 1)
+#define CTX_RING_HEAD			(0x04 + 1)
+#define CTX_RING_TAIL			(0x06 + 1)
+#define CTX_RING_BUFFER_START		(0x08 + 1)
+#define CTX_RING_BUFFER_CONTROL		(0x0a + 1)
+#define CTX_BB_STATE			(0x10 + 1)
+#define CTX_BB_PER_CTX_PTR		(0x18 + 1)
+#define CTX_PDP3_UDW			(0x24 + 1)
+#define CTX_PDP3_LDW			(0x26 + 1)
+#define CTX_PDP2_UDW			(0x28 + 1)
+#define CTX_PDP2_LDW			(0x2a + 1)
+#define CTX_PDP1_UDW			(0x2c + 1)
+#define CTX_PDP1_LDW			(0x2e + 1)
+#define CTX_PDP0_UDW			(0x30 + 1)
+#define CTX_PDP0_LDW			(0x32 + 1)
+#define CTX_R_PWR_CLK_STATE		(0x42 + 1)
 
 #define GEN9_CTX_RING_MI_MODE		0x54
 
 /* GEN12+ Reg State Context */
-#define GEN12_CTX_BB_PER_CTX_PTR		0x12
-#define GEN12_CTX_LRI_HEADER_3			0x41
-
-#define CTX_REG(reg_state, pos, reg, val) do { \
-	u32 *reg_state__ = (reg_state); \
-	const u32 pos__ = (pos); \
-	(reg_state__)[(pos__) + 0] = i915_mmio_reg_offset(reg); \
-	(reg_state__)[(pos__) + 1] = (val); \
-} while (0)
+#define GEN12_CTX_BB_PER_CTX_PTR		(0x12 + 1)
 
 #define ASSIGN_CTX_PDP(ppgtt, reg_state, n) do { \
 	u32 *reg_state__ = (reg_state); \
 	const u64 addr__ = i915_page_dir_dma_addr((ppgtt), (n)); \
-	(reg_state__)[CTX_PDP ## n ## _UDW + 1] = upper_32_bits(addr__); \
-	(reg_state__)[CTX_PDP ## n ## _LDW + 1] = lower_32_bits(addr__); \
+	(reg_state__)[CTX_PDP ## n ## _UDW] = upper_32_bits(addr__); \
+	(reg_state__)[CTX_PDP ## n ## _LDW] = lower_32_bits(addr__); \
 } while (0)
 
 #define ASSIGN_CTX_PML4(ppgtt, reg_state) do { \
 	u32 *reg_state__ = (reg_state); \
 	const u64 addr__ = px_dma(ppgtt->pd); \
-	(reg_state__)[CTX_PDP0_UDW + 1] = upper_32_bits(addr__); \
-	(reg_state__)[CTX_PDP0_LDW + 1] = lower_32_bits(addr__); \
+	(reg_state__)[CTX_PDP0_UDW] = upper_32_bits(addr__); \
+	(reg_state__)[CTX_PDP0_LDW] = lower_32_bits(addr__); \
 } while (0)
 
 #define GEN8_CTX_RCS_INDIRECT_CTX_OFFSET_DEFAULT	0x17
diff --git a/drivers/gpu/drm/i915/gt/selftest_lrc.c b/drivers/gpu/drm/i915/gt/selftest_lrc.c
index 93a871bfd95d..22ea2e747064 100644
--- a/drivers/gpu/drm/i915/gt/selftest_lrc.c
+++ b/drivers/gpu/drm/i915/gt/selftest_lrc.c
@@ -2201,3 +2201,145 @@ int intel_execlists_live_selftests(struct drm_i915_private *i915)
 
 	return i915_live_subtests(tests, i915);
 }
+
+static void hexdump(const void *buf, size_t len)
+{
+	const size_t rowsize = 8 * sizeof(u32);
+	const void *prev = NULL;
+	bool skip = false;
+	size_t pos;
+
+	for (pos = 0; pos < len; pos += rowsize) {
+		char line[128];
+
+		if (prev && !memcmp(prev, buf + pos, rowsize)) {
+			if (!skip) {
+				pr_info("*\n");
+				skip = true;
+			}
+			continue;
+		}
+
+		WARN_ON_ONCE(hex_dump_to_buffer(buf + pos, len - pos,
+						rowsize, sizeof(u32),
+						line, sizeof(line),
+						false) >= sizeof(line));
+		pr_info("[%04zx] %s\n", pos, line);
+
+		prev = buf + pos;
+		skip = false;
+	}
+}
+
+static int live_lrc_layout(void *arg)
+{
+	struct intel_gt *gt = arg;
+	struct intel_engine_cs *engine;
+	enum intel_engine_id id;
+	u32 *mem;
+	int err;
+
+	/*
+	 * Check the registers offsets we use to create the initial reg state
+	 * match the layout saved by HW.
+	 */
+
+	mem = kmalloc(PAGE_SIZE, GFP_KERNEL);
+	if (!mem)
+		return -ENOMEM;
+
+	err = 0;
+	for_each_engine(engine, gt->i915, id) {
+		u32 *hw, *lrc;
+		int dw;
+
+		if (!engine->default_state)
+			continue;
+
+		hw = i915_gem_object_pin_map(engine->default_state,
+					     I915_MAP_WB);
+		if (IS_ERR(hw)) {
+			err = PTR_ERR(hw);
+			break;
+		}
+		hw += LRC_STATE_PN * PAGE_SIZE / sizeof(*hw);
+
+		lrc = memset(mem, 0, PAGE_SIZE);
+		execlists_init_reg_state(lrc,
+					 engine->kernel_context,
+					 engine,
+					 engine->kernel_context->ring,
+					 true);
+
+		dw = 0;
+		do {
+			u32 lri = hw[dw];
+
+			if (lri == 0) {
+				dw++;
+				continue;
+			}
+
+			if ((lri & GENMASK(31, 23)) != MI_INSTR(0x22, 0)) {
+				pr_err("%s: Expected LRI command at dword %d, found %08x\n",
+				       engine->name, dw, lri);
+				err = -EINVAL;
+				break;
+			}
+
+			if (lrc[dw] != lri) {
+				pr_err("%s: LRI command mismatch at dword %d, expected %08x found %08x\n",
+				       engine->name, dw, lri, lrc[dw]);
+				err = -EINVAL;
+				break;
+			}
+
+			lri &= 0x7f;
+			lri++;
+			dw++;
+
+			while (lri) {
+				if (hw[dw] != lrc[dw]) {
+					pr_err("%s: Different registers found at dword %d, expected %x, found %x\n",
+					       engine->name, dw, hw[dw], lrc[dw]);
+					err = -EINVAL;
+					break;
+				}
+
+				/*
+				 * Skip over the actual register value as we
+				 * expect that to differ.
+				 */
+				dw += 2;
+				lri -= 2;
+			}
+		} while ((lrc[dw] & ~BIT(0)) != MI_BATCH_BUFFER_END);
+
+		if (err) {
+			pr_info("%s: HW register image:\n", engine->name);
+			hexdump(hw, PAGE_SIZE);
+
+			pr_info("%s: SW register image:\n", engine->name);
+			hexdump(lrc, PAGE_SIZE);
+		}
+
+		i915_gem_object_unpin_map(engine->default_state);
+		if (err)
+			break;
+	}
+
+	kfree(mem);
+	return err;
+}
+
+int intel_lrc_live_selftests(struct drm_i915_private *i915)
+{
+	static const struct i915_subtest tests[] = {
+		SUBTEST(live_lrc_layout),
+	};
+
+	if (!HAS_LOGICAL_RING_CONTEXTS(i915))
+		return 0;
+
+	return intel_gt_live_subtests(tests, &i915->gt);
+}
diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c
index c1b764233761..524f6710b7aa 100644
--- a/drivers/gpu/drm/i915/i915_perf.c
+++ b/drivers/gpu/drm/i915/i915_perf.c
@@ -1673,10 +1673,8 @@ static u32 oa_config_flex_reg(const struct i915_oa_config *oa_config,
  * in the case that the OA unit has been disabled.
  */
 static void
-gen8_update_reg_state_unlocked(struct i915_perf_stream *stream,
-			       struct intel_context *ce,
-			       u32 *reg_state,
-			       const struct i915_oa_config *oa_config)
+gen8_update_reg_state_unlocked(const struct intel_context *ce,
+			       const struct i915_perf_stream *stream)
 {
 	struct drm_i915_private *i915 = ce->engine->i915;
 	u32 ctx_oactxctrl = i915->perf.ctx_oactxctrl_offset;
@@ -1691,21 +1689,19 @@ gen8_update_reg_state_unlocked(struct i915_perf_stream *stream,
 		EU_PERF_CNTL5,
 		EU_PERF_CNTL6,
 	};
+	u32 *reg_state = ce->lrc_reg_state;
 	int i;
 
-	CTX_REG(reg_state, ctx_oactxctrl, GEN8_OACTXCONTROL,
+	reg_state[ctx_oactxctrl + 1] =
 		(stream->period_exponent << GEN8_OA_TIMER_PERIOD_SHIFT) |
 		(stream->periodic ? GEN8_OA_TIMER_ENABLE : 0) |
-		GEN8_OA_COUNTER_RESUME);
+		GEN8_OA_COUNTER_RESUME;
 
-	for (i = 0; i < ARRAY_SIZE(flex_regs); i++) {
-		CTX_REG(reg_state, ctx_flexeu0 + i * 2, flex_regs[i],
-			oa_config_flex_reg(oa_config, flex_regs[i]));
-	}
+	for (i = 0; i < ARRAY_SIZE(flex_regs); i++)
+		reg_state[ctx_flexeu0 + i * 2 + 1] =
+			oa_config_flex_reg(stream->oa_config, flex_regs[i]);
 
-	CTX_REG(reg_state,
-		CTX_R_PWR_CLK_STATE, GEN8_R_PWR_CLK_STATE,
-		intel_sseu_make_rpcs(i915, &ce->sseu));
+	reg_state[CTX_R_PWR_CLK_STATE] = intel_sseu_make_rpcs(i915, &ce->sseu);
 }
 
 struct flex {
@@ -1729,7 +1725,7 @@ gen8_store_flex(struct i915_request *rq,
 	offset = i915_ggtt_offset(ce->state) + LRC_STATE_PN * PAGE_SIZE;
 	do {
 		*cs++ = MI_STORE_DWORD_IMM_GEN4 | MI_USE_GGTT;
-		*cs++ = offset + (flex->offset + 1) * sizeof(u32);
+		*cs++ = offset + flex->offset * sizeof(u32);
 		*cs++ = 0;
 		*cs++ = flex->value;
 	} while (flex++, --count);
@@ -1863,7 +1859,7 @@ static int gen8_configure_all_contexts(struct i915_perf_stream *stream,
 	struct drm_i915_private *i915 = stream->dev_priv;
 	/* The MMIO offsets for Flex EU registers aren't contiguous */
 	const u32 ctx_flexeu0 = i915->perf.ctx_flexeu0_offset;
-#define ctx_flexeuN(N) (ctx_flexeu0 + 2 * (N))
+#define ctx_flexeuN(N) (ctx_flexeu0 + 2 * (N) + 1)
 	struct flex regs[] = {
 		{
 			GEN8_R_PWR_CLK_STATE,
@@ -1871,7 +1867,7 @@ static int gen8_configure_all_contexts(struct i915_perf_stream *stream,
 		},
 		{
 			GEN8_OACTXCONTROL,
-			i915->perf.ctx_oactxctrl_offset,
+			i915->perf.ctx_oactxctrl_offset + 1,
 			((stream->period_exponent << GEN8_OA_TIMER_PERIOD_SHIFT) |
 			 (stream->periodic ? GEN8_OA_TIMER_ENABLE : 0) |
 			 GEN8_OA_COUNTER_RESUME)
@@ -2299,9 +2295,8 @@ static int i915_oa_stream_init(struct i915_perf_stream *stream,
 	return ret;
 }
 
-void i915_oa_init_reg_state(struct intel_engine_cs *engine,
-			    struct intel_context *ce,
-			    u32 *regs)
+void i915_oa_init_reg_state(const struct intel_context *ce,
+			    const struct intel_engine_cs *engine)
 {
 	struct i915_perf_stream *stream;
 
@@ -2313,7 +2308,7 @@ void i915_oa_init_reg_state(struct intel_engine_cs *engine,
 
 	stream = engine->i915->perf.exclusive_stream;
 	if (stream)
-		gen8_update_reg_state_unlocked(stream, ce, regs, stream->oa_config);
+		gen8_update_reg_state_unlocked(ce, stream);
 }
 
 /**
diff --git a/drivers/gpu/drm/i915/i915_perf.h b/drivers/gpu/drm/i915/i915_perf.h
index a412b16d9ffc..f4fb311184b1 100644
--- a/drivers/gpu/drm/i915/i915_perf.h
+++ b/drivers/gpu/drm/i915/i915_perf.h
@@ -25,8 +25,7 @@ int i915_perf_add_config_ioctl(struct drm_device *dev, void *data,
 			       struct drm_file *file);
 int i915_perf_remove_config_ioctl(struct drm_device *dev, void *data,
 				  struct drm_file *file);
-void i915_oa_init_reg_state(struct intel_engine_cs *engine,
-			    struct intel_context *ce,
-			    u32 *reg_state);
+void i915_oa_init_reg_state(const struct intel_context *ce,
+			    const struct intel_engine_cs *engine);
 
 #endif /* __I915_PERF_H__ */
diff --git a/drivers/gpu/drm/i915/selftests/i915_live_selftests.h b/drivers/gpu/drm/i915/selftests/i915_live_selftests.h
index 1ccf0f731ac0..66d83c1390c1 100644
--- a/drivers/gpu/drm/i915/selftests/i915_live_selftests.h
+++ b/drivers/gpu/drm/i915/selftests/i915_live_selftests.h
@@ -15,6 +15,7 @@ selftest(workarounds, intel_workarounds_live_selftests)
 selftest(gt_engines, intel_engine_live_selftests)
 selftest(gt_timelines, intel_timeline_live_selftests)
 selftest(gt_contexts, intel_context_live_selftests)
+selftest(gt_lrc, intel_lrc_live_selftests)
 selftest(requests, i915_request_live_selftests)
 selftest(active, i915_active_live_selftests)
 selftest(objects, i915_gem_object_live_selftests)
-- 
2.23.0

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

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: [PATCH v2] drm/i915/selftests: Verify the LRC register layout between init and HW
  2019-09-24 14:59 ` [PATCH v2] drm/i915/selftests: Verify the LRC register layout between init and HW Chris Wilson
@ 2019-09-24 15:04   ` Chris Wilson
  0 siblings, 0 replies; 22+ messages in thread
From: Chris Wilson @ 2019-09-24 15:04 UTC (permalink / raw)
  To: intel-gfx

Quoting Chris Wilson (2019-09-24 15:59:50)
> Before we submit the first context to HW, we need to construct a valid
> image of the register state. This layout is defined by the HW and should
> match the layout generated by HW when it saves the context image.
> Asserting that this should be equivalent should help avoid any undefined
> behaviour and verify that we haven't missed anything important!
> 
> Of course, having insisted that the initial register state within the
> LRC should match that returned by HW, we need to ensure that it does.
> 
> v2: Drop the RELATIVE_MMIO flag from gen11, we ignore it for
> constructing the lrc image.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
> Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>

Chatting with Mika, he was happy enough to give an r-b without the gen11
chunk. To REG16 or not to REG16 is a decision for later, it was not a
critical issue.

Reviewed-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 1/2] drm/i915/selftests: Verify the LRC register layout between init and HW
  2019-09-24 10:43   ` Chris Wilson
@ 2019-09-24 15:07     ` Mika Kuoppala
  0 siblings, 0 replies; 22+ messages in thread
From: Mika Kuoppala @ 2019-09-24 15:07 UTC (permalink / raw)
  To: Chris Wilson, intel-gfx

Chris Wilson <chris@chris-wilson.co.uk> writes:

> Quoting Mika Kuoppala (2019-09-24 11:21:38)
>> Chris Wilson <chris@chris-wilson.co.uk> writes:
>> 
>> > Before we submit the first context to HW, we need to construct a valid
>> > image of the register state. This layout is defined by the HW and should
>> > match the layout generated by HW when it saves the context image.
>> > Asserting that this should be equivalent should help avoid any undefined
>> > behaviour and verify that we haven't missed anything important!
>> >
>> > Of course, having insisted that the initial register state within the
>> > LRC should match that returned by HW, we need to ensure that it does.
>> >
>> > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
>> > Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
>> > Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
>
>> > +static u32 *set_offsets(u32 *regs,
>> > +                     const u8 *data,
>> > +                     const struct intel_engine_cs *engine)
>> > +#define NOP(x) (BIT(7) | (x))
>> > +#define LRI(count, flags) ((flags) << 6 | (count))
>> > +#define POSTED BIT(0)
>> > +#define REG(x) (((x) >> 2) | BUILD_BUG_ON_ZERO(x >= 0x200))
>> > +#define REG16(x) \
>> > +     (((x) >> 9) | BIT(7) | BUILD_BUG_ON_ZERO(x >= 0x10000)), \
>> > +     (((x) >> 2) & 0x7f)
>> 
>> I am still not sure if the actual saving are worth the complexity.
>> 
>> > +#define END() 0
>> > +{
>> > +     const u32 base = engine->mmio_base;
>> > +
>> > +     while (*data) {
>> > +             u8 count, flags;
>> > +
>> > +             if (*data & BIT(7)) { /* skip */
>> > +                     regs += *data++ & ~BIT(7);
>> > +                     continue;
>> > +             }
>> > +
>> > +             count = *data & 0x3f;
>> > +             flags = *data >> 6;
>> > +             data++;
>> > +
>> > +             *regs = MI_LOAD_REGISTER_IMM(count);
>> > +             if (flags & POSTED)
>> > +                     *regs |= MI_LRI_FORCE_POSTED;
>> > +             if (INTEL_GEN(engine->i915) >= 11)
>> > +                     *regs |= MI_LRI_CS_MMIO;
>> > +             regs++;
>> > +
>> > +             GEM_BUG_ON(!count);
>> > +             do {
>> > +                     u32 offset = 0;
>> > +                     u8 v;
>> > +
>> > +                     do {
>> > +                             v = *data++;
>> > +                             offset <<= 7;
>> > +                             offset |= v & ~BIT(7);
>> > +                     } while (v & BIT(7));
>> 
>> ...but perhaps this amount of extra can be tolerated.
>> 
>> Did you check how this would play out with just REG being wide enough?
>
> When I started, I thought we could get away with only one REG16. Looking
> at the context image I think we might want a few non engine->mmio_base
> regs in there (if I read it right, some of the 0x4000 range are per
> engine). That will need a slightly different encoding as well :|
>
> No, I haven't but since you ask, I shall.

Now we know the bloat diff and the complexity addition
is tiny so I am fine with using the tighter REG/REG16
split.

>
>> > +
>> > +                     *regs = base + (offset << 2);
>> 
>> In here reader is yearning for an asserts of not trampling
>> on wrong territory.
>
> If you have an idea for a good assert, go for it :)
>
> What range should be checked. offset < 0x1000 ?
>

I am fine at selftest trying to take the burden.
(that can be read like that I can't make up good asserts)

>> But I would guess that you want this part to be like
>> oiled lightning and test the machinery with selftest..as the
>> subject seems to promise.
>
> The importance is certainly placed on having a selftest and the
> confidence in keeping our offsets in line with the HW. The goal was to
> have a compact description for the register offsets, in terms of
> readability I think the emphasis should be on the tables
> (gen8_xcs_offsets[]).
>
>> > @@ -3092,7 +3451,7 @@ void intel_execlists_set_default_submission(struct intel_engine_cs *engine)
>> >                       engine->flags |= I915_ENGINE_HAS_PREEMPTION;
>> >       }
>> >  
>> > -     if (engine->class != COPY_ENGINE_CLASS && INTEL_GEN(engine->i915) >= 12)
>> > +     if (engine->class != COPY_ENGINE_CLASS && INTEL_GEN(engine->i915) >= 11)
>> >               engine->flags |= I915_ENGINE_HAS_RELATIVE_MMIO;
>> 
>> Ok, first I thought this was unintentional. But prolly not.
>> Do you need it for the verifier to work?
>
> No, I ended up completely ignoring this flag as the HW does not
> differentiate between engines. On gen11+, it sets the LRI flag everywhere
> in the context image.
>
>> Could we still rip it out to be a first in the series.
>> Just would want to differiante possible icl hickups apart
>> from this patch.

With the relative MMIO for gen11 lifted as a separate
patch prior to this one,

Reviewed-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>


>
> Sure.
>
>> > +static int live_lrc_layout(void *arg)
>> > +{
>> > +     struct intel_gt *gt = arg;
>> > +     struct intel_engine_cs *engine;
>> > +     enum intel_engine_id id;
>> > +     u32 *mem;
>> > +     int err;
>> > +
>> > +     /*
>> > +      * Check the registers offsets we use to create the initial reg state
>> > +      * match the layout saved by HW.
>> > +      */
>> > +
>> > +     mem = kmalloc(PAGE_SIZE, GFP_KERNEL);
>> > +     if (!mem)
>> > +             return -ENOMEM;
>> > +
>> > +     err = 0;
>> > +     for_each_engine(engine, gt->i915, id) {
>> > +             u32 *hw, *lrc;
>> > +             int dw;
>> > +
>> > +             if (!engine->default_state)
>> > +                     continue;
>> > +
>> > +             hw = i915_gem_object_pin_map(engine->default_state,
>> > +                                          I915_MAP_WB);
>> 
>> This default state is not pristine as we have trampled
>> it with our first submission, right?
>
> It is the context image saved after the first request.
>  
>> But being succeeded at doing so, the next context
>> save should overwrite our trampling and it would
>> then represent the hw accurate context save
>> state.
>> 
>> Against which we will compare of our reg state
>> writer.
>
> Right, default_state is the HW version of our init_reg_state.
>
>> > +             if (IS_ERR(hw)) {
>> > +                     err = PTR_ERR(hw);
>> > +                     break;
>> > +             }
>> > +             hw += LRC_STATE_PN * PAGE_SIZE / sizeof(*hw);
>> > +
>> > +             lrc = memset(mem, 0, PAGE_SIZE);
>> > +             execlists_init_reg_state(lrc,
>> > +                                      engine->kernel_context,
>> > +                                      engine,
>> > +                                      engine->kernel_context->ring,
>> > +                                      true);
>> > +
>> > +             dw = 0;
>> > +             do {
>> > +                     u32 lri = hw[dw];
>> > +
>> > +                     if (lri == 0) {
>> > +                             dw++;
>> > +                             continue;
>> > +                     }
>> > +
>> > +                     if ((lri & GENMASK(31, 23)) != MI_INSTR(0x22, 0)) {
>> > +                             pr_err("%s: Expected LRI command at dword %d, found %08x\n",
>> > +                                    engine->name, dw, lri);
>> > +                             err = -EINVAL;
>> > +                             break;
>> > +                     }
>> > +
>> > +                     if (lrc[dw] != lri) {
>> > +                             pr_err("%s: LRI command mismatch at dword %d, expected %08x found %08x\n",
>> > +                                    engine->name, dw, lri, lrc[dw]);
>> > +                             err = -EINVAL;
>> > +                             break;
>> > +                     }
>> > +
>> > +                     lri &= 0x7f;
>> > +                     lri++;
>> > +                     dw++;
>> > +
>> > +                     while (lri) {
>> > +                             if (hw[dw] != lrc[dw]) {
>> > +                                     pr_err("%s: Different registers found at dword %d, expected %x, found %x\n",
>> > +                                            engine->name, dw, hw[dw], lrc[dw]);
>> > +                                     err = -EINVAL;
>> > +                                     break;
>> > +                             }
>> > +
>> > +                             /*
>> > +                              * Skip over the actual register value as we
>> > +                              * expect that to differ.
>> > +                              */
>> > +                             dw += 2;
>> > +                             lri -= 2;
>> 
>> This makes me wonder if we could use this machinery post hang. Just to
>> get a little more triage data out, ie 'your context looks corrupted at
>> offset %x'...
>
> Certainly possible, but what we check here is _mostly_ the privileged
> registers that are not really meant to be changed by the user -- and we
> are only checking the offsets, so unlikely there to be just one wrong.
>
> The general principle was that we should provide raw information and
> have the smarts in userspace (so that we could always enhance our
> processing and reanalyse existing dumps). But at the end of the day,
> whatever allows us to prevent bugs or fix bugs is paramount.
>
> But I'm not yet sold this helps. Maybe if we find an example where it
> proves useful...
>
>> > +                     }
>> > +             } while ((lrc[dw] & ~BIT(0)) != MI_BATCH_BUFFER_END);
>> 
>> Ok, you tie up always the generate image. For future work add the hw batch
>> endpoint be a part of checker?
>
> It's not always in the first page, I'm not even sure if a BB_END is
> always included in the older gen. (I have a feeling the HW definitely
> started including it ~gen10.)
> -Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 22+ messages in thread

* ✗ Fi.CI.CHECKPATCH: warning for series starting with [v2] drm/i915/selftests: Verify the LRC register layout between init and HW (rev5)
  2019-09-23 23:02 [PATCH 1/2] drm/i915/selftests: Verify the LRC register layout between init and HW Chris Wilson
                   ` (8 preceding siblings ...)
  2019-09-24 14:59 ` [PATCH v2] drm/i915/selftests: Verify the LRC register layout between init and HW Chris Wilson
@ 2019-09-24 15:57 ` Patchwork
  2019-09-24 16:25 ` ✓ Fi.CI.BAT: success " Patchwork
  2019-09-25  6:56 ` ✓ Fi.CI.IGT: " Patchwork
  11 siblings, 0 replies; 22+ messages in thread
From: Patchwork @ 2019-09-24 15:57 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: series starting with [v2] drm/i915/selftests: Verify the LRC register layout between init and HW (rev5)
URL   : https://patchwork.freedesktop.org/series/67135/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
48cb8fb0a186 drm/i915/selftests: Verify the LRC register layout between init and HW
-:65: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'x' - possible side-effects?
#65: FILE: drivers/gpu/drm/i915/gt/intel_lrc.c:481:
+#define REG(x) (((x) >> 2) | BUILD_BUG_ON_ZERO(x >= 0x200))

-:66: ERROR:COMPLEX_MACRO: Macros with complex values should be enclosed in parentheses
#66: FILE: drivers/gpu/drm/i915/gt/intel_lrc.c:482:
+#define REG16(x) \
+	(((x) >> 9) | BIT(7) | BUILD_BUG_ON_ZERO(x >= 0x10000)), \
+	(((x) >> 2) & 0x7f)

-:66: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'x' - possible side-effects?
#66: FILE: drivers/gpu/drm/i915/gt/intel_lrc.c:482:
+#define REG16(x) \
+	(((x) >> 9) | BIT(7) | BUILD_BUG_ON_ZERO(x >= 0x10000)), \
+	(((x) >> 2) & 0x7f)

total: 1 errors, 0 warnings, 2 checks, 1117 lines checked
87a5399333b9 drm/i915/tgl: Swap engines for no rc6/rps (gpu powersave and reclocking)

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

^ permalink raw reply	[flat|nested] 22+ messages in thread

* ✓ Fi.CI.BAT: success for series starting with [v2] drm/i915/selftests: Verify the LRC register layout between init and HW (rev5)
  2019-09-23 23:02 [PATCH 1/2] drm/i915/selftests: Verify the LRC register layout between init and HW Chris Wilson
                   ` (9 preceding siblings ...)
  2019-09-24 15:57 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [v2] drm/i915/selftests: Verify the LRC register layout between init and HW (rev5) Patchwork
@ 2019-09-24 16:25 ` Patchwork
  2019-09-25  6:56 ` ✓ Fi.CI.IGT: " Patchwork
  11 siblings, 0 replies; 22+ messages in thread
From: Patchwork @ 2019-09-24 16:25 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: series starting with [v2] drm/i915/selftests: Verify the LRC register layout between init and HW (rev5)
URL   : https://patchwork.freedesktop.org/series/67135/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_6948 -> Patchwork_14518
====================================================

Summary
-------

  **SUCCESS**

  No regressions found.

  External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14518/

New tests
---------

  New tests have been introduced between CI_DRM_6948 and Patchwork_14518:

### New IGT tests (1) ###

  * igt@i915_selftest@live_gt_lrc:
    - Statuses : 42 pass(s)
    - Exec time: [0.40, 2.14] s

  

Known issues
------------

  Here are the changes found in Patchwork_14518 that come from known issues:

### IGT changes ###

#### Issues hit ####

  * igt@i915_selftest@live_gtt:
    - fi-glk-dsi:         [PASS][1] -> [INCOMPLETE][2] ([fdo#103359] / [k.org#198133])
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6948/fi-glk-dsi/igt@i915_selftest@live_gtt.html
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14518/fi-glk-dsi/igt@i915_selftest@live_gtt.html

  * igt@kms_chamelium@hdmi-hpd-fast:
    - fi-icl-u2:          [PASS][3] -> [FAIL][4] ([fdo#109483])
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6948/fi-icl-u2/igt@kms_chamelium@hdmi-hpd-fast.html
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14518/fi-icl-u2/igt@kms_chamelium@hdmi-hpd-fast.html
    - fi-kbl-7500u:       [PASS][5] -> [FAIL][6] ([fdo#111045] / [fdo#111096])
   [5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6948/fi-kbl-7500u/igt@kms_chamelium@hdmi-hpd-fast.html
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14518/fi-kbl-7500u/igt@kms_chamelium@hdmi-hpd-fast.html

  * igt@kms_frontbuffer_tracking@basic:
    - fi-hsw-peppy:       [PASS][7] -> [DMESG-WARN][8] ([fdo#102614])
   [7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6948/fi-hsw-peppy/igt@kms_frontbuffer_tracking@basic.html
   [8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14518/fi-hsw-peppy/igt@kms_frontbuffer_tracking@basic.html
    - fi-icl-u2:          [PASS][9] -> [FAIL][10] ([fdo#103167])
   [9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6948/fi-icl-u2/igt@kms_frontbuffer_tracking@basic.html
   [10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14518/fi-icl-u2/igt@kms_frontbuffer_tracking@basic.html

  
#### Possible fixes ####

  * igt@gem_exec_suspend@basic-s4-devices:
    - fi-blb-e6850:       [INCOMPLETE][11] ([fdo#107718]) -> [PASS][12]
   [11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6948/fi-blb-e6850/igt@gem_exec_suspend@basic-s4-devices.html
   [12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14518/fi-blb-e6850/igt@gem_exec_suspend@basic-s4-devices.html

  * igt@gem_tiled_fence_blits@basic:
    - {fi-tgl-u2}:        [SKIP][13] ([fdo#111714]) -> [PASS][14] +2 similar issues
   [13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6948/fi-tgl-u2/igt@gem_tiled_fence_blits@basic.html
   [14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14518/fi-tgl-u2/igt@gem_tiled_fence_blits@basic.html

  * igt@kms_frontbuffer_tracking@basic:
    - {fi-tgl-u2}:        [FAIL][15] ([fdo#111604]) -> [PASS][16]
   [15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6948/fi-tgl-u2/igt@kms_frontbuffer_tracking@basic.html
   [16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14518/fi-tgl-u2/igt@kms_frontbuffer_tracking@basic.html

  
  {name}: This element is suppressed. This means it is ignored when computing
          the status of the difference (SUCCESS, WARNING, or FAILURE).

  [fdo#102614]: https://bugs.freedesktop.org/show_bug.cgi?id=102614
  [fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
  [fdo#103359]: https://bugs.freedesktop.org/show_bug.cgi?id=103359
  [fdo#107718]: https://bugs.freedesktop.org/show_bug.cgi?id=107718
  [fdo#109483]: https://bugs.freedesktop.org/show_bug.cgi?id=109483
  [fdo#111045]: https://bugs.freedesktop.org/show_bug.cgi?id=111045
  [fdo#111096]: https://bugs.freedesktop.org/show_bug.cgi?id=111096
  [fdo#111604]: https://bugs.freedesktop.org/show_bug.cgi?id=111604
  [fdo#111714]: https://bugs.freedesktop.org/show_bug.cgi?id=111714
  [fdo#111718]: https://bugs.freedesktop.org/show_bug.cgi?id=111718
  [k.org#198133]: https://bugzilla.kernel.org/show_bug.cgi?id=198133


Participating hosts (52 -> 43)
------------------------------

  Additional (1): fi-icl-dsi 
  Missing    (10): fi-ilk-m540 fi-tgl-u fi-cml-h fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-kbl-8809g fi-icl-y fi-byt-clapper fi-bdw-samus 


Build changes
-------------

  * CI: CI-20190529 -> None
  * Linux: CI_DRM_6948 -> Patchwork_14518

  CI-20190529: 20190529
  CI_DRM_6948: 485ca160d8ffac7ffb5be5e76fa12ad46a7e5a19 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGT_5201: 3c1633abec14679300d52eeaf9fb7b63e435e51e @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_14518: 87a5399333b9a25a262d798f24e8c7b7c61a9f39 @ git://anongit.freedesktop.org/gfx-ci/linux


== Linux commits ==

87a5399333b9 drm/i915/tgl: Swap engines for no rc6/rps (gpu powersave and reclocking)
48cb8fb0a186 drm/i915/selftests: Verify the LRC register layout between init and HW

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14518/index.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 22+ messages in thread

* ✓ Fi.CI.IGT: success for series starting with [v2] drm/i915/selftests: Verify the LRC register layout between init and HW (rev5)
  2019-09-23 23:02 [PATCH 1/2] drm/i915/selftests: Verify the LRC register layout between init and HW Chris Wilson
                   ` (10 preceding siblings ...)
  2019-09-24 16:25 ` ✓ Fi.CI.BAT: success " Patchwork
@ 2019-09-25  6:56 ` Patchwork
  11 siblings, 0 replies; 22+ messages in thread
From: Patchwork @ 2019-09-25  6:56 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: series starting with [v2] drm/i915/selftests: Verify the LRC register layout between init and HW (rev5)
URL   : https://patchwork.freedesktop.org/series/67135/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_6948_full -> Patchwork_14518_full
====================================================

Summary
-------

  **SUCCESS**

  No regressions found.

  

Known issues
------------

  Here are the changes found in Patchwork_14518_full that come from known issues:

### IGT changes ###

#### Issues hit ####

  * igt@debugfs_test@read_all_entries_display_on:
    - shard-skl:          [PASS][1] -> [DMESG-WARN][2] ([fdo#106107])
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6948/shard-skl4/igt@debugfs_test@read_all_entries_display_on.html
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14518/shard-skl1/igt@debugfs_test@read_all_entries_display_on.html

  * igt@gem_ctx_shared@exec-single-timeline-bsd:
    - shard-iclb:         [PASS][3] -> [SKIP][4] ([fdo#110841])
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6948/shard-iclb8/igt@gem_ctx_shared@exec-single-timeline-bsd.html
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14518/shard-iclb4/igt@gem_ctx_shared@exec-single-timeline-bsd.html

  * igt@gem_exec_balancer@smoke:
    - shard-iclb:         [PASS][5] -> [SKIP][6] ([fdo#110854])
   [5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6948/shard-iclb2/igt@gem_exec_balancer@smoke.html
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14518/shard-iclb8/igt@gem_exec_balancer@smoke.html

  * igt@gem_exec_schedule@preempt-queue-bsd1:
    - shard-iclb:         [PASS][7] -> [SKIP][8] ([fdo#109276]) +15 similar issues
   [7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6948/shard-iclb2/igt@gem_exec_schedule@preempt-queue-bsd1.html
   [8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14518/shard-iclb8/igt@gem_exec_schedule@preempt-queue-bsd1.html

  * igt@gem_exec_schedule@preemptive-hang-bsd:
    - shard-iclb:         [PASS][9] -> [SKIP][10] ([fdo#111325]) +3 similar issues
   [9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6948/shard-iclb8/igt@gem_exec_schedule@preemptive-hang-bsd.html
   [10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14518/shard-iclb4/igt@gem_exec_schedule@preemptive-hang-bsd.html

  * igt@gem_workarounds@suspend-resume-context:
    - shard-apl:          [PASS][11] -> [DMESG-WARN][12] ([fdo#108566]) +3 similar issues
   [11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6948/shard-apl7/igt@gem_workarounds@suspend-resume-context.html
   [12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14518/shard-apl8/igt@gem_workarounds@suspend-resume-context.html

  * igt@i915_pm_rps@waitboost:
    - shard-apl:          [PASS][13] -> [FAIL][14] ([fdo#102250])
   [13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6948/shard-apl6/igt@i915_pm_rps@waitboost.html
   [14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14518/shard-apl5/igt@i915_pm_rps@waitboost.html

  * igt@kms_atomic@crtc_invalid_params_fence:
    - shard-snb:          [PASS][15] -> [SKIP][16] ([fdo#109271]) +2 similar issues
   [15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6948/shard-snb7/igt@kms_atomic@crtc_invalid_params_fence.html
   [16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14518/shard-snb2/igt@kms_atomic@crtc_invalid_params_fence.html

  * igt@kms_cursor_crc@pipe-c-cursor-128x128-random:
    - shard-iclb:         [PASS][17] -> [INCOMPLETE][18] ([fdo#107713])
   [17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6948/shard-iclb6/igt@kms_cursor_crc@pipe-c-cursor-128x128-random.html
   [18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14518/shard-iclb1/igt@kms_cursor_crc@pipe-c-cursor-128x128-random.html

  * igt@kms_cursor_crc@pipe-c-cursor-64x64-random:
    - shard-apl:          [PASS][19] -> [INCOMPLETE][20] ([fdo#103927]) +1 similar issue
   [19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6948/shard-apl2/igt@kms_cursor_crc@pipe-c-cursor-64x64-random.html
   [20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14518/shard-apl3/igt@kms_cursor_crc@pipe-c-cursor-64x64-random.html

  * igt@kms_frontbuffer_tracking@fbc-1p-primscrn-pri-shrfb-draw-blt:
    - shard-iclb:         [PASS][21] -> [FAIL][22] ([fdo#103167]) +8 similar issues
   [21]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6948/shard-iclb2/igt@kms_frontbuffer_tracking@fbc-1p-primscrn-pri-shrfb-draw-blt.html
   [22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14518/shard-iclb6/igt@kms_frontbuffer_tracking@fbc-1p-primscrn-pri-shrfb-draw-blt.html

  * igt@kms_pipe_crc_basic@suspend-read-crc-pipe-a:
    - shard-skl:          [PASS][23] -> [INCOMPLETE][24] ([fdo#104108])
   [23]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6948/shard-skl5/igt@kms_pipe_crc_basic@suspend-read-crc-pipe-a.html
   [24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14518/shard-skl2/igt@kms_pipe_crc_basic@suspend-read-crc-pipe-a.html

  * igt@kms_plane_alpha_blend@pipe-a-constant-alpha-min:
    - shard-skl:          [PASS][25] -> [FAIL][26] ([fdo#108145])
   [25]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6948/shard-skl4/igt@kms_plane_alpha_blend@pipe-a-constant-alpha-min.html
   [26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14518/shard-skl9/igt@kms_plane_alpha_blend@pipe-a-constant-alpha-min.html

  * igt@kms_psr@psr2_no_drrs:
    - shard-iclb:         [PASS][27] -> [SKIP][28] ([fdo#109441]) +2 similar issues
   [27]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6948/shard-iclb2/igt@kms_psr@psr2_no_drrs.html
   [28]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14518/shard-iclb6/igt@kms_psr@psr2_no_drrs.html

  * igt@kms_vblank@pipe-c-ts-continuation-dpms-suspend:
    - shard-kbl:          [PASS][29] -> [INCOMPLETE][30] ([fdo#103665])
   [29]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6948/shard-kbl4/igt@kms_vblank@pipe-c-ts-continuation-dpms-suspend.html
   [30]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14518/shard-kbl1/igt@kms_vblank@pipe-c-ts-continuation-dpms-suspend.html

  
#### Possible fixes ####

  * igt@gem_ctx_isolation@vecs0-s3:
    - shard-skl:          [INCOMPLETE][31] ([fdo#104108]) -> [PASS][32]
   [31]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6948/shard-skl9/igt@gem_ctx_isolation@vecs0-s3.html
   [32]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14518/shard-skl1/igt@gem_ctx_isolation@vecs0-s3.html

  * igt@gem_ctx_switch@rcs0-heavy-queue:
    - shard-iclb:         [INCOMPLETE][33] ([fdo#107713]) -> [PASS][34]
   [33]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6948/shard-iclb7/igt@gem_ctx_switch@rcs0-heavy-queue.html
   [34]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14518/shard-iclb7/igt@gem_ctx_switch@rcs0-heavy-queue.html

  * igt@gem_eio@reset-stress:
    - shard-snb:          [FAIL][35] ([fdo#109661]) -> [PASS][36]
   [35]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6948/shard-snb1/igt@gem_eio@reset-stress.html
   [36]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14518/shard-snb7/igt@gem_eio@reset-stress.html

  * igt@gem_exec_schedule@wide-bsd:
    - shard-iclb:         [SKIP][37] ([fdo#111325]) -> [PASS][38] +5 similar issues
   [37]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6948/shard-iclb1/igt@gem_exec_schedule@wide-bsd.html
   [38]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14518/shard-iclb3/igt@gem_exec_schedule@wide-bsd.html

  * igt@gem_pipe_control_store_loop@reused-buffer:
    - shard-apl:          [INCOMPLETE][39] ([fdo#103927]) -> [PASS][40]
   [39]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6948/shard-apl6/igt@gem_pipe_control_store_loop@reused-buffer.html
   [40]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14518/shard-apl5/igt@gem_pipe_control_store_loop@reused-buffer.html

  * igt@gem_tiled_swapping@non-threaded:
    - shard-apl:          [DMESG-WARN][41] ([fdo#108686]) -> [PASS][42]
   [41]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6948/shard-apl8/igt@gem_tiled_swapping@non-threaded.html
   [42]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14518/shard-apl1/igt@gem_tiled_swapping@non-threaded.html

  * {igt@i915_pm_dc@dc5-dpms}:
    - shard-iclb:         [FAIL][43] ([fdo#111795 ]) -> [PASS][44]
   [43]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6948/shard-iclb3/igt@i915_pm_dc@dc5-dpms.html
   [44]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14518/shard-iclb8/igt@i915_pm_dc@dc5-dpms.html

  * igt@kms_flip@flip-vs-suspend-interruptible:
    - shard-hsw:          [INCOMPLETE][45] ([fdo#103540]) -> [PASS][46]
   [45]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6948/shard-hsw5/igt@kms_flip@flip-vs-suspend-interruptible.html
   [46]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14518/shard-hsw2/igt@kms_flip@flip-vs-suspend-interruptible.html

  * igt@kms_frontbuffer_tracking@fbc-1p-primscrn-spr-indfb-draw-render:
    - shard-iclb:         [FAIL][47] ([fdo#103167]) -> [PASS][48] +1 similar issue
   [47]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6948/shard-iclb2/igt@kms_frontbuffer_tracking@fbc-1p-primscrn-spr-indfb-draw-render.html
   [48]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14518/shard-iclb8/igt@kms_frontbuffer_tracking@fbc-1p-primscrn-spr-indfb-draw-render.html

  * igt@kms_frontbuffer_tracking@fbc-suspend:
    - shard-apl:          [DMESG-WARN][49] ([fdo#108566]) -> [PASS][50] +2 similar issues
   [49]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6948/shard-apl5/igt@kms_frontbuffer_tracking@fbc-suspend.html
   [50]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14518/shard-apl4/igt@kms_frontbuffer_tracking@fbc-suspend.html

  * igt@kms_frontbuffer_tracking@fbcpsr-slowdraw:
    - shard-iclb:         [INCOMPLETE][51] ([fdo#106978] / [fdo#107713]) -> [PASS][52]
   [51]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6948/shard-iclb7/igt@kms_frontbuffer_tracking@fbcpsr-slowdraw.html
   [52]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14518/shard-iclb4/igt@kms_frontbuffer_tracking@fbcpsr-slowdraw.html

  * igt@kms_plane_alpha_blend@pipe-b-coverage-7efc:
    - shard-skl:          [FAIL][53] ([fdo#108145] / [fdo#110403]) -> [PASS][54]
   [53]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6948/shard-skl9/igt@kms_plane_alpha_blend@pipe-b-coverage-7efc.html
   [54]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14518/shard-skl1/igt@kms_plane_alpha_blend@pipe-b-coverage-7efc.html

  * igt@kms_psr2_su@frontbuffer:
    - shard-iclb:         [SKIP][55] ([fdo#109642] / [fdo#111068]) -> [PASS][56] +1 similar issue
   [55]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6948/shard-iclb4/igt@kms_psr2_su@frontbuffer.html
   [56]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14518/shard-iclb2/igt@kms_psr2_su@frontbuffer.html

  * igt@kms_setmode@basic:
    - shard-hsw:          [FAIL][57] ([fdo#99912]) -> [PASS][58]
   [57]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6948/shard-hsw2/igt@kms_setmode@basic.html
   [58]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14518/shard-hsw1/igt@kms_setmode@basic.html

  * igt@kms_vblank@pipe-a-ts-continuation-dpms-suspend:
    - shard-kbl:          [INCOMPLETE][59] ([fdo#103665]) -> [PASS][60]
   [59]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6948/shard-kbl6/igt@kms_vblank@pipe-a-ts-continuation-dpms-suspend.html
   [60]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14518/shard-kbl3/igt@kms_vblank@pipe-a-ts-continuation-dpms-suspend.html

  * igt@perf@polling:
    - shard-skl:          [FAIL][61] ([fdo#110728]) -> [PASS][62]
   [61]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6948/shard-skl6/igt@perf@polling.html
   [62]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14518/shard-skl8/igt@perf@polling.html

  * igt@perf@short-reads:
    - shard-skl:          [FAIL][63] ([fdo#103183]) -> [PASS][64]
   [63]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6948/shard-skl9/igt@perf@short-reads.html
   [64]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14518/shard-skl10/igt@perf@short-reads.html

  * igt@prime_vgem@fence-wait-bsd2:
    - shard-iclb:         [SKIP][65] ([fdo#109276]) -> [PASS][66] +20 similar issues
   [65]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6948/shard-iclb8/igt@prime_vgem@fence-wait-bsd2.html
   [66]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14518/shard-iclb4/igt@prime_vgem@fence-wait-bsd2.html

  
#### Warnings ####

  * igt@gem_mocs_settings@mocs-reset-bsd2:
    - shard-iclb:         [SKIP][67] ([fdo#109276]) -> [FAIL][68] ([fdo#111330])
   [67]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6948/shard-iclb6/igt@gem_mocs_settings@mocs-reset-bsd2.html
   [68]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14518/shard-iclb1/igt@gem_mocs_settings@mocs-reset-bsd2.html

  * igt@kms_atomic_transition@4x-modeset-transitions:
    - shard-snb:          [SKIP][69] ([fdo#109271] / [fdo#109278]) -> [SKIP][70] ([fdo#109271])
   [69]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6948/shard-snb7/igt@kms_atomic_transition@4x-modeset-transitions.html
   [70]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14518/shard-snb2/igt@kms_atomic_transition@4x-modeset-transitions.html

  * igt@kms_cursor_crc@pipe-a-cursor-suspend:
    - shard-apl:          [INCOMPLETE][71] ([fdo#103927]) -> [DMESG-WARN][72] ([fdo#108566])
   [71]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6948/shard-apl1/igt@kms_cursor_crc@pipe-a-cursor-suspend.html
   [72]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14518/shard-apl6/igt@kms_cursor_crc@pipe-a-cursor-suspend.html

  
  {name}: This element is suppressed. This means it is ignored when computing
          the status of the difference (SUCCESS, WARNING, or FAILURE).

  [fdo#102250]: https://bugs.freedesktop.org/show_bug.cgi?id=102250
  [fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
  [fdo#103183]: https://bugs.freedesktop.org/show_bug.cgi?id=103183
  [fdo#103540]: https://bugs.freedesktop.org/show_bug.cgi?id=103540
  [fdo#103665]: https://bugs.freedesktop.org/show_bug.cgi?id=103665
  [fdo#103927]: https://bugs.freedesktop.org/show_bug.cgi?id=103927
  [fdo#104108]: https://bugs.freedesktop.org/show_bug.cgi?id=104108
  [fdo#106107]: https://bugs.freedesktop.org/show_bug.cgi?id=106107
  [fdo#106978]: https://bugs.freedesktop.org/show_bug.cgi?id=106978
  [fdo#107713]: https://bugs.freedesktop.org/show_bug.cgi?id=107713
  [fdo#108145]: https://bugs.freedesktop.org/show_bug.cgi?id=108145
  [fdo#108566]: https://bugs.freedesktop.org/show_bug.cgi?id=108566
  [fdo#108686]: https://bugs.freedesktop.org/show_bug.cgi?id=108686
  [fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
  [fdo#109276]: https://bugs.freedesktop.org/show_bug.cgi?id=109276
  [fdo#109278]: https://bugs.freedesktop.org/show_bug.cgi?id=109278
  [fdo#109441]: https://bugs.freedesktop.org/show_bug.cgi?id=109441
  [fdo#109642]: https://bugs.freedesktop.org/show_bug.cgi?id=109642
  [fdo#109661]: https://bugs.freedesktop.org/show_bug.cgi?id=109661
  [fdo#110403]: https://bugs.freedesktop.org/show_bug.cgi?id=110403
  [fdo#110728]: https://bugs.freedesktop.org/show_bug.cgi?id=110728
  [fdo#110841]: https://bugs.freedesktop.org/show_bug.cgi?id=110841
  [fdo#110854]: https://bugs.freedesktop.org/show_bug.cgi?id=110854
  [fdo#111068]: https://bugs.freedesktop.org/show_bug.cgi?id=111068
  [fdo#111325]: https://bugs.freedesktop.org/show_bug.cgi?id=111325
  [fdo#111330]: https://bugs.freedesktop.org/show_bug.cgi?id=111330
  [fdo#111795 ]: https://bugs.freedesktop.org/show_bug.cgi?id=111795 
  [fdo#99912]: https://bugs.freedesktop.org/show_bug.cgi?id=99912


Participating hosts (9 -> 9)
------------------------------

  No changes in participating hosts


Build changes
-------------

  * CI: CI-20190529 -> None
  * Linux: CI_DRM_6948 -> Patchwork_14518

  CI-20190529: 20190529
  CI_DRM_6948: 485ca160d8ffac7ffb5be5e76fa12ad46a7e5a19 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGT_5201: 3c1633abec14679300d52eeaf9fb7b63e435e51e @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_14518: 87a5399333b9a25a262d798f24e8c7b7c61a9f39 @ git://anongit.freedesktop.org/gfx-ci/linux
  piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14518/
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 22+ messages in thread

* ✓ Fi.CI.BAT: success for series starting with [1/2] drm/i915/selftests: Verify the LRC register layout between init and HW (rev2)
  2019-09-20 19:55 [PATCH 1/2] drm/i915/selftests: Verify the LRC register layout between init and HW Chris Wilson
@ 2019-09-22 14:54 ` Patchwork
  0 siblings, 0 replies; 22+ messages in thread
From: Patchwork @ 2019-09-22 14:54 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: series starting with [1/2] drm/i915/selftests: Verify the LRC register layout between init and HW (rev2)
URL   : https://patchwork.freedesktop.org/series/67018/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_6935 -> Patchwork_14489
====================================================

Summary
-------

  **SUCCESS**

  No regressions found.

  External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14489/

New tests
---------

  New tests have been introduced between CI_DRM_6935 and Patchwork_14489:

### New IGT tests (1) ###

  * igt@i915_selftest@live_gt_lrc:
    - Statuses : 41 pass(s)
    - Exec time: [0.37, 2.07] s

  

Known issues
------------

  Here are the changes found in Patchwork_14489 that come from known issues:

### IGT changes ###

#### Issues hit ####

  * igt@gem_ctx_create@basic-files:
    - fi-apl-guc:         [PASS][1] -> [INCOMPLETE][2] ([fdo#103927])
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6935/fi-apl-guc/igt@gem_ctx_create@basic-files.html
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14489/fi-apl-guc/igt@gem_ctx_create@basic-files.html

  * igt@gem_ctx_switch@rcs0:
    - fi-cml-u2:          [PASS][3] -> [INCOMPLETE][4] ([fdo#110566])
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6935/fi-cml-u2/igt@gem_ctx_switch@rcs0.html
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14489/fi-cml-u2/igt@gem_ctx_switch@rcs0.html

  * igt@gem_exec_suspend@basic-s3:
    - fi-blb-e6850:       [PASS][5] -> [INCOMPLETE][6] ([fdo#107718])
   [5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6935/fi-blb-e6850/igt@gem_exec_suspend@basic-s3.html
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14489/fi-blb-e6850/igt@gem_exec_suspend@basic-s3.html

  * igt@kms_frontbuffer_tracking@basic:
    - fi-hsw-peppy:       [PASS][7] -> [DMESG-WARN][8] ([fdo#102614])
   [7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6935/fi-hsw-peppy/igt@kms_frontbuffer_tracking@basic.html
   [8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14489/fi-hsw-peppy/igt@kms_frontbuffer_tracking@basic.html

  
#### Possible fixes ####

  * igt@gem_ctx_switch@rcs0:
    - {fi-icl-guc}:       [INCOMPLETE][9] ([fdo#107713]) -> [PASS][10]
   [9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6935/fi-icl-guc/igt@gem_ctx_switch@rcs0.html
   [10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14489/fi-icl-guc/igt@gem_ctx_switch@rcs0.html

  * igt@i915_selftest@live_hangcheck:
    - {fi-icl-dsi}:       [DMESG-FAIL][11] ([fdo#111678]) -> [PASS][12]
   [11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6935/fi-icl-dsi/igt@i915_selftest@live_hangcheck.html
   [12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14489/fi-icl-dsi/igt@i915_selftest@live_hangcheck.html

  
  {name}: This element is suppressed. This means it is ignored when computing
          the status of the difference (SUCCESS, WARNING, or FAILURE).

  [fdo#102614]: https://bugs.freedesktop.org/show_bug.cgi?id=102614
  [fdo#103927]: https://bugs.freedesktop.org/show_bug.cgi?id=103927
  [fdo#107713]: https://bugs.freedesktop.org/show_bug.cgi?id=107713
  [fdo#107718]: https://bugs.freedesktop.org/show_bug.cgi?id=107718
  [fdo#109100]: https://bugs.freedesktop.org/show_bug.cgi?id=109100
  [fdo#110566]: https://bugs.freedesktop.org/show_bug.cgi?id=110566
  [fdo#111593]: https://bugs.freedesktop.org/show_bug.cgi?id=111593
  [fdo#111678]: https://bugs.freedesktop.org/show_bug.cgi?id=111678


Participating hosts (55 -> 48)
------------------------------

  Missing    (7): fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-icl-y fi-byt-clapper fi-bdw-samus 


Build changes
-------------

  * CI: CI-20190529 -> None
  * Linux: CI_DRM_6935 -> Patchwork_14489

  CI-20190529: 20190529
  CI_DRM_6935: fd159a931308ad279c27e138e1724265e04326dd @ git://anongit.freedesktop.org/gfx-ci/linux
  IGT_5196: 98783313b8b3097680df69007a9551c6248ab209 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_14489: d35131b8ca313f7d9d43635a66a82638a8d7ce60 @ git://anongit.freedesktop.org/gfx-ci/linux


== Linux commits ==

d35131b8ca31 drm/i915/tgl: Swap engines for rc6/powersaving
3651aa32b5c0 drm/i915/selftests: Verify the LRC register layout between init and HW

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14489/index.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2019-09-25  6:56 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-23 23:02 [PATCH 1/2] drm/i915/selftests: Verify the LRC register layout between init and HW Chris Wilson
2019-09-23 23:02 ` [PATCH 2/2] drm/i915/tgl: Swap engines for rps (gpu reclocking) Chris Wilson
2019-09-24  7:09   ` [PATCH] drm/i915/tgl: Swap engines for no rc6/rps (gpu powersave and reclocking) Chris Wilson
2019-09-23 23:08 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [1/2] drm/i915/selftests: Verify the LRC register layout between init and HW Patchwork
2019-09-23 23:31 ` ✓ Fi.CI.BAT: success " Patchwork
2019-09-24  7:17 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [1/2] drm/i915/selftests: Verify the LRC register layout between init and HW (rev2) Patchwork
2019-09-24  7:43 ` ✓ Fi.CI.BAT: success " Patchwork
2019-09-24  7:59   ` Chris Wilson
2019-09-24 10:21 ` [PATCH 1/2] drm/i915/selftests: Verify the LRC register layout between init and HW Mika Kuoppala
2019-09-24 10:43   ` Chris Wilson
2019-09-24 15:07     ` Mika Kuoppala
2019-09-24 11:00   ` Chris Wilson
2019-09-24 11:58     ` Mika Kuoppala
2019-09-24 13:23 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [1/2] drm/i915/selftests: Verify the LRC register layout between init and HW (rev3) Patchwork
2019-09-24 13:48 ` ✓ Fi.CI.BAT: success " Patchwork
2019-09-24 13:58   ` Chris Wilson
2019-09-24 14:59 ` [PATCH v2] drm/i915/selftests: Verify the LRC register layout between init and HW Chris Wilson
2019-09-24 15:04   ` Chris Wilson
2019-09-24 15:57 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [v2] drm/i915/selftests: Verify the LRC register layout between init and HW (rev5) Patchwork
2019-09-24 16:25 ` ✓ Fi.CI.BAT: success " Patchwork
2019-09-25  6:56 ` ✓ Fi.CI.IGT: " Patchwork
  -- strict thread matches above, loose matches on Subject: below --
2019-09-20 19:55 [PATCH 1/2] drm/i915/selftests: Verify the LRC register layout between init and HW Chris Wilson
2019-09-22 14:54 ` ✓ Fi.CI.BAT: success for series starting with [1/2] drm/i915/selftests: Verify the LRC register layout between init and HW (rev2) Patchwork

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.