Skip to content

Commit cbc8764

Browse files
Tvrtko UrsulinChristianKoenigAMD
authored andcommitted
drm/sched: Always wake up correct scheduler in drm_sched_entity_push_job
Since drm_sched_entity_modify_sched() can modify the entities run queue, lets make sure to only dereference the pointer once so both adding and waking up are guaranteed to be consistent. Alternative of moving the spin_unlock to after the wake up would for now be more problematic since the same lock is taken inside drm_sched_rq_update_fifo(). v2: * Improve commit message. (Philipp) * Cache the scheduler pointer directly. (Christian) Signed-off-by: Tvrtko Ursulin <[email protected]> Fixes: b37aced ("drm/scheduler: implement a function to modify sched list") Cc: Christian König <[email protected]> Cc: Alex Deucher <[email protected]> Cc: Luben Tuikov <[email protected]> Cc: Matthew Brost <[email protected]> Cc: David Airlie <[email protected]> Cc: Daniel Vetter <[email protected]> Cc: Philipp Stanner <[email protected]> Cc: [email protected] Cc: <[email protected]> # v5.7+ Reviewed-by: Christian König <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Signed-off-by: Christian König <[email protected]>
1 parent 4286cc2 commit cbc8764

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

drivers/gpu/drm/scheduler/sched_entity.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,9 @@ void drm_sched_entity_push_job(struct drm_sched_job *sched_job)
599599

600600
/* first job wakes up scheduler */
601601
if (first) {
602+
struct drm_gpu_scheduler *sched;
603+
struct drm_sched_rq *rq;
604+
602605
/* Add the entity to the run queue */
603606
spin_lock(&entity->rq_lock);
604607
if (entity->stopped) {
@@ -608,13 +611,16 @@ void drm_sched_entity_push_job(struct drm_sched_job *sched_job)
608611
return;
609612
}
610613

611-
drm_sched_rq_add_entity(entity->rq, entity);
614+
rq = entity->rq;
615+
sched = rq->sched;
616+
617+
drm_sched_rq_add_entity(rq, entity);
612618
spin_unlock(&entity->rq_lock);
613619

614620
if (drm_sched_policy == DRM_SCHED_POLICY_FIFO)
615621
drm_sched_rq_update_fifo(entity, submit_ts);
616622

617-
drm_sched_wakeup(entity->rq->sched);
623+
drm_sched_wakeup(sched);
618624
}
619625
}
620626
EXPORT_SYMBOL(drm_sched_entity_push_job);

0 commit comments

Comments
 (0)