Skip to content

drm/asahi: m3: support firmware-driven deep sleep on T8122 - #3504

Merged
satchlj merged 6 commits into
aurora-silicon:mainfrom
satchlj:feat/m3-gpu-deep-sleep
Dec 2, 2026
Merged

satchlj merged 6 commits into
aurora-silicon:mainfrom
satchlj:feat/m3-gpu-deep-sleep

Conversation

@satchlj

@satchlj satchlj commented Nov 28, 2026 •

Copy link
Copy Markdown
Member

What: Add firmware-driven deep sleep (mem/deep) suspend/resume support for the Apple M3 (G15G / T8122) GPU driver (aurora), deferring the GPU stop to apple-sleep's commit hook (asahi_g16_commit_prepare / asahi_g17_commit_finish, matching G16/G17 and PMP) so pre-commit aborted suspends return with live GPU submission on the same boot, and warm-restarting RTKit on firmware wake without tearing down DRM/userspace state.
Tested: J613 M3 Air 13" at 334cbace033d (apple_sleep.deep=1): 3/3 pre-commit aborts (dry-run, pm_test=devices, pm_test=core) reopened submission immediately with Borealis Vulkan and glmark2-es2-drm (939–959 score, +1895–1932 retired GPU jobs) before any second suspend; 3/3 consecutive real mem/deep cycles (boot object resumes 0 -> 1 -> 2 -> 3), GPU firmware back in 879–1834 µs, live Borealis Vulkan and 941–952 glmark2-es2-drm; 1/1 s2idle cycle (+462 GPU jobs); m3-sleep-steps-tests.py 6/6 (including 5 negative-control mutations); 0 failed units.
Risk: two-way · M3 (T8122)
Not yet: M3 Pro / M3 Max (T603x) deep sleep (tested on T8122 J613); default-cmdline deep sleep without apple_sleep.deep=1 (tracked separately).

Details
  • Prepare: Drain active GPU work, pause and flush completion, drop the CLPC performance request, and register the commit-time stop via asahi_g16_commit_prepare() (keeping the PMP GPU vote across sleep, matching G16). Hold the attached power domain across suspend_noirq() via asahi_sleep_pd_suspend_noirq_hold(dev, hold_firmware).
  • Commit stop: After every refusal passes, apple-sleep runs asahi_g17_commit_stop() (polled RTKit idle, mailbox RX off, ASC run bit clear, PS_GFX lower) before stopping PMP.
  • Complete:
    • Pre-commit abort (!stopped && !real_wake): firmware never stopped; reopen submission immediately on the same boot.
    • Real firmware wake (real_wake): raise PS_GFX, restore automatic power management, and warm-restart RTKit without tearing down DRM/userspace state.
    • Post-commit unwind without firmware wake (stopped && !real_wake): raise PS_GFX and hold submission closed until the next real deep sleep lowers PS_GFX and restarts firmware on wake.
  • Host tests: drivers/gpu/drm/asahi/m3/m3_sleep_steps.rs and tools/asahi/m3-sleep-steps-tests.py (registered in tools/asahi/run-host-tests.py) cover the prepare/complete state machine and five negative-control mutations.
Evidence

