Repository navigation
drm/asahi: g17: lockless fence status, published-source coalescing, and G17P direct compute sources - #3392
Conversation
…nd G17P direct compute sources Cut kernel CPU and device-mutex overhead on cross-queue GPU fence handoffs across G17P and M5: 1. Lockless fence status (asahi_g17_fence_status): query dma_fence_is_signaled() followed by smp_rmb() and READ_ONCE(fence->error) instead of taking fence->lock with IRQs disabled via dma_fence_get_status() on every input fence, scope node, and collected leaf. Also check sources.contains_input() before re-querying fence_status() in Queue::enqueue(), and back collect_coalesced() with a 4-leaf inline stack buffer to avoid per-submit heap allocations on the common path. 2. Published-source coalescing: ExportFence intentionally keeps an independent dma_fence context so out-of-order early failures cannot violate core dma_fence monotonicity. Record the packed (qid, published_seq) atomically on Submission alongside published_epoch and coalesce healthy unsignalled published ExportFences sharing (epoch, qid) in both collect_leaf() and Backend::input_sources() to the latest publication ordinal, leaving failed, unpublished, cross-epoch, and cross-QID leaves intact. 3. G17P direct compute submission with input sources: record immutable stamp_va and monotonic exec_share identity on PublishedSource so resolve_direct_sources(), compute_direct(), and compute_readiness() handle same-VM compute sources without taking the device mutex on G17P as well as M5 (using kick barriers for same-execution-context G17P sources and NativeWait records via publish_with_native_waits() for cross-context sources, while skipping duplicate self-QID barriers). Signed-off-by: DjDeveloperr <[email protected]>
There was a problem hiding this comment.
Verdict: Changes requested at 10f3766eb504.
The coalescer drops an earlier unsignalled export in favor of the latest publication on the same epoch and QID. Checking that both are healthy at collection does not establish that a later fence reports an independent failure of the earlier export. The new unit test marks the earlier source failed only after checking that it was discarded, and then checks the key rather than the consumer result. Please prove that later publication subsumes the earlier fence outcome, or retain the earlier error dependency separately. Add a consumer-side test where an earlier initially healthy export fails after collection while the later export completes. The current J700 results are substantial; the M5 row remains open.
|
J714s (MacBook Pro M5 Pro,
|
drivers/gpu/drm/asahi/g17/sync_input.c now queries fence status locklessly via asahi_g17_fence_status() (using dma_fence_is_signaled(), smp_rmb(), and READ_ONCE(fence->error)) and coalesces published ExportFences via asahi_g17_export_coalesce_key(). Update the standalone C host-test shim in test-fence-signalling.py that includes sync_input.c directly so it models signaled + error fields on struct dma_fence, provides dma_fence_is_signaled(), smp_rmb(), READ_ONCE(), and asahi_g17_export_coalesce_key(), and covers lockless fence status and published-source coalescing. Signed-off-by: DjDeveloperr <[email protected]>
There was a problem hiding this comment.
The new fixture verifies same-(epoch,QID) collection selects the newest unsignalled fence and releases references. It does not exercise the pending error case from the previous review: an earlier unsignalled export discarded by coalescing can fail after collection while the retained export succeeds. The runtime selection is unchanged. Please retain the earlier error dependency or demonstrate the production invariant that the later completion synthesizes that earlier failure. Add a consumer outcome assertion for the late-error case. The reported prior-head M5 row helps cover the unchanged runtime.
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
|
M5 hardware row, J813 (MacBook Air 13" M5, G17G) at Kernel: main
The light-compute program is the one from #3389's J813 row: a ring of N fences, each submit one 1×1×1
Not run: dEQP-VK, a multi-client or multi-queue stress test, or a workload with cross-queue dependencies. Assisted-by: LLM (Claude:Opus 5.5) |
…rces Coalescing healthy unsignalled published compute ExportFences on the same (epoch, physical QID) in sync_input.c discarded the earlier ExportFence reference before Backend::input_sources() could record it. Because an earlier submission on the same QID can still fail independently after collection (for example via its own producer error, cancellation, or recovery interrupt) while a later publication on that QID completes cleanly, dropping the earlier reference could hide a late failure from a consumer waiting on the coalesced set. Remove cross-context ExportFence coalescing from sync_input.c so collect_coalesced() returns all distinct-context ExportFence leaves, and perform same-(epoch, QID) firmware-wait coalescing in sync_input::coalesce_source() / Backend::input_sources() while retaining every superseded earlier Submission in Sources::coalesced_errors. Sources::check() checks both wait sources and coalesced_errors lock-free (before publication, at retirement, in DeferredBatch::finish(), and before signalling the consumer fence), so firmware still emits at most one barrier/NativeWait per QID while any late error on an earlier coalesced source fails the consumer with PRODUCER_FAILED. Add KUnit and host mutation tests (drop-coalesced-error and skip-coalesced-error-check) asserting the consumer outcome when an earlier initially healthy coalesced export fails after collection while the retained later export completes cleanly. Signed-off-by: DjDeveloperr <[email protected]>
There was a problem hiding this comment.
Verdict: HOLD for exact-head hosted checks and final-stack G17P/M5 rows. The new head addresses the late-error finding.
Checked: Collection now preserves distinct-context export leaves. Firmware wait coalescing keeps the latest publication for a physical queue and retains the earlier Submission in a separate error list. The common status check includes that list, including the new pre-publication check after native waits are assembled. The added fixture covers an earlier export that fails after collection while the later export completes. The posted J813 row predates this delta.
Conflict in drivers/gpu/drm/asahi/g17/fence.rs: main and this branch each added code next to the same lines; all of main's code is kept and this branch's additions sit beside it (nothing of main's removed). drm/asahi builds with the Apple config.
|
Merged main in at |
|
Merging at |
The two harnesses copy driver code next to stand-ins. Code that landed on main 12-01 calls stand-ins they did not have, so both fail to compile: - g17-output-fence-tests: fence.rs (aurora-silicon#3392) calls KickDependency::qid(). - g17-render-owed-stamp-tests (aurora-silicon#3229): backend.rs calls Packet::note_first_excuse()/first_excuse() and Queues::forfeit_blocker() (compute allowance forfeit), and recovery::note_retired() now takes the retired command number. The render cases have no compute command, so the new stand-ins record no excuse and forfeit nothing. All g17 host tests pass (329 jobs).
What:
Cut kernel-side CPU and global device-mutex overhead on cross-queue GPU fence handoffs (
gpubench-vk sync.signaland multi-queue compute pipelines) across G17P and M5 without any chip allowlists or new parameters:asahi_g17_fence_status): checkdma_fence_is_signaled(), pair withsmp_rmb(), and readREAD_ONCE(fence->error)instead of takingfence->lockwith IRQs off viadma_fence_get_status()on every input fence, scope node, and collected leaf. Also skip redundantjob::fence_status()inQueue::enqueue()whensources.contains_input()already matched, and backsync_input::collect_coalesced()with a 4-leaf inline stack buffer to eliminate per-submit heap allocations on the common path.sync_input::coalesce_source/Sources::coalesced_errors):ExportFencekeeps an independentdma_fencecontext so early/out-of-order failures never violate coredma_fencemonotonicity;collect_coalesced()preserves all distinct-contextExportFenceleaves, andBackend::input_sources()records packed(qid, published_seq)atomically onSubmissionalongsidepublished_epochto collapse healthy unsignalled published computeExportFences sharing(epoch, qid)to the latest publication ordinal inSources::sourceswhile retaining every superseded earlierSubmissioninSources::coalesced_errors.Sources::check()checks bothsourcesandcoalesced_errorslock-free before publication, at retirement, inDeferredBatch::finish(), and before signalling the consumer fence, so firmware emits at most one barrier/NativeWaitper QID while any independent late failure on an earlier coalesced export still fails the consumer withPRODUCER_FAILEDeven if the retained later export completes cleanly (leaving failed, unpublished, retired, cross-epoch, and cross-QID leaves uncoalesced).compute_direct&compute_readiness): carry immutablestamp_vaand monotonicexec_shareidentity onPublishedSourceso G17P resolves same-VM compute sources lock-free onto the primary channel without the device mutex (kick barriers for M5 and shared-execution-context G17P sources,NativeWaitcompletion-wait records viaqueue.publish_with_native_waits()for cross-context G17P sources, and implicit-parent skip for same-QID sources).Tested:
871fe9798f34(7.3.0-m5-pr3392v2, built on the M5,origin/mainDTB), one trial boot, default7.3.0-m5-cdirect16restored with 253/253 ESP hashes verified: PASS, 0 GPU faults, 0 kernel WARNs, GPU online with 0 crashed and 0 quarantineddeqp-vk1.4.7.1), 0 failed:synchronization.smoke.*12/12,synchronization2.op.single_queue.barrier.*_read_image_compute*412/412,synchronization.basic.*29/29,synchronization.internally_synchronized_objects.*2/2 (Mesa kit inst-A),synchronization.timeline_semaphore.one_to_n.*955/955 (M5 system Mesavk-aac82bea8e)sync.signalhost d1124.9 us, queue d216.96 us/hop; the same session's main-based kernel (main9e38a276dcb4+ drm/asahi: g17: allow compute_direct() on mixed render/compute contexts #3429 +perf/g17-publication-direct-lazy) gave127.3 usand17.59 us/hop, so this PR is not slower than a main-based kernel.compute.cull_mdiCRC07f6c861valid (d11043.8 us, d2888.1 usper submit)871fe9798f34008da22802e2548a5dc4f3bd59ad(7.3.0-neo-g17fs2), one-shot boot, default7.3.0-41untouched,STOCK_DIFF=0, 0 GPU faults, 0 kernel WARNs, 0 SELinux AVCs: PASSsync.signaltimeline d2: P015.924 us/hop, unpinned15.430 us/hop; binary d2: P015.643 us/hop, unpinned15.383 us/hop(status=ok)deqp-vk): 9,584/9,584 executed passed, 0 failed (synchronization.timeline_semaphore.*2880/2880,synchronization2.timeline_semaphore.*2873/2873,synchronization.basic.binary_semaphore.*5/5,synchronization2.basic.binary_semaphore.*6/6, all 4signal_order.shared_{timeline,binary}_semaphore.*suites 955/2865 passed, 1910 not supported, 0 failed)10f3766eb5044(7.3.0-neo-g17fs) vsorigin/main88ddea8bae4ae(7.3.0-neo-g17base), 4-boot BAAB (cand,base,base,cand), default cmdline,STOCK_DIFF=0, 0 GPU faults, 0 kernel WARNs, 0 SELinux AVCs:sync.signaltimeline d2: P016.685 -> 15.651 us/hop(-6.20%), E130.331 -> 27.502 us/hop(-9.33%), unpinned16.147 -> 15.235 us/hop(-5.65%)sync.signaltimeline d4: P017.039 -> 15.809 us/hop(-7.22%), unpinned15.684 -> 15.280 us/hop(-2.57%)sync.signalbinary d2: P017.246 -> 15.933 us/hop(-7.61%), E130.965 -> 28.844 us/hop(-6.85%), unpinned16.583 -> 15.635 us/hop(-5.72%); binary d4 unpinned16.395 -> 15.362 us/hop(-6.30%)sync.signalhost d1+0.34%,compute.lightd1+0.10%/ d4-0.08%,compute.heavyalu d2-0.60%,concurrent.crd4-0.54%,render.lightd1/d4+0.35%,render.deferred0.00%(CRC2cfe9a54exact match),render.postfx0.00%(CRC4707efa8exact match)perfon candidate confirms bothdma_fence_get_statusandFirmware::publish_compute_rawdisappeared from thesync.signaltimeline profileasahi*) at871fe9798f340: 462/465 passed (3 skipped, 0 failed), includingpublished_export_coalesce_key_tracks_epoch_qid_and_invalidation(verifying both arrival orders and consumerPRODUCER_FAILEDoutcome when an earlier coalesced export fails after collection while the retained later export completes cleanly) andlockless_fence_status_tracks_unsignaled_success_and_error871fe9798f340:tools/asahi/run-host-tests.py --only g17-233/233 passed (includingdrop-coalesced-errorandskip-coalesced-error-checkmutations asserting consumer late-error failure),tools/asahi/run-host-tests.py --only asahi-m41/1 passed;scripts/checkpatch.pl --git HEAD~1..HEAD: 0 errors, 0 warningsRisk:
two-way · G17P (J700 MacBook Neo) and M5 (J714s / J813 / J815) — a plain revert restores the previous locked status checks and device-mutex G17P compute input path.
Not yet:
asahi_g17_scope_childreninline lock insync_scope.c(remaining 2.73% under_raw_spin_unlock_irqrestore) is intentionally untouched here to avoid conflicting with open PR drm/asahi: g17: set an output fence's error and signal it under its lock #3311.