From 1c7275a8414c001b52a2722b83a859dab92c9611 Mon Sep 17 00:00:00 2001 From: DjDeveloperr Date: Wed, 2 Dec 2026 21:49:15 -0500 Subject: [PATCH] drm/asahi: g17: hold one compute cell lock while choosing a channel A lockdep kernel on J714s (M5 Pro) reports a possible recursive lock on g17::ComputeCell::queue during the GPU stress, from publish_compute_on(): one cell is locked while another is held. select_compute_channel() runs min_by_key() on the locked queues themselves. min_by_key() keeps the best item while it looks at the next one, so the best queue's cell stays locked while the next cell is being locked. All other walks over the cells hold one cell at a time. It cannot deadlock: the cells are distinct, only a holder of the device mutex takes a second one, and direct publishers hold one cell and never wait for the device mutex. But the walk can stall a direct publisher on the held cell, and lockdep turns itself off after the report, so it hides every later one. Read the key and the QID of each queue under its own lock and compare the keys. The choice is unchanged. Fixes: 7bb65ce97e1d ("drm/asahi: g17: fan M5 Pro compute out to sibling channels for sustained heavy kicks") Signed-off-by: DjDeveloperr --- drivers/gpu/drm/asahi/g17/runtime.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/asahi/g17/runtime.rs b/drivers/gpu/drm/asahi/g17/runtime.rs index 7a1510d1ebeb4..c0d13cf272be2 100644 --- a/drivers/gpu/drm/asahi/g17/runtime.rs +++ b/drivers/gpu/drm/asahi/g17/runtime.rs @@ -618,15 +618,18 @@ impl Registry { .flatten() .filter_map(|entry| entry.queue.as_deref()) .filter(|queue| queue.owner() == Some(owner)) - .min_by_key(|queue| { - ( + // Compare keys, not guards: a kept guard would be held while the next cell is locked. + .map(|queue| { + let key = ( queue.configuring(), queue.active_len(), queue.last_published(), queue.channel_index(), - ) + ); + (key, queue.qid()) }) - .map(|queue| queue.qid()) + .min_by_key(|(key, _)| *key) + .map(|(_, qid)| qid) } /// Appends covered active compute kicks from every compute channel of `owner` other than