Repository navigation
drm/asahi: g17: retire latched compute queues and split multi-command work states - #3330
Conversation
…tions scan_compute_summary() latches completion records from the shared compute completion ring into active.observed for every physical queue, even when the waking event mask names only another queue. Queue::retire() previously gated retirement on selected(masks), skipping queues whose front command already had a latched completion observation and leaving retirement_polling() false when no later stamp event arrived for that QID. Treat a latched front observation as selected for retirement and polling so already-completed compute commands retire on the same pass instead of stalling behind unrelated events. Signed-off-by: DjDeveloperr <[email protected]>
The G17 firmware stores completion stamps for a work-state node only once every kick counted on that node finishes. When a multi-command submit ioctl packs dozens of render and compute commands onto one shared WorkStateLease, early commands cannot retire until the last command in the ioctl completes (often 2-6 ms later), pinning the render ring full and delaying timestamp writers needed by later query_access computes. Give multi-command submissions per-chunk ChunkWork holders that release their WorkStateLease immediately once every member of the chunk retires or drops (matching Submission's lifecycle so exported fences never pin work states). Split chunks at RENDER_DEPTH / 8 commands, after host-timestamp writers, and before query_access computes. Expand identity::Order's ORDER_WINDOW to 2048 and cap extra intra-ioctl splits at ORDER_WINDOW / 2 so 1024 full ordinals remain permanently reserved for new ioctls. Single-command ioctls keep the existing Submission path unchanged. Signed-off-by: DjDeveloperr <[email protected]>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
|
Verdict at My blocker at Blockers none Checked
Before merge
Evidence |
Unlike Submission, ChunkWork started remaining and owners at 0 and counted each command only when enqueue() attached it. Because enqueue() submits command k to the GPU immediately and latched compute retirement can complete in ~60 us, preempting the ioctl thread before command k+1 attaches lets command k retire or drop, driving the ChunkWork counts to 0 and releasing its WorkStateLease early so command k+1 fails with ECANCELED. Give ChunkWork the same initial remaining=1 / owners=1 enqueue guard as Submission, pass the created chunks into Outputs::publish_with_status(), and release each chunk's guard via ChunkWork::finish_enqueue() in Outputs::drop() after the enqueue loop finishes. Add g17-chunk-work-guard-tests (with two mutations) covering early retire and early drop of command 0 before command 1 attaches, all-early completion before finish_enqueue(), and error teardown. Signed-off-by: DjDeveloperr <[email protected]>
|
Fixed the
|
|
J714s (MacBook Pro 14" M5 Pro, G17S B1) row at exact head
1. Vulkan CTS (
There were 0 EBUSY in the runner and case logs. 2. Multi-command submit smoke: one BeamNG
3. Kernel log for the whole boot:
|
|
J700 (MacBook Neo, G17P B1) at
|
There was a problem hiding this comment.
Verdict: MERGE at 8962d5f5 (once cancelled CI checks are rerun green)
Blockers: none (code, host tests, and two-generation exact-head hardware rows are ready; rerun the 3 cancelled CI checks before merge).
Checked:
drivers/gpu/drm/asahi/g17/queue/compute.rs:1105-1143: verifiedretirement_polling()andselected()both checkself.active.front().is_some_and(|a| a.observed.is_some())so latched completion records are retired immediately.drivers/gpu/drm/asahi/g17/context/identity.rs,context.rs,fence.rs,queue/mod.rs: verifiedORDER_WINDOW = 2048/ORDER_SPLIT_LIMIT = 1024preserves 1024 full ordinals for new ioctls; verifiedChunkWorkinitializesremaining = 1andowners = 1enqueue guards released inOutputs::drop()viafinish_enqueue(self.result)so early-retiring or dropped commands cannot free a chunk'sWorkStateLeasebefore later commands in the chunk attach; single-command ioctls remain unchanged.tools/asahi/g17-chunk-work-guard-tests.py: verified guard test + 2 mutations (no-guard,no-finish-enqueue).- Verified exact-head (
8962d5f51572) standalone hardware rows on both J714s (M5 Pro, G17S: 170/170 CTS, 170 s BeamNG, 0 faults) and J700 (Neo, G17P: 67,553/0compute.*, 3,000/0 sync smoke, 1,928/0query_pool, clean gpubench CRCs).
Evidence
- Diff reviewed at
8962d5f5(all 7 files, 650 lines). - CI at review time: 20 passed, 0 failed, 3 cancelled.
|
Merge-train status at |
|
Merging under the 6-point rule (Ryan 09:29, permanent), at |
|
Correction to the merge note above: the merge didn't happen. After the PRs merged just ahead of it (#3285 and others), this branch no longer merges cleanly with main. @DjDeveloperr, please forward-merge main (no force push). It goes back into the queue at the new head, and the App re-approval plus the rows still apply if the merge is conflict-only. |
Forward-merge main. g17/queue/mod.rs conflicted where main started reusing the submit scratch (guards.drain_all(), pending.drain_all()): the work-state split and ChunkWork per command are kept as in this branch, iterating the scratch the way main does now. Main's new query-access ordering test sits next to the work-state split test. Signed-off-by: Ryan Murray <[email protected]>
|
Forward-merged main into this branch (merge commit 33b7e5a, no force push). The g17/queue/mod.rs conflict came from main now reusing the submit scratch ( |
There was a problem hiding this comment.
Re-reviewed the queue merge resolution. It retains the per-command work-state attachment while consuming main's reusable pending and guard scratch via drain_all(), with one guard and one work-state entry consumed per command. The query-access ordering and work-state split coverage both remain. Keep current-head hosted CI and the runtime evidence gates.
|
code-owner ping @DjDeveloperr: closeout merge at |
|
Updated the branch with main (now |
|
Merging under the 6-point rule (Ryan 09:29, permanent), at |
Main (#3330, granular work-state retire) added a multi-command path that splits an ioctl into chunked work-state leases and publishes them with Outputs::publish_with_status(), next to the single-command Outputs::publish(). This branch makes publish() take a lease created by the caller, so the interruptible order-window wait happens before any output is published. Kept both: the multi-command path is main's unchanged (its first WorkStateLease::deferred() now waits interruptibly too, before publication); the single-command path creates its lease before publish() as this branch does. note_render() runs just before either publication, after any wait. Outputs keeps main's publish_source() split with this branch's publish_with(Option<lease>) on top. tools/asahi/g17-output-fence-tests.py (main, #3311/#3648) extracts impl Submission and expected one Arc::new() there, the one in Submission::new(), which this branch removes; it now expects none. Signed-off-by: Ryan Murray <[email protected]>
What
Eliminates two host-side retirement bottlenecks on G17 that left completed render and compute commands unretired for 2-11 ms:
g17/queue/compute.rs):scan_compute_summary()latches completion records from the shared compute completion ring intoactive.observedfor every physical queue, even when the waking event mask names another QID.Queue::retire()previously skipped queues whose!self.selected(masks)andretirement_polling()ignoredactive.observed.is_some(), stranding already-finished compute commands up to 11.45 ms until an unrelated event woke the worker. Treat a latched front observation as selected for retirement and polling.WorkStateLeaseacross multi-command submissions (g17/context/identity.rs,g17/context.rs,g17/fence.rs,g17/queue/mod.rs): G17 firmware stores completion stamps for a work-state node only once every kick counted on that node completes. When a multi-commandDRM_IOCTL_ASAHI_SUBMITioctl packs dozens of commands onto one sharedWorkStateLease, early commands cannot retire until the last command finishes (2-6 ms later), pinning the 32-slot render ring full and delaying timestamp writers needed by laterquery_accesscomputes. Give multi-command submissions per-chunkChunkWorkholders (releasing theirWorkStateLeaseimmediately on chunk retirement/drop, matchingSubmission's lifecycle), splitting atRENDER_DEPTH / 8commands, after host-timestamp writers, and beforequery_accesscomputes. ExpandORDER_WINDOWfrom 1024 to 2048 and cap extra intra-ioctl splits viaWorkStateLease::deferred_split()atORDER_WINDOW / 2so 1024 full ordinals remain permanently reserved for new ioctls. Single-command ioctls keep the existingSubmissionpath unchanged.Tested
8962d5f51572(exact head, standalone): PASS (#issuecomment-7206654524;170/170query/multiview CTS, 170 s BeamNGwcusasmoke, 0 GPU faults, 0 EBUSY, 0 WARN).8962d5f51572(2nd-gen exact head): PASS (#issuecomment-7207257611;67,553/0compute.*,3,000/0sync smoke,1,928/0query_pool,gpubench-vk/glCRCs clean, 0 EBUSY/faults).8962d5f51572: PASS (223/223run-host-tests.py --only g17, includingg17-chunk-work-guard-tests+ 2 mutations;checkpatch.pl --strict --ignore FILE_PATH_CHANGES0/0/0).bec51415b9e1(stacked on drm/asahi: g17: do not host-wait query_access on timestamp-free chains #3319 for game-FPS A/B): PASS (0 GPU faults, 0 EBUSY, 170/170 query/multiview CTS)../scripts/checkpatch.pl --strict --git origin/main..HEAD: 0 errors, 0 warnings, 0 checks on both commits.python3 tools/asahi/run-host-tests.py --only g17: 223/223 passed (g17-chunk-work-guard-tests+ 2 mutations added at8962d5f51572).3024x1964,GP_NOANAT=1, identical Mesa kitinst-Klibvulkan_asahi.so1cf23c9f22d5), tested stacked on drm/asahi: g17: do not host-wait query_access on timestamp-free chains #3319 (NO_TS) with0GPU faults,0EBUSY,0kernel errors:deqp-vk1.4.7.1):query_pool.occlusion_query.copy_*152/152 PASS (7 unsupported),query_pool.concurrent_queries.*2/2 PASS,multiview.queries.*16/16 PASS.origin/mainbaseline:41.24,41.41(mean41.33).#3319alone:50.17,51.51,49.89(mean50.52).#3319+ this PR (clean):52.66,52.87(mean52.77, +4.5% over#3319alone, +27.7% overorigin/main; GPU union busy89.31%->91.44%).wcusasteady-state windows 2-5 FPS:origin/mainbaseline:34.79mean.#3319alone:35.87mean (1% low ~34.5).#3319+ this PR:36.44,36.31,36.24(mean36.33, +1.3% over#3319, +4.4% overorigin/main;1% lowrose34.5->36.0-36.4, +4.5%).91.82%->94.04%, median retirement latency319.1 us->59.8 us(5.3x), compute>2 msretire stalls2,556->0, idle gaps>200 us230.9 ms(2.31%wall) ->14.5 ms(0.14%wall, 16x reduction).Risk
Risk: two-way · G17 compute retirement and multi-command work-state lifecycle (
drivers/gpu/drm/asahi/g17/context/identity.rs,context.rs,fence.rs,queue/compute.rs,queue/mod.rs); no UAPI or firmware ABI changes, single-command ioctls unchanged, cleanly revertible.Not yet
vkd3d_queueCPU time) if needed is out of scope here.