From 56e41d7558f0fd33e108b6dbe588293e8263e280 Mon Sep 17 00:00:00 2001 From: jsg Date: Mon, 19 Jul 2021 10:03:08 +0000 Subject: [PATCH] drm/sched: Avoid data corruptions From Andrey Grodzovsky 0687411e2a8858262de2fc4a1d576016fd77292e in linux 5.10.y/5.10.51 0b10ab80695d61422337ede6ff496552d8ace99d in mainline linux --- sys/dev/pci/drm/scheduler/sched_entity.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sys/dev/pci/drm/scheduler/sched_entity.c b/sys/dev/pci/drm/scheduler/sched_entity.c index 3127cba770d..c69321bea1a 100644 --- a/sys/dev/pci/drm/scheduler/sched_entity.c +++ b/sys/dev/pci/drm/scheduler/sched_entity.c @@ -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); -- 2.20.1