Skip to content

drm/asahi: g17: M5 Pro: find a queue's own compute inputs without the device mutex - #2074

Closed
DjDeveloperr wants to merge 1 commit into
mainfrom
djdev/g17-m5-local-inputs-v3
Closed

DjDeveloperr wants to merge 1 commit into
mainfrom
djdev/g17-m5-local-inputs-v3

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

On the M5 Pro (J714s), userspace backs same-priority Vulkan queues of one device with one kernel queue, so a semaphore wait between two such queues names earlier work of the consumer's own kernel queue. Today each such source takes the device mutex in the submit ioctl (a recovery-word read and a walk of every compute queue) to find its publication, and every compute queue is walked again at publication.

Every command of a logical queue reaches its one bound queue in submission order, so an own-queue source is already published (or complete) when its consumer is published, and the ioctl's publication check and wait have nothing to find. This change:

  • records the publishing logical queue in each submission (Submission::origin);
  • skips the submit-ioctl publication lookup for a source of the consumer's own queue;
  • at publication, looks for such a source on the consumer's bound queue first. A source found there takes exactly the existing path: the same ticket, recovery-epoch, cancellation and status checks (source_dependency), the same kick-entry dependency and binding loan, and the same firmware-consumer mark (note_input_consumer), so a failed or recovered source fails or replays its consumer as before. A local source not live on that queue takes the walk.

Only boards where explicit waits take the completion class (M5) take the new path; others are unchanged. The capacity view counts the local sources found on their own queue (local=).

Measured on the M5 Pro

Current intg10 kit (4d7e036, carrying #2066's held kick order and #2073's GPU power floor), runtime-switch test form e3593c8 of this change, gpubench 0dae261. Five interleaved, rotated paired rounds per row; two test boots because of deep-sleep priority. Every completed control/change/no-dependency comparison was performed within one boot. Medians of the per-unit medians, us per hop (lower is better):

row stock path this change without dep/loan/mark
sync.signal kind=queue, sema=binary, 2 queues 20.37 19.03 (-6.6%) 18.99
sync.signal kind=queue, sema=timeline, 2 queues 20.27 18.84 (-7.0%) 18.57

Occlusion extra time remains below 1 us: depth 1, 0.37 -> -0.37 us (measurement noise around zero); depth 16, 0.36 -> 0.47 us. Zero GPU faults, other failure matches or new kernel lines in either timing segment. Both test turns restored and verified the default.

The current hop gain is smaller than on the earlier intg7-based run (binary 18.24 -> 15.10; timeline 17.85 -> 15.03 us). Those are different boots and kernel bases; they do not isolate the cause of the difference. Current hops still trail the historical macOS reference (~13.1 us, W about 0.69). A separate factorial experiment has now completed on one boot (five rotated paired rounds per row, source 36034c6 on merged integration bf423bf, frozen intg10 Image/DTB). The A patch has the same stable patch-id as this head:

hop, us A off, held order A v3, held A off, pre-held order A v3, pre-held
binary 20.09 18.90 17.94 15.15
timeline 20.42 18.80 18.69 15.19

The restored pre-#2066-commit-2 path changes only the held/order transaction; wake reconfiguration and the GPU power floor remain. This isolates a kick-order interaction on the tested boot, while the earlier cross-base comparisons still contain other changes. Zero faults or new kernel lines in this segment, and default restored/verified before release. The old-order arm is a timing diagnostic: these rows do not qualify its post-wake correctness. Even the combined 15.15/15.19 us hops still trail the historical macOS reference (W about 0.87/0.86).

Checks

  • Fedora compile/link with the M5 config on this head (integration/aurora d5a8a25 + this commit): OK, no new warnings. 13 host tests that read the touched files pass (g17-capacity-fault, g17-growth*, g17-compute-*, g17-unpublished, g17-shared-pool, g17-uninstalled-cleanup, g17-admission-order, g17-pool-release, g17-owner-release-order, g17-resource).
  • M5 Pro, one alternating pair on an older base (fc05050 + this change vs fc05050 alone, dEQP-VK synchronization*, synchronization2*, compute, query_pool, memory.pipeline_barrier and api fence, 225,813 cases, 16 jobs): both arms hit the same pre-existing GPU write fault (unmapped, requestor 0x4) once; Pass 119,891 vs 119,899, the difference being collateral of that fault's full recovery in one arm plus one 2 s compute-watchdog loss on a cross-device shared-semaphore case (not an own-queue source) that drm/asahi: g17: M5: compute kicks after a deep sleep (configure again at the wake; host port before the doorbell) #2066 addresses. Gate safe-stress tests 10/10.
  • Native M5 external-module build of the runtime-switch test form on the intg10 kit: compile/link OK; the shared kit stayed unchanged. Current-base timing above is complete.
  • Six alternating current-intg10 rounds completed on the same runtime-switch module (build ID 5a4245c4f5384c006e0ad662b0ead873c91bc1cc), stock Mesa wsitip6251, 225,813 results per round, 16 jobs. Switch readbacks were 1/0/1/0/1/0. Common counts: 94,177 NotSupported, 11,729 NotRun and eight QualityWarning.
round v3 enabled Pass Fail Crash kernel result
1 yes 119895 4 0 level-1 write/unmapped IAP(0), full recovery, 42 in flight
2 no 119899 0 0 no new kernel lines
3 yes 119899 0 0 no new kernel lines
4 no 119891 7 1 level-1 write/unmapped IAP(0), full recovery, 37 in flight; lost-device report
5 yes 119899 0 0 no new kernel lines
6 no 119899 0 0 no new kernel lines

One affected round out of three on each side, with the same level-1/full-recovery class also present on control. This matrix establishes no added failure class at this sample size; it does not solve the shared fault or prove absence of a causal effect. On/off safe stress completed 20/20 pass. Every turn restored and verified the default. Frozen source/results were preserved across #2080's later integration merge.

  • Before merge: an A18 Pro row (the publication loop is shared code; the new path itself is M5-only). The six requested current-base rounds are complete, with the shared fault disclosed above.

Not yet

  • Neo J700: run the shared publication-loop guard. Carry forward the existing M5 runs only if the branch history and tested source match.

… device mutex

On the M5 Pro a compute input from another compute command becomes a
firmware wait when its producer declares a visible completion: the
consumer's kick entry names the producer's kick, and the consumer takes
a loan on the producer queue's binding. Finding that producer takes the
device mutex once per pending source in the submit ioctl, with a
recovery-word read and a walk of every compute queue each time, and
every compute queue is walked again at publication.

Userspace backs same-priority Vulkan queues with one kernel queue, so a
semaphore wait between two such queues names earlier work of the
consumer's own queue. Every command of a logical queue goes to its one
bound queue in submission order, so such a source is either published
there ahead of the consumer or still queued ahead of it: by the time the
consumer is published, its own sources are published or complete, and
the ioctl's publication check and wait have nothing to find.

Record the publishing logical queue in each submission. A source of the
consumer's own queue skips the publication lookup in the submit ioctl.
At publication it is looked for on the consumer's bound queue first. A
source found there takes the same checks as one found by the walk
(ticket, recovery epoch, cancellation and status), the same kick-entry
dependency and binding loan, and the same firmware-consumer mark, so a
failed or recovered source fails or replays its consumer as before. A
local source not live on that queue takes the walk. Other boards are
unchanged.

The capacity view counts the local sources found on their own queue
(local=).

Signed-off-by: Diljit Singh <hey@djdev.me>
@RyanTheTide

Copy link
Copy Markdown
Contributor

Early note on this draft (no full review yet):

  1. drivers/gpu/drm/asahi/g17/runtime.rs:1703: the new own-queue lookup checks m5 && source.local, which is a chip check (init.is_m5()). source.local is only set when the board's completion_inputs() capability holds (drivers/gpu/drm/asahi/g17/runtime/backend.rs:149), so the capability already decides this path. Drop the m5 && so the new path follows the capability alone and any GPU that reports completion inputs takes it.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor

Not on integration/aurora; the commit (ca9bf84) applies cleanly to 110861f. The open note from the early review stands: the own-queue lookup in g17/runtime.rs checks m5 && source.local, while source.local is already set only when completion_inputs() holds, so the chip check can go and the capability alone decide the path. A full review follows once the draft is ready.

Build check of 110861f plus this change (arm64, LLVM=1, Image, dtbs and every directory it touches, Fedora config plus asahi.config): builds, no warnings in the files it touches. Host tests (tools/asahi/run-host-tests.py --only) on 110861f plus this change: g17 passes (90/90).

@DjDeveloperr
DjDeveloperr marked this pull request as ready for review November 30, 2026 20:46
@DjDeveloperr
DjDeveloperr requested review from a team as code owners November 30, 2026 20:46
@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) merge-conflict Conflicts with the base branch (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot) labels Nov 30, 2026
@github-actions

