If the hardware queue for a scheduler is empty then we don't need to the shift the entities from their current scheduler as they are not getting scheduled because of some dependency. v2: to calculate the least loaded scheduler we only use hw_rq_count when the number of jobs in their run queue are same Signed-off-by: Nayan Deshmukh <nayan26deshmukh@xxxxxxxxx> --- drivers/gpu/drm/scheduler/sched_entity.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/scheduler/sched_entity.c b/drivers/gpu/drm/scheduler/sched_entity.c index 3e22a54a99c2..cfe48df6621d 100644 --- a/drivers/gpu/drm/scheduler/sched_entity.c +++ b/drivers/gpu/drm/scheduler/sched_entity.c @@ -125,15 +125,21 @@ bool drm_sched_entity_is_ready(struct drm_sched_entity *entity) static struct drm_sched_rq * drm_sched_entity_get_free_sched(struct drm_sched_entity *entity) { - struct drm_sched_rq *rq = NULL; + struct drm_sched_rq *rq = NULL, *curr_rq = NULL; unsigned int min_jobs = UINT_MAX, num_jobs; int i; for (i = 0; i < entity->num_rq_list; ++i) { - num_jobs = atomic_read(&entity->rq_list[i]->sched->num_jobs); + curr_rq = entity->rq_list[i]; + num_jobs = atomic_read(&curr_rq->sched->num_jobs); if (num_jobs < min_jobs) { min_jobs = num_jobs; - rq = entity->rq_list[i]; + rq = curr_rq; + } else if (num_jobs == min_jobs) { + if (atomic_read(&curr_rq->sched->hw_rq_count) < + atomic_read(&rq->sched->hw_rq_count)) { + rq = curr_rq; + } } } -- 2.14.3 _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel