Skip to contentSkip to conversation

drm/i915/gt: Avoid duplicating CCS mode workaround

PATCH In review Andi Shyti 4 participants 7 messages Mar 25, 2025

Subsystems (2)
lore
Share & tools
lore

Andi Shyti

author
#0 lore raw

PATCH 1/1 drm/i915/gt: Avoid duplicating CCS mode workaround

When generating workarounds for the CCS engine, specifically for setting the CCS mode related to compute load balancing, the function 'ccs_engine_wa_mode()' is called twice: once for the render engine and once for the compute engine.

Add a check to ensure the engine class is compute before applying the workaround to avoid redundant programming.

---
 drivers/gpu/drm/i915/gt/intel_workarounds.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/gt/intel_workarounds.c +3 -1
index 116683ebe074..37251546b755 100644
@@ -2897,7 +2897,9 @@ engine_init_workarounds(struct intel_engine_cs *engine, struct i915_wa_list *wal
 	 */
 	if (engine->flags & I915_ENGINE_FIRST_RENDER_COMPUTE) {
 		general_render_compute_wa_init(engine, wal);
-		ccs_engine_wa_mode(engine, wal);
+
+		if (engine->class == COMPUTE_CLASS)
+			ccs_engine_wa_mode(engine, wal);
 	}
 
 	if (engine->class == COMPUTE_CLASS)
Signature · 1 line
2.47.2
#1 lore raw

Quoting Andi Shyti (2025-03-25 13:01:37)

Quoted 19 lines

When generating workarounds for the CCS engine, specifically for setting the CCS mode related to compute load balancing, the function 'ccs_engine_wa_mode()' is called twice: once for the render engine and once for the compute engine.

Add a check to ensure the engine class is compute before applying the workaround to avoid redundant programming.

---
 drivers/gpu/drm/i915/gt/intel_workarounds.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/gt/intel_workarounds.c +0 -0
index 116683ebe074..37251546b755 100644

drivers/gpu/drm/i915/gt/intel_workarounds.c engine_init_workarounds(struct intel_engine_cs *engine, struct i915_wa_list *wal · line 2902

Quoted 7 lines
drivers/gpu/drm/i915/gt/intel_workarounds.c +3 -1
@@ -2897,7 +2897,9 @@ engine_init_workarounds(struct intel_engine_cs *engine, struct i915_wa_list *wal
         */
        if (engine->flags & I915_ENGINE_FIRST_RENDER_COMPUTE) {
                general_render_compute_wa_init(engine, wal);
-               ccs_engine_wa_mode(engine, wal);
+
+               if (engine->class == COMPUTE_CLASS)
+                       ccs_engine_wa_mode(engine, wal);

FIRST_RENDER_COMPUTE is meant to only be on the first engine of either rcs or ccs (which share certain register domains), one engine.

It looks like that was broken by

	commit 1bfc03b1375244f9029bb448ee8224b3b6dae99f
	Author: Lucas De Marchi <[email protected]>
	Date:   Tue Mar 19 23:03:03 2024 -0700

	    drm/i915: Remove special handling for !RCS_MASK()

-Chris

author
#2 lore raw
Quoted 31 lines · Chris Wilson

Quoting Andi Shyti (2025-03-25 13:01:37)

Quoted 19 lines

When generating workarounds for the CCS engine, specifically for setting the CCS mode related to compute load balancing, the function 'ccs_engine_wa_mode()' is called twice: once for the render engine and once for the compute engine.

Add a check to ensure the engine class is compute before applying the workaround to avoid redundant programming.

---
 drivers/gpu/drm/i915/gt/intel_workarounds.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/gt/intel_workarounds.c +0 -0
index 116683ebe074..37251546b755 100644

drivers/gpu/drm/i915/gt/intel_workarounds.c engine_init_workarounds(struct intel_engine_cs *engine, struct i915_wa_list *wal · line 2902

Quoted 7 lines
drivers/gpu/drm/i915/gt/intel_workarounds.c +3 -1
@@ -2897,7 +2897,9 @@ engine_init_workarounds(struct intel_engine_cs *engine, struct i915_wa_list *wal
         */
        if (engine->flags & I915_ENGINE_FIRST_RENDER_COMPUTE) {
                general_render_compute_wa_init(engine, wal);
-               ccs_engine_wa_mode(engine, wal);
+
+               if (engine->class == COMPUTE_CLASS)
+                       ccs_engine_wa_mode(engine, wal);

FIRST_RENDER_COMPUTE is meant to only be on the first engine of either rcs or ccs (which share certain register domains), one engine.

Quoted 7 lines

It looks like that was broken by

	commit 1bfc03b1375244f9029bb448ee8224b3b6dae99f
	Author: Lucas De Marchi <[email protected]>
	Date:   Tue Mar 19 23:03:03 2024 -0700

	    drm/i915: Remove special handling for !RCS_MASK()

Aha! So the logic here[*] breaks the meaning of I915_ENGINE_FIRST_RENDER_COMPUTE, becasue, other than PVC, we forgot that we have DG2 that needs the special check that uses !RCS_MASK().

I need then to restore the original check.

Thanks Chris!
Andi

[*]
- if ((engine->class == COMPUTE_CLASS && !RCS_MASK(engine->gt) &&
- __ffs(CCS_MASK(engine->gt)) == engine->instance) ||
- engine->class == RENDER_CLASS)
+ if ((engine->class == COMPUTE_CLASS || engine->class == RENDER_CLASS) &&
+ __ffs(CCS_MASK(engine->gt) | RCS_MASK(engine->gt)) == engine->instance)

#3 lore raw
Quoted 32 lines · Andi Shyti
Quoted 31 lines · Chris Wilson

Quoting Andi Shyti (2025-03-25 13:01:37)

Quoted 19 lines

When generating workarounds for the CCS engine, specifically for setting the CCS mode related to compute load balancing, the function 'ccs_engine_wa_mode()' is called twice: once for the render engine and once for the compute engine.

Add a check to ensure the engine class is compute before applying the workaround to avoid redundant programming.

---
 drivers/gpu/drm/i915/gt/intel_workarounds.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/gt/intel_workarounds.c +0 -0
index 116683ebe074..37251546b755 100644

drivers/gpu/drm/i915/gt/intel_workarounds.c engine_init_workarounds(struct intel_engine_cs *engine, struct i915_wa_list *wal · line 2902

Quoted 7 lines
drivers/gpu/drm/i915/gt/intel_workarounds.c +3 -1
@@ -2897,7 +2897,9 @@ engine_init_workarounds(struct intel_engine_cs *engine, struct i915_wa_list *wal
         */
        if (engine->flags & I915_ENGINE_FIRST_RENDER_COMPUTE) {
                general_render_compute_wa_init(engine, wal);
-               ccs_engine_wa_mode(engine, wal);
+
+               if (engine->class == COMPUTE_CLASS)
+                       ccs_engine_wa_mode(engine, wal);

FIRST_RENDER_COMPUTE is meant to only be on the first engine of either rcs or ccs (which share certain register domains), one engine.

Quoted 4 lines
Quoted 4 lines

It looks like that was broken by

	commit 1bfc03b1375244f9029bb448ee8224b3b6dae99f
	Author: Lucas De Marchi <[email protected]>

yep, my bad.

Quoted 8 lines
Quoted 3 lines
	Date:   Tue Mar 19 23:03:03 2024 -0700

	    drm/i915: Remove special handling for !RCS_MASK()

Aha! So the logic here[*] breaks the meaning of I915_ENGINE_FIRST_RENDER_COMPUTE, becasue, other than PVC, we forgot that we have DG2 that needs the special check that uses !RCS_MASK().

no, that would mean a DG2 without render engine.

The previous check to enable I915_ENGINE_FIRST_RENDER_COMPUTE was:

	if ((engine->class == COMPUTE_CLASS && !RCS_MASK(engine->gt) &&
	     __ffs(CCS_MASK(engine->gt)) == engine->instance) ||
	     engine->class == RENDER_CLASS)

i.e. if render is fused off, it enables it in the first compute engine. Otherwise it enables it in the render.

And assuming we don't have platforms with render fused off (which still holds true as far as I'm aware), that became:

	if ((engine->class == COMPUTE_CLASS || engine->class == RENDER_CLASS) &&
	    __ffs(CCS_MASK(engine->gt) | RCS_MASK(engine->gt)) == engine->instance)

It was supposed to mean the same thing... but doesn't as engine->instance starts from 0 for each class.

Just checking for RENDER_CLASS and eventually even removing the I915_ENGINE_FIRST_RENDER_COMPUTE flag would be better. See
https://lore.kernel.org/all/[email protected]/#t

Lucas De Marchi

Quoted 12 lines

I need then to restore the original check.

Thanks Chris!
Andi

[*]

(quoted diff) +2 -3
-       if ((engine->class == COMPUTE_CLASS && !RCS_MASK(engine->gt) &&
-            __ffs(CCS_MASK(engine->gt)) == engine->instance) ||
-            engine->class == RENDER_CLASS)
+       if ((engine->class == COMPUTE_CLASS || engine->class == RENDER_CLASS) &&
+           __ffs(CCS_MASK(engine->gt) | RCS_MASK(engine->gt)) == engine->instance)
author
#4 lore raw

Hi Lucas,

Quoted 21 lines
Quoted 12 lines
Quoted 12 lines

drivers/gpu/drm/i915/gt/intel_workarounds.c engine_init_workarounds(struct intel_engine_cs *engine, struct i915_wa_list *wal · line 2902

Quoted 8 lines
drivers/gpu/drm/i915/gt/intel_workarounds.c +3 -1
@@ -2897,7 +2897,9 @@ engine_init_workarounds(struct intel_engine_cs *engine, struct i915_wa_list *wal
         */
        if (engine->flags & I915_ENGINE_FIRST_RENDER_COMPUTE) {
                general_render_compute_wa_init(engine, wal);
-               ccs_engine_wa_mode(engine, wal);
+
+               if (engine->class == COMPUTE_CLASS)
+                       ccs_engine_wa_mode(engine, wal);

FIRST_RENDER_COMPUTE is meant to only be on the first engine of either rcs or ccs (which share certain register domains), one engine.

Quoted 4 lines
Quoted 4 lines

It looks like that was broken by

	commit 1bfc03b1375244f9029bb448ee8224b3b6dae99f
	Author: Lucas De Marchi <[email protected]>

yep, my bad.

Quoted 2 lines
Quoted 2 lines
	Date:   Tue Mar 19 23:03:03 2024 -0700
Quoted 8 lines
Quoted 6 lines
Quoted 1 line

drm/i915: Remove special handling for !RCS_MASK()

Aha! So the logic here[*] breaks the meaning of I915_ENGINE_FIRST_RENDER_COMPUTE, becasue, other than PVC, we forgot that we have DG2 that needs the special check that uses !RCS_MASK().

no, that would mean a DG2 without render engine.

OK, I don't know the history, I thought that the idea was to remove support for PVC, the only multi-CCS machine that once i915 supported other than DG2.

Quoted 6 lines

The previous check to enable I915_ENGINE_FIRST_RENDER_COMPUTE was:

	if ((engine->class == COMPUTE_CLASS && !RCS_MASK(engine->gt) &&
	     __ffs(CCS_MASK(engine->gt)) == engine->instance) ||
	     engine->class == RENDER_CLASS)
Quoted 8 lines

i.e. if render is fused off, it enables it in the first compute engine. Otherwise it enables it in the render.

And assuming we don't have platforms with render fused off (which still holds true as far as I'm aware), that became:

	if ((engine->class == COMPUTE_CLASS || engine->class == RENDER_CLASS) &&
	    __ffs(CCS_MASK(engine->gt) | RCS_MASK(engine->gt)) == engine->instance)

The difference is that this applies in two cases: it's true for the first CCS we encounter and also for the only RCS. Arshad noticed that we end up applying the workaround twice.

So the !RCS_MASK(gt) check is still needed.

Alternatively, as Matt suggested, we could assign
I915_ENGINE_FIRST_RENDER_COMPUTE only to the RCS.

I have a slight preference for the way it was done before because it make the logic clearer.

Thanks,
Andi

Quoted 2 lines

It was supposed to mean the same thing... but doesn't as engine->instance starts from 0 for each class.

#5 lore raw
Quoted 30 lines · Andi Shyti

Hi Lucas,

Quoted 28 lines
Quoted 12 lines
Quoted 12 lines

drivers/gpu/drm/i915/gt/intel_workarounds.c engine_init_workarounds(struct intel_engine_cs *engine, struct i915_wa_list *wal · line 2902

Quoted 8 lines
drivers/gpu/drm/i915/gt/intel_workarounds.c +3 -1
@@ -2897,7 +2897,9 @@ engine_init_workarounds(struct intel_engine_cs *engine, struct i915_wa_list *wal
         */
        if (engine->flags & I915_ENGINE_FIRST_RENDER_COMPUTE) {
                general_render_compute_wa_init(engine, wal);
-               ccs_engine_wa_mode(engine, wal);
+
+               if (engine->class == COMPUTE_CLASS)
+                       ccs_engine_wa_mode(engine, wal);

FIRST_RENDER_COMPUTE is meant to only be on the first engine of either rcs or ccs (which share certain register domains), one engine.

Quoted 4 lines
Quoted 4 lines

It looks like that was broken by

	commit 1bfc03b1375244f9029bb448ee8224b3b6dae99f
	Author: Lucas De Marchi <[email protected]>

yep, my bad.

Quoted 8 lines
Quoted 3 lines
	Date:   Tue Mar 19 23:03:03 2024 -0700

	    drm/i915: Remove special handling for !RCS_MASK()

Aha! So the logic here[*] breaks the meaning of I915_ENGINE_FIRST_RENDER_COMPUTE, becasue, other than PVC, we forgot that we have DG2 that needs the special check that uses !RCS_MASK().

Quoted 5 lines
Quoted 1 line

no, that would mean a DG2 without render engine.

OK, I don't know the history, I thought that the idea was to remove support for PVC, the only multi-CCS machine that once i915 supported other than DG2.

the problem is not about having multiple compute engines. The removal of PVC meant we don't have any platform left without render engine.

Quoted 10 lines
Quoted 10 lines

The previous check to enable I915_ENGINE_FIRST_RENDER_COMPUTE was:

	if ((engine->class == COMPUTE_CLASS && !RCS_MASK(engine->gt) &&
	     __ffs(CCS_MASK(engine->gt)) == engine->instance) ||
	     engine->class == RENDER_CLASS)

i.e. if render is fused off, it enables it in the first compute engine. Otherwise it enables it in the render.

Quoted 8 lines
Quoted 5 lines

And assuming we don't have platforms with render fused off (which still holds true as far as I'm aware), that became:

	if ((engine->class == COMPUTE_CLASS || engine->class == RENDER_CLASS) &&
	    __ffs(CCS_MASK(engine->gt) | RCS_MASK(engine->gt)) == engine->instance)

The difference is that this applies in two cases: it's true for the first CCS we encounter and also for the only RCS. Arshad

yes, this is the same thing I said in my reply:

	It was supposed to mean the same thing... but doesn't as engine->instance
	starts from 0 for each class.
Quoted 3 lines

noticed that we end up applying the workaround twice.

So the !RCS_MASK(gt) check is still needed.

I don't think the !RCS_MASK() makes sense - you are checking for "do we have any render engine?" when we always do and it's always 1. All platforms supported by i915 have 1 render engine.

Quoted 3 lines

Alternatively, as Matt suggested, we could assign
I915_ENGINE_FIRST_RENDER_COMPUTE only to the RCS.

yes, that's what I said, but the reply here was cut short:

Just checking for RENDER_CLASS and eventually even removing the I915_ENGINE_FIRST_RENDER_COMPUTE flag would be better. See
https://lore.kernel.org/all/[email protected]/#t

Lucas De Marchi

Quoted 9 lines

I have a slight preference for the way it was done before because it make the logic clearer.

Thanks,
Andi

Quoted 2 lines

It was supposed to mean the same thing... but doesn't as engine->instance starts from 0 for each class.

#6 lore raw

✗ i915.CI.BAT: failure for drm/i915/gt: Avoid duplicating CCS mode workaround

In reply to Andi Shyti
== Series Details ==

== Series Details ==

Series: drm/i915/gt: Avoid duplicating CCS mode workaround
URL : https://patchwork.freedesktop.org/series/146727/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_16313 -> Patchwork_146727v1
====================================================

Summary
-------

**FAILURE**

Serious unknown changes coming with Patchwork_146727v1 absolutely need to be verified manually.

If you think the reported changes have nothing to do with the changes
introduced in Patchwork_146727v1, please notify your bug team ([email protected]) to allow them to document this new failure mode, which will reduce false positives in CI.

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

Participating hosts (41 -> 40)
------------------------------

Missing (1): fi-snb-2520m

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

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

### IGT changes ###

#### Possible regressions ####

* igt@i915_selftest@live:
- bat-twl-1: [PASS][1] -> [ABORT][2] +1 other test abort
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_16313/bat-twl-1/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_146727v1/bat-twl-1/igt@[email protected]

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

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

### IGT changes ###

#### Issues hit ####

* igt@i915_selftest@live@workarounds:
- bat-arlh-2: [PASS][3] -> [DMESG-FAIL][4] ([i915#12061]) +1 other test dmesg-fail
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_16313/bat-arlh-2/igt@i915_selftest@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_146727v1/bat-arlh-2/igt@i915_selftest@[email protected]
- bat-mtlp-6: [PASS][5] -> [DMESG-FAIL][6] ([i915#12061]) +1 other test dmesg-fail
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_16313/bat-mtlp-6/igt@i915_selftest@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_146727v1/bat-mtlp-6/igt@i915_selftest@[email protected]

#### Possible fixes ####

* igt@i915_selftest@live@workarounds:
- bat-arlh-3: [DMESG-FAIL][7] ([i915#12061]) -> [PASS][8] +1 other test pass
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_16313/bat-arlh-3/igt@i915_selftest@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_146727v1/bat-arlh-3/igt@i915_selftest@[email protected]
- bat-mtlp-9: [DMESG-FAIL][9] ([i915#12061]) -> [PASS][10] +1 other test pass
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_16313/bat-mtlp-9/igt@i915_selftest@[email protected]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_146727v1/bat-mtlp-9/igt@i915_selftest@[email protected]

[i915#12061]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/12061

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

* Linux: CI_DRM_16313 -> Patchwork_146727v1

CI-20190529: 20190529
CI_DRM_16313: 3184acdb71d9b0b23a0876f3bc0aaf9e471b88cc @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_8283: e4eb2265f06fc69e37e56cb6b609e019b6071435 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
Patchwork_146727v1: 3184acdb71d9b0b23a0876f3bc0aaf9e471b88cc @ git://anongit.freedesktop.org/gfx-ci/linux

== Logs ==

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