[PATCH 1/2] drm/amdgpu/gfx8: count both wave limit writes in the compute frame size
From: Eren Özen via B4 Relay
Date: Wed Dec 02 2026 - 21:06:38 EST
From: Eren Özen <erenozen@xxxxxxxxxxxxxx>
On a high-priority compute ring, amdgpu_ib_schedule() calls
emit_wave_limit() twice per submission: before the IBs to limit the
waves of gfx and of the other compute pipes, and after them to restore
the defaults. On gfx8 each call writes SPI_WCL_PIPE_PERCENT_GFX and
three SPI_WCL_PIPE_PERCENT_CS registers, 4 * 5 = 20 dwords, but the
compute emit_frame_size counts only one call. emit_wave_limit() and its
single 5-dword count already existed when the commit in the Fixes: tag
started calling it twice per submission, and
commit f8bf64501873 ("drm/amdgpu: enable wave limit on non high prio cs
pipes") then added the three CS writes, also counted once.
The other terms of the gfx8 compute frame size match what is emitted at
most, so a high-priority submission that emits every optional packet
writes 20 dwords more than amdgpu_ring_alloc() reserved for it. From
reading the code, this only runs past the 256-dword aligned reservation
when a submission emits nearly every optional packet (VM flush with the
PASID mapping write, GDS switch, MEM_SYNC, user fence), most of its IBs
carry AMDGPU_IB_FLAG_RESET_GDS_MAX_WAVE_ID, which makes each of them 7
dwords instead of 4, and its IB count is just below a 256-dword boundary:
17 to 19, 54 to 56 or 90 to 92 IBs on a dGPU, and 19, 55, 56 or 92 on an
APU, which skips the HDP flush and invalidate. The submission still fits
in max_dw, so the effect is that amdgpu_ring_commit() reports "writing
more dwords to the ring than expected!".
Count both calls. The worst case becomes 139 + 125 * 7 = 1014 dwords,
1024 after alignment, which is exactly the max_dw of 1024 that
gfx_v8_0_compute_ring_init() passes, so the ring size does not change.
Not tested on gfx8 hardware. On a gfx9 APU, where the same two calls go
to gfx_v9_0_emit_wave_limit(), the dwords written by high-priority
submissions matched the code only with both calls included.
Fixes: 22e4f3152953 ("drm/amdgpu: enable gfx wave limiting for high priority compute jobs")
Cc: stable@xxxxxxxxxxxxxxx # 6.5+
Signed-off-by: Eren Özen <erenozen@xxxxxxxxxxxxxx>
---
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
index 82b5a2d77b0d..d0eaa9456231 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
@@ -6832,8 +6832,8 @@ static const struct amdgpu_ring_funcs gfx_v8_0_ring_funcs_compute = {
VI_FLUSH_GPU_TLB_NUM_WREG * 5 + 7 + /* gfx_v8_0_ring_emit_vm_flush */
7 + 7 + 7 + /* gfx_v8_0_ring_emit_fence_compute x3 for user fence, vm fence */
7 + /* gfx_v8_0_emit_mem_sync_compute */
- 5 + /* gfx_v8_0_emit_wave_limit for updating mmSPI_WCL_PIPE_PERCENT_GFX register */
- 15, /* for updating 3 mmSPI_WCL_PIPE_PERCENT_CS registers */
+ 2 * 5 + /* gfx_v8_0_emit_wave_limit x2: mmSPI_WCL_PIPE_PERCENT_GFX */
+ 2 * 15, /* x2: 3 mmSPI_WCL_PIPE_PERCENT_CS registers */
.emit_ib_size = 7, /* gfx_v8_0_ring_emit_ib_compute */
.emit_ib = gfx_v8_0_ring_emit_ib_compute,
.emit_fence = gfx_v8_0_ring_emit_fence_compute,
--
2.56.1