Skip to contentSkip to conversation

drm/i915/dg2: Add per-context control for Wa_22013059131

PATCH Superseded Jia Yao 3 participants 3 messages Jun 9 – Jun 10

Subsystems (4)

v4 of 13 Superseded Latest is v13 →

lore
Share & tools
lore

Jia Yao

author
#0 lore raw

PATCH v4 1/1 drm/i915/dg2: Add per-context control for Wa_22013059131

Wa_22013059131 sets FORCE_1_SUB_MESSAGE_PER_FRAGMENT in LSC_CHICKEN_BIT_0 at engine init, but this is known to cause GPU hangs in certain workloads. Add I915_CONTEXT_PARAM_WA_22013059131 so userspace that handles the workaround itself (e.g. by limiting SLM size) can set it to 1 to let the kernel know bit 15 programming is not needed for that context.

LSC_CHICKEN_BIT_0 is not context-saved by hardware, so the kernel restores the correct value on every context switch via the indirect context batchbuffer to avoid leaking state between contexts. The old unconditional application of Wa22013059131 in intel_workarounds.c is removed.

v4:
- Add a link of the userspace using this API

v3:
- Kernel-internal context will not change workaround settings

Bspec: 54833

Fixes 645cc0b9d972 ("drm/i915/dg2: Add initial gt/ctx/engine workarounds")
Cc Shuicheng Lin <[email protected]>
Cc Matt Roper <[email protected]>
Cc Joonas Lahtinen <[email protected]>
Cc Rodrigo Vivi <[email protected]>
Cc Maciej Plewka <[email protected]>
Cc Andi Shyti <[email protected]>
---
 drivers/gpu/drm/i915/gem/i915_gem_context.c   | 12 +++++
 .../gpu/drm/i915/gem/i915_gem_context_types.h |  1 +
 drivers/gpu/drm/i915/gt/intel_context_types.h |  1 +
 drivers/gpu/drm/i915/gt/intel_lrc.c           | 44 ++++++++++++++++++-
 drivers/gpu/drm/i915/gt/intel_workarounds.c   | 10 ++---
 include/uapi/drm/i915_drm.h                   | 10 +++++
 6 files changed, 72 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_context.c +12 -0
