mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 04:34:03 +02:00
drm/sched: Disallow initializing entities with no schedulers
Since we have removed the case where amdgpu was initializing entitites with either no schedulers on the list, or with a single NULL scheduler, and there appears no other drivers which rely on this, we can simplify the scheduler by explicitly rejecting that early. Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com> Cc: Christian König <christian.koenig@amd.com> Cc: Danilo Krummrich <dakr@kernel.org> Cc: Matthew Brost <matthew.brost@intel.com> Cc: Philipp Stanner <phasta@kernel.org> Reviewed-by: Christian König <christian.koenig@amd.com> Acked-by: Philipp Stanner <phasta@kernel.org> Tested-by: Vitaly Prosyak <vitaly.prosyak@amd.com> Signed-off-by: Philipp Stanner <phasta@kernel.org> Link: https://patch.msgid.link/20260417103744.76020-2-tvrtko.ursulin@igalia.com
This commit is contained in:
parent
cac96c8d93
commit
28c5bf2876
|
|
@ -61,32 +61,27 @@ int drm_sched_entity_init(struct drm_sched_entity *entity,
|
||||||
unsigned int num_sched_list,
|
unsigned int num_sched_list,
|
||||||
atomic_t *guilty)
|
atomic_t *guilty)
|
||||||
{
|
{
|
||||||
if (!(entity && sched_list && (num_sched_list == 0 || sched_list[0])))
|
if (!entity || !sched_list || !num_sched_list || !sched_list[0])
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
memset(entity, 0, sizeof(struct drm_sched_entity));
|
memset(entity, 0, sizeof(struct drm_sched_entity));
|
||||||
INIT_LIST_HEAD(&entity->list);
|
INIT_LIST_HEAD(&entity->list);
|
||||||
entity->rq = NULL;
|
entity->rq = NULL;
|
||||||
entity->guilty = guilty;
|
entity->guilty = guilty;
|
||||||
entity->num_sched_list = num_sched_list;
|
|
||||||
entity->priority = priority;
|
entity->priority = priority;
|
||||||
entity->last_user = current->group_leader;
|
entity->last_user = current->group_leader;
|
||||||
/*
|
entity->num_sched_list = num_sched_list;
|
||||||
* It's perfectly valid to initialize an entity without having a valid
|
|
||||||
* scheduler attached. It's just not valid to use the scheduler before it
|
|
||||||
* is initialized itself.
|
|
||||||
*/
|
|
||||||
entity->sched_list = num_sched_list > 1 ? sched_list : NULL;
|
entity->sched_list = num_sched_list > 1 ? sched_list : NULL;
|
||||||
RCU_INIT_POINTER(entity->last_scheduled, NULL);
|
RCU_INIT_POINTER(entity->last_scheduled, NULL);
|
||||||
RB_CLEAR_NODE(&entity->rb_tree_node);
|
RB_CLEAR_NODE(&entity->rb_tree_node);
|
||||||
|
|
||||||
if (num_sched_list && !sched_list[0]->sched_rq) {
|
if (!sched_list[0]->sched_rq) {
|
||||||
/* Since every entry covered by num_sched_list
|
/* Since every entry covered by num_sched_list
|
||||||
* should be non-NULL and therefore we warn drivers
|
* should be non-NULL and therefore we warn drivers
|
||||||
* not to do this and to fix their DRM calling order.
|
* not to do this and to fix their DRM calling order.
|
||||||
*/
|
*/
|
||||||
pr_warn("%s: called with uninitialized scheduler\n", __func__);
|
pr_warn("%s: called with uninitialized scheduler\n", __func__);
|
||||||
} else if (num_sched_list) {
|
} else {
|
||||||
/* The "priority" of an entity cannot exceed the number of run-queues of a
|
/* The "priority" of an entity cannot exceed the number of run-queues of a
|
||||||
* scheduler. Protect against num_rqs being 0, by converting to signed. Choose
|
* scheduler. Protect against num_rqs being 0, by converting to signed. Choose
|
||||||
* the lowest priority available.
|
* the lowest priority available.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user