Repository navigation
drm/asahi: g17: deduplicate sync-input chains and resolve M5 cross-QID sources directly - #3025
Conversation
…D sources directly Cross-queue compute handoffs previously hit three layers of host lock contention and fallback overhead: 1. asahi_g17_collect_fences() expanded every unsignaled node in a timeline dma_fence_chain without same-context coalescing (forcing reallocations and per-leaf global device-mutex scans inside Backend::input_sources()). 2. Backend::input_sources(), compute_readiness(), and sources_published() always took the global device mutex and linearly scanned compute queues to check whether a same-VM producer was published. 3. Backend::compute_direct() unconditionally rejected packets with converted input sources, forcing every cross-QID compute submission through compute_inline() under the global device mutex (and holding m5_outer across mailbox doorbell I/O in ComputeHost::notify()). Coalesce healthy unsignaled leaves sharing a non-zero fence context in collect_leaf() (keeping only the latest seqno via dma_fence_is_later() while preserving every failed leaf with status < 0), keeping the initial Rust collection capacity at 4, and hoist the fallback device mutex out of the leaf loop in Backend::input_sources(). Publish immutable cross-QID kick metadata (PublishedSource: epoch, publication order, KickDependency, and producer source_readers counter) onto fence::Submission once compute::Queue::publish() commits and rings its doorbell, invalidating it on retirement, error, replay, and cancel. Track the live epoch in published_epoch (AtomicU64, 0 = unpublished) so has_published_epoch() and empty clear_published() skip Submission::state, and store immutable vm_status outside Mutex<State> so same_vm() is lock-free. Remove ReaderHint's blind spot so lock-free Hold::new() loans are always observed by shareable(), can_rearm(), and reset_for_owner(). Use the PublishedSource snapshot for lock-free checks in input_sources(), compute_readiness(), and sources_published(), allow M5 compute_direct() to resolve same-VM compute sources directly (skipping duplicate explicit barriers, self-reader Holds, and firmware_consumer marks when a source was already published on the consumer's own physical QID in the same epoch while still validating source_status() and recovery/epoch), mark firmware_consumer atomically on cross-QID producers, and drop m5_outer before port.notify() in ComputeHost::notify(). Add host C+Rust tests and mutation controls in g17-m5-cross-qid-direct-tests. Signed-off-by: Diljit Singh <[email protected]>
3a3b032 to
550b955
Compare
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
|
Rebased onto Conflicts were all in
The stack is unchanged: on #2969 ( Host tests: |
…i-g17-m5-direct-cross-qid-sources Bring in the base PR's merge of main up to 6ec49ac, including its m5_history_view() update for the relocated M5 submission-history fields. Conflict in tools/asahi/run-host-tests.py: both sides register a new g17 test; both are kept. Signed-off-by: Diljit Singh <[email protected]>
|
Merged the updated base (with |
DjDeveloperr
left a comment
There was a problem hiding this comment.
No code blockers.
What I checked
collect_leaf()insync_input.c: it keeps only the latest healthy unsignaled fence per context, asdma_fence_unwrap_merge()does, and never coalesces failed leaves.PublishedSource: it is set only for live, unerrored, unretired firmware sources, and cleared on error, retire, cancel and replay.resolve_direct_sources()re-checks epoch, recovery state and source status after taking theHold, and drops the hold on every skip.- The
cross_qid_maskshift is bounded (at most 31 sources). - The same-QID skip uses the target QID.
- The
same_vm()behaviour change: its only caller runs aftersource_status()has confirmed the source is not complete. ReaderHint::has_readers()is now always exact, which is the conservative direction.ComputeCell::qidis mirrored under the cell lock.- Against #3023 and #3036 the only overlap is
run-host-tests.py(test-only).
To merge:
- a T6050 / J714s (M5 Pro) row built from this head (a batched fleet candidate that contains this head unchanged counts).
- a T8140 / J700 (Neo, G17P) regression row at this head, because this PR changes shared G17 code that also runs on Neo (
sync_input.ccoalescing,fence::Submissionpublished-source tracking). - CI: the only red check is
host-tests, and its three failures (m3-recovery-tests,m3-recovery-tests --mutate,m3-runtime-tests) fail the same way onmainitself (0c4e19df, run 45466941208). They are not from this PR. Every G17 host test passes. - Base:
mainhas moved past6ec49ac7(now77561654). The new commits touch none of this PR's files and the head merges cleanly, so a branch update needs no new row.
|
Hardware row at Build: fleet candidate Since the 11-24 row (at Result:
Not run: GLES CTS (the surfaceless |
…i-g17-m5-direct-cross-qid-sources Bring in the base branch, which now carries main up to a73023b. Conflict: - drivers/gpu/drm/asahi/g17/sync_input.c: main (4ec3675) gives collect_leaf() a coalesce_contexts mode for G16's firmware barriers, drops already-signalled leaves and merges repeated ones, while G17 kept the collector that does not coalesce. This branch coalesces same-context leaves for G17's input sources. main's collector is kept, its coalescing mode also leaves context 0 alone (it names no timeline), as this branch did, and G17's Backend::input_sources() now collects through sync_input::collect_coalesced(). The Rust collect(), which nothing calls any more, goes away; the C collector without coalescing stays, as main's M4 fence-signalling selftest checks it. g17-m5-cross-qid-direct-tests.py calls collect_leaf() in its coalescing mode, and its mutations follow main's condition. Signed-off-by: Diljit Singh <[email protected]>
Split the Submission::state initializer that "drm/asahi: g17: deduplicate sync-input chains and resolve M5 cross-QID sources directly" left at 111 columns, as checkpatch asks. No functional change. Signed-off-by: Diljit Singh <[email protected]>
…i-g17-m5-direct-cross-qid-sources Bring in the removal of the unused unlocked M5 history update from the base branch. No conflicts. Signed-off-by: Diljit Singh <[email protected]>
satchlj
left a comment
There was a problem hiding this comment.
Verdict: MERGE at e35ddb55bc59
Blockers: none
Checked: Full diff audit of drivers/gpu/drm/asahi/g17/ (completion.rs, fence.rs, job.rs, queue/compute.rs, runtime.rs, runtime/backend.rs, sync_input.c, and sync_input.rs) plus paginated CI and J714s hardware row verification.
Evidence
- Fence coalescing & published-source lifecycle:
sync_input.ccoalesces healthy unsignaled leaves sharing a non-zerodma_fencecontext while preserving errored leaves and context 0.fence::Submissionencodespublished_epoch(epoch.wrapping_add(1)withtag != 0guard), clearsPublishedSourceon retire, error, cancel, replay, andrelease_state(), andqueue/compute.rsre-checkscancel_requested()afternote_source_published(). - Lock-free cross-QID resolution:
Backend::resolve_direct_sources()validatessource_status(), skips explicit barriers/holds for same-QID sources already ordered by the queue's implicit parent, takesHold::new(&published.readers)for cross-QID sources (withReaderHint::has_readers()readingcountdirectly), re-validatesrecovery_state == 0,port.generation() == generation,source_status(), andhas_published_epoch(generation), and falls back to the device-mutex path on any mismatch.KICK_BARRIERS_MAXis 31 (< 64), socross_qid_maskshifts cannot overflow. - CI & hardware evidence: Paginated numeric-ID check-runs 19/19 passed (
0 active / 0 bad), commit statuses clean, exact-head J714s Apple M5 Pro pass row posted (wip/m5-wavec-fleet-candidate-20261125atb7b130a75bab); unrun boards are explicitly noted inNot yet:.
|
Tested (
|
The merge-base changed after approval.
satchlj
left a comment
There was a problem hiding this comment.
Verdict: MERGE at e35ddb55bc59
Blockers: none
Checked:
- Clean-room diff with no Apple copyrighted material, decompiled listings, or copied firmware/tuning data.
- No hardcoded model, board, or firmware gates and no new module or command-line parameters.
- No hardcoded hardware safety limits; safety and hardware values come from machine descriptors and runtime state.
- Clean human
Signed-off-by:DCO on every commit and zero AI attribution across commits and PR text. - Exact-head hardware rows pass on both J714s (M5 Pro) and J700 (Neo) with clean merge preview on
main, and all paginated CI checks are green.
Evidence
- Incremental diff audit above
#2969(10 files):drivers/gpu/drm/asahi/g17/sync_input.candsync_input.rs: coalesces healthy unsignaled leaves sharing a non-zerodma_fencecontext while preserving errored leaves and context 0;ReaderHint::has_readers()readscountdirectly so direct-pathHold::new()loans are always observed.drivers/gpu/drm/asahi/g17/fence.rs,completion.rs,job.rs,queue/compute.rs: stores immutablevm_statusfor lock-freesame_vm(), encodespublished_epoch(epoch.wrapping_add(1)withtag != 0guard), clearsPublishedSourceon retire, error, cancel, replay, andrelease_state(), and re-checkscancel_requested()afternote_source_published().drivers/gpu/drm/asahi/g17/runtime.rsandruntime/backend.rs: mirrorsComputeCell::qidatomically under the cell lock, dropsm5_outerbefore mailbox I/O inComputeHost, skips duplicate explicit barriers for same-QID sources, and inresolve_direct_sources()takesHold::new(&published.readers)for cross-QID sources followed by re-checkingrecovery_state == 0,port.generation() == generation,source_status(), andhas_published_epoch(generation), falling back on any mismatch.KICK_BARRIERS_MAX(31) keepscross_qid_maskshifts in bounds.
- Hardware rows & CI:
- Exact-head Apple M5 Pro (
T6050 / J714s / G17S B1) pass row in fleet candidateb7b130a75bab(gpubench-vkok, Vulkan CTS 0 fail, 0 GPU/DART faults). - Exact-head MacBook Neo (
J700 / G17P B1) combined Wave C pass row (7bb607c48427):215/215g17host tests,2,880/2,880timeline semaphore CTS pass,373focused compute/sync CTS pass / 0 fail,5/5compute CRCs, 0 GPU faults / 0 AVCs. - Paginated CI check-runs at
e35ddb55bc59: 19/19 green (0active,0failed), clean merge preview ontomain.
- Exact-head Apple M5 Pro (
The merge-base changed after approval.
Merge origin/main (f3bfe50) to keep the union of host test entries in tools/asahi/run-host-tests.py after #3024, #3036, and #3023 landed. Signed-off-by: Diljit Singh <[email protected]>
|
Merged |
What: Stacked on #2969. Cross-queue compute handoffs hit three layers of host lock contention:
asahi_g17_collect_fences()expanded every unsignaleddma_fence_chainnode without same-context coalescing,input_sources()/compute_readiness()/sources_published()always took the global device mutex to scan compute queues, and M5compute_direct()rejected every packet with converted input sources (so cross-QID compute went throughcompute_inline()under the device mutex). This coalesces same-context fence leaves, publishes immutable cross-QID kick metadata for lock-free checks, and lets M5compute_direct()resolve same-VM compute sources directly.Tested: J714s M5 Pro (G17S B1), Aurora 7.3.0 M5 integration test kernels (builds 7 and 8): 0 GPU faults, 0 kernel warnings, multi-queue/sync Vulkan CTS 3,976/3,985 pass, 0 fail, and 2,984/2,985 CTS on build 8; multi-queue binary and timeline semaphore handoffs (d=2) +25.8 % to +27.3 % (18.88 → 14.83 us, 18.76 → 14.91 us), concurrent multi-pass compute/render overlap +21.2 % to +26.1 %. Host tests
--only g17116/116 pass (10/10 mutations killed).Risk: two-way · M5 family; the fence-chain coalescing in
sync_input.c(main's coalescing collector, which G17 input sources now use) and thefence::Submissionpublished-source tracking are shared G17 code and also run on Neo (G17P).Not yet: Neo (G17P) at this head (its last row predates the
mainmerge), M5 Max (J716C), M5 Ultra (J775D) and M5 (J813) not run; failed systemd units not captured (SELinux is not enabled in the test kernel config).After the
mainmerge (11-25,maina73023bc5f1f):main'scollect_leaf()gained a coalescing mode for G16 (#3043); G17'sinput_sources()now uses it throughsync_input::collect_coalesced(), which also leaves context 0 alone, as this PR did.Details
Stacking: stacked cleanly on #2969 (
d13f2358d742, which builds on #2947 and #2955). The sole new commit on top of #2969 isdrm/asahi: g17: deduplicate sync-input chains and resolve M5 cross-QID sources directly. Independent of the idle-housekeeping and render fast-done follow-up PRs; targetsintegration/aurorasoHost testsCI runs on the full stack.New commit:
550b955538f4.Cross-queue compute handoffs previously hit three layers of host lock contention and fallback overhead:
asahi_g17_collect_fences()expanded every unsignaled node in a timelinedma_fence_chainwithout same-context coalescing (forcing reallocations and per-leaf global device-mutex scans insideBackend::input_sources()).Backend::input_sources(),compute_readiness(), andsources_published()always took the global device mutex and linearly scanned compute queues to check whether a same-VM producer was published.Backend::compute_direct()unconditionally rejected packets with converted input sources, forcing every cross-QID compute submission throughcompute_inline()under the global device mutex (and holdingm5_outeracross mailbox doorbell I/O inComputeHost::notify()).This commit:
collect_leaf()(drivers/gpu/drm/asahi/g17/sync_input.c), keeping only the latest seqno viadma_fence_is_later()while preserving every failed leaf (status < 0), keeping the initial Rust collection capacity at 4, and hoisting the fallback device mutex out of the leaf loop inBackend::input_sources().PublishedSource: epoch, publication order,KickDependency, and producersource_readerscounter) ontofence::Submissiononcecompute::Queue::publish()commits and rings its doorbell, invalidating it on retirement, error, replay, and cancel. Tracks the live epoch inpublished_epoch(AtomicU64,0= unpublished) sohas_published_epoch()and emptyclear_published()skipSubmission::state, stores immutablevm_statusoutsideMutex<State>sosame_vm()is lock-free, and removesReaderHint's blind spot so lock-freeHold::new()loans are always observed byshareable(),can_rearm(), andreset_for_owner().PublishedSourcefor lock-free checks ininput_sources(),compute_readiness(), andsources_published(), allows M5compute_direct()to resolve same-VM compute sources directly (skipping redundant explicit barriers, self-readerHolds, andfirmware_consumermarks when a source was already published on the consumer's own physical QID in the same epoch while still validatingsource_status()and recovery/epoch), marksfirmware_consumeratomically on cross-QID producers, and dropsm5_outerbeforeport.notify()inComputeHost::notify().tools/asahi/g17-m5-cross-qid-direct-tests.py.Evidence
scripts/checkpatch.pl --strict(sync_input.c):0 errors, 0 warnings, 0 checks.python3 -I tools/asahi/run-host-tests.py --only g17):116/116passed (g17-m5-cross-qid-direct-tests: base C+Rust pass +10/10mutations killed:no-chain-dedup,coalesce-failed-leaf,hint-blind-spot,skip-epoch-check,skip-recovery-recheck,lock-per-leaf,hold-m5-outer-compute-host,same-qid-emits-barrier,lock-has-published-epoch,lock-same-vm).Apple M5 Pro / J714s / G17S B1): qualified in Aurora 7.3.0 M5 integration test kernel builds 7 and 8 (0GPU faults,0kernel warnings;3,976/3,985multi-queue/sync Vulkan CTS passed with0failures and2,984/2,985CTS on build 8); improved multi-queue binary and timeline semaphore signal handoffs (d=2) by +25.8% to +27.3% (18.88 -> 14.83 us,18.76 -> 14.91 us) and concurrent multi-pass compute/render overlap by +21.2% to +26.1%.Regression tuple (pre-PR checklist §5)
60a40c285fon builds 7/8; test buildgit-8956dffd84(with aurora-silicon/mesa#793) on build 90(microbenchmark health checkgpu_faults_delta=0, stress gate, CTS runs)0(as recorded in the run summaries; the raw dmesg of these runs was not kept)2,984/2,985passed,0failed; build 9:4,058/4,068multi-queue + timeline semaphore passed,0failedCONFIG_SECURITY_SELINUXunsetsystemctl --failedoutput was kept for these runs