AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 0/9] drm/amdgpu/amdkfd: fix MES queue lifecycle on multi-GPU
@ 2026-11-24 14:34 Armas Spann
  2026-11-24 14:34 ` [PATCH v1 1/9] drm/amdgpu/mes: distinguish rejected from timed out commands Armas Spann
                   ` (9 more replies)
  0 siblings, 10 replies; 19+ messages in thread
From: Armas Spann @ 2026-11-24 14:34 UTC (permalink / raw)
  To: amd-gfx; +Cc: alexander.deucher, christian.koenig, Felix.Kuehling, Armas Spann

On a dual R9700 Pro (gfx 12.0.1) system running RCCL distributed
training, MES hits 2-second preemption timeouts on REMOVE_QUEUE and
SUSPEND after 90 to 120 seconds of operation. Both GPUs fail during
RCCL collectives. The timeout triggers a MODE1 reset, which loses VRAM
and cascades into a second reset on the peer GPU.

Root cause: cwsr_enable=0 prevents MES from preempting running compute
waves. When an RCCL kernel on GPU0 waits for its peer on GPU1, and
GPU1's queue gets evicted, MES cannot preempt GPU0's kernel because
there is no CWSR. The 2s MES preemption timeout fires, MES rejects the
command, and the driver treats it as a hang.

Separately, KFD frees queue storage (MQD, doorbell id, gang context)
before MES has confirmed the removal. A REMOVE_QUEUE that completes
late writes the queue state back into an MQD that has been given to the
next queue. This is a use-after-free on the firmware side.

This series fixes both problems:

  1/9  Distinguish rejected from timed-out MES commands so callers
       can tell a firmware that said no from one that stopped answering.
       Add a ticket for late completion polling.
  2/9  Factor out per-queue MES resource freeing into a helper.
  3/9  Track per-queue MES state (mapped/unmapped/pending) so the rest
       of the dqm knows whether MES may still reference storage.
  4/9  Add a quarantine for queues that MES has not released. A reaper
       workqueue polls for late completions and cleans up.
  5/9  Defer freeing of queue storage until MES has confirmed retirement
       in all four teardown paths (destroy, create failure, termination,
       process exit).
  6/9  Keep eviction and restore consistent when MES fails. Do not
       restore a queue whose eviction was not confirmed.
  7/9  Apply queue property updates only after the queue is unmapped,
       not while MES still owns it.
  8/9  Reconcile KFD queue state with MES after a scheduler restart.
       Queues from the previous firmware instance are retired.
  9/9  Force cwsr_enable=1 on gfx11+ discrete GPUs when a second MES
       GPU is present. Per-device decision, logged to dmesg.

Tested on a dual R9700 Pro system (gfx 12.0.1, Threadripper 1950X,
64GB, Gentoo, kernel 7.3.5-p1 with these patches):

  - RCCL all_reduce stress 150s: 85,582 iters, 570.5 it/s, 0 errors
  - RCCL all_reduce stress 600s: 343,647 iters, 572.7 it/s, 0 errors
  - F5-TTS dual-GPU training 50,780 steps: completed, no MES errors
  - dmesg after all tests: zero MES rejects, zero resets
  - Patch 9 override test (cwsr_enable=0 in cmdline): kernel forces 1,
    logs warning per affected GPU

Related reports:

  https://github.com/ROCm/hrx-system/issues/2938
  https://github.com/ROCm/TheRock/issues/9279
  https://github.com/ROCm/TheRock/issues/9299
  https://github.com/ROCm/rccl/issues/2193

Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: Felix Kuehling <Felix.Kuehling@amd.com>

Armas Spann (9):
  drm/amdgpu/mes: distinguish rejected from timed out commands
  drm/amdkfd: factor out freeing of per-queue MES resources
  drm/amdkfd: track whether MES knows each queue
  drm/amdkfd: add a quarantine for queues MES has not retired
  drm/amdkfd: keep queue storage until MES confirmed retirement
  drm/amdkfd: keep eviction and restore consistent when MES fails
  drm/amdkfd: apply queue property updates only after unmap
  drm/amdkfd: reconcile queue state with MES after a restart
  drm/amdkfd: force CWSR on with more than one MES GPU

 drivers/gpu/drm/amd/amdgpu/amdgpu.h           |   1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c       |  99 ++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c       |  79 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h       |  44 ++
 drivers/gpu/drm/amd/amdgpu/mes_v11_0.c        |  51 +-
 drivers/gpu/drm/amd/amdgpu/mes_v12_0.c        |  52 +-
 drivers/gpu/drm/amd/amdgpu/mes_v12_1.c        |  57 +-
 drivers/gpu/drm/amd/amdkfd/kfd_device.c       |  35 +-
 .../drm/amd/amdkfd/kfd_device_queue_manager.c | 627 ++++++++++++++++--
 .../drm/amd/amdkfd/kfd_device_queue_manager.h |  31 +
 drivers/gpu/drm/amd/amdkfd/kfd_priv.h         |  51 ++
 drivers/gpu/drm/amd/amdkfd/kfd_process.c      |  51 +-
 .../amd/amdkfd/kfd_process_queue_manager.c    | 167 +++--
 drivers/gpu/drm/amd/amdkfd/kfd_queue.c        |  30 +
 14 files changed, 1247 insertions(+), 128 deletions(-)

-- 
2.56.1


^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2026-11-25 14:17 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24 14:34 [PATCH v1 0/9] drm/amdgpu/amdkfd: fix MES queue lifecycle on multi-GPU Armas Spann
2026-11-24 14:34 ` [PATCH v1 1/9] drm/amdgpu/mes: distinguish rejected from timed out commands Armas Spann
2026-11-24 16:19   ` sashiko-bot
2026-11-24 14:34 ` [PATCH v1 2/9] drm/amdkfd: factor out freeing of per-queue MES resources Armas Spann
2026-11-24 16:09   ` sashiko-bot
2026-11-24 14:34 ` [PATCH v1 3/9] drm/amdkfd: track whether MES knows each queue Armas Spann
2026-11-24 16:30   ` sashiko-bot
2026-11-24 14:34 ` [PATCH v1 4/9] drm/amdkfd: add a quarantine for queues MES has not retired Armas Spann
2026-11-24 16:29   ` sashiko-bot
2026-11-24 14:34 ` [PATCH v1 5/9] drm/amdkfd: keep queue storage until MES confirmed retirement Armas Spann
2026-11-24 16:29   ` sashiko-bot
2026-11-24 14:34 ` [PATCH v1 6/9] drm/amdkfd: keep eviction and restore consistent when MES fails Armas Spann
2026-11-24 16:30   ` sashiko-bot
2026-11-24 14:34 ` [PATCH v1 7/9] drm/amdkfd: apply queue property updates only after unmap Armas Spann
2026-11-24 16:42   ` sashiko-bot
2026-11-24 14:34 ` [PATCH v1 8/9] drm/amdkfd: reconcile queue state with MES after a restart Armas Spann
2026-11-24 16:53   ` sashiko-bot
2026-11-24 14:34 ` [PATCH v1 9/9] drm/amdkfd: force CWSR on with more than one MES GPU Armas Spann
2026-11-25 14:15 ` [PATCH v1 0/9] drm/amdgpu/amdkfd: fix MES queue lifecycle on multi-GPU Armas Spann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox