Skip to contentSkip to conversation

drm/i915: Add Wa_18022495364

PATCH Superseded Dnyaneshwar Bhadane 3 participants 4 messages Sep 14, 2023

Subsystems (2)

v6 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

PATCH v6 1/1 drm/i915: Add Wa_18022495364

Invalidate instruction and State cache bit using INDIRECT_CTX on every gpu context switch for gen12.
The goal of this workaround is to actually perform an explicit invalidation of that cache (by re-writing the register) during every GPU context switch, which is accomplished via a "workaround batchbuffer" that's attached to the context via INDIRECT_CTX. (Matt Ropper)
BSpec: 11354

Please refer [1] for more reviews and comment on the same patch

[1] https://patchwork.freedesktop.org/patch/556154/

v2:
- Remove extra parentheses from the condition (Lucas)
- Align spacing and new line (Lucas)

v3:
- Fix commit message.

v4:
- Only GEN12 changes are kept (Matt Ropper)
- Fix the commit message for r-b (Matt Ropper)
- Rename the register bit in define

v5:
- Move out this workaround from golden context init (Matt Roper)
- Use INDIRECT_CTX to set bit on each GPU context switch (Matt Roper)

v6:
- Change IP Version base condition for Gen12 (Matt Ropper)
- Made imperative form of commit version messages (Suraj)
- s/Added/Add in patch header (Suraj)

Cc Lucas De Marchi <[email protected]>
Cc Matt Roper <[email protected]>
Cc Suraj Kandpal <[email protected]>
---
 drivers/gpu/drm/i915/gt/intel_gt_regs.h |  2 ++
 drivers/gpu/drm/i915/gt/intel_lrc.c     | 13 +++++++++++++
 2 files changed, 15 insertions(+)
drivers/gpu/drm/i915/gt/intel_gt_regs.h +2 -0
index a00ff51c681d..0d5260d126d8 100644
@@ -164,6 +164,8 @@
 #define GEN9_CSFE_CHICKEN1_RCS			_MMIO(0x20d4)
 #define   GEN9_PREEMPT_GPGPU_SYNC_SWITCH_DISABLE	(1 << 2)
 #define   GEN11_ENABLE_32_PLANE_MODE		(1 << 7)
+#define GEN12_CS_DEBUG_MODE2			_MMIO(0x20d8)
+#define   INSTRUCTION_STATE_CACHE_INVALIDATE	REG_BIT(6)
 
 #define GEN7_FF_SLICE_CS_CHICKEN1		_MMIO(0x20e0)
 #define   GEN9_FFSC_PERCTX_PREEMPT_CTRL		(1 << 14)
drivers/gpu/drm/i915/gt/intel_lrc.c +13 -0
index b99efa348ad1..56c916730e9b 100644
@@ -1333,6 +1333,15 @@ dg2_emit_draw_watermark_setting(u32 *cs)
 	return cs;
 }
 
