Skip to content

drm/asahi: stop G15S in prepare and preserve firmware SRAM - #3813

Merged
DjDeveloperr merged 3 commits into
mainfrom
feat/asahi-g15s-t6030-s2r
Dec 2, 2026
Merged

DjDeveloperr merged 3 commits into
mainfrom
feat/asahi-g15s-t6030-s2r

Conversation

@DjDeveloperr

Copy link
Copy Markdown
Contributor

What: Stop G15S during suspend prepare, save its firmware SRAM before power-down, and restore it before restarting the ASC. Keep the firmware stopped after a refused sleep until a real wake. Use thermal zones when PMP has no GPU telemetry entry. This series uses the qualified prepare path without bring-up parameters or PMU scratch writes.

Tested: Strict checkpatch and whitespace checks passed. AArch64 built the Aurora module object and PMP telemetry object. The GPU module build emitted the same 38 warnings as its parent. Both PMP GPU-vote host runs passed.

J516s, integrated kernel af2647f710fd, direct-t357h-02: the G15S firmware stopped in prepare and recovered after both wakes. Vulkan produced the expected render checksum, the GPU returned to ACTUAL 0, and the sensor, fault and recovery counters stayed unchanged. The second RTC latch check failed.

Risk: Two-way door. The prepare stop and SRAM region are selected by the G15S match data. The C glue and cooling fallback are shared.

Not yet: Hardware rows at this head on J516s and another generation, including an aborted suspend and a real wake, and independent review. Stacked on #3806 for the shared RTKit mailbox interface.

@DjDeveloperr
DjDeveloperr marked this pull request as ready for review December 1, 2026 17:02
@DjDeveloperr
DjDeveloperr requested review from a team as code owners December 1, 2026 17:02
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

J516s t358b-01, integrated kernel 88015f7de308: after 180.08 s of physical RTC deep sleep, G15S firmware returned in 5,070 µs; the render ordinal advanced from 404 to 858, GPU health reported zero failures, and vulkaninfo ran. The GPU scratch byte was unchanged. The second systemctl attempt was denied before suspend. Exact-head and peer GPU hardware rows remain open.

