drm/amdgpu: add per ring reset support (v5)
authorAlex Deucher <alexander.deucher@amd.com>
Mon, 3 Jun 2024 18:38:20 +0000 (14:38 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 16 Aug 2024 18:17:52 +0000 (14:17 -0400)
If a specific job is hung, try and reset just the
ring associated with the job.

v2: move to amdgpu_job.c
v3: fix drm_sched_stop() handling when ring reset fails
v4: drop unnecessary amdgpu_fence_driver_clear_job_fences() and
    drm_sched_increase_karma()
v5: rework sched_stop handling

Acked-by: Vitaly Prosyak <vitaly.prosyak@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c

index 908e134551523366c4adc914cfa192232f5c0036..c2de3fd172455ef113f1fab8f518143883671d0a 100644 (file)
@@ -72,6 +72,25 @@ static enum drm_gpu_sched_stat amdgpu_job_timedout(struct drm_sched_job *s_job)
 
        dma_fence_set_error(&s_job->s_fence->finished, -ETIME);
 
+       /* attempt a per ring reset */
+       if (amdgpu_gpu_recovery &&
+           ring->funcs->reset) {
+               /* stop the scheduler, but don't mess with the
+                * bad job yet because if ring reset fails
+                * we'll fall back to full GPU reset.
+                */
+               drm_sched_wqueue_stop(&ring->sched);
+               r = amdgpu_ring_reset(ring, job->vmid);
+               if (!r) {
+                       if (amdgpu_ring_sched_ready(ring))
+                               drm_sched_stop(&ring->sched, s_job);
+                       amdgpu_fence_driver_force_completion(ring);
+                       if (amdgpu_ring_sched_ready(ring))
+                               drm_sched_start(&ring->sched, true);
+                       goto exit;
+               }
+       }
+
        if (amdgpu_device_should_recover_gpu(ring->adev)) {
                struct amdgpu_reset_context reset_context;
                memset(&reset_context, 0, sizeof(reset_context));