Verified on MacBook Air 13" M3 (J613, T8122, macOS 26.6.2 / 25G83 firmware) at exact head 334cbace033d (apple_sleep.deep=1 on top of default command line):

  • Baseline: vulkaninfo --summary reports Apple M3 (G15G C0) (Borealis), glmark2-es2-drm --off-screen score 939, /sys/kernel/debug/asahi-m3/progress completed 2639 -> 4533 (+1894, healthy=1).
  • Pre-commit aborts (immediate render on the same boot before any second suspend):
    1. Dry-run (untested_commit=0, pm_test=none): M3 GPU: sleep refused before commit; firmware never stopped -> immediate Borealis Vulkan + glmark2-es2-drm score 954, completed 4533 -> 6455 (+1922, healthy=1).
    2. pm_test=devices (untested_commit=1): M3 GPU: sleep refused before commit; firmware never stopped -> immediate Borealis Vulkan + glmark2-es2-drm score 939, completed 6455 -> 8350 (+1895, healthy=1).
    3. pm_test=core (untested_commit=1, full suspend_noirq unwind): M3 GPU: sleep refused before commit; firmware never stopped -> immediate Borealis Vulkan + glmark2-es2-drm score 959, completed 8350 -> 10282 (+1932, healthy=1).
  • Real committed mem/deep (3/3 consecutive cycles on the same boot, pm_test=none, untested_commit=1, 15 s RTC wake):
    • boot object resumes: 0 -> 1 -> 2 -> 3
    • GPU domain after the wake: 0x1f0023ff (floor 0, saved 0x1f0023ff) on all 3 cycles
    • M3 GPU: ASC before restart: ctrl=0x0 status=0x2a on all 3 cycles
    • GPU firmware wake latency: 923 us, 879 us, 1834 us
    • Post-wake Borealis Vulkan + glmark2-es2-drm: scores 951 (10322 -> 12238, +1916), 952 (12247 -> 14168, +1921), 941 (14178 -> 16074, +1896), all healthy=1
    • Zero GPU stop at the commit: or PS gfx: resync warnings; Wi-Fi up, both audio cards present, zero EDAC/WARNING/Call Trace lines in dmesg, systemctl --failed = 0.
  • Suspend-to-idle (s2idle): 1/1 clean cycle -> glmark2-es2-drm score 914, completed 16541 -> 17003 (+462, healthy=1).
  • Host tests: tools/asahi/run-host-tests.py --only m3-sleep-steps -> 6/6 passed (unit tests + 5 negative-control mutations).

Add system suspend/resume support for the Apple M3 (G15G / T8122) GPU driver across firmware-driven deep sleep:

- Drain in-flight work, idle RTKit, release the PMP GPU power vote, and lower PS_GFX via apple-sleep on suspend so the sleep controller can commit deep sleep cleanly.
- On resume, restore the PMP GPU power vote and PS_GFX domain, perform an RTKit warm restart of the GPU coprocessor without tearing down user DRM state, and resume command submission.
- Avoid sleeping under RCU read locks during the suspend/resume teardown and restart path.

Tested across 3 consecutive real deep sleep cycles (mem/deep, pm_test=none) on MacBook Air 13" M3 (J613, T8122) with live Borealis Vulkan and OpenGL ES (glmark2-es2-drm) rendering after every wake.

Signed-off-by: Satya Benson <satya@benson.earth>
@satchlj
satchlj requested review from a team and DjDeveloperr as code owners November 28, 2026 08:56
@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot) labels Nov 28, 2026
@github-actions

github-actions Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Merge readiness at 966fc1fe: not ready yet

Check Detail
CI at head running running: apple-build, pr-text / pr-text, KUnit asahi
Review ok approved by RyanTheTide
Requested changes ok none
Hardware row at head ok comment at 966fc1fe
Conflicts ok none
PR text ok Risk: two-way · M3 (T8122)

Areas: area:gpu

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

@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: FINISH, then merge at 8e6a5b81

Blockers:

  1. pr-text CI failure (runs/46128162271): add the required Tested: line (exact head SHA + Mac + result) and Risk: line (two-way or one-way + affected Macs) to the PR description so pr-text passes.
  2. Wait for the remaining queued KUnit CI jobs to finish green.

Checked:

  • M3 (T8122/G15G) firmware-driven deep sleep suspend/resume path (drain GPU work, idle RTKit, release PMP GPU power vote, lower PS_GFX; restore vote + PS_GFX and warm-restart RTKit on resume) is clean and proven across 3 consecutive real mem/deep cycles on J613 (boot object resumes 0 -> 3).
  • Checked for Apple material, tool attribution, private serials, and board gating: clean; MERGEABLE on main; human Signed-off-by present.
Evidence
  • Head: 8e6a5b81 (base: main, mergeable: MERGEABLE, +674/-20 across 9 files).

@github-actions github-actions Bot added ci-failing A check failed at the PR head (bot) blast:m3 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) and removed needs-hw-row No hardware row at the PR head (bot) needs-template PR body lacks Tested or Risk (bot) labels Nov 28, 2026
satchlj added a commit to satchlj/linux that referenced this pull request Nov 28, 2026
Keep .untested = true and .display_no_restart = true on t8122_sleep_soc
so /sys/power/mem_sleep remains [s2idle] by default until all T8122
deep-sleep prerequisites (aurora-silicon#3425, aurora-silicon#3504, aurora-silicon#3445, aurora-silicon#3452) have landed and
27.2-firmware T8122 boards (J615) have a matching display sleep path.

With .untested and .display_no_restart preserved, default s2idle and
apple_sleep.deep=1 dry runs stay intact on both 26.6.2 (J613) and 27.2
(J615), while committed J613 deep sleep runs via apple_sleep.deep=1
apple_sleep.untested_commit=1.

Signed-off-by: Satya Benson <satya@benson.earth>
@RyanTheTide

Copy link
Copy Markdown
Contributor

Second T8122 row, on a J615 (M3 Air 15", 27.2 firmware). Kernel: main 965d4a7 + this PR (8e6a5b8) + #3505 (263ce82), one-shot boot with apple_sleep.deep=1.

  • Boot: clean, 0 failed units, no new kernel errors compared with the same Mac on its normal kernel.
  • s2idle x2 (default path): PASS, same boot, display/Wi-Fi/BT/NVMe back after each.
  • deep: refused at device prepare by the GPU: aurora-g16 292400000.gpu: PM: device_prepare(): genpd_prepare returns -16. On 27.2 the T8122 GPU is taken by the shared G16 backend (g16::claims() in driver.rs), not by the m3 path this PR changes, and G16's T8122 row has deep_sleep: false (g16/hw.rs), so sleep_prepare() returns EBUSY. Clean refusal, same boot, nothing broken.

So on 27.2 boards this PR changes nothing. No regression from the J615, but its deep sleep isn't covered either. That needs the G16 T8122 row to gain deep sleep, which is separate from this PR.

@satchlj

satchlj commented Nov 29, 2026 •

Copy link
Copy Markdown
Member Author

Hardware row at this head on J613 (MacBook Air 13" M3, T8122): 3/3 mem/deep cycles completed with the GPU powered down through this PR.

Setup: main 972a5665 merged with this PR at 8e6a5b81735d, #3590 0f755337, #2163 2115ca6e and #1490 16915f57. Daily command line plus apple_sleep.deep=1 apple_sleep.untested_commit=1. 8 s RTC wakes.

Results:

Not yet: a GPU workload across a deep sleep. The desktop was idle, and this row did not render after each wake.

@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 8e6a5b81735d

Converts this App's earlier review at the same head to an approval under the 12-01 merge bar (better than before and doesn't break; block only on a shown failure). No code blocker was found in it. The merge gate (a row on one Mac at this head + fast CI) is tracked by pr-readiness, not held here.

Checked: - M3 (T8122/G15G) firmware-driven deep sleep suspend/resume path (drain GPU work, idle RTKit, release PMP GPU power vote, lower PS_GFX; restore vote + PS_GFX and warm-restart RTKit on resume) is clean and proven across 3 consecutive real mem/deep cycles on J613 (boot object resumes 0 -> 3).

  • Checked for Apple material, tool attribution, private serials, and board gating: clean; MERGEABLE on main; human Signed-off-by present.

Follow-ups (not blocking): add Tested/Risk lines so pr-text passes; queued KUnit

@satchlj

satchlj commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

Hardware rows at this head (8e6a5b81) on J613 (MacBook Air 13" M3, T8122, 26.6.2 / 25G83 firmware).

Kernel: main 7ccd92ac with #3605 222e0e6b, #3607 40936f13, #3608 87830763, this PR 8e6a5b81 and #3590 0f755337 merged unchanged. linux-aurora packaging and config, non-debug (no BRCMDBG). Booted once on a read-only root with a tmpfs overlay. Each cycle is rtcwake -m mem -s 15 with mem_sleep set to deep, pm_test=none.

Row Cmdline addition Cycles Result
A apple_sleep.deep=1 5 Every suspend stopped before the commit. That is the sleep driver's dry run for T8122 without apple_sleep.untested_commit=1. No hang; the GPU checks passed after each one
A2 apple_sleep.deep=1 apple_sleep.untested_commit=1 5 5/5 deep. boot object resumes 0 → 5; suspend_stats success 0 → 5
B same as A2 10 10/10 deep. boot object resumes 0 → 10; no reset

After every wake, in A2 and B (15 wakes):

  • GPU firmware came back with real=true in 788–1626 µs. Each wake logged PS_GFX lowered via apple-sleep, stopped and released PMP GPU device 5 and GPU domain after the wake: 0x1f0023ff.
  • asahi-m3/progress: healthy=1, with completed climbing (320 → 11257 in A2).
  • vulkaninfo --summary: Apple M3 (G15G C0), Borealis.
  • glmark2-es2-drm --off-screen -b build:duration=2.0: scores from 962 to 1016 (1001 before the first sleep).
  • After each row: 0 failed units, and no new EDAC reports.

Not covered: M3 Pro and M3 Max. Deep sleep still needs apple_sleep.untested_commit=1 on T8122, which is the sleep driver's gate, not this PR's. Wake sources other than the RTC, and sleeps longer than 15 s, were not tested.

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

An aborted deep suspend can leave the GPU offline. In m3_runtime.rs:1619–1624, sleep_suspend detaches the RTKit mailbox and stops the ASC before releasing the PMP vote. If the release returns an error, m3_drm.rs returns before setting sleep_stopped. On PM unwind, sleep_complete sees neither sleep_stopped nor a commit descriptor and reopens submission without restarting the firmware. Track each completed suspend step and recover it on abort. Please test a PMP release failure after ASC stop and verify the GPU still completes work.

The firmware stop in .suspend() detaches the RTKit mailbox, stops the
ASC, then releases the PMP GPU power vote. If the release failed, the
error returned before sleep_stopped was set; on the PM core's unwind,
.complete() saw neither sleep_stopped nor a commit descriptor and
reopened submission on stopped firmware, leaving the GPU offline.

Record each step as it completes (mailbox detached, ASC stopped, PMP
vote released, PS_GFX lowered) in m3_sleep_steps::Steps. .complete()
undoes exactly the recorded steps, in reverse order: raise PS_GFX only
if it was lowered, take the PMP vote again only if it was released,
then warm-restart the coprocessor whenever any step ran, before
submission reopens. A stop that never started leaves firmware alone, as
before. If the undo itself fails, the runtime is marked failed and
pending work is failed, as for a failed wake.

The step sequence and the undo plan live in a module with no kernel
dependencies, so the production code runs in host tests
(tools/asahi/m3-sleep-steps-tests.py). They inject a PMP release
failure after the ASC stop and an ASC stop failure after the mailbox
detach, and check that firmware is restarted, without re-acquiring a
vote that was never released, before submission may reopen. Two
negative controls (restart only after a full stop; record the ASC stop
only after the PMP release) are both killed.

Signed-off-by: Satya Benson <satya@benson.earth>
@satchlj

satchlj commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

@DjDeveloperr Thanks, you're right: that abort path reopened submission on stopped firmware. Head 8e6a5b81 → 87596f8a (one commit appended, no rebase).

What changed (87596f8a, "drm/asahi: m3: track each deep-sleep stop step and undo it on abort")

  • New m3/m3_sleep_steps.rs records each suspend step as it completes: MAILBOX_OFF, ASC_STOPPED, PMP_RELEASED, PS_LOWERED. Runtime::sleep_suspend() runs the stop through m3_sleep_steps::stop(), so a failure at the PMP release leaves MAILBOX_OFF | ASC_STOPPED recorded. Backend::sleep_suspend() records PS_LOWERED where it used to set sleep_stopped, which this commit removes.
  • Backend::sleep_complete() takes the recorded steps and undoes exactly those, in reverse order (m3_sleep_steps::complete()):
    • raise PS_GFX and hand it back from apple-sleep, only if it was lowered;
    • take the PMP vote again, only if it was released;
    • then warm-restart the coprocessor and RTKit whenever any step ran.
      Submission reopens (sleep_unhold()) only after the restart succeeds. If the undo fails, the runtime is marked failed and pending work is failed (sleep_fail()), as for a failed wake. When no step ran (a stop that never started, or the commit-descriptor path), the firmware is left alone, as before.
  • In your case (the PMP release fails after the ASC stop), .complete() now warm-restarts the firmware without re-acquiring a vote that was never released, then reopens submission.

Tests

  • Host test tools/asahi/m3-sleep-steps-tests.py, registered in run-host-tests.py. It builds the production module with rustc --test against a GPU model whose firmware runs only with the mailbox attached, the ASC running and the vote held:
    • pmp_release_failure_after_asc_stop_restarts_firmware: injects the release failure after the ASC stop and asserts the recorded steps, the plan (restart, no PMP acquire, no PS raise), the call order and that firmware is running again before submission reopens.
    • Also: an ASC stop failure after the mailbox detach; a full stop, which restores power before the restart; no step, which leaves firmware alone; and a failed re-acquire, which reports the error and does not restart.
    • Negative controls --mutate restart-only-full-stop (the old behaviour) and --mutate late-asc-mark are both killed.
  • Results: 3/3 runs pass (5/5 tests; both mutants killed). drivers/gpu/drm/asahi/ builds (arm64, LLVM, CONFIG_DRM_ASAHI_M3_T8122=y) with no warnings in the touched files.

Untested on hardware. "The GPU still completes work after an aborted suspend" has not run on a Mac at 87596f8a, and the original 3-cycle deep row was at 8e6a5b81. Rows owed on J613, default command line, mem_sleep=deep:

  1. Aborted suspend after the ASC stop. Make the PMP release fail once after stop_asc(), using a one-shot debug fault-injection build of this head (not part of the PR), then run echo mem > /sys/power/state. Pass: the suspend is refused, dmesg shows sleep stop failed ... after steps 0x3 then firmware back in ... plan=Plan { raise_ps: false, acquire_pmp: false, restart: true }, healthy=1, and vkcube --c 300 plus glmark2-es2-drm complete afterwards.
  2. Regression of the normal path. 3 consecutive real deep cycles at 87596f8a: boot object resumes increment, firmware back with plan showing all three set, live Borealis Vulkan and glmark2-es2-drm after each wake, 0 failed units, 0 new kernel errors.

Our J613's recovery path is down right now, so these wait until it is back. I'll post them as a regression request.

On M3 (T8122), once the GPU firmware has idled it does not answer a warm RTKit handshake without iBoot's firmware wake path. An aborted deep sleep (!pm_resume_via_firmware()) after any stop step therefore cannot warm-restart the coprocessor in .complete() — doing so times out with -ETIMEDOUT and marks the GPU dead.

Track the stop steps across cycles and decide .complete() recovery from both steps and pm_resume_via_firmware():

- No stop step ran -> Plan::Reopen: reopen submission directly.
- Any stop step ran and !real_wake -> Plan::Hold { raise_ps }: raise PS_GFX and clear PS_LOWERED if it was lowered, keep submission closed with EAGAIN (non-fatal to client VMs, GPU remains healthy), and retain the remaining stop bits.
- Next real deep sleep skips already-completed stop steps in .suspend(), lowers PS_GFX, and on real firmware wake (real_wake) runs Plan::Restart { raise_ps, acquire_pmp } to restore power, warm-restart the firmware, and reopen submission.

Update the host unit tests and negative controls in m3_sleep_steps.rs, tools/asahi/m3-sleep-steps-tests.py, and tools/asahi/run-host-tests.py to cover the hardware wake rule, resumable stop steps, PS_GFX re-raise on hold, and all four negative-control mutations.

Signed-off-by: Satya Benson <satya@benson.earth>
@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 Dec 1, 2026
RyanTheTide
RyanTheTide previously approved these changes Dec 1, 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 the 2cc7c04 delta. An abort before any stop step reopens submission. An abort after a partial stop holds submission, retains completed stop bits, and restores a lowered PS_GFX before the next retry. The real wake path finishes the remaining steps and warm-restarts. I compiled and ran the exact sleep-step unit file, 5/5 passed. B2 is tracking the exact-head hardware row and series size.

@satchlj

satchlj commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

2cc7c04 MacBook Air (M3, 13-inch) J613 PASS — Row 1 (injected PMP release failure -> sleep_hold -> Cycle 2 deep sleep recovery) and Row 2 (3/3 committed deep sleep + audio/GPU/Borealis/glmark2/Wi-Fi, 0 EDAC).

Hardware rows at 2cc7c04bbc (MacBook Air 13-inch M3 / J613, T8122, macOS 26.6.2 25G83 stub, pre-#3535 DTB)

Note: both rows used a pre-#3535 Stage 2 DTB paired with current Aura Stage 2 (1.0.0b18-g34534c5f); #3535 DTB deep sleep is tracked separately in #3834. Both rows used apple_sleep.deep=1 apple_sleep.untested_commit=1 (volatile trial boot; default-cmdline J613 deep sleep is #3760).

Row 1 — Injected PMP release failure -> sleep_hold -> recovery (one-shot debug injection atop 2cc7c04bbc):

  • Cycle 1 (rtcwake -d /dev/rtc0 -m mem -s 15): injected PMP release failure logged (M3 GPU: injected one-shot PMP release failure), suspend aborted (rc=1) with sleep_hold asserted and zero commit.
  • Cycle 2 (rtcwake -d /dev/rtc0 -m mem -s 15): M3 GPU: stopped and released PMP GPU device 5 in 263 us, back from sleep, boot object resumes 0 -> 1, M3 GPU: firmware back in 1259 us (real=true plan=Restart { raise_ps: true, acquire_pmp: true }); same boot_id, clean recovery.

Row 2 — Clean exact-head 2cc7c04bbc (no injection), 3/3 committed deep sleep (12 s RTC wakes):

  • Cycle 1: M3 GPU: stopped and released PMP GPU device 5 in 597 us -> back from sleep, boot object resumes 0 -> 1 -> M3 GPU: firmware back in 1242 us
  • Cycle 2: M3 GPU: stopped and released PMP GPU device 5 in 554 us -> back from sleep, boot object resumes 1 -> 2 -> M3 GPU: firmware back in 2969 us
  • Cycle 3: M3 GPU: stopped and released PMP GPU device 5 in 585 us -> back from sleep, boot object resumes 2 -> 3 -> M3 GPU: firmware back in 1201 us
  • Post-wake verification after every cycle (0, 1, 2, 3, same boot_id):
    • Audio capture hw:AppleJ613,0: 48000 Hz (4011–4015 ms) and 44100 Hz (4010–4014 ms), rc=0 on all 4 checks
    • GPU progress: healthy=1, completed: 138 -> 2301 -> 4408 -> 6565
    • Vulkan (vulkaninfo --summary): Apple M3 (G15G C0) / driverName = Borealis
    • DRM render (glmark2-es2-drm --off-screen -b build:duration=2.0): Score 1007 -> 987 -> 1003 -> 1001
    • Wi-Fi (wlan0): reconnected on every wake; 0 failed systemd units; 0 EDAC errors; 0 kernel WARNING: traces.

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

Re-reviewed 2cc7c04bbc and the J613 fault-injection row. The retry recovers the GPU on the next successful deep sleep. The first failed suspend still returns to the running system with the GPU firmware stopped and submissions held: m3_drm.rs:463–472 leaves the device in that state until a separate firmware-driven wake. A user who cancels the retry or whose machine keeps refusing deep sleep loses GPU use after an aborted suspend.

Please restore usable GPU submission on the same boot after PM unwind, before any second suspend. The existing one-shot PMP-release injection is a good reproducer. Run a render or Vulkan submission immediately after the first abort, then verify the subsequent real deep-sleep cycle still works.

Brings in asahi_g17_map() nonposted MMIO handling (ioremap_np) needed
for T8122 commit-time GPU stop registers.

Signed-off-by: Satya Benson <satya@benson.earth>
Stopping the M3 GPU firmware in .suspend() left submission held until a
second real deep sleep whenever suspend unwound before firmware sleep,
because AGX firmware does not answer a warm RTKit handshake without
iBoot's wake program.

Move the M3 deep-sleep stop to apple-sleep's commit hook via
asahi_g16_commit_prepare() / asahi_g17_commit_finish() (matching G16,
G17, and PMP), keeping the PMP GPU vote across sleep and holding the
attached genpd across suspend_noirq() via
asahi_sleep_pd_suspend_noirq_hold(dev, hold_firmware):

- In .prepare(), drain active GPU work, pause/flush completion, and arm
  asahi_g16_commit_prepare() unconditionally for firmware-driven deep
  sleep (and drop the CLPC performance request).
- Drop the .suspend() callback and the suspend-time PMP release /
  asahi_sleep_pd_domain_set() path.
- In .complete(), finish the commit descriptor: if the sleep aborted
  before commit, firmware never stopped and submission reopens
  immediately on the same boot; on a real firmware wake, raise PS_GFX
  and warm-restart firmware; if a sleep ever unwinds after the commit
  stop without a firmware wake, raise PS_GFX and hold submission closed
  until the next real deep sleep lowers PS_GFX and restarts firmware.
- Update m3_sleep_steps.rs and tools/asahi/m3-sleep-steps-tests.py
  (with negative-control mutations in run-host-tests.py) to cover the
  commit-time prepare/complete state machine.

Signed-off-by: Satya Benson <satya@benson.earth>
@satchlj

satchlj commented Dec 2, 2026

Copy link
Copy Markdown
Member Author

Updated in 334cbace033d (forward-merged main 6c83a2a64539 for ioremap_np in asahi_g17_map(), then moved M3's deep-sleep GPU stop to apple-sleep's commit hook).

What changed

  • Because AGX firmware does not answer a warm RTKit handshake without iBoot's wake program once stopped, stopping the GPU in .suspend() cannot restore submission on the same boot after an abort.
  • Moved the T8122 deep-sleep stop to commit time via asahi_g16_commit_prepare() / asahi_g17_commit_finish() (matching G16/G17 and PMP), keeping the PMP GPU vote across sleep and holding the attached power domain across suspend_noirq() via asahi_sleep_pd_suspend_noirq_hold(dev, hold_firmware).
  • Dropped the .suspend() callback and the suspend-time PMP release / asahi_sleep_pd_domain_set() path. Any sleep aborted before commit now unwinds with firmware untouched and reopens GPU submission immediately on the same boot.
  • Updated m3_sleep_steps.rs, tools/asahi/m3-sleep-steps-tests.py, and tools/asahi/run-host-tests.py for the commit-time state machine (6/6 host tests including 5 negative-control mutations).

Exact-head J613 verification (334cbace033d, apple_sleep.deep=1)

  1. Pre-commit aborts -> immediate GPU submission on the same boot before any second suspend:
    • Dry-run (untested_commit=0, pm_test=none): logged M3 GPU: sleep refused before commit; firmware never stopped, followed immediately by Borealis vulkaninfo + glmark2-es2-drm score 954 (asahi-m3/progress completed 4533 -> 6455, +1922, healthy=1).
    • pm_test=devices (untested_commit=1): logged M3 GPU: sleep refused before commit; firmware never stopped, followed immediately by Borealis vulkaninfo + glmark2-es2-drm score 939 (6455 -> 8350, +1895, healthy=1).
    • pm_test=core (untested_commit=1, full suspend_noirq unwind): logged M3 GPU: sleep refused before commit; firmware never stopped, followed immediately by Borealis vulkaninfo + glmark2-es2-drm score 959 (8350 -> 10282, +1932, healthy=1).
  2. Subsequent real committed deep sleep on the same boot (pm_test=none, untested_commit=1, 3/3 cycles, 15 s RTC wake):
    • boot object resumes: 0 -> 1 -> 2 -> 3
    • GPU domain after the wake: 0x1f0023ff (floor 0, saved 0x1f0023ff), ASC before restart: ctrl=0x0 status=0x2a
    • M3 GPU: firmware back in 923 us / 879 us / 1834 us
    • Post-wake Borealis vulkaninfo + glmark2-es2-drm: scores 951 (+1916 jobs), 952 (+1921 jobs), 941 (+1896 jobs), healthy=1
    • Zero GPU stop at the commit: or PS gfx: resync warnings; Wi-Fi up, audio cards intact, 0 failed units.
  3. Suspend-to-idle (s2idle): 1/1 clean cycle -> glmark2-es2-drm score 914 (16541 -> 17003, +462 jobs, healthy=1).

Ready for re-review @DjDeveloperr.

@satchlj
satchlj requested a review from DjDeveloperr December 2, 2026 03:47
RyanTheTide
RyanTheTide previously approved these changes Dec 2, 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.

The original abort failure is addressed by moving the stop to commit. I ran the exact state-machine suite and all five negative controls failed as expected. The J613 row confirms usable render submissions immediately after the first abort, including the noirq unwind, and three real deep-sleep cycles afterwards.

@DjDeveloperr
DjDeveloperr dismissed stale reviews from themself December 2, 2026 04:14

Resolved at 334cbac. T8122 now stops the GPU in apple-sleep only after all returnable refusals. The exact-head J613 row completed render and Vulkan work on the same boot after all three pre-commit aborts, then completed three real deep-sleep cycles.

@github-actions github-actions Bot removed changes-requested A reviewer requested changes (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Dec 2, 2026
Keep the T8112 commit-time power-domain hold from main and extend the shared noirq callback to honor the T8122 hold.

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

satchlj commented Dec 2, 2026

Copy link
Copy Markdown
Member Author

Checked merge commit 966fc1fe36f5 against 334cbace033d and main: all drivers/gpu/drm/asahi/m3/* and tools/asahi/* files are byte-identical to hardware-verified 334cbace033d, and drivers/gpu/drm/asahi/driver.rs cleanly combines the merged #3865 g14_v27_2 branch with m3 in sleep_suspend_noirq_driver() (sleep_pd.c/sleep_pd.h are now in main). The J613 hardware row from 334cbace033d carries over unchanged.

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

Rechecked the merge with the T8112 hold change. The shared noirq callback keeps each backend’s hold decision. The extracted exact callback compiled and passed in all four combinations of the T8112 and T8122 build switches.

@satchlj
satchlj merged commit cf03d96 into aurora-silicon:main Dec 2, 2026
11 of 12 checks passed
satchlj added a commit that referenced this pull request Dec 2, 2026
Pulls in merged #3504 (M3 GPU deep sleep), #1490 (J613 USB4), and #3865.

Signed-off-by: Satya Benson <satya@benson.earth>
satchlj added a commit that referenced this pull request Dec 2, 2026
Pulls in merged #3504 (M3 GPU firmware-driven deep sleep) and recent main commits.

Signed-off-by: Satya Benson <satya@benson.earth>
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:m3 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants