Jobs submitted to a stopped entity do not go anywhere due how they are handled in drm_sched_rq_add_entity() so there is no point to allow them to change their run-queue. We can simply bail out early which makes entity->stopped a clearer boundary than it currently is.
This is completely safe because it is always guaranteed entity->rq is valid if drm_sched_entity_init() succeeded. Signed-off-by: Tvrtko Ursulin <[email protected]> Cc: Christian König <[email protected]> Cc: Danilo Krummrich <[email protected]> Cc: Matthew Brost <[email protected]> Cc: Philipp Stanner <[email protected]> --- drivers/gpu/drm/scheduler/sched_entity.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/scheduler/sched_entity.c b/drivers/gpu/drm/scheduler/sched_entity.c index 95bb79b3d003..3ca671af02ed 100644 --- a/drivers/gpu/drm/scheduler/sched_entity.c +++ b/drivers/gpu/drm/scheduler/sched_entity.c @@ -584,13 +584,16 @@ void drm_sched_entity_select_rq(struct drm_sched_entity *entity) return; spin_lock(&entity->lock); + + /* Cannot submit to stopped entity anyway so bail out early. */ + if (entity->stopped) + goto out; + fence = entity->last_scheduled; /* stay on the same engine if the previous job hasn't finished */ - if (fence && !dma_fence_is_signaled(fence)) { - spin_unlock(&entity->lock); - return; - } + if (fence && !dma_fence_is_signaled(fence)) + goto out; sched = drm_sched_pick_best(entity->sched_list, entity->num_sched_list); rq = sched ? sched->sched_rq[entity->rq_priority] : NULL; @@ -602,6 +605,7 @@ void drm_sched_entity_select_rq(struct drm_sched_entity *entity) if (entity->num_sched_list == 1) entity->sched_list = NULL; +out: spin_unlock(&entity->lock); } -- 2.55.0
