Skip to contentSkip to conversation

drm/amdgpu/gfx9: Fix Ring and IB test fail after mode2

PATCH Christoph Berliner 1 participant 1 message Nov 20

lore
Share & tools
lore

Christoph Berliner

author Tested-by
#0 lore raw

Hi Jiqian,

a late test report for this patch (upstream as c3988a7ad479) on a Ryzen 5 5600G (Cezanne, gfx90c, GC 9.3.0, MEC firmware 0x1e3, HWS, amdgpu.noretry=1, kernel 7.0.14 with this patch included):

The KCQ part works as described: after MODE2 the compute ring and IB tests pass and graphics/Vulkan keep working.

KFD however stays unusable after the reset. The next HIP program hangs, and the kernel prints

qcm fence wait loop timeout expired
The cp might be in an unrecoverable state due to an unsuccessful queues preemption
process pid ... DQM create queue type 0 failed. ret -62

followed by another reset, and that repeats until reboot.

Dumping all compute HQDs before MODE2 and again at resume (before KIQ init) showed that the HIQ (MEC2 pipe 0 queue 0) is still ACTIVE with its old MQD/PQ after MODE2, i.e. the same stale-HQD problem you found for the KCQs. The HIQ is not torn down during a reset because kq_uninitialize() only calls destroy_mqd() if it can take the reset domain semaphore, which amdgpu_device_gpu_recover() already holds for write at that point.

Deactivating all active compute HQDs except the KIQ before MODE2 fixes it on my machine (same boot, old path vs. new path: hang vs. HIP/rocBLAS tests passing). I wrote this up, with the two patches I use as a workaround, here:
https://www.google.com/url?q=https://gitlab.freedesktop.org/drm/amd/-/issues/6177&source=gmail&ust=1795269404456000&sa=E

The patches only touch the GC 9.3.0 path and have not been tested on any hardware other than mine. I don't know this code well enough to rule out side effects elsewhere, so please take them as a starting point rather than a finished fix.

Two small observations from the dump that may matter for other users of gfx_v9_0_deactivate_kcq_hqd():
- the dequeue loop runs to adev->usec_timeout but compares the counter against AMDGPU_MAX_USEC_TIMEOUT, so the manual CP_HQD_ACTIVE=0 fallback is not reached;
- on Renoir the HQD registers of MEC2 pipes 2/3 read back as those of pipes 0/1, so a loop over all pipes sees the KIQ twice.

The analysis and the patches were done with the help of an AI coding assistant (Claude Code); all tests on my hardware.

Thanks,
Christoph