Skip to content

Commit e0023c8

Browse files
author
Philipp Stanner
committed
drm/nouveau: Fix race in nouveau_sched_fini()
nouveau_sched_fini() uses a memory barrier before wait_event(). wait_event(), however, is a macro which expands to a loop which might check the passed condition several times. The barrier would only take effect for the first check. Replace the barrier with a function which takes the spinlock. Cc: [email protected] # v6.8+ Fixes: 5f03a50 ("drm/nouveau: implement 1:1 scheduler - entity relationship") Acked-by: Danilo Krummrich <[email protected]> Signed-off-by: Philipp Stanner <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent d25e3a6 commit e0023c8

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

drivers/gpu/drm/nouveau/nouveau_sched.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,15 +482,25 @@ nouveau_sched_create(struct nouveau_sched **psched, struct nouveau_drm *drm,
482482
return 0;
483483
}
484484

485+
static bool
486+
nouveau_sched_job_list_empty(struct nouveau_sched *sched)
487+
{
488+
bool empty;
489+
490+
spin_lock(&sched->job.list.lock);
491+
empty = list_empty(&sched->job.list.head);
492+
spin_unlock(&sched->job.list.lock);
493+
494+
return empty;
495+
}
485496

486497
static void
487498
nouveau_sched_fini(struct nouveau_sched *sched)
488499
{
489500
struct drm_gpu_scheduler *drm_sched = &sched->base;
490501
struct drm_sched_entity *entity = &sched->entity;
491502

492-
rmb(); /* for list_empty to work without lock */
493-
wait_event(sched->job.wq, list_empty(&sched->job.list.head));
503+
wait_event(sched->job.wq, nouveau_sched_job_list_empty(sched));
494504

495505
drm_sched_entity_fini(entity);
496506
drm_sched_fini(drm_sched);

0 commit comments

Comments
 (0)