As a preparational step to lock the access of entity->last_scheduled, it
is necessary to lock the call to spsc_queue_pop() in
drm_sched_entity_pop_job(). The reason is that later the existing lock
needs to be moved upward and the relative order between spsc_queue_pop()
and drm_sched_rq_pop_entity() needs to be preserved.

Guard spsc_queue_pop() with the existing spinlock.

Signed-off-by: Philipp Stanner <[email protected]>
---
 drivers/gpu/drm/scheduler/sched_entity.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/scheduler/sched_entity.c 
b/drivers/gpu/drm/scheduler/sched_entity.c
index 274d7a702298..e168f445f2ab 100644
--- a/drivers/gpu/drm/scheduler/sched_entity.c
+++ b/drivers/gpu/drm/scheduler/sched_entity.c
@@ -563,9 +563,8 @@ struct drm_sched_job *drm_sched_entity_pop_job(struct 
drm_sched_entity *entity)
         */
        smp_wmb();
 
-       spsc_queue_pop(&entity->job_queue);
-
        spin_lock(&entity->lock);
+       spsc_queue_pop(&entity->job_queue);
        drm_sched_rq_pop_entity(entity);
        spin_unlock(&entity->lock);
 
-- 
2.55.0

Reply via email to