Skip to content

drm/asahi: g16: keep a VM's last PB epoch until its next render retires - #3101

Merged
DjDeveloperr merged 3 commits into
mainfrom
djdev/g16-pm-vm-last-epoch
Nov 25, 2026
Merged

DjDeveloperr merged 3 commits into
mainfrom
djdev/g16-pm-vm-last-epoch

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes a G16 multi-client Parameter Manager (gPM_SP(0), unit 0xe0) "write unmapped" GPU fault triggered under KWin + multi-process depth-16 render pressure when warm PB slot reuse (e30cdb92b4f5, #3043) displaces a live VM's warm PB slot and unmaps its PB page list before the VM's next cold InitBM runs.

  • Retains each VM's last successfully retired PB epoch + TTBAT binding in Pools::vm_last until its next render retires, reclaiming closed-VM entries once drained and exposing the kept counter in debugfs pb.
  • Review follow-up (f445466d8f881c8cdcf3c9331afb408c0ecd28f4): canceling a closed VM's final unpublished render wakes idle reclaim so its displaced vm_last epoch and ASID are released promptly, and a passed abort returns the discarded suffix's render credits while retaining published backing in quarantine.

Risk

  • Risk class: Two-way (scoped to drivers/gpu/drm/asahi/g16/; revertible; does not change UAPI or non-G16 drivers).
  • Affected scope: G16 Macs (M4 / T8132, G16G B0).

Tested

  • Exact head f445466d8f881c8cdcf3c9331afb408c0ecd28f4:
    • Host unit/resource tests: 26/26 host scripts + 72/72 resource tests PASS (including both review-fix regressions).
    • J773g (T8132, G16G B0) combined 14-PR train row (#2741..#3087, #3046, #3101, candidate b4a8df87339a): 13/13 depth-16 render.light procs with KWin active (pb kept 2 -> 254), 10,639/10,639 Vulkan CTS recorded (7,358 Pass, 3,281 NotSupported, 0 fail), 202/202 full GPUBench, 1/1 compute.long, 3/3 queue.exhaust, 1/1 s2idle + 2/2 post-wake smoke, 0 GPU faults / 0 recoveries / 0 hang kills (drm/asahi: g16: keep a VM's last PB epoch until its next render retires #3101 (comment)).

Not yet

  • None for G16G B0 merge readiness (#3042 and #3043 also have exact-head Neo J700 G17P B1 second-gen PASS rows).

Compute commands queued behind compute flights of any VM, so the CDM
pipes ran dispatches of different VMs at once, without a barrier
between them. With six dEQP-VK processes, about one draw in 285 of
dEQP-VK.glsl.texture_functions.* then read back zero or a partial
image, with no fault and no recovery: the readback copy, running beside
another VM's compute, lost its results. One process never fails, every
failed case passes alone, and the failures stop entirely once compute
waits for other VMs' flights, over three full runs. gpubench
compute.long showed the same loss: a ray-query dispatch that another
VM's compute overlapped was reported complete with its results
unwritten.

Let compute publish behind its own VM's flights only, on either pipe,
as it already did behind another VM's render, and as G15 runs one VM at
a time. Compute of one VM still pipelines on both pipes, and renders
still pipeline across VMs.

Signed-off-by: Diljit Singh <hey@djdev.me>
@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) blast:m4 Macs affected, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot) labels Nov 25, 2026
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Merge readiness at f445466d: not ready yet

Check Detail
CI at head running running: pr-text / pr-text
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 f445466d, a Mac and a result in the PR body or a comment
Conflicts ok not computed yet
PR text ok Risk: two-way · Risk class: (scoped to drivers/gpu/drm/asahi/g16/; revertible; does not change UAPI or non-G16 drivers). - Affected scope: G16 Macs (M4 / T8132, G16G B0).

Areas: area:gpu

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

With the display manager running, gpubench-vk render.light kind=tri
--mode procs at depth 16 faults in 5 to 11 of 13 runs on J773g, and the
GPU can be lost for the rest of the boot. With the display manager
stopped, the same kernels pass. Every fault has one shape:

  fault bank 3: status 0x8f81fdc021 va 0x704000cf00
    (write unmapped level 0 unit 0xe0 ctx 62)
  attribution: busy=0 ctx=62 flight_matches=1 live_vm=Some(108)
    event=0xffffffff flights=1

Unit 0xe0 is gPM_SP(0), the parameter manager. The DYNAMIC window holds
only PB page lists: the faulting addresses are records 16 to 976 of a
VM's first (0x7040000000) or second (0x704000c000) page list. The
context is an open client's, and the only flight is that client's cold
InitBM render.

kwin and the login greeter's VMs move the round-robin [home, alt] PB
slot pairs, so 16 clients and those VMs share 16 warm slots and take
displaced slots from each other while all are open. When another VM's
epoch retires on slot k, retire_flight() replaces owners[k] and the
open VM's epoch goes, unmapping its page list. At that VM's next InitBM,
the parameter manager writes back to the page list of the manager the
context used last, through that context, and the list is gone.
Commit 047b934 ("drm/asahi: g16: keep closed VMs' PB epochs until
their slot is replaced") covered only closed VMs.

Keep each VM's last retired epoch in Pools, indexed by its TTBAT slot,
which the entry keeps bound. A newer render of the same VM replaces it
once that render fully retired; a failed render keeps it. A closed VM's
entry goes once none of its accepted renders is unpublished or in
flight, so closed VMs pin nothing extra. An open VM whose slot was taken
keeps one more epoch (two 32 KiB lists and its records) until its next
render retires. Count such replacements as "kept" on the debugfs pb
line.

Add host tests for the open-VM sequence and the closed-VM release, and
for the extra reclaim pass a closed VM's entry asks for.

Fixes: e30cdb9 ("drm/asahi: g16: scale warm render PB/UMA slots to 16 and keep pass slots VM-affine")
Signed-off-by: Diljit Singh <hey@djdev.me>
@DjDeveloperr
DjDeveloperr force-pushed the djdev/g16-pm-vm-last-epoch branch from 30bb38a to 990b848 Compare November 25, 2026 00:06

DjDeveloperr commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor Author

Verdict at f445466: FINISH, then merge

Both code blockers are resolved. drivers/gpu/drm/asahi/g16/resources.rs:1037 schedules reclaim after a closed VM's final reservation is released. drivers/gpu/drm/asahi/g16/poll.rs:1689 returns discarded suffix credits once while preserving the published quarantine backing.

All 26 asahi-m4 host scripts passed at f445466d8f881c8cdcf3c9331afb408c0ecd28f4, including all 72 resource tests and both new regressions.

The two-way Risk classification is present. Correct the full SHA in Tested and Not yet to the one above, and record the J773g result at that head before merge.

…fix credits

Address two review findings on the per-VM last PB epoch retention:
- When a closed VM's final unpublished render reservation is cancelled, wake
  idle closed-VM reclaim so its displaced vm_last epoch and ASID do not stay
  pinned while idle.
- When recovery retains an aborted job for quarantine and discards its
  unpublished suffix, return the discarded suffix's render credits while
  keeping the published quarantine backing intact.

Add host regression tests covering both paths.

Signed-off-by: Diljit Singh <hey@djdev.me>
@github-actions github-actions Bot added door:two-way Revertible or not, from Merge risk (bot) and removed blast:m4 Macs affected, from Merge risk (bot) needs-template PR body lacks Tested or Risk (bot) labels Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

J773g combined G16 train PASS on Apple M4 (T8132, G16G B0).

Candidate b4a8df87339aba8e7c39323d031f845293235cc1 merges #3042, #3101 and #3046 into main at ef99c025131c, which includes #3098. This merge order retains all 14 exact PR heads. The candidate built with 0 Rust errors. uname -r reported 7.3.0-ARCH-m4g16train, and the live aurora.ko Build ID matched e419e356594f113eb8748c3d1ea55562f0e76e68.

  • The compiled J773g DTB booted over wld0 with zero DTB workarounds. GPU features included RENDER_RAY_QUERY, BOUNDED_AS_BUILD, CUMULATIVE_SIGNALS and VDM_USC_INVALIDATE. KWin stayed active, /lib pointed to usr/lib, and failed units stayed at 0.
  • render.light kind=tri, depth 16, --mode procs passed 13/13 (10 short, 3 default). Debugfs pb kept rose 2 → 254.
  • Vulkan CTS recorded 10,639/10,639 cases, with 7,358 Pass, 3,281 NotSupported and 0 failures. api.smoke 8/8 Pass, ray-query subset 1,615 Pass + 225 NotSupported, compute subset 745 Pass + 34 NotSupported, and vk-mustpass-short 87/87 Pass. The six-process glsl.texture_functions.* run recorded 4,903 Pass + 3,022 NotSupported, with cross-VM drain holds rising 1,370 → 17,918.
  • GPUBench VK full passed 202/202, compute.long passed 1/1 (268 iterations, 3,014,901 checks), and queue.exhaust passed 3/3 (40 usable queues and 181 checks per run).
  • rtcwake -d /dev/rtc1 -m freeze -s 10 passed 1/1 on the focused rerun, followed by 2/2 GPU smoke (render.light and compute.light). The first sleep had also resumed successfully. The benchmark rejected a launcher flag, so the focused rerun used the same kernel kit and supported flags.
  • Across the runs, GPU faults, recoveries and hang kills were all 0. Restored 7.3.0-ARCH-m4prod25d with aura-383-r3-stage2.bin, verified KWin, 0 failed units and /lib -> usr/lib, and removed the candidate modules.
All 14 exact PR heads verified as merge ancestors

@github-actions github-actions Bot added blast:m4 Macs affected, from Merge risk (bot) needs-hw-row No hardware row at the PR head (bot) labels Nov 25, 2026
@DjDeveloperr
DjDeveloperr changed the base branch from djdev/g16-no-cross-vm-compute to main November 25, 2026 01:38
@DjDeveloperr
DjDeveloperr requested review from a team as code owners November 25, 2026 01:38
@DjDeveloperr
DjDeveloperr merged commit b8313dd into main Nov 25, 2026
5 of 6 checks passed
@RyanTheTide
RyanTheTide deleted the djdev/g16-pm-vm-last-epoch branch November 27, 2026 13:21
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:m4 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.

1 participant