Repository navigation
drm/asahi: g17: keep a work-state node for the other engine - #570
Merged
DjDeveloperr merged 1 commit intoOct 29, 2026
Merged
Conversation
A context has 63 work-state nodes. All engines of one ioctl share its node, which returns only once every command of the ioctl has retired. That leaves a deadlock open when render and compute work share a context. Render admission takes nodes for newer ioctls (a render plus a compute command) as their renders retire. Each node stays held until that ioctl's compute command completes, and that command sits in the compute queue behind an older compute ioctl that has no node yet. Once render admission holds every node, the compute queue can admit nothing: the commands that would return the nodes are behind it. gpubench-stress queue.depth hits this on a Neo (A18 Pro). It keeps 128 compute and 64 render submissions in flight on one queue, each render followed by a compute copy. Debugfs capacity samples taken every 10 ms show the following. Within 50 ms of the start, the context holds 63 of 63 work states. No compute or render command is active and every published command has completed. The compute queue's next command and the render queue's next render loop between prepare and wait. After 15 s the client times out. An engine now never takes the last free node while it already holds one. The other engine can always take a node, and an engine refused that way waits only for nodes it took for ioctls ahead of its waiting command. Each engine admits a context's ioctls in submission order. Such waits therefore cannot form a cycle: an ioctl held by render that waits on compute would have to be both older and newer than one held by compute that waits on render. The decision is serialized under the context's work-storage lock, which initialization already took. The lease records which engine took its node. Signed-off-by: DjDeveloperr <[email protected]>
This was referenced Oct 29, 2026
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.
This fixes a host-side deadlock on a G17 context's work-state nodes. It is one of two failures behind gpubench-stress
queue.depth(aurora-silicon/gpubench#4) on the Neo. The other is a GPU stall that this PR does not fix (see "Still open").What broke
A context has 63 work-state nodes, and all engines of one ioctl share its node. The node returns only after every command of the ioctl has retired.
queue.depthkeeps 128 compute and 64 render submissions in flight on one queue, and each render submission also carries a compute copy. With that load:Evidence
On the stock kernel, debugfs
asahi-g17/capacitywas sampled every 10 ms alongside everyasahi_g17tracepoint:work_used=63/63, with computeactive=0and renderactive=0.schedulephases 5/6, detail=1) for 15 s, until the client gives up.Fix
An engine never takes the last free node while it already holds one.
The decision is serialized under the context's work-storage lock, which initialization already took. The lease records which engine took its node, and a release decrements that engine's count.
Qualification
asahi_g17*passes 149/149 under QEMU arm64 with 16K pages. That includes the newasahi_g17_work_statessuite, covering the admission rule, the one-node reserve, and release bookkeeping.PERFORMANCE-REGRESSION-PASS.Still open: GPU stall under the same load (not fixed here)
With this change,
queue.depthstill loses the device. After about 0.5–4 s at 128 compute + 64 render on one queue, all completions of the context stop:Native macOS runs the same firmware, so until shown otherwise our driver does something native does not; that trigger has not been found. Each change below was tested as a diagnostic knob together with this rule:
synchronizationpass (64871 cases, 6 workers) retires about 9.1k compute commands on the 50 ms stampless fallback on the stock kernel, with either Mesa: lifetime counter 1 → 9216 with the baseline Mesa, 9216 → 18304 with mesa#98.