restore_process_queues_cpsch() decrements qpd->evicted to zero and maps
the queues back, but a reset in flight is about to drop the mappings
those queues are built against. The restore then publishes queues that
point at state the reset discards.

Bail out with -EAGAIN while the device is fenced or resetting, leaving
the eviction reference held so the restore is retried once the device is
back.

Signed-off-by: Xiang Liu <[email protected]>
---
 drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 7 +++++++
 1 file changed, 7 insertions(+)

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 0c402a685b61..0d69d261ea1c 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
@@ -1636,6 +1636,13 @@ static int restore_process_queues_cpsch(struct 
device_queue_manager *dqm,
                goto out;
        }
 
+       /* A restore now would map queues against mappings the reset will drop 
*/
+       if (amdgpu_amdkfd_is_fed(dqm->dev->adev) ||
+           amdgpu_in_reset(dqm->dev->adev)) {
+               retval = -EAGAIN;
+               goto out;
+       }
+
        /* The debugger creates processes that temporarily have not acquired
         * all VMs for all devices and has no VMs itself.
         * Skip queue restore on process restore.
-- 
2.34.1

Reply via email to