index 6ac0f23570f3..d24e449f1eb3 100644
@@ -911,6 +911,15 @@ static int set_proto_ctx_param(struct drm_i915_file_private *fpriv,
 			ret = -EINVAL;
 		break;
 
+	case I915_CONTEXT_PARAM_WA_22013059131:
+		if (args->size)
+			ret = -EINVAL;
+		else if (args->value)
+			pc->user_flags |= BIT(UCONTEXT_WA_22013059131);
+		else
+			pc->user_flags &= ~BIT(UCONTEXT_WA_22013059131);
+		break;
+
 	case I915_CONTEXT_PARAM_RECOVERABLE:
 		if (args->size)
 			ret = -EINVAL;
@@ -1003,6 +1012,9 @@ static int intel_context_set_gem(struct intel_context *ce,
 	if (test_bit(UCONTEXT_LOW_LATENCY, &ctx->user_flags))
 		__set_bit(CONTEXT_LOW_LATENCY, &ce->flags);
 
+	if (test_bit(UCONTEXT_WA_22013059131, &ctx->user_flags))
+		__set_bit(CONTEXT_WA_22013059131, &ce->flags);
+
 	return ret;
 }
 
drivers/gpu/drm/i915/gem/i915_gem_context_types.h +1 -0
index 0267c924634b..4efc0e758d3b 100644
@@ -338,6 +338,7 @@ struct i915_gem_context {
 #define UCONTEXT_RECOVERABLE		3
 #define UCONTEXT_PERSISTENCE		4
 #define UCONTEXT_LOW_LATENCY		5
+#define UCONTEXT_WA_22013059131		6
 
 	/**
 	 * @flags: small set of booleans
drivers/gpu/drm/i915/gt/intel_context_types.h +1 -0
index 10070ee4d74c..84011ce7c84d 100644
@@ -133,6 +133,7 @@ struct intel_context {
 #define CONTEXT_EXITING			13
 #define CONTEXT_LOW_LATENCY		14
 #define CONTEXT_OWN_STATE		15
+#define CONTEXT_WA_22013059131		16
 
 	struct {
 		u64 timeout_us;
drivers/gpu/drm/i915/gt/intel_lrc.c +43 -1

62 lines not on this page · raw message

drivers/gpu/drm/i915/gt/intel_workarounds.c +5 -5
index 24ea5d8d529c..ef6eea3ab597 100644
@@ -2840,7 +2840,11 @@ general_render_compute_wa_init(struct intel_engine_cs *engine, struct i915_wa_li
 	if (IS_GFX_GT_IP_STEP(gt, IP_VER(12, 70), STEP_A0, STEP_B0) ||
 	    IS_GFX_GT_IP_STEP(gt, IP_VER(12, 71), STEP_A0, STEP_B0) ||
 	    IS_DG2(i915)) {
-		/* Wa_22014226127 */
+		/*
+		 * Wa_22014226127: Note that this workaround also needs to be
+		 * re-applied in intel_lrc.c when LSC_CHICKEN_BIT_0 is
+		 * re-written for Wa_22013059131.
+		 */
 		wa_mcr_write_or(wal, LSC_CHICKEN_BIT_0, DISABLE_D8_D16_COASLESCE);
 	}
 
@@ -2867,10 +2871,6 @@ general_render_compute_wa_init(struct intel_engine_cs *engine, struct i915_wa_li
 				     MAXREQS_PER_BANK,
 				     REG_FIELD_PREP(MAXREQS_PER_BANK, 2));
 
-		/* Wa_22013059131:dg2 */
-		wa_mcr_write_or(wal, LSC_CHICKEN_BIT_0,
-				FORCE_1_SUB_MESSAGE_PER_FRAGMENT);
-
 		/*
 		 * Wa_22012654132
 		 *
include/uapi/drm/i915_drm.h +10 -0
index 535cb68fdb5c..0f553bb12fb0 100644
@@ -2172,6 +2172,16 @@ struct drm_i915_gem_context_param {
  * Note that this is a debug API not available on production kernel builds.
  */
 #define I915_CONTEXT_PARAM_CONTEXT_IMAGE	0xf
+
+/*
+ * I915_CONTEXT_PARAM_WA_22013059131:
+ *
+ * Default value 0 means the kernel programs Wa_22013059131 for this context.
+ * Set to 1 to inform the kernel that userspace is taking responsibility for
+ * applying the preferred workaround implementation, so the kernel programming
+ * of LSC_CHICKEN_BIT_0 bit 15 is not needed for this context. DG2-G11 only.
+ */
+#define I915_CONTEXT_PARAM_WA_22013059131	0x10
 /* Must be kept compact -- no holes and well documented */
 
 	/** @value: Context parameter value to be set or queried */
Signature · 1 line
2.43.0
#1 lore raw

✓ i915.CI.BAT: success for drm/i915/dg2: Add per-context control for Wa_22013059131 (rev4)

== Series Details ==

== Series Details ==

Series: drm/i915/dg2: Add per-context control for Wa_22013059131 (rev4)
URL : https://patchwork.freedesktop.org/series/164198/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_18653 -> Patchwork_164198v4
====================================================

Summary
-------

**SUCCESS**

No regressions found.

External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_164198v4/index.html

Participating hosts (42 -> 40)
------------------------------

Missing (2): bat-dg2-13 fi-snb-2520m

Changes
-------

No changes found

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

* Linux: CI_DRM_18653 -> Patchwork_164198v4

CI-20190529: 20190529
CI_DRM_18653: 724e06af260b571e2d970d4a806ae3d620ff0b7a @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_8956: 8956
Patchwork_164198v4: 724e06af260b571e2d970d4a806ae3d620ff0b7a @ git://anongit.freedesktop.org/gfx-ci/linux

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_164198v4/index.html

maintainer
#2 lore raw
In reply to Jia Yao

Quoting Jia Yao (2026-06-09 21:30:02)

Quoted 11 lines

Wa_22013059131 sets FORCE_1_SUB_MESSAGE_PER_FRAGMENT in LSC_CHICKEN_BIT_0 at engine init, but this is known to cause GPU hangs in certain workloads. Add I915_CONTEXT_PARAM_WA_22013059131 so userspace that handles the workaround itself (e.g. by limiting SLM size) can set it to 1 to let the kernel know bit 15 programming is not needed for that context.

LSC_CHICKEN_BIT_0 is not context-saved by hardware, so the kernel restores the correct value on every context switch via the indirect context batchbuffer to avoid leaking state between contexts. The old unconditional application of Wa22013059131 in intel_workarounds.c is removed.

Quoted 8 lines

v4:
- Add a link of the userspace using this API

v3:
- Kernel-internal context will not change workaround settings

Bspec: 54833

Fixes 645cc0b9d972 ("drm/i915/dg2: Add initial gt/ctx/engine workarounds")

This is not a fixup to be backported to older kernels, this is a new feature, so please drop this. It'll cause unnecessary noise.

Quoted 2 lines

Definitely not for stable for above reasons.

Regards, Joonas