drm/amdgpu: add lock in kfd_process_dequeue_from_device
authorjsg <jsg@openbsd.org>
Mon, 9 Sep 2024 09:49:12 +0000 (09:49 +0000)
committerjsg <jsg@openbsd.org>
Mon, 9 Sep 2024 09:49:12 +0000 (09:49 +0000)
From Yunxiang Li
381113ef01e28282f5f5a3267584b075427529f0 in linux-6.6.y/6.6.50
d225960c2330e102370815367b877baaf8bb8b5d in mainline linux

sys/dev/pci/drm/amd/amdkfd/kfd_process_queue_manager.c

index 43eff22..8aca926 100644 (file)
@@ -28,6 +28,7 @@
 #include "kfd_priv.h"
 #include "kfd_kernel_queue.h"
 #include "amdgpu_amdkfd.h"
+#include "amdgpu_reset.h"
 
 static inline struct process_queue_node *get_queue_by_qid(
                        struct process_queue_manager *pqm, unsigned int qid)
@@ -87,8 +88,12 @@ void kfd_process_dequeue_from_device(struct kfd_process_device *pdd)
                return;
 
        dev->dqm->ops.process_termination(dev->dqm, &pdd->qpd);
-       if (dev->kfd->shared_resources.enable_mes)
-               amdgpu_mes_flush_shader_debugger(dev->adev, pdd->proc_ctx_gpu_addr);
+       if (dev->kfd->shared_resources.enable_mes &&
+           down_read_trylock(&dev->adev->reset_domain->sem)) {
+               amdgpu_mes_flush_shader_debugger(dev->adev,
+                                                pdd->proc_ctx_gpu_addr);
+               up_read(&dev->adev->reset_domain->sem);
+       }
        pdd->already_dequeued = true;
 }