Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/sched: Remove racy hack from drm_sched_fini()

drm_sched_fini() contained a hack to work around a race in amdgpu.
According to AMD, the hack should not be necessary anymore. In case
there should have been undetected users,

commit 975ca62a014c ("drm/sched: Add warning for removing hack in drm_sched_fini()")

had added a warning one release cycle ago.

Thus, it can be derived that the hack can be savely removed by now.

Remove the hack.

Acked-by: Danilo Krummrich <dakr@kernel.org>
Signed-off-by: Philipp Stanner <phasta@kernel.org>
Link: https://patch.msgid.link/20260108083019.63532-2-phasta@kernel.org

+1 -37
+1 -37
drivers/gpu/drm/scheduler/sched_main.c
··· 1418 1418 */ 1419 1419 void drm_sched_fini(struct drm_gpu_scheduler *sched) 1420 1420 { 1421 - struct drm_sched_entity *s_entity; 1422 1421 int i; 1423 1422 1424 1423 drm_sched_wqueue_stop(sched); 1425 1424 1426 - for (i = DRM_SCHED_PRIORITY_KERNEL; i < sched->num_rqs; i++) { 1427 - struct drm_sched_rq *rq = sched->sched_rq[i]; 1428 - 1429 - spin_lock(&rq->lock); 1430 - list_for_each_entry(s_entity, &rq->entities, list) { 1431 - /* 1432 - * Prevents reinsertion and marks job_queue as idle, 1433 - * it will be removed from the rq in drm_sched_entity_fini() 1434 - * eventually 1435 - * 1436 - * FIXME: 1437 - * This lacks the proper spin_lock(&s_entity->lock) and 1438 - * is, therefore, a race condition. Most notably, it 1439 - * can race with drm_sched_entity_push_job(). The lock 1440 - * cannot be taken here, however, because this would 1441 - * lead to lock inversion -> deadlock. 1442 - * 1443 - * The best solution probably is to enforce the life 1444 - * time rule of all entities having to be torn down 1445 - * before their scheduler. Then, however, locking could 1446 - * be dropped alltogether from this function. 1447 - * 1448 - * For now, this remains a potential race in all 1449 - * drivers that keep entities alive for longer than 1450 - * the scheduler. 1451 - * 1452 - * The READ_ONCE() is there to make the lockless read 1453 - * (warning about the lockless write below) slightly 1454 - * less broken... 1455 - */ 1456 - if (!READ_ONCE(s_entity->stopped)) 1457 - dev_warn(sched->dev, "Tearing down scheduler with active entities!\n"); 1458 - s_entity->stopped = true; 1459 - } 1460 - spin_unlock(&rq->lock); 1425 + for (i = DRM_SCHED_PRIORITY_KERNEL; i < sched->num_rqs; i++) 1461 1426 kfree(sched->sched_rq[i]); 1462 - } 1463 1427 1464 1428 /* Wakeup everyone stuck in drm_sched_entity_flush for this scheduler */ 1465 1429 wake_up_all(&sched->job_scheduled);