drm/sched: Avoid job cleanup if sched thread is parked.
authorAndrey Grodzovsky <andrey.grodzovsky@amd.com>
Thu, 7 Nov 2019 22:55:15 +0000 (17:55 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 7 Nov 2019 23:08:07 +0000 (18:08 -0500)
When the sched thread is parked we assume ring_mirror_list is
not accessed from here.

Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/scheduler/sched_main.c

index 362cf1a..3c57e84 100644 (file)
@@ -650,9 +650,13 @@ drm_sched_get_cleanup_job(struct drm_gpu_scheduler *sched)
        struct drm_sched_job *job;
        unsigned long flags;
 
-       /* Don't destroy jobs while the timeout worker is running */
-       if (sched->timeout != MAX_SCHEDULE_TIMEOUT &&
-           !cancel_delayed_work(&sched->work_tdr))
+       /*
+        * Don't destroy jobs while the timeout worker is running  OR thread
+        * is being parked and hence assumed to not touch ring_mirror_list
+        */
+       if ((sched->timeout != MAX_SCHEDULE_TIMEOUT &&
+           !cancel_delayed_work(&sched->work_tdr)) ||
+           __kthread_should_park(sched->thread))
                return NULL;
 
        spin_lock_irqsave(&sched->job_list_lock, flags);