@@ -84,9 +84,12 @@ int drm_sched_entity_init(struct drm_sched_entity *entity,
/* The "priority" of an entity cannot exceed the number
* of run-queues of a scheduler.
*/
- if (entity->priority >= sched_list[0]->num_rqs)
- entity->priority = max_t(u32, sched_list[0]->num_rqs,
- DRM_SCHED_PRIORITY_MIN);
+ if (entity->priority >= sched_list[0]->num_rqs) {
+ drm_err(sched_list[0], "entity with out-of-bounds priority:%u num_rqs:%u\n",
+ entity->priority, sched_list[0]->num_rqs);
+ entity->priority = max_t(s32, (s32) sched_list[0]->num_rqs - 1,
+ (s32) DRM_SCHED_PRIORITY_MIN);
+ }
entity->rq = sched_list[0]->sched_rq[entity->priority];
}
If we're given a malformed entity in drm_sched_entity_init()--shouldn't happen, but we verify--with out-of-bounds priority value, we set it to an allowed value. Fix the expression which sets this limit. Signed-off-by: Luben Tuikov <ltuikov89@gmail.com> Fixes: 56e449603f0ac5 ("drm/sched: Convert the GPU scheduler to variable number of run-queues") --- drivers/gpu/drm/scheduler/sched_entity.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) base-commit: b3c5a7de9aeb51cb19160f3f61343ed87487abde