* [PATCH] drm/sched: Preserve entity->rq when no schedulers are ready
@ 2026-12-06 9:40 Li Sheng
0 siblings, 0 replies; only message in thread
From: Li Sheng @ 2026-12-06 9:40 UTC (permalink / raw)
To: dri-devel
Cc: Philipp Stanner, Tvrtko Ursulin, Matthew Brost, Danilo Krummrich,
Christian König, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, linux-kernel
Commit 2df5efb45425 ("drm/sched: Remove redundant entity->rq
initialization and checks") removed the !entity->rq checks from
drm_sched_entity_kill(), drm_sched_entity_flush(), and
drm_sched_job_init() under the assumption that entity->rq can never be
NULL once an entity is initialized.
However, when a multi-scheduler entity calls
drm_sched_entity_select_rq() and all schedulers in entity->sched_list
have !sched->ready (for example when amdgpu marks rings not ready
during reset or teardown), drm_sched_pick_best() returns NULL and
drm_sched_entity_select_rq() overwrites entity->rq with NULL.
Immediately afterwards, drm_sched_job_arm() dereferences
entity->rq->sched unconditionally, and drm_sched_entity_push_job(),
drm_sched_entity_kill(), drm_sched_entity_flush(), and
drm_sched_entity_wakeup() likewise assume entity->rq is non-NULL.
Keep the existing entity->rq (and entity->sched_list) when
drm_sched_pick_best() returns NULL, matching single-scheduler entities
and preserving the entity->rq != NULL invariant. Also drop the stale
-ENOENT warning from the drm_sched_job_init() kernel-doc comment left
behind by commit 2df5efb45425.
Fixes: 2df5efb45425 ("drm/sched: Remove redundant entity->rq initialization and checks")
Cc: stable@vger.kernel.org
Signed-off-by: Li Sheng <wirsbf@gmail.com>
---
drivers/gpu/drm/scheduler/sched_entity.c | 16 +++++++++-------
drivers/gpu/drm/scheduler/sched_main.c | 5 -----
2 files changed, 9 insertions(+), 12 deletions(-)
diff --git a/drivers/gpu/drm/scheduler/sched_entity.c b/drivers/gpu/drm/scheduler/sched_entity.c
index 03e68b410..2fc6802e7 100644
--- a/drivers/gpu/drm/scheduler/sched_entity.c
+++ b/drivers/gpu/drm/scheduler/sched_entity.c
@@ -595,14 +595,16 @@ void drm_sched_entity_select_rq(struct drm_sched_entity *entity)
}
sched = drm_sched_pick_best(entity->sched_list, entity->num_sched_list);
- rq = sched ? sched->sched_rq[entity->rq_priority] : NULL;
- if (rq != entity->rq) {
- drm_sched_rq_remove_entity(entity->rq, entity);
- entity->rq = rq;
- }
+ if (sched) {
+ rq = sched->sched_rq[entity->rq_priority];
+ if (rq != entity->rq) {
+ drm_sched_rq_remove_entity(entity->rq, entity);
+ entity->rq = rq;
+ }
- if (entity->num_sched_list == 1)
- entity->sched_list = NULL;
+ if (entity->num_sched_list == 1)
+ entity->sched_list = NULL;
+ }
spin_unlock(&entity->lock);
}
diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c
index 1a40a3549..b990a49df 100644
--- a/drivers/gpu/drm/scheduler/sched_main.c
+++ b/drivers/gpu/drm/scheduler/sched_main.c
@@ -584,11 +584,6 @@ EXPORT_SYMBOL(drm_sched_resubmit_jobs);
* of struct drm_sched_job. Take a look at that struct's documentation to see
* who sets which struct member with what lifetime.
*
- * WARNING: amdgpu abuses &drm_sched.ready to signal when the hardware
- * has died, which can mean that there's no valid runqueue for a @entity.
- * This function returns -ENOENT in this case (which probably should be -EIO as
- * a more meanigful return value).
- *
* Returns 0 for success, negative error code otherwise.
*/
int drm_sched_job_init(struct drm_sched_job *job,
--
2.56.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-12-06 9:40 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-06 9:40 [PATCH] drm/sched: Preserve entity->rq when no schedulers are ready Li Sheng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®