Skip to content

Commit

Permalink
drm/sched: Fix dynamic job-flow control race
Browse files Browse the repository at this point in the history
Fixes a race condition reported here: AsahiLinux#309 (comment)

The whole premise of lockless access to a single-producer-single-
consumer queue is that there is just a single producer and single
consumer.  That means we can't call drm_sched_can_queue() (which is
about queueing more work to the hw, not to the spsc queue) from
anywhere other than the consumer (wq).

This call in the producer is just an optimization to avoid scheduling
the consuming worker if it cannot yet queue more work to the hw.  It
is safe to drop this optimization to avoid the race condition.

Suggested-by: Asahi Lina <[email protected]>
Fixes: a78422e ("drm/sched: implement dynamic job-flow control")
Signed-off-by: Rob Clark <[email protected]>
  • Loading branch information
robclark authored and intel-lab-lkp committed Sep 13, 2024
1 parent e75356e commit bdbd100
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions drivers/gpu/drm/scheduler/sched_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1020,8 +1020,7 @@ EXPORT_SYMBOL(drm_sched_job_cleanup);
void drm_sched_wakeup(struct drm_gpu_scheduler *sched,
struct drm_sched_entity *entity)
{
if (drm_sched_can_queue(sched, entity))
drm_sched_run_job_queue(sched);
drm_sched_run_job_queue(sched);
}

/**
Expand Down

0 comments on commit bdbd100

Please sign in to comment.