@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) area:platform Area from CODEOWNERS (bot) ci-failing A check failed at the PR head (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 Dec 1, 2026
@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Merge readiness at 51dcfeaa: ready to merge

Check Detail
CI at head ok 2 checks passed
Review ok approved by satchlj
Requested changes ok none
Hardware row at head ok comment at 51dcfeaa
Conflicts ok none
PR text ok Risk: two-way · . The prepare stop and SRAM region are selected by the G15S match data. The C glue and cooling fallback are shared.

Areas: area:gpu, area:platform, area:rust
Merge: gh pr merge 3813 --merge (Owners and Core through the bypass: add --admin).

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

@github-actions github-actions Bot removed the ci-failing A check failed at the PR head (bot) label Dec 1, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

J516s (T6030, M3 Pro) hardware qualification PASS for exact head 970b014fc43c9321a48467767b8ca8d4c7328865 (qualified unchanged inside the integrated #3818 T6030 S2R candidate e9ce12c1c2381a20e24ea1ed3ebf19a02ae7f24f, run pr3818-qual-03, 7.3.0-t6030s2r #64, boot=e8c203da-da14-410c-9946-25636a7b8481):

  • 2 consecutive same-boot zero-flag production deep-sleep cycles: resumes 0 -> 1 -> 2 (90.06s + 59.31s, NUB.SPMI0.SW3, MBSE 0x10650, 0 suspend/resume priority 0–3 kernel errors, all 5 PMU scratch regions byte-identical to stock boot).
  • Scoped verification: PMP supplier / coprocessor wake coordination (PMP wake 0x4d0 6us / 0x4c8 8us, 10 coprocessors up and stopped on both cycles).
  • Clean stock handback: verified back on stock 7.3.0 (boot=428632eb-f34e-427f-8014-cd7167d9cea1, both ESPs efab68fa..., empty grubenv, 0 failed units). Non-T6030 shared-driver peer hardware rows remain tracked separately before merge.

@github-actions github-actions Bot added area:rust Area from CODEOWNERS (bot) needs-hw-row No hardware row at the PR head (bot) and removed needs-hw-row No hardware row at the PR head (bot) labels Dec 1, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Added 35b425b2a611 to keep G16/G15S GPU firmware parked across dark wakes (with a PM_POST_SUSPEND safety net and was_dark SRAM restore) and expose rust_helper_pm_dark_wake(). Verified in a 600 s J516s physical deep-sleep soak across a macsmc dark wake at 492.563 s plus 3×20 s rapid cycles.

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

Copy link
Copy Markdown
Contributor Author

J516s hardware verification for exact head 35b425b2a611d37d5d2c656b8305e5f846803c17:

  • Verified in merged T6030 S2R candidate (098d2b244e078adb3b5b9c23f220ef84fb76ab0a, boot f713a241-9f3e-4536-bd6d-c27ec12643b1): GPU firmware restarted in 4771 us after wake; GB_VERIFY=1 gpubench-vk --test render.mdi passed before and after 2 physical deep-sleep cycles (crc: 06f8412a, valid: true, depth 1 & 4) with 0 GPU faults.
  • Dark-wake parking path also verified live during the 600 s soak (f1678207-2630-47e5-a754-9d28f813f331): aurora-g16 stayed stopped across the 492.563 s dark wake, re-entered sleep cleanly, and restarted in 4901 us on final wake.
  • Stock 7.3.0 restored (boot_id=5c2faf10-ca29-4e2e-8b48-0b040cc2a613).

Stop the T6030 GPU before the firmware sleep starts and keep its
SRAM data before power is lost. Leave the firmware stopped across
a refused sleep and restore it on a real wake. Let thermal zones
provide cooling when the PMP lacks the GPU telemetry entry.

Signed-off-by: Diljit Singh <hey@djdev.me>
When the system wakes into a dark wake (pm_dark_wake()), avoid restarting
the G16/G15S GPU firmware only to stop it again milliseconds later for
re-entry. Record sleep_dark_held in Shared while parked so the re-entry
prepare path only lowers the GFX power domain without clobbering the saved
awake power word, and ensure SRAM is restored on the eventual full wake
(including for SleepStop::Commit devices).

Register a devm PM_POST_SUSPEND notifier as a safety net so if a dark-wake
re-entry aborts before reaching the GPU's .prepare/.complete callbacks,
the GPU firmware is still restarted cleanly before userspace resumes.

Expose pm_dark_wake() via rust/helpers/suspend.c.

Signed-off-by: Diljit Singh <hey@djdev.me>
Keep the two-argument commit registration used by the T8122 runtime.
Give the Rust G16 backend a separate entry point for the G15S quiet
stop and SRAM options. The default registration still skips SRAM
saving and leaves the PMP vote alone.

Signed-off-by: Diljit Singh <hey@djdev.me>
@DjDeveloperr
DjDeveloperr force-pushed the feat/asahi-g15s-t6030-s2r branch from 35b425b to 51dcfea Compare December 2, 2026 06:45
@github-actions github-actions Bot added the needs-hw-row No hardware row at the PR head (bot) label Dec 2, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

J714s (M5 Pro, T6050) second-generation peer-control S2R row at exact unchanged head 51dcfeaaaba8fa673da4dbdc4e3d169d3cba90b9: PASS.

Candidate: refs/aurora/m3-lead/shared-control-batch-20261202-v2 (59b414a7cbe3d97067e2b7c2d76359be8cc29af5 on main cf03d96bf209, all 13 PR heads included unchanged as merge parents).

  • Kernel: 7.3.0-m5-s2rbatch-59b414a7 (boot_id 158c330e-c583-4032-a79d-f092b07c7828, 16 SLC planes, SEP writes ENABLED, 0 GPU/MMU/DART/IOMMU/DCP/ISP/RTKit/BCM4377 faults).
  • Physical PMU RTC deep sleep/wake: rtcwake -d /dev/rtc1 -m mem -s 30 exited 0, suspend_stats 0 -> 1 (fail 0), firmware boot object resumes 0 -> 1 (AP 76 NUB.SPMI0Sw3IRQ / rtc), elapsed 30.492 s, same boot_id pre/post.
  • Handback: clean return to stock 7.3.0-m5-pr67 (boot_id 6c48d997-34de-4cbd-abe5-b8ecd12b4a7d, 13/13 slot+Stage2 hashes, 71/71 ICD hashes, pacman -Qkk mesa 0 altered).
  • Subsystem evidence: Shared GPU sleep peer control on J714s (G17S): 16 SLC planes, both M5 initdata acks, clean commit stop (GFX 0x1000030f, PMP request withdrawn: 0) & wake (0x1f0403ff), online=1 (crashed=0, quarantined=0, leaked=0), 0 GPU/MMU faults; GPUBench RT 3/3 b541b83e pre-sleep (402.5 FPS, GPU 430.5 FPS), post-wake (402.7 FPS, GPU 430.7 FPS), stock (403.3 FPS, GPU 430.9 FPS).

@github-actions github-actions Bot removed the needs-hw-row No hardware row at the PR head (bot) label Dec 2, 2026
Base automatically changed from feat/apple-sio-rtkit-held-rx to main December 2, 2026 08:53
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

J516s (M3 Pro, T6030) integration receipt on 7.3.0-m3-s2r-gae108162ce24 (origin/main 973ced809eba + T6030 S2R stack, zero-flag cmdline, mem_sleep=s2idle [deep], boot_id=43e0a6d2-5f93-47c4-b016-999232b43404, 2 consecutive 30 s physical deep sleeps via rtcwake -d rtc0 -m mem -s 30): suspend_stats/success 0 -> 1 -> 2, fail=0, boot object resumes 0 -> 1 -> 2, 0 failed systemd units.

PR #3813 exact head: 51dcfeaaaba8

  • Cycle 1: GPU stopped for the sleep: SRAM 0, idle 0 in 200 us, ... -> GPU firmware back in 4811 us.
  • Cycle 2: GPU stopped for the sleep: SRAM 0, idle 0 in 200 us, ... -> GPU firmware back in 4846 us.
  • Post-wake gpubench-vk --test transfer.ops --depths 4 --runs 2 on Apple M3 Pro (G15S B1): 45.61 us/submit, 91.97 GB/s, CRC 55a4e6b1 (valid: true), 0 GPU faults.

@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 51dcfea

Checked:

  • Other GPUs: the two-argument asahi_g16_commit_prepare() stays as a wrapper (quiet=false, no SRAM save), so T8122 (m3_drm.rs) registers as before. The asahi_g17_commit_free() line only acts when g16_sram_saved is set. apple_pmp_gpu_get() is only used by g16/glue.c. Only the t6030 config gets stop-in-prepare + SRAM save. G13/G14G/G15G/G17 paths are unchanged.
  • #3865 hold: this PR doesn't touch sleep_pd.c/driver.rs. A trial merge with main is clean and keeps asahi_sleep_pd_suspend_noirq_hold().
  • Error/abort paths: the receive-interrupt hold and resume pair once per stop on real wake, refused sleep, dark park + re-entry, and re-entry failing before or after .prepare (the PM_POST_SUSPEND notifier restarts the firmware). Registration failure drops the snapshot and the PMP vote.
  • SRAM: length and alignment are checked, the mapping is bounds-checked, the 128 KiB kvmalloc buffer is reused, the save and restore lengths must match, and everything is under the Shared::state mutex (the sleeping calls are legal).
  • rust/helpers/suspend.c wraps an inline that exists with and without CONFIG_PM_SLEEP. Provenance is our own macOS MMIO/s2r traces, with no blobs or disassembly.

Follow-ups (not blocking):

  1. g16/boot.rs:907 sets start-policy word 1 = 1 whenever layout.powered is set. That includes the 27.2 G16 layout (0x648), so J713 (T8132) gets it too, along with the dark-wake parking. There is no J713 row at this head. Post a J713 G16 27.2 boot+wake row, or gate both to T6030.
  2. A sleep refused after the GPU's .prepare leaves T6030's firmware stopped until the next real sleep. That is intended per the PR and is not a regression (main refuses deep on T6030). The SleepStop::Prepare doc in g16/hw.rs says it "restarts warm after every sleep, real or refused", which contradicts this. The aborted-suspend row is still "Not yet".
  3. The PM notifier is registered in Gpu::new before the driver data is set, and sleep_gpu() has no NULL check. The window is narrow (POST_SUSPEND during probe or unbind).
  4. The static asahi_g16_sram buffer and ioremap leak on each DRM_ASAHI module unload.
  5. Consider refusing the sleep when the SRAM save fails, instead of stopping anyway.

@satchlj satchlj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Verdict: APPROVE at 51dcfeaa

Reviewed the full diff across g16/{boot,hw,mod,sleep}.rs, g16/glue.c, g17/sleep.{c,h}, pmp-telemetry.c, and rust/helpers/suspend.c:

  • SoC scoping & shared paths: SleepStop::Prepare, sleep_quiet_stop, and sleep_sram (0xd60000, save 0x20000, restore 0x14000) are enabled only on t6030; t8132 and t8122 remain SleepStop::Commit with quiet: false and sleep_sram: None. asahi_g16_commit_prepare() stays a wrapper preserving existing callers. asahi_g16_tvm_enable() checks apple,t8132-gfx-tvm and returns 0 when absent. apple_pmp_gpu_get() checks device_is_bound() under device_lock so a bound PMP without telemetry returns -ENODEV instead of deferring forever, letting asahi_g16_cooling_register() fall back cleanly to thermal-zone backstop cooling.
  • SRAM & dark-wake lifecycle: asahi_g16_sram_save() validates non-zero length, restore_len <= save_len, and 8-byte alignment, runs under Shared::state, and clears asahi_g16_sram_restore_len both on abort (!c->ran) and after restore before ASC_RUN. Dark-wake parking (sleep_dark_held + PM_POST_SUSPEND sleep_dark_finish safety net) pairs apple_rtkit_hold_rx() and apple_rtkit_resume_rx() once per stop across real wake, refused sleep, dark-wake re-entry, and aborted re-entry.
  • CI & hardware evidence: CI passes at 51dcfeaaaba8, with exact-head J516s 2-cycle physical deep-sleep + post-wake gpubench-vk PASS (#issuecomment-7343746020), prior J516s 600 s dark-wake soak PASS (#issuecomment-7329205610), and J714s (G17S) second-generation peer-control S2R PASS (#issuecomment-7339043925).

Non-blocking follow-ups:

  1. g16/boot.rs:907 (policy.words[1] = 1 whenever layout.powered.is_some()) and dark-wake parking in g16/sleep.rs also apply to T8132 (G16) on 27.2; please post the queued G16 27.2 boot+wake check (or gate to T6030 if G16 objects).
  2. g16/mod.rs:754 registers the PM_POST_SUSPEND notifier in Gpu::new before dev_set_drvdata completes, and sleep_gpu() does not null-check dev_get_drvdata(dev) — worth guarding that narrow probe/unbind window in a follow-up.
  3. Update the SleepStop::Prepare doc comment in g16/hw.rs to match the refused-sleep behavior, and free/unmap static asahi_g16_sram / asahi_g16_sram_io on module unload.

@github-actions github-actions Bot added ready-to-merge Meets the merge policy: merge it (bot) and removed needs-review No approving review from Core or Omarchy Mac yet (bot) labels Dec 2, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

J773g (G16 27.2) hardware validation PASS on exact head 51dcfeaaaba8 merged unchanged onto origin/main (deedd808cefd).

Environment & Build

  • Board: Apple Mac mini M4 (Mac16,10, J773g, T8132, G16G B0, 27.2 stub)
  • Base / Head / Merge: origin/main deedd808cefd51c08ba11350e4990437984e7521 + exact refs/pull/3813/head 51dcfeaaaba8fa673da4dbdc4e3d169d3cba90b9 -> clean merge 1f98d351843eb633b5d0f0147e16df264c73fdda
  • Image SHA-256: 483912dcd1f9ec0e59c7f4f04c0f48fc4fd0af8be135346fc1e0a5e71fbb0a52
  • Running kernel: 7.3.0-j773g-pr3813-51dcfeaa (default stock cmdline)
  • boot_id: 62af4d9b-8d07-4304-bc06-be15c85fbe72

Results

  • Pre-s2idle GPU smoke: Apple M4 (G16G B0) (0x10005/0x8132, Borealis Mesa 26.3.0-devel git-d4ad4a4dce, API 1.4.363), dEQP-VK.api.smoke.* 8/8 PASS, gpubench-vk --verify render.light 131.10 us (crc f4fcc288, valid=true) & compute.light 110.47 us (crc f85c92cb, valid=true), S10, health: failed 0, recoveries 0.
  • 1x s2idle cycle: rtcwake -d /dev/rtc1 -m freeze -s 5 succeeded (suspend_stats/success: 0 -> 1, fail=0).
  • Post-s2idle GPU smoke: dEQP-VK.api.smoke.* 8/8 PASS, gpubench-vk --verify render.light 132.35 us (crc 1894a4fe, valid=true) & compute.light 107.85 us (crc 5f66f115, valid=true).
  • Cumulative GPU & kernel health: 62,469 jobs / 62,477 job_cmds, health: failed 0 errno 0 degraded 0, recoveries 0, hang_kills 0, quarantined 0, FAILED_UNITS=0, 0 kernel WARNs, BUGs, or Oops.

@DjDeveloperr
DjDeveloperr merged commit 37916aa into main Dec 2, 2026
6 checks passed
@DjDeveloperr
DjDeveloperr deleted the feat/asahi-g15s-t6030-s2r branch December 2, 2026 14:22
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) area:platform Area from CODEOWNERS (bot) area:rust Area from CODEOWNERS (bot) door:two-way Revertible or not, from Merge risk (bot) ready-to-merge Meets the merge policy: merge it (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants