Repository navigation
drm/asahi: g16: widen compute concurrency to 64/16 and cache shared UMA and fw_stamp - #3340
Conversation
…o 64 With non-SCS compute VMs sharing one UMA descriptor, pool, and hardware UMA slot across all units, each extension compute unit only backs 288 KiB of preempt, auxiliary, and context-store state. Previously, COMPUTE_UNITS=24, COMPUTE_PIPES=8, and a 32-flight compute cap forced 16 concurrent compute processes to share 8 pipes and contend over only 16 reusable units, and capped deep d=32/d=64 single-queue streams at 23 commands in flight. Widen COMPUTE_UNITS to 64, COMPUTE_PIPES to 16 (events 15..=30 in type-1 event word 1), and FLIGHTS to 64, and derive params::compute_flights() from COMPUTE_UNITS and FLIGHTS: - Compact extension compute unit records (k >= 2) into 1 MiB intervals at EXT_COMPUTE_REC_BASE (0x70b4000000..0x70b7e00000), keeping 26 disjoint 33 MiB SharedComputeUma migration windows below it and base units 0..2 unchanged. - Widen compute unit bitmasks (quarantined_compute_mask, compute_slot_mask, Lifetime masks) from u32 to u64 while keeping SCS slot selection bounded by COMPUTE_UMA_SLOTS (32). - Update host selftests to validate 64 compute units, 16 compute pipes, 26 UMA migration windows, and 64-bit unit masks. Signed-off-by: DjDeveloperr <hey@djdev.me>
…ached Shared compute UMA descriptors and compute queue fw_stamp records do not need to be uncached on the firmware side: - Add a device-lifetime ComputeUmaPool on Factory that allocates persistent ASC-cached (FwCoherent) SharedComputeUma descriptors paired with uncached (Fw) counters. Because the descriptor is never unmapped, firmware can cache it across flights; a lease returns to the pool on drop only when every published flight has retired normally, keeping aborted or quarantined records out of circulation. - Map compute QueueSession fw_stamp records ASC-cached (FwCached) and observe compute retirement through the uncached service stamp written by the notifier service after firmware descriptor bookkeeping. This drops uncached firmware writes on every shared compute flight and eliminates the host read of the shared descriptor at retirement. Signed-off-by: DjDeveloperr <hey@djdev.me>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
|
Non-author review at Commit 1: 64 units, 16 pipes, 64 flights (
Commit 2: ASC-cached shared UMA descriptor and compute
Local checks (scratch worktree)
Owed before merge
|
Address non-blocking review notes on PR #3340: - Update the stale FLIGHTS = 32 reference in the RENDER_SLOTS doc comment to FLIGHTS = 64. - Format the two new compute_list/compute_context compile-time asserts in g16/hw.rs to match rustfmt. Documented clarifications from review: - Userspace visibility: widening FLIGHTS to 64 raises QUEUE_LIMITS.max_in_flight_per_queue from 32 to 64. - Compute retirement ordering: in 26B123 armfw_g16g.im4p, firmware advances UMA COMPLETED and cleans the ASC-cached descriptor in FUNC_0x2d540 before AGFCLDataMasterPostProcessingCallback (0x24fd8) and notifier flush FUNC_0x25198 store the uncached service stamp at 0x25634 (matching the J773g 26B123 live Metal compute hypervisor capture where descriptors and fw_stamp map 0x443 ASC-cached while service stamps map uncached). Signed-off-by: DjDeveloperr <hey@djdev.me>
|
Re-review at Blocker: firmware disassembly details in the new commit message and the PR body
Checked at this head
Still owed: the text fix above, the J516s (M3 Pro, G15S) row, and build and KUnit once the PR is retargeted to |
Document the 64-flight limit and format the layout assertions. The reported per-queue limit rises from 32 to 64. Compute completion uses the uncached service stamp so progress and retirement do not depend on CPU reads of cached firmware records. Signed-off-by: DjDeveloperr <hey@djdev.me>
3695a16 to
1de4e8f
Compare
There was a problem hiding this comment.
Superseded 12-01: not a hold under the merge bar (no shown failure). Full diff review deferred; follow-ups: land #3287 and retarget, main CI, hardware row, keep firmware-disassembly text out
Verdict: HOLD at 1de4e8f8
Blockers:
- Targets open non-
mainbase branchperf/g16-compute-shared-uma(#3287is stillOPEN); fullmainCI has not run. - Missing hardware row at head (
needs-hw-row), and ensure any firmware-disassembly details flagged in the earlier review comment stay stripped from commit messages and PR text before merge.
Checked:
- Verified
#3287is stillOPENand base ref isperf/g16-compute-shared-uma. - Deferred full diff review until
#3287lands and this PR is retargeted ontomainwith green CI and hardware row.
Evidence
- Base ref:
perf/g16-compute-shared-uma(#3287state:OPEN).
Registry::reserve() takes a TTBAT slot for a VM's first queue and no longer counts the VM against its file. Reserve without a file; the file limit is covered by the asahi-m4 selftest test-vm-registry.py. Signed-off-by: DjDeveloperr <hey@djdev.me>
…u64-cached-uma Sixteen compute pipes keep up to sixteen exited clients' VMs bound, eight more than main's pipes. Vulkan clients take one TTBAT slot each with this. A LiveToken of #3695's host test takes the new field. Signed-off-by: DjDeveloperr <hey@djdev.me>
Whether a retired compute or render owner was displaced was decided by comparing it with every other owner, and the engine asks that of every unit a VM may use several times for each submission. That is a pairwise scan. It costs nothing while units are unused, which is how a driver starts, but it runs in full once every unit has retired work, and it grows with the square of the units: one pass over the ledger took 0.7 us with 24 units and 8 pipes and 6.6 us with 64 units and 16 pipes on an x86 build host. The J773g row of linux#3340 shows it. The time gpubench measures in the submit calls of compute.light rose from 9-11 us to 19 us at procs depths 8 and 16, and queue depth 1 went from 104 to 116 us per submission in the second pass, with the ledger full. In the first it was level with linux#3695 and linux#3699 alone. Keep the answer in each owner instead and update it when a publication retires, which already walks the ledger. The same pass then takes 0.05 us at either size. Nothing else changes: an owner is displaced by the same publications as before. A host test compares the kept answer with the pairwise scan over random transitions, in-order and ordered pipes alike. Signed-off-by: DjDeveloperr <hey@djdev.me>
There was a problem hiding this comment.
Verdict: MERGE at d50ef24
Checked: The current head includes the deferred binding from #4077. A Vulkan physical-device VM leaves the TTBAT slot free, and the logical-device VM takes one when it creates a queue. The 16-process host case passes with the desktop VMs and retired owners still present. The other host cases cover failed binding, close during binding, queue reuse, per-file quota and retained leases. The cached displacement ledger matched the pairwise reference in the exact test. All 56 targeted host tests passed across VM slots, VM registry, lifetime and stamp retirement. The earlier J773g ENOSPC report applies to eb8c98e.
Merge #3695, #3699 and #4077 first.
Follow-ups: #4078 tracks the slot retained when first queue setup fails after binding. The previous code already reserved it at VM creation.
Signed-off-by: DjDeveloperr <hey@djdev.me>
|
Forward-merged main |
There was a problem hiding this comment.
Verdict: MERGE at a134833
Checked: Both landed UMA prerequisites and the exact #4077 first-queue binding are ancestors of this head. The merge retains the previously reviewed VM ownership, slot, and compute retirement paths. The current G16 match data and hardware definitions preserve the widened resource limits. Four exact-tree host suites passed 145 cases across resources, VM registry, VM slots, and stamp wrap. The VM sharing control passed and rejected all three mutations, and the recovery checks covered a stale service stamp, abort grace, and an innocent compute completion.
Land #4077 first. The hardware receipt remains a merge gate.
|
J773g row at What
Tested
Risk
Not yet
|
|
J516s (MacBook Pro 16-inch M3 Pro, T6030, G15S B1, 18 active cores, OS firmware Stack and build
Results
|
Keep the 64-bit compute quarantine mask and the render quarantine fallback from main. Signed-off-by: DjDeveloperr <hey@djdev.me>
|
Forward-merged current main I compared the J773g and J516s build trees. Their G16 sources match each other, and the J516s #4213 delta is PCIe-only. Relative to those rows, the only G16 changes are the landed #4185 render changes, using the existing 64-bit ledger and compute mask. The compute, VM, and recovery changes in this PR match the tested ones. #3490's G15/M3 stats and telemetry files come directly from main, as do the G14/firmware changes. #4197 touches no Asahi driver files. On this head, the arm64 LLVM 23.1.3 GitHub reports the merge as clean of conflicts. This head needs a new non-pusher approval. Exact #4077 is already in its ancestry and the combined tree has its resource test fix, so #4077 can close once this lands. |
|
Landing receipt for I rebuilt The current main |
What: widen G16 compute concurrency to firmware/ring bounds and map shared compute UMA descriptors and compute
fw_stampcells ASC-cached.Two commits stacked cleanly on #3287 (
078f963c,perf/g16-compute-shared-uma):Widen compute units, pipes, and flights (
ee819069):Now that non-SCS compute VMs share one 32 MiB UMA pool and hardware UMA slot (
1..=32) instead of one per unit, compute concurrency is no longer capped at 24 units / 8 pipes / 32 flights. Every size is derived from its hardware/firmware limit:COMPUTE_UNITS = 64: bounded by theu64slot/quarantine mask width (<= 64),SCHEDULER_CREDITS = 64, the 256-entry compute work ring ((COMPUTE_UNITS - 1) * MAX_COMPUTE_RING_ENTRIES = 63 * 3 = 189 < QUEUE_CAP = 256), and client VA compaction (62 * 1 MiBextension records atEXT_COMPUTE_REC_BASE..scs_compute_records(0), preserving 26 disjoint 33 MiBSharedComputeUmamigration windows belowEXT_COMPUTE_REC_BASE, all compile-time asserted).COMPUTE_PIPES = 16: 16 contiguous Type-1 completion events (15..=30) in event word 1, fitting entirely inside word 1 without reading an extra event word (RETIRED_COMPUTE_PIPES = 16).FLIGHTS = 64: one in-flightFlightper compute unit, well insideAHEAD_RECORDS = 128and the wrapped stamp half-window.compute_flights() = COMPUTE_UNITS.saturating_sub(1).min(FLIGHTS) = 63: retains one spare compute unit for displacement so one queue never starves another queue or VM.SCS_COMPUTE_UNITSstays bounded byCOMPUTE_UMA_SLOTS = 32andpick_scs_compute_slots()clamps toCOMPUTE_UMA_SLOTS.Map shared compute UMA descriptors and compute
fw_stampASC-cached (97d88a25):ComputeUmaPoolonFactorythat allocates persistent ASC-cached (Class::FwCoherent,0x443)SharedComputeUmadescriptors paired with uncached (Class::Fw) submission counters. Because descriptors are never unmapped, firmware caches them across flights; aComputeUmaLeasereturns to the pool on drop only when every published flight retired normally (published_flights == retired_flights), keeping aborted or quarantined records permanently out of circulation.QueueSession.fw_stampASC-cached (Class::FwCached,0x443), matching macOS 26B123 (renderfw_stampstaysClass::Shared), and observe compute progress and retirement through the uncached compute service stamp written by the notifier service after firmware updatesfw_stampand completes descriptor bookkeeping.Merged here: main, drm/asahi: g16: rebuild a drained compute UMA manager without reseeding its pool #3699 (with drm/asahi: g16: keep compute UMA managers bound and ASC-cached #3695) and drm/asahi: g16: bind a VM to its TTBAT slot with its first queue #4077. drm/asahi: g16: keep compute UMA managers bound and ASC-cached #3695's per-slot records replace the
ComputeUmaPooldescribed in point 2; the widths, masks, VA layout, the ASC-cachedfw_stampand its recovery witness stay.drivers/gpu/drm/asahiafter the drm/asahi: g16: rebuild a drained compute UMA manager without reseeding its pool #3699 merge is treedfe6cfb96b05, the one the J773g comparison ran.VM_CREATEENOSPC is a main bug that the 16 pipes expose: closed clients' newest owners keep up to one VM per pipe bound (8 more than main's 8), and each Vulkan client takes two of the 63 TTBAT slots, one for a VM that never has a queue. The fix binds a VM with its first queue and shortens no lease. Its host test fails at the earlier head of this PR at the 9th of 16 processes and passes now.Keep displacement in the owner ledger (last commit).
Lifetime::available()compared a retired owner with every other one, so one pass over 64 units was 6.6 us against 0.7 us for 24 (x86 host, every unit retired) and the engine makes several per submission. It is now 0.05 us. Owners are displaced by the same publications as before. In the J773g row thesubmittime ofcompute.lighthad gone from 9-11 us to 19 us at procs d8/d16, and queue d1 from 104 to 116 us in the second pass only, when the ledger is full.A third candidate commit (clearing
work+0x81con non-tail commands of multi-command compute flights + an 8 us sliding compute coalesce deadline) was A/B tested and dropped: the 8 us sliding timeout fragmented 4–5 command flights into 1–2 command flights (grouped 435k -> 309k,+95kSubmitRecords) and regressedcompute.light d=16/32/64by +3.3% to +6.2%.Tested:
3695a16489beb, including the documented per-queue limit increase from 32 to 64.asahiKUnit (./tools/testing/kunit/kunit.py run --arch=arm64 --make_options LLVM=1 --kunitconfig=drivers/gpu/drm/asahi/.kunitconfig): 463 tests: 459 passed, 4 skipped, 0 failed.tools/testing/selftests/drivers/gpu/asahi-m4/run-host-tests.py): 26/26 passed, includingtest-resources.py(75/75:FwCoherentdescriptor /Fwcounter classes, settled pool recycling, permanent quarantine non-recycling, 64-unit VA disjointness),test-publication.py(87/87),test-poll-retire.py(43/43),test-stamp-wrap.py(28/28), andtest-progress-wrap.py(20/20).scripts/checkpatch.pl --stricton all 3 commits (078f963c..3695a16489beb): 0 errors, 0 warnings, 0 checks per commit;rustfmt: 0 new diffs.7.3.0-ARCH-m4cir2final-3695a164, module build ID58aae568f3648ecfdb946e319fad5077e30ad71b, standalone on drm/asahi: g16: share one compute UMA descriptor and pool per VM #3287 without drm/asahi: g16: map the compute notifier records ASC-cached #3285,946,628jobs, 0 kernel findings, 0 GPU faults/recoveries/hangs,compute_owners: retired 64 quarantined 0 reusable 48):vk-uma-quarantine clean 35):pre_ok=35 post_ok=35/35 fresh_ok=1.compute.light d=4/8/16/32/64:40.94 / 29.45 / 22.70 / 20.96 / 20.29 us(d=16/32/64beat Metal 4 by 4.3%–5.5% even before stacking drm/asahi: g16: map the compute notifier records ASC-cached #3285);procs d=16:38.93 us.sync.signal binary / timeline / host:24.77 / 24.87 / 169.25 us(binary/timeline beat Metal 4 by 0.9%–1.6%).compute.heavy alu d=1/2/4:771.61 / 537.35 / 537.35 us;bw d=1/2/4:1519.91 / 1267.43 / 1269.04 us;concurrent.cr interleave / queues:64.17 us / 1.03x;render.light tri d=16:58.93 us.s2idlegate ran stacked on#3285 + #3287(r2base = 9e0a1b30,r2cu64 = efe761b6,r2c2 = 70ad7b64, where#3285relocates the same uncachedwork+0x800service stamp fromnotifier + COMPUTE_STAMPtouser_stamp):r2base -> r2cu64):compute.light d=6422.87 -> 21.48 us(-6.10%),d=3222.59 -> 21.97 us(-2.73%),procs d=1639.96 -> 39.04 us(-2.31%); slot holds dropped 95.5% (384,607 -> 17,266) and cross-VM compute retargets dropped 98% (2,900 -> 60).r2cu64 -> r2c2):compute.light d=4-5.24%,d=16-9.92%,d=32-12.04%,d=64-11.49%,procs d=16-8.25%,sync.signal binary-10.46%,sync.signal timeline-10.10%.r2base -> r2c2 -> r2c2 -> r2base, 144/144 ok, 0 kernel findings, 0 GPU faults/recoveries/hangs, ~963k–994k jobs perr2c2boot):r2base(#3285+#3287)r2c2(C1+C2)compute.light d=4compute.light d=8compute.light d=16compute.light d=32compute.light d=64compute.light procs d=16sync.signal binary d=2sync.signal timeline d=2sync.signal host d=1compute.heavy alu d=1compute.heavy alu d=2compute.heavy alu d=4compute.heavy bw d=1compute.heavy bw d=2compute.heavy bw d=4concurrent.cr light interleave d=4concurrent.cr heavy queues d=4render.light tri d=16J773g gate boot (
kit-r2c2,198,348jobs /348,964commands /job_max 64, 0 kernel findings, 0 GPU faults/recoveries/hangs):vk-uma-quarantine clean 35):pre_ok=35 post_ok=35/35 fresh_ok=1.--jobs 1, excluding drm/asahi g16: dEQP-VK.synchronization*multi_queue* faults the GPU and fail-stops it on J773g (main 61c7b88a) #3201multi_queue/cross_instance, 16,500 cases executed in slot):8,088 Pass / 8,412 NotSupported / 0 Fail,recoveries=0.s2idlesuspend/resume: woke cleanly after 13 s (S2IDLE_POST success=1 fail=0,DELTA_ERR=0), post-wake 7/7 suite passed (including CRC-verifiedrender.postfxMSAA 4x,compress.bw1440p,render.mdi1024 draws;compute.light d=16= 22.19 us).Host tests at the current merge of drm/asahi: g16: rebuild a drained compute UMA manager without reseeding its pool #3699 and drm/asahi: g16: bind a VM to its TTBAT slot with its first queue #4077:
tools/asahi/run-host-tests.py --only asahi-m4pass (including the new displacement check andtest-vm-slots.py),--only g162/2,--only g1515/19; the four others need rustc 1.93.1, which the build host doesn't have. Arm64W=1build ofdrivers/gpu/drm/asahi/: no errors. checkpatch--strictclean on the ledger commit.Risk: two-way · Macs on the g16 backend (M4 G16G; M3 G15S and G15G). A plain revert undoes it.
SharedComputeUma.descriptorasFwCoherentand computefw_stampasFwCachedrelies on device-lifetime backing for cached descriptors and on firmware writing the uncached compute service stamp only after descriptor bookkeeping completes. The J773g stress and suspend/resume rows above exercised this assumption. Mitigated byComputeUmaPoolnever unmapping allocated descriptors, refusing to recycle any lease whose published flights did not all retire normally (published_flights == retired_flights), retaining active leases inSlotsacross hardware slot handoff, and host selftests verifying both normal reuse and permanent quarantine pinning.sync.signal host d=1(+1.85%) andcompute.heavy d=1(+0.76% to +0.99%) show minor shifts while remaining 7.6%–14.0% ahead of Metal 4 oncompute.heavy d=1.Not yet:
compute.light procs d=16(ENOSPC, point 3) and measuredidle.wakeslower; a GPU recovery with innocent compute running is still owed. T8122 has no row.