Acquire the reset-domain semaphore for read with a trylock before sending
the MES unmap notification. If recovery owns it, skip the hardware access
but retain the periodic rearm while queues remain oversubscribed.

Signed-off-by: Prike Liang <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c
index 4cb37cdbf821..4138080edbea 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c
@@ -1192,7 +1192,11 @@ static void 
amdgpu_mes_userq_notify_unmap_work_handler(struct work_struct *work)
                                               userq_notify_unmap_work.work);
        struct amdgpu_device *adev = mes->adev;
 
-       amdgpu_mes_notify_unmap_queue(adev);
+       /* Do not block reset-time cancellation or lose the periodic retry. */
+       if (down_read_trylock(&adev->reset_domain->sem)) {
+               amdgpu_mes_notify_unmap_queue(adev);
+               up_read(&adev->reset_domain->sem);
+       }
 
        /* Re-arm if still oversubscribed */
        if (atomic_read(&mes->userq_hw_queue_count) >
-- 
2.34.1

Reply via email to