If the engine is hung, we shouldn't need this since it won't be
powered down, but we could potentially have a case where
a queue can be preempted, but due to logic errors in the commands,
the fence never signals.  The engine could potentially go into
the off state.  Protect against that.

Signed-off-by: Alex Deucher <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
index b5c2d1d4d8839..c8a1aa88a9de0 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
@@ -137,7 +137,15 @@ static enum drm_gpu_sched_stat amdgpu_job_timedout(struct 
drm_sched_job *s_job)
                        s_job->sched->name);
                /* Stop the scheduler to prevent anybody else from touching the 
ring buffer. */
                drm_sched_wqueue_stop(&ring->sched);
+               if (ring->funcs->type == AMDGPU_RING_TYPE_GFX ||
+                   ring->funcs->type == AMDGPU_RING_TYPE_COMPUTE ||
+                   ring->funcs->type == AMDGPU_RING_TYPE_SDMA)
+                       amdgpu_gfx_off_ctrl(adev, false);
                r = amdgpu_ring_reset(ring, job->vmid, job->hw_fence);
+               if (ring->funcs->type == AMDGPU_RING_TYPE_GFX ||
+                   ring->funcs->type == AMDGPU_RING_TYPE_COMPUTE ||
+                   ring->funcs->type == AMDGPU_RING_TYPE_SDMA)
+                       amdgpu_gfx_off_ctrl(adev, true);
                if (!r) {
                        /* Start the scheduler again */
                        drm_sched_wqueue_start(&ring->sched);
-- 
2.55.0

Reply via email to