Skip to contentSkip to conversation

drm/amdgpu: Fix cond_exec handling in amdgpu_ib_schedule()

PATCH In review Alex Deucher 3 participants 3 messages Jan 27 – Jan 28

Subsystems (2)
lore
Share & tools
lore

Alex Deucher

author maintainer
#0 lore raw

PATCH 1/1 drm/amdgpu: Fix cond_exec handling in amdgpu_ib_schedule()

The EXEC_COUNT field must be > 0. In the gfx shadow handling we always emit a cond_exec packet after the gfx_shadow packet, but the EXEC_COUNT never gets patched. This leads to a hang when we try and reset queues on gfx11 APUs.

Fixes c68cbbfd54c6 ("drm/amdgpu: cleanup conditional execution")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +3 -2
index 72ec455fa932c..44f230d67da24 100644
@@ -235,7 +235,7 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned int num_ibs,
 
 	amdgpu_ring_ib_begin(ring);
 
-	if (ring->funcs->emit_gfx_shadow)
+	if (ring->funcs->emit_gfx_shadow && adev->gfx.cp_gfx_shadow)
 		amdgpu_ring_emit_gfx_shadow(ring, shadow_va, csa_va, gds_va,
 					    init_shadow, vmid);
 
@@ -291,7 +291,8 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned int num_ibs,
 				       fence_flags | AMDGPU_FENCE_FLAG_64BIT);
 	}
 
-	if (ring->funcs->emit_gfx_shadow && ring->funcs->init_cond_exec) {
+	if (ring->funcs->emit_gfx_shadow && ring->funcs->init_cond_exec &&
+	    adev->gfx.cp_gfx_shadow) {
 		amdgpu_ring_emit_gfx_shadow(ring, 0, 0, 0, false, 0);
 		amdgpu_ring_init_cond_exec(ring, ring->cond_exe_gpu_addr);
 	}
Signature · 1 line
2.52.0
#1 lore raw

Ping?

Quoted 39 lines · Alex Deucher

The EXEC_COUNT field must be > 0. In the gfx shadow handling we always emit a cond_exec packet after the gfx_shadow packet, but the EXEC_COUNT never gets patched. This leads to a hang when we try and reset queues on gfx11 APUs.

Fixes c68cbbfd54c6 ("drm/amdgpu: cleanup conditional execution")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +3 -3
index 72ec455fa932c..44f230d67da24 100644
@@ -235,7 +235,7 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned int num_ibs,
 
        amdgpu_ring_ib_begin(ring);
 
-       if (ring->funcs->emit_gfx_shadow)
+       if (ring->funcs->emit_gfx_shadow && adev->gfx.cp_gfx_shadow)
                amdgpu_ring_emit_gfx_shadow(ring, shadow_va, csa_va, gds_va,
                                            init_shadow, vmid);
 
@@ -291,7 +291,8 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned int num_ibs,
                                       fence_flags | AMDGPU_FENCE_FLAG_64BIT);
        }
 
-       if (ring->funcs->emit_gfx_shadow && ring->funcs->init_cond_exec) {
+       if (ring->funcs->emit_gfx_shadow && ring->funcs->init_cond_exec &&
+           adev->gfx.cp_gfx_shadow) {
                amdgpu_ring_emit_gfx_shadow(ring, 0, 0, 0, false, 0);
                amdgpu_ring_init_cond_exec(ring, ring->cond_exe_gpu_addr);
        }
--

2.52.0

Reviewed-by Alex Deucher
#2 lore raw

[AMD Official Use Only - AMD Internal Distribution Only]

Quoted 55 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Wednesday, January 28, 2026 6:56 AM
To: Deucher, Alexander <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH] drm/amdgpu: Fix cond_exec handling in amdgpu_ib_schedule()

Ping?

drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c int amdgpu_ib_schedule(struct amdgpu_ring *ring,

Quoted 29 lines · Alex Deucher

The EXEC_COUNT field must be > 0. In the gfx shadow handling we always emit a cond_exec packet after the gfx_shadow packet, but the EXEC_COUNT never gets patched. This leads to a hang when we try and reset queues on gfx11 APUs.

Fixes c68cbbfd54c6 ("drm/amdgpu: cleanup conditional execution")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +1 -1
index 72ec455fa932c..44f230d67da24 100644
@@ -235,7 +235,7 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring,
 unsigned int num_ibs,
 
        amdgpu_ring_ib_begin(ring);
 
-       if (ring->funcs->emit_gfx_shadow)
+       if (ring->funcs->emit_gfx_shadow && adev->gfx.cp_gfx_shadow)
                amdgpu_ring_emit_gfx_shadow(ring, shadow_va, csa_va, gds_va,
                                            init_shadow, vmid);
@@ -291,7 +291,8 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring,

unsigned int num_ibs,

Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +2 -2
                                       fence_flags | AMDGPU_FENCE_FLAG_64BIT);
        }
 
-       if (ring->funcs->emit_gfx_shadow && ring->funcs->init_cond_exec) {
+       if (ring->funcs->emit_gfx_shadow && ring->funcs->init_cond_exec &&
+           adev->gfx.cp_gfx_shadow) {
                amdgpu_ring_emit_gfx_shadow(ring, 0, 0, 0, false, 0);
                amdgpu_ring_init_cond_exec(ring, ring->cond_exe_gpu_addr);
        }
--

2.52.0