drm/sched: Avoid data corruptions
authorjsg <jsg@openbsd.org>
Mon, 19 Jul 2021 10:03:08 +0000 (10:03 +0000)
committerjsg <jsg@openbsd.org>
Mon, 19 Jul 2021 10:03:08 +0000 (10:03 +0000)
From Andrey Grodzovsky
0687411e2a8858262de2fc4a1d576016fd77292e in linux 5.10.y/5.10.51
0b10ab80695d61422337ede6ff496552d8ace99d in mainline linux

sys/dev/pci/drm/scheduler/sched_entity.c

index 3127cba..c69321b 100644 (file)
@@ -235,11 +235,16 @@ static void drm_sched_entity_kill_jobs_cb(struct dma_fence *f,
 static void drm_sched_entity_kill_jobs(struct drm_sched_entity *entity)
 {
        struct drm_sched_job *job;
+       struct dma_fence *f;
        int r;
 
        while ((job = to_drm_sched_job(spsc_queue_pop(&entity->job_queue)))) {
                struct drm_sched_fence *s_fence = job->s_fence;
 
+               /* Wait for all dependencies to avoid data corruptions */
+               while ((f = job->sched->ops->dependency(job, entity)))
+                       dma_fence_wait(f, false);
+
                drm_sched_fence_scheduled(s_fence);
                dma_fence_set_error(&s_fence->finished, -ESRCH);