[PATCH 2/2] drm/amdgpu/gfx9: count both wave limit writes in the compute frame size
From: Eren Özen via B4 Relay
Date: Wed Dec 02 2026 - 21:06:35 EST
From: Eren Özen <erenozen@xxxxxxxxxxxxxx>
gfx9 has the same single count as gfx8: on a high-priority compute
ring, amdgpu_ib_schedule() calls emit_wave_limit() twice per
submission, and 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.
Here the shortfall is hidden today because the TLB flush is reserved
generously: SOC15_FLUSH_GPU_TLB_NUM_WREG * 5 +
SOC15_FLUSH_GPU_TLB_NUM_REG_WAIT * 7 = 51 dwords, while the TLB flush
and the PASID mapping write emit at most 22 + 5 = 27 on the GFXHUB used
by the compute rings (17 + 5 with MEC firmware that supports
write-and-wait). That leaves 24 spare dwords, which cover the missing
20. Count both calls anyway, so the frame size does not depend on that
margin.
The worst case becomes 170 + 125 * 7 = 1045 dwords, 1280 after
alignment, below the compute max_dw of 2048, so the ring size does not
change. This needs that max_dw of 2048 from "drm/amdgpu/gfx9: make room
for the SPM VMID write in the compute rings": with a max_dw of 1024,
amdgpu_ring_init() would hit WARN_ON(max_ibs_dw > max_dw) for every
compute ring. Because the TLB flush reserve covers the missing dwords,
nothing visible is broken today, so this patch has no Fixes: tag;
backported without that commit it would also trigger the WARN.
Tested on a Ryzen 7 5800H (Cezanne, GC 9.3.0) with a debug print of the
dwords each submission wrote. The test sent 250 high-priority compute
jobs of 1 to 125 IBs from two contexts in turn, with a GDS buffer in
every other job, a page table update before each job, a user fence and
AMDGPU_IB_FLAG_EMIT_MEM_SYNC. Besides the IBs (4 dwords each) they wrote
102 to 127 dwords. By the code, 40 of these are the two wave limit
calls, and the counts imply a VM flush in every job and a GDS switch in
almost every job of up to 102 IBs. All jobs completed and stayed at
least 74 dwords below the old 256-dword-aligned reservation. No WARNs at
boot, the compute rings are still 16 KiB, and the IB tests in debugfs
amdgpu_test_ib pass.
Signed-off-by: Eren Özen <erenozen@xxxxxxxxxxxxxx>
---
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
index 68282c8a2035..b1c9a9e29bd2 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
@@ -7736,8 +7736,8 @@ static const struct amdgpu_ring_funcs gfx_v9_0_ring_funcs_compute = {
SOC15_FLUSH_GPU_TLB_NUM_REG_WAIT * 7 +
8 + 8 + 8 + /* gfx_v9_0_ring_emit_fence x3 for user fence, vm fence */
7 + /* gfx_v9_0_emit_mem_sync */
- 5 + /* gfx_v9_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_v9_0_emit_wave_limit x2: mmSPI_WCL_PIPE_PERCENT_GFX */
+ 2 * 15 + /* x2: 3 mmSPI_WCL_PIPE_PERCENT_CS registers */
2, /* gfx_v9_0_ring_emit_cleaner_shader */
.emit_ib_size = 7, /* gfx_v9_0_ring_emit_ib_compute */
.emit_ib = gfx_v9_0_ring_emit_ib_compute,
--
2.56.1