Repository navigation
drm/asahi: g17: hold one compute cell lock while choosing a channel - #4039
Open
DjDeveloperr wants to merge 1 commit into
Open
DjDeveloperr wants to merge 1 commit into
DjDeveloperr wants to merge 1 commit into
Conversation
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: 7bb65ce ("drm/asahi: g17: fan M5 Pro compute out to sibling channels for sustained heavy kicks") Signed-off-by: DjDeveloperr <hey@djdev.me>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
RyanTheTide
approved these changes
Dec 3, 2026
RyanTheTide
left a comment
Contributor
There was a problem hiding this comment.
Reviewed 1c7275a. The iterator keeps the same channel selection key and returns an owned key/QID pair, so each cell guard drops before the next cell is locked. The reported host checks pass. A J714s lockdep rerun is pending.
Contributor
Author
|
J714s (Apple M5 Pro / T6050 / G17S B1) verification on exact head
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What: A lockdep kernel on J714s reported
possible recursive lockingong17::ComputeCell::queueinpublish_compute_on().select_compute_channel()kept the best queue locked while it locked the next one. It now compares plain keys, so it holds one queue at a time. It can't deadlock today, but the report switches lockdep off, so it hides any later one.Tested: no Mac at
1c7275a8414cyet. Build only:drivers/gpu/drm/asahi/with W=1 has 0 errors and the same warnings as main, the g17 host tests pass 337/337, and checkpatch --strict is clean.Risk: two-way door · M5 Pro (only there does an owner have more than one compute channel, up to three). J700 and the other G17 Macs run the same function with one channel; its choice is unchanged.
Not yet: a J714s rerun of the lockdep stress that produced the report, and a J700 no-regression row.
Details
min_by_key()ran on the queue guards themselves. It keeps the best item while it pulls the next one, and here an item is a locked cell:Why it isn't a deadlock:
select_compute_channel()always runs with the device mutex held, so only one thread at a time can hold two cells. It takes them in registry order.compute_direct(),compute_readiness(),hold_claim()) hold one cell at a time. While they hold it, they take no second cell, no device mutex and noouter_compute.This was the only walk over the cells that kept a guard while it took the next one. The other
min_by_key()users over the cells already map to a key and a QID first; this one now does the same. The walk also no longer makes a direct publisher of the best queue wait while it is blocked on another queue's lock.Evidence
From the J714s lockdep kernel (main
37a630623169+ #3681, 240 s GPU stress), shortened:debug_locksin/proc/lockdep_statswent from 1 before the stress to 0 after it. #3681 doesn't touch this file; main has the same code.Local checks at this head (base main
5f32aa72fa7e):make W=1 drivers/gpu/drm/asahi/(arm64, LLVM, asahi profile): base 41 warnings, head 41, same text, 0 errors.tools/asahi/run-host-tests.py --only g17: 337/337.--only m3-stamp-admission: 2/2.checkpatch.pl --strict: 0 errors, 0 warnings, 0 checks.