Skip to content

drm/asahi: g16: widen compute concurrency to 64/16 and cache shared UMA and fw_stamp - #3340

Merged
DjDeveloperr merged 15 commits into
mainfrom
perf/g16-compute-cu64-cached-uma
Dec 3, 2026
Merged

DjDeveloperr merged 15 commits into
mainfrom
perf/g16-compute-cu64-cached-uma

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

What: widen G16 compute concurrency to firmware/ring bounds and map shared compute UMA descriptors and compute fw_stamp cells ASC-cached.

Two commits stacked cleanly on #3287 (078f963c, perf/g16-compute-shared-uma):

  1. 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 the u64 slot/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 MiB extension records at EXT_COMPUTE_REC_BASE..scs_compute_records(0), preserving 26 disjoint 33 MiB SharedComputeUma migration windows below EXT_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-flight Flight per compute unit, well inside AHEAD_RECORDS = 128 and 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_UNITS stays bounded by COMPUTE_UMA_SLOTS = 32 and pick_scs_compute_slots() clamps to COMPUTE_UMA_SLOTS.
  2. Map shared compute UMA descriptors and compute fw_stamp ASC-cached (97d88a25):

    • Add a device-lifetime ComputeUmaPool on Factory that allocates persistent ASC-cached (Class::FwCoherent, 0x443) SharedComputeUma descriptors paired with uncached (Class::Fw) submission counters. Because descriptors are never unmapped, firmware caches them across flights; a ComputeUmaLease returns 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.
    • Map compute QueueSession.fw_stamp ASC-cached (Class::FwCached, 0x443), matching macOS 26B123 (render fw_stamp stays Class::Shared), and observe compute progress and retirement through the uncached compute service stamp written by the notifier service after firmware updates fw_stamp and completes descriptor bookkeeping.
    • Drop host reads of the ASC-cached shared descriptor at retirement and idle reuse, checking the uncached host submission counter and host conservation instead.
  3. 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 ComputeUmaPool described in point 2; the widths, masks, VA layout, the ASC-cached fw_stamp and its recovery witness stay. drivers/gpu/drm/asahi after the drm/asahi: g16: rebuild a drained compute UMA manager without reseeding its pool #3699 merge is tree dfe6cfb96b05, the one the J773g comparison ran.

    • The row's VM_CREATE ENOSPC 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.
  4. 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 the submit time of compute.light had 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+0x81c on 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, +95k SubmitRecords) and regressed compute.light d=16/32/64 by +3.3% to +6.2%.

Tested:

  • J773g at 3695a16489beb, including the documented per-queue limit increase from 32 to 64.
    • Arm64 kernel compile + asahi KUnit (./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.
    • Host selftests (tools/testing/selftests/drivers/gpu/asahi-m4/run-host-tests.py): 26/26 passed, including test-resources.py (75/75: FwCoherent descriptor / Fw counter 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), and test-progress-wrap.py (20/20).
    • scripts/checkpatch.pl --strict on all 3 commits (078f963c..3695a16489beb): 0 errors, 0 warnings, 0 checks per commit; rustfmt: 0 new diffs.
    • J773g native build + exact-head re-gate boot (7.3.0-ARCH-m4cir2final-3695a164, module build ID 58aae568f3648ecfdb946e319fad5077e30ad71b, 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,628 jobs, 0 kernel findings, 0 GPU faults/recoveries/hangs, compute_owners: retired 64 quarantined 0 reusable 48):
      • 35-VM concurrent live Vulkan compute stress (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/64 beat 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.
  • J773g (M4 Mac mini, T8132, G16G B0, 26B123 firmware) full ABBA + CTS + s2idle gate ran stacked on #3285 + #3287 (r2base = 9e0a1b30, r2cu64 = efe761b6, r2c2 = 70ad7b64, where #3285 relocates the same uncached work+0x800 service stamp from notifier + COMPUTE_STAMP to user_stamp):
    • Commit isolation (2-boot A/B per step, 0 faults/recoveries/findings):
      • C1 (r2base -> r2cu64): compute.light d=64 22.87 -> 21.48 us (-6.10%), d=32 22.59 -> 21.97 us (-2.73%), procs d=16 39.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).
      • C2 (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%.
    • Formal 4-boot ABBA (r2base -> r2c2 -> r2c2 -> r2base, 144/144 ok, 0 kernel findings, 0 GPU faults/recoveries/hangs, ~963k–994k jobs per r2c2 boot):
benchmark r2base (#3285+#3287) r2c2 (C1+C2) delta Metal 4 vs Metal
compute.light d=4 40.73 us 39.29 us -3.54% 37.31 us +5.31%
compute.light d=8 29.31 us 28.63 us -2.33% 27.72 us +3.28%
compute.light d=16 23.41 us 22.25 us -4.95% 23.89 us -6.86%
compute.light d=32 22.56 us 20.20 us -10.46% 21.90 us -7.74%
compute.light d=64 22.80 us 19.74 us -13.40% 21.46 us -8.01%
compute.light procs d=16 40.55 us 36.40 us -10.24% 32.38 us +12.42%
sync.signal binary d=2 25.92 us 23.97 us -7.52% 25.00 us -4.12%
sync.signal timeline d=2 26.00 us 24.00 us -7.70% 25.28 us -5.06%
sync.signal host d=1 163.56 us 166.59 us +1.85% 156.00 us +6.79%
compute.heavy alu d=1 757.00 us 764.53 us +0.99% 827.81 us -7.64%
compute.heavy alu d=2 537.06 us 537.06 us 0.00% 538.79 us -0.32%
compute.heavy alu d=4 537.06 us 537.06 us 0.00% 538.79 us -0.32%
compute.heavy bw d=1 1512.87 us 1524.39 us +0.76% 1773.05 us -14.02%
compute.heavy bw d=2 1272.27 us 1275.53 us +0.26% 1436.78 us -11.22%
compute.heavy bw d=4 1270.65 us 1275.53 us +0.38% 1436.78 us -11.22%
concurrent.cr light interleave d=4 64.02 us 63.38 us -0.99% 57.10 us +11.00%
concurrent.cr heavy queues d=4 1.03x 1.03x -0.03% 1.00x +3.00%
render.light tri d=16 60.60 us 59.74 us -1.41% 48.29 us +23.71%

Risk: two-way · Macs on the g16 backend (M4 G16G; M3 G15S and G15G). A plain revert undoes it.

  • Mapping SharedComputeUma.descriptor as FwCoherent and compute fw_stamp as FwCached relies 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 by ComputeUmaPool never unmapping allocated descriptors, refusing to recycle any lease whose published flights did not all retire normally (published_flights == retired_flights), retaining active leases in Slots across hardware slot handoff, and host selftests verifying both normal reuse and permanent quarantine pinning.
  • sync.signal host d=1 (+1.85%) and compute.heavy d=1 (+0.76% to +0.99%) show minor shifts while remaining 7.6%–14.0% ahead of Metal 4 on compute.heavy d=1.

Not yet:

…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>
@DjDeveloperr
DjDeveloperr requested review from a team as code owners November 27, 2026 03:19
@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) blast:all Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 27, 2026
@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Merge readiness at 6c07506a: not ready yet

Check Detail
CI at head running running: host-tests, apple-build, KUnit plan
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 6c07506a, a Mac and a result in the PR body or a comment
Conflicts ok none
PR text ok Risk: two-way · Macs on the g16 backend (M4 G16G; M3 G15S and G15G). A plain revert undoes it. - Mapping SharedComputeUma.descriptor as FwCoherent and compute fw_stamp as FwCached relies 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 by ComputeUmaPool never unmapping allocated descriptors, refusing to recycle any lease whose published flights did not all retire normally (published_flights == retired_flights), retaining active leases in Slots across hardware slot handoff, and host selftests verifying both normal reuse and permanent quarantine pinning. - sync.signal host d=1 (+1.85%) and compute.heavy d=1 (+0.76% to +0.99%) show minor shifts while remaining 7.6%–14.0% ahead of Metal 4 on compute.heavy d=1.

Areas: area:gpu

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

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Non-author review at 97d88a257221: READY on the code, 0 blockers. This PR is stacked on #3287 (perf/g16-compute-shared-uma, 078f963c8b97) and merges after it. CI and hardware rows at this head are still owed (below).

Commit 1: 64 units, 16 pipes, 64 flights (ee8190697514)

  • Bounds: these hold and are asserted at compile time.
    • Compute ring: 63 × 3 = 189 entries, below QUEUE_CAP 256.
    • Flights: compute flights are 63 (COMPUTE_UNITS - 1) within FLIGHTS 64, and all flights stay under AHEAD_RECORDS 128.
    • Events: the 16 pipe events 15..=30 fit in type-1 event word 1 (EVENT + COMPUTE_PIPES <= 32 is asserted), and TA/FS stay in word 4.
  • Masks: the compute unit masks (quarantine, slot, Lifetime) are now u64, and the UMA-slot masks stay u32 for the 32 slots. pick_scs_compute_slots() now clamps to COMPUTE_UMA_SLOTS, which also keeps the compute_slot_mask() as u32 cast in compute_uma_mask() lossless.
  • Client VA:
    • Extension unit records move to EXT_COMPUTE_REC_BASE at a 1 MiB stride and end below scs_compute_records(0) (asserted).
    • The 26 shared UMA pool windows end at or below EXT_COMPUTE_REC_BASE (asserted).
    • Both Placement::Base unit sets are built with the shared UMA, so compute_pool(k) never sees a unit index past the windows; ComputeSlot::new is dead code.
  • Chips: the sizes apply to the whole g16 backend, so T6030 and T8122 change as well, hence the J516s row below.

Commit 2: ASC-cached shared UMA descriptor and compute fw_stamp (97d88a257221)

  • Lease accounting: ComputeUmaLease counts publish() once per published shared flight, and retire() only on a full receipt (owner_retired()). After an abnormal retirement the set stays out of the pool for good; that is bounded by quarantine.
  • When a set can be reused:
    • A set returns to the pool only when its last holder drops.
    • retained_uma[slot] keeps it until another owner overwrites that hardware slot, so firmware's uma_mgr_table never points at a set that is being reused.
    • A reused set is zero-filled and then fully rewritten with compute_uma_manager_image before first use.
    • The early-error paths drop an unpublished, settled lease, so the set goes back to the pool.
  • Coherency: the descriptor is a firmware-only FwCoherent record (cacheable host and ASC mappings), the same contract its first use already relies on.
  • fw_stamp:
    • Compute fw_stamp is now FwCached, and the host never writes it.
    • Every host read now goes to the uncached notifier COMPUTE_STAMP.
    • The remaining users of the fw_stamp VA are firmware barrier records (c2c, c2ta, c2fs), which the ASC evaluates through its own mapping.
    • Render fw_stamp stays Shared.

Local checks (scratch worktree)

  • checkpatch.pl --strict: clean on both commits.
  • asahi-m4 host suite (run-host-tests.py): 26/26 pass.
  • rustfmt: one new hunk. The two new const _: () = assert! lines in g16/hw.rs would each fit on one line. The other files add no new differences.
  • Both commits are signed off, with no attribution.

Owed before merge

  • Build and KUnit at this head. Only pr-text / pr-text ran here at posting: apple-build, KUnit and host-tests only run for PRs against main, so nothing has compiled this exact head yet. That includes the Default derives removed from Stats and Prof. Either build it on the mini or retarget once drm/asahi: g16: share one compute UMA descriptor and pool per VM #3287 lands.
  • A J773g row at this exact head.
  • A J516s (M3 Pro, G15S) row, because this is shared g16 code.
  • Notes, not blocking:
    • Retirement now trusts the service stamp alone: compute_uma_retired() compares only host-written values, and the idle check no longer reads COMPLETED or COUNTER. Please name in the commit message the 26B123 capture that shows the service stamp is stored after the UMA descriptor bookkeeping.
    • QUEUE_LIMITS.max_in_flight_per_queue, as reported to userspace, goes from 32 to 64 with FLIGHTS. That is worth a line in the commit message.
    • The RENDER_SLOTS doc in g16/hw.rs still says "post at most FLIGHTS = 32 SubmitRecords".

DjDeveloperr added a commit that referenced this pull request Nov 27, 2026
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>
@github-actions github-actions Bot added ci-failing A check failed at the PR head (bot) and removed needs-hw-row No hardware row at the PR head (bot) labels Nov 27, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Re-review at 3695a16489be: CHANGES NEEDED, 1 blocker. The blocker is in the text only; the code is fine.

Blocker: firmware disassembly details in the new commit message and the PR body

  • To explain the retirement ordering, the 3695a16489be commit message cites function offsets, a code address and an Apple symbol name taken from a disassembly of the 26B123 GPU firmware. The PR body's Tested line repeats the offsets.
  • These are RE byproducts, and the org rules keep them private (AGENTS.md rule 1, policy/ip-and-tainted-data.md). What we learned from them can be stated in our own words.
  • Fix:
    • State the ordering the way our own J773g 26B123 capture or a measurement shows it, and drop the offsets, the address and the symbol name. If the ordering rests only on the disassembly, it needs a basis of our own, such as a trace or a measurement.
    • Edit the PR body now.
    • Fix the commit message before merge: the stack gets rebased when it is retargeted to main. At that point the two clarifications (the ordering, and QUEUE_LIMITS going from 32 to 64) are best folded into the commits that make those changes.

Checked at this head

  • Delta: 97d88a257221..3695a16489be is a fast-forward of one commit that touches only g16/hw.rs. It fixes the RENDER_SLOTS doc (FLIGHTS = 64) and reformats the two new asserts, with no code change. rustfmt now reports no differences in hw.rs, and checkpatch.pl --strict is clean. The commit is signed off, with no attribution.
  • Hardware: the J773g rows at this exact head (35-VM stress 35/35 and the gpubench rows) close the exact-head row I asked for. The CTS and s2idle gate is still from the stack that includes drm/asahi: g16: map the compute notifier records ASC-cached #3285.
  • CI: pr-text / pr-text,readiness / readiness. The other checks only run for PRs against main, so build and KUnit come with the retarget.

Still owed: the text fix above, the J516s (M3 Pro, G15S) row, and build and KUnit once the PR is retargeted to main.

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>
@DjDeveloperr
DjDeveloperr force-pushed the perf/g16-compute-cu64-cached-uma branch from 3695a16 to 1de4e8f Compare November 27, 2026 23:29
@github-actions github-actions Bot added needs-hw-row No hardware row at the PR head (bot) and removed ci-failing A check failed at the PR head (bot) labels Nov 27, 2026

@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.

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:

  1. Targets open non-main base branch perf/g16-compute-shared-uma (#3287 is still OPEN); full main CI has not run.
  2. 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 #3287 is still OPEN and base ref is perf/g16-compute-shared-uma.
  • Deferred full diff review until #3287 lands and this PR is retargeted onto main with green CI and hardware row.
Evidence
  • Base ref: perf/g16-compute-shared-uma (#3287 state: OPEN).

@github-actions github-actions Bot added the merge-conflict Conflicts with the base branch (bot) label Nov 29, 2026
Base automatically changed from perf/g16-compute-shared-uma to main November 29, 2026 16:01
@github-actions github-actions Bot removed the needs-hw-row No hardware row at the PR head (bot) label Nov 30, 2026
@github-actions github-actions Bot added merge-conflict Conflicts with the base branch (bot) and removed merge-conflict Conflicts with the base branch (bot) labels Dec 1, 2026
…4-cached-uma

#3695 keeps the shared compute UMA managers in per-slot records and #3699
rebuilds drained ones. They replace this branch's ComputeUmaPool. The
widths, masks, client VA layout, the ASC-cached compute fw_stamp and its
recovery witness stay.

Signed-off-by: DjDeveloperr <hey@djdev.me>
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>

@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: 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.

@github-actions github-actions Bot added the merge-conflict Conflicts with the base branch (bot) label Dec 3, 2026
Signed-off-by: DjDeveloperr <hey@djdev.me>
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Forward-merged main c5bdd6820568 as a134833c6f92. Git merged cleanly locally. Both #3695 and #3699 are now in main and their exact heads are ancestors of the merge. The CPU-only Asahi M4 suite passed 27/27, and g16-vm-share-tests.py --mutations passed its control and caught all three mutations. #4077 still lands first. The new head needs the J773g desktop 16-process retest and recovery with innocent compute in flight, the J516s check, and fresh approval.

@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: 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.

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

J773g row at a134833c6f92, merged onto main 536a613c0abe: PASS. This covers the desktop 16-process retest and recovery with innocent compute in flight.

What

  • Mac: J773g (Mac mini M4, T8132, G16G B0, OS firmware 27.2), desktop up (graphical.target + kwin). Watchdog (60 s) and dead-man (40 min) armed.
  • Kernel: 7.3.0-j773g-r4077, built from main 536a613c0abe merged with drm/asahi: g16: bind a VM to its TTBAT slot with its first queue #4077, with this head's aurora.ko in updates/.
  • Module and boot: aurora.ko build id 8d78cad04a18, boot fe679c7f-5410-4587-8a9a-733d1f84cf39. Same ICD as arm A.
  • Run 17:03-17:10Z from kit work/j773g-3340-armB-20261203 (seal 47f5c716), booted from stock.
    • That kit is the sealed work/j773g-4077-3340-rows-20261203's arm B, with three kit fixes:
      1. B boots from stock. Booted after arm A's reboot -f, Stage 2 refused ANS ("not adoptable").
      2. The recovery script's counter no longer prints two numbers.
      3. The judge leaves out the two systemd watchdog-arming lines.
    • Arm A (drm/asahi: g16: bind a VM to its TTBAT slot with its first queue #4077, the same Image) is that kit's 16:50Z run, boot 50528de1.

Tested

  • 16-process retest:
    • compute.light procs was ok and checked at d=2, 4, 8 and 16 in both passes (pass 2, d=16: 32.9 µs/submit; A: 33.1).
    • The churn (5 × procs d=8) and three more procs d=16 runs were all ok.
    • No VM_CREATE ENOSPC. The 06:09Z finding at eb8c98e615c0 is gone. vm_bindings peaked at live 35 (A: 27), and compute owners ended at retired 64 reusable 48 quarantined 0.
  • All 31 results in each pass were ok and checked. After the bench: health: failed 0, recoveries 0, and no GPU, MMU, RTKit or WARNING line that the stock boot lacks.
  • compute.light µs/submit, B against A:
    • queue d=4: −2.4% / −2.4%; d=16: −1.6% / −1.5%; d=64: +0.6% / −13.3% (pass 1 / pass 2).
    • procs d=2..16: all within ±3%.
  • Recovery with innocent compute in flight (three rounds of a guilty compute hang):
    • In round 1, firmware recovered twice (generation 2 resumed). Then the 5 s administrative deadline fail-stopped the GPU until reboot (health: failed 1 errno -110), so the fresh client failed in every round.
    • Arm A (drm/asahi: g16: bind a VM to its TTBAT slot with its first queue #4077 alone) did the same after one recovery. B is no worse than A.
    • The innocent loops exited (0 stuck), and neither arm logged a WARNING, BUG or Oops.
  • Judge: linux#3340 (arm B + recovery A/B): PASS, linux#4077 (arm A): PASS, VERDICT PASS. The Mac is back on stock main3685 (boot 427ec3f9), and the kit's files are removed.
  • Exact merge tree with main 33be24af74f4 (b8718ccfccfa, clean), in the CI image: asahi-m4 1/1, g16 2/2, g16-vm-share-tests --mutations 3/3 mutants killed.
    • Main's 25 commits after 536a613c0abe touch no file in drivers/gpu/drm/asahi/ or the asahi-m4 tests.
    • W=1 LLVM drivers/gpu/drm/asahi/ showed 0 new warnings on 536a613c0abe + this head (the kit's local checks).

Risk

  • A guilty compute hang ends in a GPU fail-stop with this PR and without it, the same as 06:09Z. This PR doesn't cause that and doesn't fix it.

Not yet

  • J516s (G15S) second-generation row at this head. The g16 backend runs on the M3 too.
    • The 12-02 J516s row ran at 323200454971, before the eb8c98e615c0 recovery fix and the forward merge, so it doesn't carry over.
    • The merge waits for that row.

@github-actions github-actions Bot added merge-conflict Conflicts with the base branch (bot) and removed needs-hw-row No hardware row at the PR head (bot) labels Dec 3, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

J516s (MacBook Pro 16-inch M3 Pro, T6030, G15S B1, 18 active cores, OS firmware 27.2 / 26B123) paired A/B GPU + recovery row for head a134833c6f92: PASS (all GPU, compute, render, transfer, churn, and recovery checks passed; zero GPU/MMU/RTKit faults or new warnings vs baseline).

Stack and build

  • Kernel: 7.3.0-pr3340j516s (vmlinux build ID 2c859517697d865778440dc9cafbbe7fd1e230aa), trial device tree t6030-j516s.dtb from the same tree.
  • Exact source stack: main 33be24af74f4 + #4213 a313071a0aad (T6030 PCIe PWREN dependency fix, drivers/pci/controller/pcie-apple.c only) + #3340 a134833c6f92 (local merge fb304dd5eb34, tree 5e15f68ad62b; drivers/gpu/drm/asahi/ and tools/ byte-identical to clean merge of #3340 onto main).
  • Arm M (baseline = main + #4213): aurora.ko build ID c77159380bb339351250cc952ab880fa71b3b0be, boot ID d91b1c04-92a8-40c5-b12c-96f4452f8c15.
  • Arm B (#3340 = main + #4213 + #3340): aurora.ko build ID 9e989f0e90ac6cddf37b89d5854487fcb11f6722, boot ID d6609128-92f9-421f-86c3-609e33919930.
  • Userspace: mesa-aurora 26.3.0 (d4ad4a4dce6), gpubench-vk (71eb16d740c5), guilty_hang.
  • Stock return: verified back on stock 7.3.0-f3822 (boot 73b30d07-cc10-497b-a821-97fc721e2bb7).

Results

  • Correctness & stability (both arms, pre-recovery):
    • Smoke, 2 full passes of compute.light (queue d=1..64, procs d=2,4,8,16, queues d=2,4,8), idle.wake, sync.signal, compute.heavy, compute.uber, render.*, transfer.*, churn 5× procs d=8 and 3× procs d=16: all ok and verified on both arms.
    • Zero ENOSPC / VM_CREATE / QUEUE_CREATE failures, health: failed 0, recoveries 0, zero GPU/MMU/RTKit faults or kernel WARNING/BUG/Oops.
    • Both arms logged the exact same 4 pre-existing non-GPU main lines absent on stock 7.3.0-f3822 (apple_sep cold-match/catacomb readiness, cs42l84 PLL lock error from the known T6030 MCA mux regression on main, and thermal_zone sustainable_power notice); zero warnings added by #3340.
  • Recovery (3 guilty compute hangs with innocent compute.light procs d=4 + compute.uber d=4 loops):
    • Identical behavior on Arm M and Arm B across all 3 rounds (round 1: fresh 2, guilty 42; round 2: fresh 2, guilty 1; round 3: fresh 2, guilty 1; stuck: 0 on both; health: failed 1 errno -110 degraded 0 on both).
  • Selected compute.light A/B medians (us/submit, Arm M -> Arm B):
    • procs d=16: Pass 1 24.83 -> 23.20 (-6.6%), Pass 2 25.17 -> 23.52 (-6.6%)
    • queue d=32: Pass 1 15.17 -> 15.20 (+0.2%), Pass 2 21.63 -> 15.35 (-29.0%)
    • queue d=64: Pass 1 14.88 -> 15.05 (+1.1%), Pass 2 22.16 -> 14.48 (-34.7%)
    • queues d=8: Pass 1 23.92 -> 24.18 (+1.1%), Pass 2 24.94 -> 24.68 (-1.0%)

Keep the 64-bit compute quarantine mask and the render quarantine fallback from main.

Signed-off-by: DjDeveloperr <hey@djdev.me>
@github-actions github-actions Bot added needs-hw-row No hardware row at the PR head (bot) and removed merge-conflict Conflicts with the base branch (bot) labels Dec 3, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Forward-merged current main c77250fb4a9d as 6c07506a3214 (tree 75506b8d9441). The only conflict was in g16/slots.rs. #4185 narrowed the old 32-unit caller with a cast after widening the shared ledger. This series needs all 64 bits, so the merge keeps the existing u64 compute mask and retains #4185's render-tier fallback.

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 W=1 build of drivers/gpu/drm/asahi/ linked aurora.o (44 Rust warnings, zero errors). The Asahi M4 host suite passed 27/27, and the G16 VM-sharing control passed and caught all three mutations.

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.

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Landing receipt for 6c07506a3214. Independent review checked the conflict resolution and found no blockers: compute masks remain u64 through the two tiers, the upper-pipe shift and the width limit. The render-tier fallback from #4185 is intact. The J773g and J516s receipts cover this compute path, and the posted tree comparison accounts for the main changes.

I rebuilt drivers/gpu/drm/asahi/ with arm64 LLVM 23.1.3, Rust 1.100.1 and W=1 on c77250fb4a9d and this head using byte-identical configs (dfcea7cdff48…). Both linked with the same 44 warnings. The 38-warning #3490 reference enabled G18, M5 and M3_T8122. Compared with that reference, our config has nine warnings the reference did not emit and omits three it did emit. This PR adds zero warnings. The Asahi M4 host suite passed 27/27 and the VM-sharing control rejected all three mutations.

The current main d140c540ea9d adds only #4213's PCIe file to the tested head. The landing tree is baa76bf559f7 and has the same Asahi sources as the checked head.

@DjDeveloperr
DjDeveloperr merged commit 2142a5e into main Dec 3, 2026
10 checks passed
@DjDeveloperr
DjDeveloperr deleted the perf/g16-compute-cu64-cached-uma branch December 3, 2026 20:03
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) blast:all Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants