]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/sched: Add warning for removing hack in drm_sched_fini()
authorPhilipp Stanner <phasta@kernel.org>
Thu, 23 Oct 2025 12:34:30 +0000 (14:34 +0200)
committerPhilipp Stanner <phasta@kernel.org>
Fri, 31 Oct 2025 14:39:08 +0000 (15:39 +0100)
The assembled developers agreed at the X.Org Developers Conference 2025
that the hack added for amdgpu in drm_sched_fini() shall be removed. It
shouldn't be needed by amdgpu anymore.

As it's unclear whether all drivers really follow the life time rule of
entities having to be torn down before their scheduler, it is reasonable
to warn for a while before removing the hack.

Add a warning in drm_sched_fini() that fires if an entity is still
active.

Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Signed-off-by: Philipp Stanner <phasta@kernel.org>
Link: https://patch.msgid.link/20251023123429.139848-2-phasta@kernel.org
drivers/gpu/drm/scheduler/sched_main.c

index 492e8af639dbe795e57b9363a6fb5a3818df5e84..2463ced2427a84abcb9cdf59543fc2bdb2ad75d4 100644 (file)
@@ -1425,7 +1425,7 @@ void drm_sched_fini(struct drm_gpu_scheduler *sched)
                struct drm_sched_rq *rq = sched->sched_rq[i];
 
                spin_lock(&rq->lock);
-               list_for_each_entry(s_entity, &rq->entities, list)
+               list_for_each_entry(s_entity, &rq->entities, list) {
                        /*
                         * Prevents reinsertion and marks job_queue as idle,
                         * it will be removed from the rq in drm_sched_entity_fini()
@@ -1446,8 +1446,15 @@ void drm_sched_fini(struct drm_gpu_scheduler *sched)
                         * For now, this remains a potential race in all
                         * drivers that keep entities alive for longer than
                         * the scheduler.
+                        *
+                        * The READ_ONCE() is there to make the lockless read
+                        * (warning about the lockless write below) slightly
+                        * less broken...
                         */
+                       if (!READ_ONCE(s_entity->stopped))
+                               dev_warn(sched->dev, "Tearing down scheduler with active entities!\n");
                        s_entity->stopped = true;
+               }
                spin_unlock(&rq->lock);
                kfree(sched->sched_rq[i]);
        }