Replace amdgpu_job_stop_all_jobs_on_sched() helper by scheduler common
drm_sched_cancel_all_jobs() and remove one duplicated instance of the
to_drm_sched_job() macro.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursu...@igalia.com>
Cc: Christian König <christian.koe...@amd.com>
Cc: Danilo Krummrich <d...@kernel.org>
Cc: Matthew Brost <matthew.br...@intel.com>
Cc: Philipp Stanner <pha...@kernel.org>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  3 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_job.c    | 34 ----------------------
 drivers/gpu/drm/amd/amdgpu/amdgpu_job.h    |  2 --
 3 files changed, 2 insertions(+), 37 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index d100bb7a137c..509460f5fe7f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -5980,7 +5980,8 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *adev,
                        drm_sched_stop(&ring->sched, job ? &job->base : NULL);
 
                        if (need_emergency_restart)
-                               amdgpu_job_stop_all_jobs_on_sched(&ring->sched);
+                               drm_sched_cancel_all_jobs(&ring->sched,
+                                                         -EHWPOISON);
                }
                atomic_inc(&tmp_adev->gpu_reset_counter);
        }
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
index 100f04475943..9e32c504b481 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
@@ -411,40 +411,6 @@ static struct dma_fence *amdgpu_job_run(struct 
drm_sched_job *sched_job)
        return fence;
 }
 
-#define to_drm_sched_job(sched_job)            \
-               container_of((sched_job), struct drm_sched_job, queue_node)
-
-void amdgpu_job_stop_all_jobs_on_sched(struct drm_gpu_scheduler *sched)
-{
-       struct drm_sched_job *s_job;
-       struct drm_sched_entity *s_entity = NULL;
-       int i;
-
-       /* Signal all jobs not yet scheduled */
-       for (i = DRM_SCHED_PRIORITY_KERNEL; i < sched->num_rqs; i++) {
-               struct drm_sched_rq *rq = sched->sched_rq[i];
-               spin_lock(&rq->lock);
-               list_for_each_entry(s_entity, &rq->entities, list) {
-                       while ((s_job = 
to_drm_sched_job(spsc_queue_pop(&s_entity->job_queue)))) {
-                               struct drm_sched_fence *s_fence = 
s_job->s_fence;
-
-                               dma_fence_signal(&s_fence->scheduled);
-                               dma_fence_set_error(&s_fence->finished, 
-EHWPOISON);
-                               dma_fence_signal(&s_fence->finished);
-                       }
-               }
-               spin_unlock(&rq->lock);
-       }
-
-       /* Signal all jobs already scheduled to HW */
-       list_for_each_entry(s_job, &sched->pending_list, list) {
-               struct drm_sched_fence *s_fence = s_job->s_fence;
-
-               dma_fence_set_error(&s_fence->finished, -EHWPOISON);
-               dma_fence_signal(&s_fence->finished);
-       }
-}
-
 const struct drm_sched_backend_ops amdgpu_sched_ops = {
        .prepare_job = amdgpu_job_prepare_job,
        .run_job = amdgpu_job_run,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.h
index ce6b9ba967ff..5a25c281d98b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.h
@@ -105,6 +105,4 @@ struct dma_fence *amdgpu_job_submit(struct amdgpu_job *job);
 int amdgpu_job_submit_direct(struct amdgpu_job *job, struct amdgpu_ring *ring,
                             struct dma_fence **fence);
 
-void amdgpu_job_stop_all_jobs_on_sched(struct drm_gpu_scheduler *sched);
-
 #endif
-- 
2.48.0

Reply via email to