+static u32 *
+gen12_invalidate_state_cache(u32 *cs)
+{
+	*cs++ = MI_LOAD_REGISTER_IMM(1);
+	*cs++ = i915_mmio_reg_offset(GEN12_CS_DEBUG_MODE2);
+	*cs++ = _MASKED_BIT_ENABLE(INSTRUCTION_STATE_CACHE_INVALIDATE);
+	return cs;
+}
+
 static u32 *
 gen12_emit_indirect_ctx_rcs(const struct intel_context *ce, u32 *cs)
 {
@@ -1346,6 +1355,10 @@ gen12_emit_indirect_ctx_rcs(const struct intel_context *ce, u32 *cs)
 
 	cs = gen12_emit_aux_table_inv(ce->engine, cs);
 
+	/* Wa_18022495364 */
+	if (IS_GFX_GT_IP_RANGE(ce->engine->gt, IP_VER(12, 0), IP_VER(12, 10)))
+		cs = gen12_invalidate_state_cache(cs);
+
 	/* Wa_16014892111 */
 	if (IS_GFX_GT_IP_STEP(ce->engine->gt, IP_VER(12, 70), STEP_A0, STEP_B0) ||
 	    IS_GFX_GT_IP_STEP(ce->engine->gt, IP_VER(12, 71), STEP_A0, STEP_B0) ||
Signature · 1 line
2.34.1
#1 lore raw
Quoted 16 lines · Dnyaneshwar Bhadane

Invalidate instruction and State cache bit using INDIRECT_CTX on every gpu context switch for gen12.
The goal of this workaround is to actually perform an explicit invalidation of that cache (by re-writing the register) during every GPU context switch, which is accomplished via a "workaround batchbuffer" that's attached to the context via INDIRECT_CTX. (Matt Ropper)
BSpec: 11354

Please refer [1] for more reviews and comment on the same patch

[1] https://patchwork.freedesktop.org/patch/556154/

v2:
- Remove extra parentheses from the condition (Lucas)
- Align spacing and new line (Lucas)

Quoted 5 lines

v3:
- Fix commit message.

v4:
- Only GEN12 changes are kept (Matt Ropper)

Not clear to me what this means, also its Matt Roper

Quoted 9 lines

- Fix the commit message for r-b (Matt Ropper)
- Rename the register bit in define

v5:
- Move out this workaround from golden context init (Matt Roper)
- Use INDIRECT_CTX to set bit on each GPU context switch (Matt Roper)

v6:
- Change IP Version base condition for Gen12 (Matt Ropper)

Matt Roper

Quoted 60 lines

- Made imperative form of commit version messages (Suraj)
- s/Added/Add in patch header (Suraj)

Cc Lucas De Marchi <[email protected]>
Cc Matt Roper <[email protected]>
Cc Suraj Kandpal <[email protected]>
---
 drivers/gpu/drm/i915/gt/intel_gt_regs.h |  2 ++
 drivers/gpu/drm/i915/gt/intel_lrc.c     | 13 +++++++++++++
 2 files changed, 15 insertions(+)
drivers/gpu/drm/i915/gt/intel_gt_regs.h +2 -0
index a00ff51c681d..0d5260d126d8 100644
@@ -164,6 +164,8 @@
 #define GEN9_CSFE_CHICKEN1_RCS			_MMIO(0x20d4)
 #define   GEN9_PREEMPT_GPGPU_SYNC_SWITCH_DISABLE	(1 << 2)
 #define   GEN11_ENABLE_32_PLANE_MODE		(1 << 7)
+#define GEN12_CS_DEBUG_MODE2			_MMIO(0x20d8)
+#define   INSTRUCTION_STATE_CACHE_INVALIDATE	REG_BIT(6)
 
 #define GEN7_FF_SLICE_CS_CHICKEN1		_MMIO(0x20e0)
 #define   GEN9_FFSC_PERCTX_PREEMPT_CTRL		(1 << 14)
drivers/gpu/drm/i915/gt/intel_lrc.c +13 -0
index b99efa348ad1..56c916730e9b 100644
@@ -1333,6 +1333,15 @@ dg2_emit_draw_watermark_setting(u32 *cs)
 	return cs;
 }
 
+static u32 *
+gen12_invalidate_state_cache(u32 *cs)
+{
+	*cs++ = MI_LOAD_REGISTER_IMM(1);
+	*cs++ = i915_mmio_reg_offset(GEN12_CS_DEBUG_MODE2);
+	*cs++ = _MASKED_BIT_ENABLE(INSTRUCTION_STATE_CACHE_INVALIDATE);
+	return cs;
+}
+
 static u32 *
 gen12_emit_indirect_ctx_rcs(const struct intel_context *ce, u32 *cs)
 {
@@ -1346,6 +1355,10 @@ gen12_emit_indirect_ctx_rcs(const struct intel_context *ce, u32 *cs)
 
 	cs = gen12_emit_aux_table_inv(ce->engine, cs);
 
+	/* Wa_18022495364 */
+	if (IS_GFX_GT_IP_RANGE(ce->engine->gt, IP_VER(12, 0), IP_VER(12, 10)))
+		cs = gen12_invalidate_state_cache(cs);
+
 	/* Wa_16014892111 */
 	if (IS_GFX_GT_IP_STEP(ce->engine->gt, IP_VER(12, 70), STEP_A0, STEP_B0) ||
 	    IS_GFX_GT_IP_STEP(ce->engine->gt, IP_VER(12, 71), STEP_A0, STEP_B0) ||
Signature · 1 line
2.34.1
#2 lore raw
Quoted 29 lines

-----Original Message-----
From: Atwood, Matthew S <[email protected]>
Sent: Friday, September 15, 2023 1:15 AM
To: Bhadane, Dnyaneshwar <[email protected]>
Cc: [email protected]; De Marchi, Lucas <[email protected]>; Garg, Nemesa <[email protected]>; Roper, Matthew D <[email protected]>; Kandpal, Suraj <[email protected]>
Subject: Re: [PATCH v6] drm/i915: Add Wa_18022495364

Quoted 16 lines · Dnyaneshwar Bhadane

Invalidate instruction and State cache bit using INDIRECT_CTX on every gpu context switch for gen12.
The goal of this workaround is to actually perform an explicit invalidation of that cache (by re-writing the register) during every GPU context switch, which is accomplished via a "workaround batchbuffer" that's attached to the context via INDIRECT_CTX. (Matt Ropper)
BSpec: 11354

Please refer [1] for more reviews and comment on the same patch

[1] https://patchwork.freedesktop.org/patch/556154/

v2:
- Remove extra parentheses from the condition (Lucas)
- Align spacing and new line (Lucas)

Quoted 6 lines
Quoted 5 lines

v3:
- Fix commit message.

v4:
- Only GEN12 changes are kept (Matt Ropper)

Not clear to me what this means,

Matt has corrected me by saying that this workaround should only be applied to Gen12 platforms. Initially, the patch was combined for the Gen12 and DG+ conditions, which was an incorrect understanding. Dnyaneshwar

Quoted 75 lines
Quoted 10 lines

also its Matt Roper
- Fix the commit message for r-b (Matt Ropper)
- Rename the register bit in define

v5:
- Move out this workaround from golden context init (Matt Roper)
- Use INDIRECT_CTX to set bit on each GPU context switch (Matt Roper)

v6:
- Change IP Version base condition for Gen12 (Matt Ropper)

Matt Roper

Quoted 33 lines

- Made imperative form of commit version messages (Suraj)
- s/Added/Add in patch header (Suraj)

Cc Lucas De Marchi <[email protected]>
Cc Matt Roper <[email protected]>
Cc Suraj Kandpal <[email protected]>
---
 drivers/gpu/drm/i915/gt/intel_gt_regs.h |  2 ++
 drivers/gpu/drm/i915/gt/intel_lrc.c     | 13 +++++++++++++
 2 files changed, 15 insertions(+)
drivers/gpu/drm/i915/gt/intel_gt_regs.h +2 -0
index a00ff51c681d..0d5260d126d8 100644
@@ -164,6 +164,8 @@
 #define GEN9_CSFE_CHICKEN1_RCS			_MMIO(0x20d4)
 #define   GEN9_PREEMPT_GPGPU_SYNC_SWITCH_DISABLE	(1 << 2)
 #define   GEN11_ENABLE_32_PLANE_MODE		(1 << 7)
+#define GEN12_CS_DEBUG_MODE2			_MMIO(0x20d8)
+#define   INSTRUCTION_STATE_CACHE_INVALIDATE	REG_BIT(6)
 
 #define GEN7_FF_SLICE_CS_CHICKEN1		_MMIO(0x20e0)
 #define   GEN9_FFSC_PERCTX_PREEMPT_CTRL		(1 << 14)
drivers/gpu/drm/i915/gt/intel_lrc.c +0 -0
index b99efa348ad1..56c916730e9b 100644

drivers/gpu/drm/i915/gt/intel_lrc.c dg2_emit_draw_watermark_setting(u32 *cs) · line 1340

Quoted 8 lines
drivers/gpu/drm/i915/gt/intel_lrc.c +5 -0
@@ -1333,6 +1333,15 @@ dg2_emit_draw_watermark_setting(u32 *cs)
 	return cs;
 }
 
+static u32 *
+gen12_invalidate_state_cache(u32 *cs) {
+	*cs++ = MI_LOAD_REGISTER_IMM(1);
+	*cs++ = i915_mmio_reg_offset(GEN12_CS_DEBUG_MODE2);
+	*cs++ =

_MASKED_BIT_ENABLE(INSTRUCTION_STATE_CACHE_INVALIDATE);

Quoted 8 lines
drivers/gpu/drm/i915/gt/intel_lrc.c +3 -0
+	return cs;
+}
+
 static u32 *
 gen12_emit_indirect_ctx_rcs(const struct intel_context *ce, u32 *cs)

{ @@ -1346,6 +1355,10 @@ gen12_emit_indirect_ctx_rcs(const struct intel_context *ce, u32 *cs)

drivers/gpu/drm/i915/gt/intel_lrc.c gen12_emit_indirect_ctx_rcs(const struct intel_context *ce, u32 *cs)

Quoted 8 lines
drivers/gpu/drm/i915/gt/intel_lrc.c +4 -0
 	cs = gen12_emit_aux_table_inv(ce->engine, cs);
 
+	/* Wa_18022495364 */
+	if (IS_GFX_GT_IP_RANGE(ce->engine->gt, IP_VER(12, 0), IP_VER(12, 10)))
+		cs = gen12_invalidate_state_cache(cs);
+
 	/* Wa_16014892111 */
 	if (IS_GFX_GT_IP_STEP(ce->engine->gt, IP_VER(12, 70), STEP_A0,

STEP_B0) ||

Quoted 5 lines

IS_GFX_GT_IP_STEP(ce->engine->gt, IP_VER(12, 71), STEP_A0,
STEP_B0) ||
--
2.34.1

Reviewed-by on v6 1/1
#3 lore raw
In reply to Dnyaneshwar Bhadane
Quoted 33 lines · Dnyaneshwar Bhadane

Invalidate instruction and State cache bit using INDIRECT_CTX on every gpu context switch for gen12.
The goal of this workaround is to actually perform an explicit invalidation of that cache (by re-writing the register) during every GPU context switch, which is accomplished via a "workaround batchbuffer" that's attached to the context via INDIRECT_CTX. (Matt Ropper)
BSpec: 11354

Please refer [1] for more reviews and comment on the same patch

[1] https://patchwork.freedesktop.org/patch/556154/

v2:
- Remove extra parentheses from the condition (Lucas)
- Align spacing and new line (Lucas)

v3:
- Fix commit message.

v4:
- Only GEN12 changes are kept (Matt Ropper)
- Fix the commit message for r-b (Matt Ropper)
- Rename the register bit in define

v5:
- Move out this workaround from golden context init (Matt Roper)
- Use INDIRECT_CTX to set bit on each GPU context switch (Matt Roper)

v6:
- Change IP Version base condition for Gen12 (Matt Ropper)
- Made imperative form of commit version messages (Suraj)
- s/Added/Add in patch header (Suraj)

Quoted 4 lines
Cc Lucas De Marchi <[email protected]>
Cc Matt Roper <[email protected]>
Cc Suraj Kandpal <[email protected]>
Quoted 53 lines
---
 drivers/gpu/drm/i915/gt/intel_gt_regs.h |  2 ++
 drivers/gpu/drm/i915/gt/intel_lrc.c     | 13 +++++++++++++
 2 files changed, 15 insertions(+)
drivers/gpu/drm/i915/gt/intel_gt_regs.h +2 -0
index a00ff51c681d..0d5260d126d8 100644
@@ -164,6 +164,8 @@
 #define GEN9_CSFE_CHICKEN1_RCS			_MMIO(0x20d4)
 #define   GEN9_PREEMPT_GPGPU_SYNC_SWITCH_DISABLE	(1 << 2)
 #define   GEN11_ENABLE_32_PLANE_MODE		(1 << 7)
+#define GEN12_CS_DEBUG_MODE2			_MMIO(0x20d8)
+#define   INSTRUCTION_STATE_CACHE_INVALIDATE	REG_BIT(6)
 
 #define GEN7_FF_SLICE_CS_CHICKEN1		_MMIO(0x20e0)
 #define   GEN9_FFSC_PERCTX_PREEMPT_CTRL		(1 << 14)
drivers/gpu/drm/i915/gt/intel_lrc.c +13 -0
index b99efa348ad1..56c916730e9b 100644
@@ -1333,6 +1333,15 @@ dg2_emit_draw_watermark_setting(u32 *cs)
 	return cs;
 }
 
+static u32 *
+gen12_invalidate_state_cache(u32 *cs)
+{
+	*cs++ = MI_LOAD_REGISTER_IMM(1);
+	*cs++ = i915_mmio_reg_offset(GEN12_CS_DEBUG_MODE2);
+	*cs++ = _MASKED_BIT_ENABLE(INSTRUCTION_STATE_CACHE_INVALIDATE);
+	return cs;
+}
+
 static u32 *
 gen12_emit_indirect_ctx_rcs(const struct intel_context *ce, u32 *cs)
 {
@@ -1346,6 +1355,10 @@ gen12_emit_indirect_ctx_rcs(const struct intel_context *ce, u32 *cs)
 
 	cs = gen12_emit_aux_table_inv(ce->engine, cs);
 
+	/* Wa_18022495364 */
+	if (IS_GFX_GT_IP_RANGE(ce->engine->gt, IP_VER(12, 0), IP_VER(12, 10)))
+		cs = gen12_invalidate_state_cache(cs);
+
 	/* Wa_16014892111 */
 	if (IS_GFX_GT_IP_STEP(ce->engine->gt, IP_VER(12, 70), STEP_A0, STEP_B0) ||
 	    IS_GFX_GT_IP_STEP(ce->engine->gt, IP_VER(12, 71), STEP_A0, STEP_B0) ||
Signature · 1 line
2.34.1
Signature · 4 lines
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation