drm/i915: avoid concurrent writes to aux_inv
Subsystems (2)
PATCH 1/1 drm/i915: avoid concurrent writes to aux_inv
From: Fei Yang <[email protected]>
GPU hangs have been observed when multiple engines write to the same aux_inv register at the same time. To avoid this each engine should only invalidate its own auxiliary table. The function gen12_emit_flush_xcs() currently invalidate the auxiliary table for all engines because the rq->engine is not necessarily the engine eventually carrying out the request, and potentially the engine could even be a virtual one (with engine->instance being -1). With the MMIO remap feature, we can actually set bit 17 of MI_LRI instruction and let the hardware to figure out the local aux_inv register at runtime to avoid invalidating auxiliary table for all engines.
Bspec: 45728
--- drivers/gpu/drm/i915/gt/gen8_engine_cs.c | 42 +++++--------------- drivers/gpu/drm/i915/gt/intel_gpu_commands.h | 1 + 2 files changed, 11 insertions(+), 32 deletions(-)
drivers/gpu/drm/i915/gt/gen8_engine_cs.c +10 -32
@@ -165,30 +165,6 @@ static u32 preparser_disable(bool state)return MI_ARB_CHECK |1 <<8 | state; } -static i915_reg_t aux_inv_reg (const struct intel_engine_cs *engine) -{ -static const i915_reg_t vd[] = { -GEN12_VD0_AUX_NV , -GEN12_VD1_AUX_NV , -GEN12_VD2_AUX_NV , -GEN12_VD3_AUX_NV , - }; - -static const i915_reg_t ve[] = { -GEN12_VE0_AUX_NV , -GEN12_VE1_AUX_NV , - }; - -if (engine->class ==VIDEO_DECODE_CLASS ) -return vd[engine->instance]; - -if (engine->class ==VIDEO_ENHANCEMENT_CLASS ) -return ve[engine->instance]; - -GEM_BUG_ON ("unknown aux_inv reg\n" ); -return INVALID_MMIO_REG ; -} -static u32 *gen12_emit_aux_table_inv (const i915_reg_t inv_reg,u32 *cs) { *cs++ =MI_LOAD_REGISTER_IMM (1 );
@@ -296,7 +272,7 @@ int gen12_emit_flush_xcs(struct i915_request *rq, u32 mode)if (!HAS_FLAT_CCS (rq->engine->i915)) { aux_inv = rq->engine->mask & ~BIT (BCS0 );if (aux_inv) - cmd +=2 *hweight32 (aux_inv) +2 ; + cmd +=4 ; } }
@@ -329,14 +305,16 @@ int gen12_emit_flush_xcs(struct i915_request *rq, u32 mode) *cs++ =0 ;/* value */ if (aux_inv) {/* hsdes: 1809175790 */ -struct intel_engine_cs *engine; -unsigned int tmp; - - *cs++ =MI_LOAD_REGISTER_IMM (hweight32 (aux_inv)); -for_each_engine_masked (engine, rq->engine->gt, aux_inv, tmp) { - *cs++ =i915_mmio_reg_offset (aux_inv_reg (engine)); - *cs++ =AUX_INV ; + *cs++ =MI_LOAD_REGISTER_IMM (1 ) |MI_LRI_MMIO_REMAP_EN ; +if (rq->engine->class ==VIDEO_DECODE_CLASS ) { + *cs++ =i915_mmio_reg_offset (GEN12_VD0_AUX_NV ); + }else if (rq->engine->class ==VIDEO_ENHANCEMENT_CLASS ) { + *cs++ =i915_mmio_reg_offset (GEN12_VE0_AUX_NV ); + }else { +GEM_BUG_ON ("unknown aux_inv reg\n" ); + *cs++ =i915_mmio_reg_offset (INVALID_MMIO_REG ); } + *cs++ =AUX_INV ; *cs++ =MI_NOOP ; }
drivers/gpu/drm/i915/gt/intel_gpu_commands.h +1 -0
@@ -144,6 +144,7 @@#define MI_LOAD_REGISTER_IMM (x) MI_INSTR(0x22, 2*(x)-1)/* Gen11+. addr = base + (ctx_restore ? offset & GENMASK(12,2) : offset) */ #define MI_LRI_LRM_CS_MMIO REG_BIT(19) +#define MI_LRI_MMIO_REMAP_EN (1 << 17)#define MI_LRI_FORCE_POSTED (1<<12)#define MI_LOAD_REGISTER_IMM_MAX_REGS (126)#define MI_STORE_REGISTER_MEM MI_INSTR(0x24, 1)
Signature · 1 line
2.25.1
Patchwork
CI[Intel-gfx] ✗ Fi.CI.BAT: failure for drm/i915: avoid concurrent writes to aux_inv (rev7)
== Series Details ==
== Series Details ==
Series: drm/i915: avoid concurrent writes to aux_inv (rev7)
URL : https://patchwork.freedesktop.org/series/100772/
State : failure
== Summary ==
CI Bug Log - changes from CI_DRM_11380 -> Patchwork_22606
====================================================
Summary
-------
**FAILURE**
Serious unknown changes coming with Patchwork_22606 absolutely need to be verified manually.
If you think the reported changes have nothing to do with the changes introduced in Patchwork_22606, please notify your bug team 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_22606/index.html
Participating hosts (47 -> 45)
------------------------------
Additional (3): bat-adlm-1 bat-jsl-2 fi-pnv-d510
Missing (5): shard-tglu bat-dg1-5 fi-bsw-cyan shard-rkl fi-bdw-samus
Possible new issues
-------------------
Here are the unknown changes that may have been introduced in Patchwork_22606:
### IGT changes ###
#### Possible regressions ####
* igt@kms_cursor_legacy@basic-flip-before-cursor-atomic:
- fi-tgl-1115g4: [PASS][1] -> [DMESG-WARN][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11380/fi-tgl-1115g4/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22606/fi-tgl-1115g4/igt@[email protected]
#### Suppressed ####
The following results come from untrusted machines, tests, or statuses. They do not affect the overall result.
* igt@i915_selftest@live@hangcheck:
- {bat-jsl-2}: NOTRUN -> [INCOMPLETE][3]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22606/bat-jsl-2/igt@i915_selftest@[email protected]
Known issues
------------
Here are the changes found in Patchwork_22606 that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@gem_huc_copy@huc-copy:
- fi-pnv-d510: NOTRUN -> [SKIP][4] ([fdo#109271]) +57 similar issues
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22606/fi-pnv-d510/igt@[email protected]
* igt@i915_selftest@live@hangcheck:
- bat-dg1-6: [PASS][5] -> [DMESG-FAIL][6] ([i915#4494] / [i915#4957])
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11380/bat-dg1-6/igt@i915_selftest@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22606/bat-dg1-6/igt@i915_selftest@[email protected]
- fi-bdw-5557u: NOTRUN -> [INCOMPLETE][7] ([i915#3921])
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22606/fi-bdw-5557u/igt@i915_selftest@[email protected]
* igt@kms_chamelium@vga-edid-read:
- fi-bdw-5557u: NOTRUN -> [SKIP][8] ([fdo#109271] / [fdo#111827]) +8 similar issues
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22606/fi-bdw-5557u/igt@[email protected]
* igt@kms_pipe_crc_basic@compare-crc-sanitycheck-pipe-c:
- fi-pnv-d510: NOTRUN -> [SKIP][9] ([fdo#109271] / [i915#5341])
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22606/fi-pnv-d510/igt@[email protected]
- fi-cfl-8109u: [PASS][10] -> [DMESG-WARN][11] ([i915#295] / [i915#5341])
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11380/fi-cfl-8109u/igt@[email protected]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22606/fi-cfl-8109u/igt@[email protected]
* igt@kms_pipe_crc_basic@read-crc-pipe-b:
- fi-cfl-8109u: [PASS][12] -> [DMESG-WARN][13] ([i915#295]) +11 similar issues
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11380/fi-cfl-8109u/igt@[email protected]
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22606/fi-cfl-8109u/igt@[email protected]
* igt@kms_setmode@basic-clone-single-crtc:
- fi-bdw-5557u: NOTRUN -> [SKIP][14] ([fdo#109271]) +14 similar issues
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22606/fi-bdw-5557u/igt@[email protected]
#### Possible fixes ####
* igt@i915_pm_rpm@module-reload:
- {bat-rpls-2}: [DMESG-WARN][15] ([i915#4391]) -> [PASS][16] +1 similar issue
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11380/bat-rpls-2/igt@[email protected]
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22606/bat-rpls-2/igt@[email protected]
{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109285]: https://bugs.freedesktop.org/show_bug.cgi?id=109285
[fdo#111825]: https://bugs.freedesktop.org/show_bug.cgi?id=111825
[fdo#111827]: https://bugs.freedesktop.org/show_bug.cgi?id=111827
[i915#1845]: https://gitlab.freedesktop.org/drm/intel/issues/1845
[i915#2190]: https://gitlab.freedesktop.org/drm/intel/issues/2190
[i915#2582]: https://gitlab.freedesktop.org/drm/intel/issues/2582
[i915#295]: https://gitlab.freedesktop.org/drm/intel/issues/295
[i915#3282]: https://gitlab.freedesktop.org/drm/intel/issues/3282
[i915#3301]: https://gitlab.freedesktop.org/drm/intel/issues/3301
[i915#3555]: https://gitlab.freedesktop.org/drm/intel/issues/3555
[i915#3576]: https://gitlab.freedesktop.org/drm/intel/issues/3576
[i915#3637]: https://gitlab.freedesktop.org/drm/intel/issues/3637
[i915#3921]: https://gitlab.freedesktop.org/drm/intel/issues/3921
[i915#4103]: https://gitlab.freedesktop.org/drm/intel/issues/4103
[i915#4391]: https://gitlab.freedesktop.org/drm/intel/issues/4391
[i915#4494]: https://gitlab.freedesktop.org/drm/intel/issues/4494
[i915#4613]: https://gitlab.freedesktop.org/drm/intel/issues/4613
[i915#4957]: https://gitlab.freedesktop.org/drm/intel/issues/4957
[i915#4983]: https://gitlab.freedesktop.org/drm/intel/issues/4983
[i915#533]: https://gitlab.freedesktop.org/drm/intel/issues/533
[i915#5338]: https://gitlab.freedesktop.org/drm/intel/issues/5338
[i915#5339]: https://gitlab.freedesktop.org/drm/intel/issues/5339
[i915#5341]: https://gitlab.freedesktop.org/drm/intel/issues/5341
[i915#5342]: https://gitlab.freedesktop.org/drm/intel/issues/5342
[i915#5361]: https://gitlab.freedesktop.org/drm/intel/issues/5361
Build changes
-------------
* Linux: CI_DRM_11380 -> Patchwork_22606
CI-20190529: 20190529
CI_DRM_11380: fe83949cd4316608ea785fc376b6ed444224adad @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_6385: f3df40281d93d5a63ee98fa30e90852d780673c9 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
Patchwork_22606: 439959df00adab483693620266652e0ba6a2ee0a @ git://anongit.freedesktop.org/gfx-ci/linux
== Linux commits ==
439959df00ad drm/i915: avoid concurrent writes to aux_inv
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22606/index.html
Quoted 71 lines · On 18/03/2022 05:26, [email protected] wrote:
From: Fei Yang <[email protected]>
GPU hangs have been observed when multiple engines write to the same
aux_invregister at the same time. To avoid this each engine should only invalidate its own auxiliary table. The functiongen12_emit_flush_xcs()currently invalidate the auxiliary table for all engines because therq->engineis not necessarily the engine eventually carrying out the request, and potentially the engine could even be a virtual one (withengine->instancebeing -1). With the MMIO remap feature, we can actually set bit 17 ofMI_LRIinstruction and let the hardware to figure out the localaux_invregister at runtime to avoid invalidating auxiliary table for all engines.Bspec: 45728
Cc Stuart Summers <[email protected]>Cc Tvrtko Ursulin <[email protected]>Signed-off-by Chris Wilson <[email protected]>Signed-off-by Fei Yang <[email protected]>--- drivers/gpu/drm/i915/gt/gen8_engine_cs.c | 42 +++++--------------- drivers/gpu/drm/i915/gt/intel_gpu_commands.h | 1 + 2 files changed, 11 insertions(+), 32 deletions(-)drivers/gpu/drm/i915/gt/gen8_engine_cs.c +1
-25@@ -165,30 +165,6 @@ static u32 preparser_disable(bool state)return MI_ARB_CHECK |1 <<8 | state; } -static i915_reg_t aux_inv_reg (const struct intel_engine_cs *engine) -{ -static const i915_reg_t vd[] = { -GEN12_VD0_AUX_NV , -GEN12_VD1_AUX_NV , -GEN12_VD2_AUX_NV , -GEN12_VD3_AUX_NV , - }; - -static const i915_reg_t ve[] = { -GEN12_VE0_AUX_NV , -GEN12_VE1_AUX_NV , - }; - -if (engine->class ==VIDEO_DECODE_CLASS ) -return vd[engine->instance]; - -if (engine->class ==VIDEO_ENHANCEMENT_CLASS ) -return ve[engine->instance]; - -GEM_BUG_ON ("unknown aux_inv reg\n" ); -return INVALID_MMIO_REG ; -} -static u32 *gen12_emit_aux_table_inv (const i915_reg_t inv_reg,u32 *cs) { *cs++ =MI_LOAD_REGISTER_IMM (1 );@@ -296,7 +272,7 @@ int gen12_emit_flush_xcs(struct i915_request *rq, u32 mode)if (!HAS_FLAT_CCS (rq->engine->i915)) { aux_inv = rq->engine->mask & ~BIT (BCS0 );if (aux_inv) - cmd +=2 *hweight32 (aux_inv) +2 ; + cmd +=4 ; } }@@ -329,14 +305,16 @@ int gen12_emit_flush_xcs(struct i915_request *rq, u32 mode) *cs++ =0 ;/* value */
drivers/gpu/drm/i915/gt/gen8_engine_cs.c int gen12_emit_flush_xcs(struct i915_request *rq, u32 mode) · line 308
Quoted 10 lines
drivers/gpu/drm/i915/gt/gen8_engine_cs.c +1
-7if (aux_inv) {/* hsdes: 1809175790 */ -struct intel_engine_cs *engine; -unsigned int tmp; - - *cs++ =MI_LOAD_REGISTER_IMM (hweight32 (aux_inv)); -for_each_engine_masked (engine, rq->engine->gt, aux_inv, tmp) { - *cs++ =i915_mmio_reg_offset (aux_inv_reg (engine)); - *cs++ =AUX_INV ; + *cs++ =MI_LOAD_REGISTER_IMM (1 ) |MI_LRI_MMIO_REMAP_EN ;
Cool, I didn't know this exists. First Bspec link I found did not mention these register, but second did. That one however (29545) has a worrying "removed by" tag which seems to point to a story suggesting the remapping table might be gone on machines with flat ccs?! Could you double check please?
drivers/gpu/drm/i915/gt/gen8_engine_cs.c int gen12_emit_flush_xcs(struct i915_request *rq, u32 mode) · line 315
Quoted 7 lines
drivers/gpu/drm/i915/gt/gen8_engine_cs.c +7
-0+if (rq->engine->class ==VIDEO_DECODE_CLASS ) { + *cs++ =i915_mmio_reg_offset (GEN12_VD0_AUX_NV ); + }else if (rq->engine->class ==VIDEO_ENHANCEMENT_CLASS ) { + *cs++ =i915_mmio_reg_offset (GEN12_VE0_AUX_NV ); + }else { +GEM_BUG_ON ("unknown aux_inv reg\n" ); + *cs++ =i915_mmio_reg_offset (INVALID_MMIO_REG );
I'd consider not emitting the LRI if we don't know what to put in unless there is some hidden point to do it?
Quoted 10 lines
drivers/gpu/drm/i915/gt/gen8_engine_cs.c +1
-0} + *cs++ =AUX_INV ; *cs++ =MI_NOOP ; }drivers/gpu/drm/i915/gt/intel_gpu_commands.h +0
-0
drivers/gpu/drm/i915/gt/intel_gpu_commands.h line 148
Quoted 5 lines
drivers/gpu/drm/i915/gt/intel_gpu_commands.h +1
-0@@ -144,6 +144,7 @@#define MI_LOAD_REGISTER_IMM (x) MI_INSTR(0x22, 2*(x)-1)/* Gen11+. addr = base + (ctx_restore ? offset & GENMASK(12,2) : offset) */ #define MI_LRI_LRM_CS_MMIO REG_BIT(19) +#define MI_LRI_MMIO_REMAP_EN (1 << 17)#define MI_LRI_FORCE_POSTED (1<<12)
Passing observation - three bits, three flavours of expressing them, sigh...
Regards,
Tvrtko
Quoted 2 lines
drivers/gpu/drm/i915/gt/intel_gpu_commands.h +0
-0#define MI_LOAD_REGISTER_IMM_MAX_REGS (126)#define MI_STORE_REGISTER_MEM MI_INSTR(0x24, 1)
Quoted 15 lines
Quoted 15 lines
static u32 *gen12_emit_aux_table_inv(const i915_reg_t inv_reg, u32 *cs) { *cs++ = MI_LOAD_REGISTER_IMM(1);drivers/gpu/drm/i915/gt/gen8_engine_cs.c +1
-1@@ -296,7 +272,7 @@ int gen12_emit_flush_xcs(struct i915_request *rq, u32 mode)if (!HAS_FLAT_CCS (rq->engine->i915)) { aux_inv = rq->engine->mask & ~BIT (BCS0 );if (aux_inv) - cmd +=2 *hweight32 (aux_inv) +2 ; + cmd +=4 ; } }@@ -329,14 +305,16 @@ int gen12_emit_flush_xcs(struct i915_request *rq, u32 mode) *cs++ =0 ;/* value */
Quoted 13 lines
drivers/gpu/drm/i915/gt/gen8_engine_cs.c int gen12_emit_flush_xcs(struct i915_request *rq, u32 mode) · line 308
Quoted 9 lines
drivers/gpu/drm/i915/gt/gen8_engine_cs.c +1
-7if (aux_inv) {/* hsdes: 1809175790 */ -struct intel_engine_cs *engine; -unsigned int tmp; - - *cs++ =MI_LOAD_REGISTER_IMM (hweight32 (aux_inv)); -for_each_engine_masked (engine, rq->engine->gt, aux_inv, tmp) { - *cs++ =i915_mmio_reg_offset (aux_inv_reg (engine)); - *cs++ =AUX_INV ; + *cs++ =MI_LOAD_REGISTER_IMM (1 ) |MI_LRI_MMIO_REMAP_EN ;Cool, I didn't know this exists. First Bspec link I found did not mention these register, but second did. That one however (29545) has a worrying "removed by" tag which seems to point to a story suggesting the remapping table might be gone on machines with flat ccs?! Could you double check please?
The variable aux_inv is set only if (!HAS_FLAT_CCS(rq->engine->i915)).
Quoted 9 lines
drivers/gpu/drm/i915/gt/gen8_engine_cs.c int gen12_emit_flush_xcs(struct i915_request *rq, u32 mode) · line 315
Quoted 7 lines
drivers/gpu/drm/i915/gt/gen8_engine_cs.c +7
-0+if (rq->engine->class ==VIDEO_DECODE_CLASS ) { + *cs++ =i915_mmio_reg_offset (GEN12_VD0_AUX_NV ); + }else if (rq->engine->class ==VIDEO_ENHANCEMENT_CLASS ) { + *cs++ =i915_mmio_reg_offset (GEN12_VE0_AUX_NV ); + }else { +GEM_BUG_ON ("unknown aux_inv reg\n" ); + *cs++ =i915_mmio_reg_offset (INVALID_MMIO_REG );I'd consider not emitting the LRI if we don't know what to put in unless there is some hidden point to do it?
That's true. I was following the original logic flow here. I think it would be better to check for engine class before setting the variable aux_inv.
Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/i915/gt/gen8_engine_cs.c +1
-0} + *cs++ =AUX_INV ; *cs++ =MI_NOOP ; }
Quoted 13 lines
drivers/gpu/drm/i915/gt/intel_gpu_commands.h line 148
Quoted 11 lines
drivers/gpu/drm/i915/gt/intel_gpu_commands.h +1
-0@@ -144,6 +144,7 @@#define MI_LOAD_REGISTER_IMM (x) MI_INSTR(0x22, 2*(x)-1)/* Gen11+. addr = base + (ctx_restore ? offset & GENMASK(12,2) : offset) */ #define MI_LRI_LRM_CS_MMIO REG_BIT(19) +#define MI_LRI_MMIO_REMAP_EN (1 << 17)#define MI_LRI_FORCE_POSTED (1<<12)Passing observation - three bits, three flavours of expressing them, sigh...
Haha, REG_BIT(17) it is. The other one causes a CHECK:SPACING, but don't want to touch that in this patch.
Quoted 2 lines
Quoted 2 lines
drivers/gpu/drm/i915/gt/intel_gpu_commands.h +0
-0#define MI_LOAD_REGISTER_IMM_MAX_REGS (126)#define MI_STORE_REGISTER_MEM MI_INSTR(0x24, 1)