Repository navigation
drm/asahi: m3: support firmware-driven deep sleep on T8122 - #3504
Conversation
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>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
There was a problem hiding this comment.
Verdict: FINISH, then merge at 8e6a5b81
Blockers:
pr-textCI failure (runs/46128162271): add the requiredTested:line (exact head SHA + Mac + result) andRisk:line (two-wayorone-way+ affected Macs) to the PR description sopr-textpasses.- 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, lowerPS_GFX; restore vote +PS_GFXand warm-restart RTKit on resume) is clean and proven across 3 consecutive realmem/deepcycles on J613 (boot object resumes 0 -> 3). - Checked for Apple material, tool attribution, private serials, and board gating: clean;
MERGEABLEonmain; humanSigned-off-bypresent.
Evidence
- Head:
8e6a5b81(base: main,mergeable: MERGEABLE,+674/-20across 9 files).
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>
|
Second T8122 row, on a J615 (M3 Air 15", 27.2 firmware). Kernel: main 965d4a7 + this PR (8e6a5b8) + #3505 (263ce82), one-shot boot with
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. |
|
Hardware row at this head on J613 (MacBook Air 13" M3, T8122): 3/3 Setup: Results:
Not yet: a GPU workload across a deep sleep. The desktop was idle, and this row did not render after each wake. |
There was a problem hiding this comment.
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;
MERGEABLEonmain; humanSigned-off-bypresent.
Follow-ups (not blocking): add Tested/Risk lines so pr-text passes; queued KUnit
|
Hardware rows at this head ( Kernel:
After every wake, in A2 and B (15 wakes):
Not covered: M3 Pro and M3 Max. Deep sleep still needs |
DjDeveloperr
left a comment
There was a problem hiding this comment.
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>
|
@DjDeveloperr Thanks, you're right: that abort path reopened submission on stopped firmware. Head What changed (
Tests
Untested on hardware. "The GPU still completes work after an aborted suspend" has not run on a Mac at
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>
RyanTheTide
left a comment
There was a problem hiding this comment.
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.
|
2cc7c04 MacBook Air (M3, 13-inch) J613 PASS — Row 1 (injected PMP release failure -> Hardware rows at
|
DjDeveloperr
left a comment
There was a problem hiding this comment.
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>
|
Updated in What changed
Exact-head J613 verification (
|
RyanTheTide
left a comment
There was a problem hiding this comment.
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.
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.
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>
|
Checked merge commit |
RyanTheTide
left a comment
There was a problem hiding this comment.
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.
Pulls in merged #3504 (M3 GPU firmware-driven deep sleep) and recent main commits. Signed-off-by: Satya Benson <satya@benson.earth>
What: Add firmware-driven deep sleep (
mem/deep) suspend/resume support for the Apple M3 (G15G / T8122) GPU driver (aurora), deferring the GPU stop toapple-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 andglmark2-es2-drm(939–959 score, +1895–1932 retired GPU jobs) before any second suspend; 3/3 consecutive realmem/deepcycles (boot object resumes 0 -> 1 -> 2 -> 3), GPU firmware back in 879–1834 µs, live Borealis Vulkan and 941–952glmark2-es2-drm; 1/1s2idlecycle (+462 GPU jobs);m3-sleep-steps-tests.py6/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
asahi_g16_commit_prepare()(keeping the PMP GPU vote across sleep, matching G16). Hold the attached power domain acrosssuspend_noirq()viaasahi_sleep_pd_suspend_noirq_hold(dev, hold_firmware).apple-sleeprunsasahi_g17_commit_stop()(polled RTKit idle, mailbox RX off, ASC run bit clear,PS_GFXlower) before stopping PMP.!stopped && !real_wake): firmware never stopped; reopen submission immediately on the same boot.real_wake): raisePS_GFX, restore automatic power management, and warm-restart RTKit without tearing down DRM/userspace state.stopped && !real_wake): raisePS_GFXand hold submission closed until the next real deep sleep lowersPS_GFXand restarts firmware on wake.drivers/gpu/drm/asahi/m3/m3_sleep_steps.rsandtools/asahi/m3-sleep-steps-tests.py(registered intools/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=1on top of default command line):vulkaninfo --summaryreportsApple M3 (G15G C0)(Borealis),glmark2-es2-drm --off-screenscore939,/sys/kernel/debug/asahi-m3/progresscompleted2639 -> 4533(+1894,healthy=1).untested_commit=0,pm_test=none):M3 GPU: sleep refused before commit; firmware never stopped-> immediate Borealis Vulkan +glmark2-es2-drmscore954,completed4533 -> 6455(+1922,healthy=1).pm_test=devices(untested_commit=1):M3 GPU: sleep refused before commit; firmware never stopped-> immediate Borealis Vulkan +glmark2-es2-drmscore939,completed6455 -> 8350(+1895,healthy=1).pm_test=core(untested_commit=1, fullsuspend_noirqunwind):M3 GPU: sleep refused before commit; firmware never stopped-> immediate Borealis Vulkan +glmark2-es2-drmscore959,completed8350 -> 10282(+1932,healthy=1).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 -> 3GPU domain after the wake:0x1f0023ff (floor 0, saved 0x1f0023ff)on all 3 cyclesM3 GPU: ASC before restart: ctrl=0x0 status=0x2aon all 3 cycles923 us,879 us,1834 usglmark2-es2-drm: scores951(10322 -> 12238,+1916),952(12247 -> 14168,+1921),941(14178 -> 16074,+1896), allhealthy=1GPU stop at the commit:orPS gfx: resyncwarnings; Wi-Fi up, both audio cards present, zero EDAC/WARNING/Call Trace lines indmesg,systemctl --failed=0.s2idle): 1/1 clean cycle ->glmark2-es2-drmscore914,completed16541 -> 17003(+462,healthy=1).tools/asahi/run-host-tests.py --only m3-sleep-steps->6/6 passed(unit tests + 5 negative-control mutations).