Skip to content

Commit b90e51e

Browse files
robclarkjannau
authored andcommitted
drm/sched: Fix dynamic job-flow control race
Fixes a race condition reported here: #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 <lina@asahilina.net> Fixes: a78422e ("drm/sched: implement dynamic job-flow control") Closes: #309 Cc: stable@vger.kernel.org Signed-off-by: Rob Clark <robdclark@chromium.org>
1 parent bcc9ecf commit b90e51e

3 files changed

Lines changed: 5 additions & 8 deletions

File tree

drivers/gpu/drm/scheduler/sched_entity.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ static void drm_sched_entity_wakeup(struct dma_fence *f,
380380
container_of(cb, struct drm_sched_entity, cb);
381381

382382
drm_sched_entity_clear_dep(f, cb);
383-
drm_sched_wakeup(entity->rq->sched, entity);
383+
drm_sched_wakeup(entity->rq->sched);
384384
}
385385

386386
/**
@@ -612,7 +612,7 @@ void drm_sched_entity_push_job(struct drm_sched_job *sched_job)
612612
if (drm_sched_policy == DRM_SCHED_POLICY_FIFO)
613613
drm_sched_rq_update_fifo(entity, submit_ts);
614614

615-
drm_sched_wakeup(entity->rq->sched, entity);
615+
drm_sched_wakeup(entity->rq->sched);
616616
}
617617
}
618618
EXPORT_SYMBOL(drm_sched_entity_push_job);

drivers/gpu/drm/scheduler/sched_main.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,15 +1022,12 @@ EXPORT_SYMBOL(drm_sched_job_cleanup);
10221022
/**
10231023
* drm_sched_wakeup - Wake up the scheduler if it is ready to queue
10241024
* @sched: scheduler instance
1025-
* @entity: the scheduler entity
10261025
*
10271026
* Wake up the scheduler if we can queue jobs.
10281027
*/
1029-
void drm_sched_wakeup(struct drm_gpu_scheduler *sched,
1030-
struct drm_sched_entity *entity)
1028+
void drm_sched_wakeup(struct drm_gpu_scheduler *sched)
10311029
{
1032-
if (drm_sched_can_queue(sched, entity))
1033-
drm_sched_run_job_queue(sched);
1030+
drm_sched_run_job_queue(sched);
10341031
}
10351032

10361033
/**

include/drm/gpu_scheduler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ void drm_sched_entity_modify_sched(struct drm_sched_entity *entity,
574574

575575
void drm_sched_tdr_queue_imm(struct drm_gpu_scheduler *sched);
576576
void drm_sched_job_cleanup(struct drm_sched_job *job);
577-
void drm_sched_wakeup(struct drm_gpu_scheduler *sched, struct drm_sched_entity *entity);
577+
void drm_sched_wakeup(struct drm_gpu_scheduler *sched);
578578
bool drm_sched_wqueue_ready(struct drm_gpu_scheduler *sched);
579579
void drm_sched_wqueue_stop(struct drm_gpu_scheduler *sched);
580580
void drm_sched_wqueue_start(struct drm_gpu_scheduler *sched);

0 commit comments

Comments
 (0)