Copy link
Copy Markdown

Merge readiness at ca9bf84b: not ready yet

Check Detail
CI at head ok 1 check passed
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head no no line with the head SHA ca9bf84b, a Mac and a result in the PR body or a comment
Conflicts no merge conflicts with main: merge it in (no force push)
PR text adopt when you next edit add a 'Tested:' line; a 'Risk:' line (door and Macs) (guide)

Areas: area:gpu

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: REQUEST CHANGES at ca9bf84b

Blockers:

  1. Branch is CONFLICTING with main. Rebase/merge current main so the PR is MERGEABLE and build/KUnit CI runs cleanly.
  2. Redundant chip gate and missing exact-head hardware verification. As noted on 2026-11-23, the own-queue lookup in drivers/gpu/drm/asahi/g17/runtime.rs checks m5 && source.local, even though source.local is already set only when completion_inputs() holds — gate on the capability rather than the chip flag. No exact-head hardware test row has been posted after rebasing onto main.

Checked:

  • Diff (+88/-23, 7 files), CONFLICTING against main.
Evidence
  • Rebase onto main, drop the redundant m5 check where source.local already encodes the capability, ensure CI passes, and attach an exact-head hardware verification row.

@aurora-silicon-review
aurora-silicon-review Bot dismissed their stale review December 1, 2026 05:00

Dismissed under the 12-01 merge bar: this review's blockers were not shown failures (CI/rows/rebase/design or re-run asks). Follow-ups, not blocking: Only diff summary checked; follow-ups: rebase, drop redundant m5 gate for source.local capability, exact-head row

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Closing as superseded by #3025 (merged 11-25). It moved the M5 submit path's source checks off the device mutex in a more general way: published sources are confirmed lock-free through the per-submission publication snapshot, the mutex is taken once outside the leaf loop only for unconfirmed ones, and same-QID sources drop their explicit barrier at publication. This branch now conflicts with that code in all four g17 files it touches. If the bound-queue-first lookup at publication still shows up in an M5 profile, it can come back as a small PR on top of #3025.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:gpu Area from CODEOWNERS (bot) merge-conflict Conflicts with the base branch (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants