Skip to content

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

Open
DjDeveloperr wants to merge 7 commits into
mainfrom
perf/g16-compute-cu64-cached-uma
Open

DjDeveloperr wants to merge 7 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.

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%
  • J773g gate boot (kit-r2c2, 198,348 jobs / 348,964 commands / job_max 64, 0 kernel findings, 0 GPU faults/recoveries/hangs):
    • 35-VM concurrent live Vulkan compute stress (vk-uma-quarantine clean 35): pre_ok=35 post_ok=35/35 fresh_ok=1.
    • VK-GL-CTS compute + synchronization subsets (--jobs 1, excluding drm/asahi g16: dEQP-VK.synchronization*multi_queue* faults the GPU and fail-stops it on J773g (main 61c7b88a) #3201 multi_queue / cross_instance, 16,500 cases executed in slot): 8,088 Pass / 8,412 NotSupported / 0 Fail, recoveries=0.
    • s2idle suspend/resume: woke cleanly after 13 s (S2IDLE_POST success=1 fail=0, DELTA_ERR=0), post-wake 7/7 suite passed (including CRC-verified render.postfx MSAA 4x, compress.bw 1440p, render.mdi 1024 draws; compute.light d=16 = 22.19 us).

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 eb8c98e6: not ready yet

Check Detail
CI at head running running: apple-build, host-tests, KUnit plan
Review ok approved by RyanTheTide
Requested changes ok none
Hardware row at head no no line with the head SHA eb8c98e6, 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
Bring in main up to 2225082.

Main moved the service stamps out of the ASC-cached notifier pages
into each queue's own uncached user_stamp cell and dropped the notifier
context checks from retirement. With compute fw_stamp now ASC-cached
here, every host read of a compute stamp goes to that cell, as main
already does for the render FS stamp: the retirement gates, the oldest
stamp check, progress sampling, the recovery snapshot and the report.
The retirement gate read is the service stamp itself, so the second
read of the same cell after the barrier goes away.

QueueSession::new_with() keeps main's Option<Class>; compute passes
Some(Class::FwCached). The private factory holds this branch's
ComputeUmaPool beside main's RenderUmaPool and PbRecordPool.

Selftests: the mocks read the compute user_stamp cell, keep main's
render user_stamp checks, and use the wider sizes of this branch.

Signed-off-by: DjDeveloperr <hey@djdev.me>
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Forward-merged main: new head 323200454971 (merge of main 2225082e1d18).

Conflicts (9 files):

  • Main moved the service stamps out of the ASC-cached notifier pages into each queue's own uncached user_stamp cell and dropped the notifier context checks. Main already does this for the render FS stamp. With compute fw_stamp now ASC-cached here, every host read of a compute stamp goes to user_stamp: the retirement gates, oldest_stamp_reached(), progress sampling, the recovery snapshot and the report line. The gate read is now the service stamp itself, so the second read of the same cell after rmb() goes away. The auto-merged notifier_page::COMPUTE_STAMP reads would not have built, because main removed that constant.
  • QueueSession::new_with() keeps main's Option<Class>, and compute passes Some(Class::FwCached). The private factory holds this PR's ComputeUmaPool beside main's RenderUmaPool and PbRecordPool.
  • Tests: the mocks read the compute user_stamp and keep main's render user_stamp checks, with this PR's sizes (16 pipes, 64 units, 64 flights). Removed a duplicate AtomicBool import, which main's prelude now provides. Also removed main's fw::graph re-export in the stamp-wrap mock: this PR's compute_uma_retired() no longer reads the shared descriptor, so the re-export was unused.

Checks (pc, x86_64 → arm64, LLVM, rustc 1.100.1):

  • linux-build/build kernel --profile asahi <tree> -- modules_prepare drivers/gpu/drm/asahi/ (defconfig + asahi.config): pass, 0 errors. Four dead-code warnings come from this PR's own code and are already there at 1de4e8f8: validate_shared_compute_descriptor has no caller left, SharedComputeUmaInner::pool is never read, and the two slots.rs lease variants are never read.
  • tools/asahi/run-host-tests.py --only asahi-m4: 26/26 pass.
  • tools/asahi/run-host-tests.py --only g16: g16-vm-share-tests 2/2 pass.
  • KUnit: not run locally (the asahi suite needs arm64 QEMU).

Rows: the body's rows predate the merge, which changes the compute retirement reads, so J773g and J516s rows at 32320045 are requested.

@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 2, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

J516s (MacBook Pro 16" M3 Pro, T6030, G15S B1) second-generation row at 323200454971 (merged onto main 105e3fbc6adc): PASS.

  • Kernel / module: 7.3.0-m3-gpu-g105e3fbc6adc with aurora.ko rebuilt from 323200454971 merged onto 105e3fbc6adc (SHA-256 940f0123753d...), boot_id=f153ec72-891c-4634-b625-58a110fc1dab, compared against same-kernel main 105e3fbc6adc (boot_id=3b704c79-537a-40e0-b39c-a89c5ec05ac9). Stock boot.bin, multi-user.target.
  • gpubench-vk compute rows & CRCs (us_per_submit median, main 105e3fbc6adc -> #3340 323200454971):
    • compute.light queue d32: 18.51 -> 15.58 µs (-15.8%), d64: 19.60 -> 15.03 µs (-23.3%).
    • compute.light procs d2: 49.29 -> 49.33 µs, d4: 32.54 -> 30.91 µs (-5.0%), d8: 28.80 -> 27.73 µs (-3.7%), d16: 29.41 -> 25.73 µs (-12.5%).
    • compute.light queues d2: 56.09 -> 54.93 µs, d4: 36.01 -> 35.87 µs, d8: 28.43 -> 27.54 µs.
    • compute.uber queue d4: 1363.64 -> 1363.64 µs (CRC 9963f56c valid); compute.heavy d1 1685.39 -> 1704.55 µs, d4 1470.59 -> 1470.59 µs; transfer.ops d4 86.71 -> 86.66 µs (CRC 55a4e6b1 valid).
    • Render smoke CRCs valid: render.postfx (4707efa8), render.bindless_ubo (57e7bedd), render.deferred msaa4 (5e4130ce).
  • CTS (dEQP-VK.compute.* smoke):
    • dEQP-VK.compute.pipeline.basic.*: 79 Pass, 2 NotSupported, 0 Fail.
    • dEQP-VK.compute.pipeline.indirect_dispatch.*: 24 Pass, 12 NotSupported, 0 Fail.
  • Faults / stats: compute_owners: fresh 0 preparing 0 published 0 retired 64 quarantined 0 reusable 48, compute: count 494088, jobs 495146, recoveries 0, hang_kills 0, health: failed 0 errno 0 degraded 0, 0 GPU faults, 0 quarantines, 0 kernel errors.

@github-actions github-actions Bot removed the needs-hw-row No hardware row at the PR head (bot) label Dec 2, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Verdict at 323200454971: no code blockers. Not mergeable yet: it needs a J773g row at this head.

Blockers

Checked

  • Widths. 64 units, 16 pipes, 64 flights. The compute ring bound (63 × 3 < 256), events 15..=30 in word 1, and the client VA layout (extension records at EXT_COMPUTE_REC_BASE, 26 UMA windows below it) are all asserted at compile time. The unit masks are u64. pick_scs_compute_slots() stays within the 32 UMA slots, so compute_uma_mask()'s cast to u32 loses nothing.
  • ASC-cached records. The shared UMA descriptor is FwCoherent and the compute fw_stamp is FwCached. The host reads neither: retirement, oldest_stamp_reached(), progress and the recovery snapshot read the uncached user_stamp. The firmware barriers still name fw_stamp through its own mapping.
  • Pool lifetime. ComputeUmaPool never unmaps a set. A lease goes back to the pool only when its last holder drops and every published flight retired normally. Slots keeps the lease until another owner takes the hardware slot. A reused set is zeroed and rewritten before first use.
  • Commits. The firmware-disassembly offsets that the earlier review flagged are no longer in any commit message.
Evidence
  • J516s PASS at this head (comment).
  • Hosted CI at this head: apple-build and host-tests passed. KUnit asahi is still queued.

@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 2, 2026
Forward-merge origin/main (6ee70d4) and reconcile multi-render-pair and StampCell changes with the wider compute concurrency (COMPUTE_PIPES=16, COMPUTE_UNITS=64, FLIGHTS=64) and ASC-cached compute fw_stamp changes:

- drivers/gpu/drm/asahi/g16/poll.rs: check compute completion via g.service_stamp().read() (uncached user_stamp) without reading ASC-cached fw_stamp or repeating the service-stamp read.
- drivers/gpu/drm/asahi/g16/recovery/logic.rs: keep RETIRED_COMPUTE_PIPES=16 alongside RETIRED_RENDER_PAIRS=8 and retired_render_stage().
- tools/testing/selftests/drivers/gpu/asahi-m4/test-{poll-retire,progress-wrap,publication,stamp-wrap}.py: combine COMPUTE_PIPES=16, COMPUTE_UNITS=64, FLIGHTS=64, u64 compute slot masks, and compute user_stamp polling with RENDER_PAIRS=2 and indexed render graphs, updating the render pair 1 stage index expectation to 2 + COMPUTE_PIPES.

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 2, 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.

Verdict: MERGE at 78ed224

Checked: The widened slot and quarantine masks, event range, ring headroom and UMA address windows are consistent. Compute progress and retirement read the uncached service stamp, and the shared record lease remains unavailable to the pool until its published flights retire cleanly and the last slot holder drops. Ran five existing host suites at this head against the source they exercise: 271 assertions passed across retirement, progress, publication, resources and stamp wrap. The current commit text omits the private material called out on the earlier head. The dependency #3287 has merged.

RyanTheTide
RyanTheTide previously approved these changes Dec 3, 2026

@RyanTheTide RyanTheTide left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 78ed224. The wider compute limit stays within the slot, ring and address-window bounds. Retirement still reads the uncached service stamp and keeps shared records leased until their flights retire. #3287 has landed.

@github-actions github-actions Bot removed the needs-review No approving review from Core or Omarchy Mac yet (bot) label Dec 3, 2026
Signed-off-by: DjDeveloperr <hey@djdev.me>
With compute fw_stamp ASC-cached, retirement gates compute on the service
stamp alone. A flight that a GPU recovery aborted can keep a stale service
stamp: it then stays pending for good, never reaches the abort grace, and
the administrative deadline fail-stops the GPU for every client. Before
this branch, the uncached fw_stamp gated retirement and the stale service
stamp led to the abort.

Do what suspect renders do. Allocate compute fw_stamp as a device-lifetime
FwCoherent object, the class render fw_stamp[1] already has, and let a
suspect flight whose service stamp is stale sync and check it. A still
running suspect stays pending, a passed one starts the abort grace, and a
full receipt still needs the service stamp. Other flights never read
fw_stamp, as before.

Signed-off-by: DjDeveloperr <hey@djdev.me>
@github-actions github-actions Bot added the needs-review No approving review from Core or Omarchy Mac yet (bot) label Dec 3, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

New head eb8c98e615c0: main (622a059b0df6) merged, plus one fix in the recovery path. The earlier approvals at 78ed2243 are dismissed by the push, so this needs a new review.

What was wrong. With fw_stamp ASC-cached, retirement waited for the compute service stamp alone. A command that a GPU recovery aborts can keep a stale service stamp. Main then uses fw_stamp as the proof that the stage passed, waits out the abort grace and fails only that job. At 78ed2243 such a flight stayed pending until the command deadline, and the driver fail-stopped the GPU for every client. It's the same bug #3503's review found for renders.

A host test shows it: the first new case below passes on main's poll.rs and fails on 78ed2243. I don't know how often the firmware leaves the stamp stale; none of this PR's rows had a recovery.

Fix (poll.rs, graph.rs). The same rule renders have. Compute fw_stamp becomes a device-lifetime FwCoherent object (same firmware leaf, host mapping cacheable). Only a flight that a recovery marked suspect and whose service stamp is stale syncs and reads it. A suspect that is still running stays pending. A full receipt still needs the service stamp, and normal flights never read fw_stamp.

Checks (local, pc):

  • asahi-m4 host tests 26/26, with two new cases (aborted, still running, pipelined, and innocent suspects). Six mutations of the fix all fail them.
  • Full host suite 1027/1028. The one failure, apple/pmgr-inherited, is main's and fixed in main since.
  • Arm64 W=1 of drivers/gpu/drm/asahi/ builds. The three new dead-code warnings are this PR's own (validate_shared_compute_descriptor, the two lease variants) and go away with drm/asahi: g16: keep compute UMA managers bound and ASC-cached #3695.
  • checkpatch --strict clean.

Order: after #3695 and #3699. Both make the compute UMA descriptor ASC-cached, in different ways. #3695's per-slot records replace this PR's ComputeUmaPool; the widths, masks, VA layout, fw_stamp and the fix stay. That merge is written and tested with all three PRs (26/26, W=1 with no new warnings) and becomes this PR's forward merge once they land.

Cost to know about: a VM that keeps compute queued now gets 62 extension units instead of 22, about 12 MiB more client memory (from the allocation sizes, not measured).

Rows owed: J773g and J516s on the composite with #3695/#3699, including a recovery with innocent compute running (this PR has never had one). The J773g comp6b kit carries 78ed2243, so its boot doesn't cover this head. T8122 has no row.

@RyanTheTide RyanTheTide left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed eb8c98e. Normal retirement retains the service-stamp requirement. A recovery-suspect flight with a stale service stamp can use the synchronized stage witness to reach abort grace after queue retirement, while that witness alone cannot establish clean completion. The regression fixture covers the previously stuck recovery path.

@github-actions github-actions Bot removed the needs-review No approving review from Core or Omarchy Mac yet (bot) label Dec 3, 2026

This branch has not been deployed

No deployments
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)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants