All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] drm/amdkfd: only flush the TLB of devices whose queues got suspended
@ 2026-11-18  5:49 Jesse Zhang
  2026-11-18  5:49 ` [PATCH 2/3] drm/amdkfd: return the memory violation data to the debugger Jesse Zhang
  2026-11-18  5:50 ` [PATCH 3/3] drm/amdkfd: don't keep the debugger pointer when DBG_TRAP_ENABLE fails Jesse Zhang
  0 siblings, 2 replies; 5+ messages in thread
From: Jesse Zhang @ 2026-11-18  5:49 UTC (permalink / raw)
  To: amd-gfx; +Cc: Alexander.Deucher, Felix Kuehling, Jonathan Kim, Jesse Zhang

suspend_queues() goes through all devices of the process, and on MES does
the debug memory fence and a heavy-weight TLB flush when total_suspended,
the number of queues suspended so far on any device, is non-zero. On a
later device without suspended queues that flushes the TLB of a VM the
process may not even have: kfd_flush_tlb() dereferences pdd->drm_priv,
which is NULL when the process never acquired a VM on that GPU.

That is a process using only one GPU of a system with more, e.g. a dGPU
plus the APU's iGPU, stopped by a debugger. On navi31 with the iGPU,
a debugger suspending a compute queue of a ptraced child that only
acquired the navi31 VM:

  Oops: general protection fault, probably for non-canonical address 0xdffffc000000002f: 0000 [#1] SMP KASAN NOPTI
  KASAN: null-ptr-deref in range [0x0000000000000178-0x000000000000017f]
  RIP: 0010:suspend_queues+0x104b/0x1a80 [amdgpu]
  Call Trace:
   kfd_ioctl_set_debug_trap+0x1234/0x1720 [amdgpu]
   kfd_ioctl+0x46a/0xb70 [amdgpu]

and the debugger ends up in D state.

Count the queues MES suspended per device and only fence and flush for
those devices. With that the queue is suspended and resumed (status 0) and
the kfdtest KFDDBGTest tests pass.

Fixes: ff114e705d6a ("drm/amdkfd: Add TLB flush after MES queue eviction/suspension")
Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
index b5d7d13f31a5..a50a49d6ed01 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
@@ -3952,7 +3952,7 @@ int suspend_queues(struct kfd_process *p,
 		struct device *dev = dqm->dev->adev->dev;
 		struct qcm_process_device *qpd = &pdd->qpd;
 		struct queue *q;
-		int r, per_device_suspended = 0;
+		int r, per_device_suspended = 0, mes_suspended = 0;
 
 		mutex_lock(&p->event_mutex);
 		dqm_lock(dqm);
@@ -3974,7 +3974,7 @@ int suspend_queues(struct kfd_process *p,
 							~exception_clear_mask;
 
 					if (is_mes)
-						total_suspended++;
+						mes_suspended++;
 					else
 						per_device_suspended++;
 				} else if (err != -EBUSY) {
@@ -3987,7 +3987,12 @@ int suspend_queues(struct kfd_process *p,
 		if (!per_device_suspended) {
 			dqm_unlock(dqm);
 			mutex_unlock(&p->event_mutex);
-			if (total_suspended) {
+			/*
+			 * Only for the queues of this device, the process may
+			 * not even have a VM on the other devices.
+			 */
+			if (mes_suspended) {
+				total_suspended += mes_suspended;
 				amdgpu_amdkfd_debug_mem_fence(dqm->dev->adev);
 				/* Heavy-weight TLB flush after MES suspends queues */
 				kfd_flush_tlb(pdd);
-- 
2.50.1


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

end of thread, other threads:[~2026-11-18  6:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-18  5:49 [PATCH 1/3] drm/amdkfd: only flush the TLB of devices whose queues got suspended Jesse Zhang
2026-11-18  5:49 ` [PATCH 2/3] drm/amdkfd: return the memory violation data to the debugger Jesse Zhang
2026-11-18  6:06   ` sashiko-bot
2026-11-18  5:50 ` [PATCH 3/3] drm/amdkfd: don't keep the debugger pointer when DBG_TRAP_ENABLE fails Jesse Zhang
2026-11-18  6:07   ` sashiko-bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.