You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
T8112 (Apple M2 / J413) suspend-to-RAM support: coordination before opening a PR #3371
I wanted to check if anyone is currently working on suspend-to-RAM (S2R) for T8112 (Apple M2, tested on MacBook Air 13" J413) via drivers/soc/apple/sleep.c, before I clean up and submit a PR.
What is currently working on real J413 hardware
I have a working sleep-t8112.h implementation tested on a J413 (System FW 27.2, OS FW 13.5 stub) that completes full hardware deep sleep and wake (boot object resumes 0 -> 1, 162/213 AP pins restored) with all core subsystems resuming cleanly:
AICv2 (irq-apple-aic.c): added apple,t8112-aic with .fw_suspend = true so aic_syscore_suspend/resume preserve AIC2 config, per-IRQ routing, and CPU0 timer FIQ.
SMC (macsmc.c): enabled saved_enabled for apple,t8112-smc and wired .smc_gen1_keys = true.
SoC sleep sequence (sleep-t8112.h + t8112-j413.dts): PMGR/AON commit-off and wake restore, SEP gate wait/restore, NCO channel enable across commit, clock mux snapshot/restore, SPMI RTC vector handling, WD1 watchdog, and SLC cache clean after AIC/state snapshot.
Verified resuming subsystems: NVMe (ANS: on after the sleep), PCIe + Wi-Fi (brcmfmac), Bluetooth (hci_bcm4377), SEP / Touch ID, Audio (apple-mca), AOP sensors, and keyboard (spi-hid).
Display (dcp.c + t8112.dtsi + apple-dart.c): wired dcp_power and dcp_s2r_t8112 (matching T8103 soc: apple: sleep: add T8103 (M1 / J313) suspend-to-RAM support #3172) plus a bounds-safe T8112 path in apple_dart_display_streams(). Note: my current test stub runs OS FW 13.5, so the internal panel warm restart (which requires OS FW 27.x for AP-link release) has not yet been hardware-verified on 27.2.
Questions before submitting
Is anyone already working on T8112 S2R that I should coordinate with?
Keeping this as the J413 suspend-to-RAM design thread. The next step is to compare the proposed changes with the current shared sleep path and specify how an RTC-backed wake and default-boot restoration would be verified.
Thanks for keeping #3371 as the J413 design thread. Here is the comparison against the current shared sleep path (main @ cec0503a5a02) and the proposed verification plan for RTC-backed wake and default-boot restoration.
1. Comparison with the current shared sleep path
The T8112 work is built directly on the existing drivers/soc/apple/sleep.c + aurora,s2r-mailbox architecture (no EFI/PSCI conduit and no core kernel/power/suspend.c hooks):
Shared sleep.c core (2-line hook only):
drivers/soc/apple/sleep.c only adds #include "sleep-t8112.h" and the "apple,t8112-sleep" entry in apple_sleep_of_match[].
All T8112-specific commit/wake sequences live in drivers/soc/apple/sleep-t8112.h, following the same apple_sleep_soc / apple_sleep_ops pattern as sleep-t8103.h and sleep-t8122.h and reusing the shared mailbox handoff, apple_sleep_read_wake_sources(), SPMI/PMU helpers, and sleep-test.c KUnit coverage.
Minimal per-subsystem wiring on top of existing shared drivers:
drivers/irqchip/irq-apple-aic.c: adds aic2_t8112_info ("apple,t8112-aic") with .fw_suspend = true so the existing aic_syscore_suspend/resume path saves/restores AIC2_CONFIG, AIC2_IRQ_CFG, and CPU0 timer FIQ state.
drivers/mfd/macsmc.c: enables smc->saved_enabled = true for "apple,t8112-smc" alongside "apple,t8103-smc".
drivers/soc/apple/pmp.rs: adds HW_CFG_T8112 (sram_backup: Some((0x2f000, 0x46000))) for "apple,t8112-pmp-v2" (still overridden if the bootloader provides apple,sram-keep).
drivers/thunderbolt/apple.c + tools/asahi/pciec-policy-tests.py: adds apple_cio_t8112_hw using the same policy as apple_cio_t8122_hw (sleep_removes_domains, restart_on_wake, phy_shared_with_dwc3, apple_dpin_m1).
arch/arm64/boot/dts/apple/t8112.dtsi, t8112-j413.dts, and apple,t8140-sleep.yaml: adds the apple,t8112-sleep node/binding, enables it on J413, and wires power-domains on &sep.
drivers/gpu/drm/apple/dcp.c + drivers/iommu/apple-dart.c: adds dcp_s2r_t8112 / apple_dcp_hw_t8112 S2R flags and a bounds-safe "apple,t8112-dart" path in apple_dart_display_streams() (T8112 DART MMIO is 0x4000 bytes, avoiding an out-of-bounds access at dart->regs + 0x4060). Note: I see main has recently moved display DART stream / power-word handling further toward DT-driven layouts (5ff9c1c58, 888805b87), so I will rebase this piece cleanly onto current main before proposing a PR.
Known gap on OS FW 13.5 internal DCP: on J413 with OS FW 13.5, apple_rtkit_idle() currently returns -62 without an A500 AP-link release + disp0 power cycle + RTKit warm restart, so the internal panel stays dark on wake while all other subsystems recover cleanly. Happy to keep 13.5 internal DCP warm-restart as a separate follow-up discussion if you prefer keeping the initial T8112 series focused on the core sleep path and subsystem enablement.
2. Verification plan: RTC-backed wake & default-boot restoration
A. RTC-backed wake verification (unattended)
J413 already defines rtc1 = &pmu_rtc (apple,t8112-pmu-rtc on Stowe PMIC pmic@e, driven by drivers/rtc/rtc-apple-pmu.c with wakeup-source and dev_pm_set_wake_irq()), and sleep-t8112.h explicitly acks and enables T8103_SPMI_VEC_RTC on nub-spmi before entering sleep and restores spmi_vec_saved on wake.
Proposed verification procedure (repeatable over SSH with no manual lid/key press):
Pre-flight checks:
Confirm cat /sys/power/mem_sleep has [deep] selected.
Confirm /dev/rtc1 binds to apple-pmu-rtc and /sys/class/rtc/rtc1/device/power/wakeup is enabled.
Record baseline timestamps (date -u), current apple-sleep boot-object resume count, and healthy device states (NVMe, Wi-Fi, BT, SEP, MCA audio, SPI-HID keyboard).
Timed deep-sleep cycles:
Run rtcwake -d rtc1 -m mem -s 20 for 3 consecutive cycles, followed by a longer rtcwake -d rtc1 -m mem -s 60 soak.
Pass criteria per cycle:
Autonomous wake occurs within the expected alarm window (~20s / ~60s) with no manual input.
dmesg logs apple-sleep: back from sleep, boot object resumes N -> N+1 and full AP pin restoration with zero errors.
rtc1 alarm interrupt is cleanly acknowledged/disarmed after wake (one-shot clear in rtc-apple-pmu, no IRQ storm or wedged wake source).
Post-wake functional checks pass: monotonic timer responsiveness (sleep 1 completes in ~1s), NVMe I/O (ANS: on after the sleep), Wi-Fi/SSH reconnection (brcmfmac), Bluetooth (hci_bcm4377), SEP (apple_sep), audio (apple-mca), and keyboard (spi-hid).
B. Default-boot restoration verification
To keep J413 safely recoverable across all hardware tests:
Non-destructive test boot setup:
Leave the stock distro kernel, initramfs, DTB, and default bootloader entry untouched.
Install the test Image.gz, initramfs, and t8112-j413.dtb under a dedicated test boot entry and select it one-shot (e.g. grub-reboot / one-shot menu entry), so any panic, watchdog reset, or hard power cycle automatically returns to the stock default OS.
Post-test restoration check:
Remove the temporary test kernel/initramfs/DTB files and test boot entry, regenerate the bootloader configuration, and verify the default entry points to the stock kernel.
Perform a cold reboot and verify:
uname -r matches the stock distro kernel.
/proc/cmdline has no leftover debug/test flags.
Stock Linux desktop/display and macOS boot entries both boot normally.
Let me know if you want any adjustments to the shared-path split or additional checks in the RTC wake / boot-restoration matrix before I rebase onto current main and run the RTC-backed verification pass on J413.
I have a J413 (MacBook Air M2) running a macOS 27.2 stub (t8112-j413-fw27.dts, live MTP handoff, 27.2 DCP/DCPEXT, and G14G 27.2 GPU via aurora/g14_v27_2) with Aura already publishing /chosen/aurora,s2r-mailbox.
I'm happy to help test your feat/t8112-s2r / pr/t8112-dcp-s2r branches on the 27.2 stub once you're ready for PR review—specifically the pieces that can't be exercised on a 13.5 stub:
Live MTP handoff across firmware sleep (alongside #3413's apple_dart_system_suspend() fix)
G14G 27.2 GPU warm restart (g14_v27_2, #3171)
t8112-j413-fw27.dts sleep node + SMC wake reasons
A few early notes from glancing at pr/t8112-dcp-s2r (87fe26b1e5) against current main (a40c5131071d1) ahead of your rebase:
apple_dart_display_streams()on == false OOB writes:pr/t8112-dcp-s2r guards the on == true path for apple,t8112-dart's 0x4000-byte MMIO window, but the on == false path on main also writes dart->regs + 0x4060 and dart->regs + 0x4000 (which are past 0x4000 on T8112's disp0_dart / dcp_dart / dispext0_dart / dcpext_dart).
27.x .map_reg_dart and dcpext: On main, apple_dcp_hw_t8103 sets .map_reg_dart = true for DCP_FIRMWARE_V_27_0 register-window DART mappings (iomfb_template.c), and #3178 added apple_dcp_hw_t8103_dcpext (dcp_s2r_t8103_ext). For T8112 dcpext@271c00000, t8112-pmgr.dtsi / t8112.dtsi give disp_cpu = 0x3c8, disp_fe = 0x388, disp_sys = 0x380, dcp_streams = BIT(5), disp_streams = BIT(0) | BIT(4).
dcp_s2r_layout_from_dt() on main: That helper currently requires both pwrgate and apple,retention-workaround, so keeping a static dcp_s2r_t8112 (like dcp_s2r_t8103) still looks right for T8112.
Let me know when you've rebased onto current main (or if you'd like early 27.2 test results on the current feat/t8112-s2r head).
Hardware test report on J413 (MacBook Air 13" M2, T8112, macOS 27.2 stub 26B123) using rjianwei/linuxfeat/t8112-s2r (d3fc11cd3) rebased onto main (ff59991a6), plus #3470 (J413 &smc wake reasons + &hpm0/&hpm1apple,sleep-ssps) and #3425 (live-MTP DART across S2R).
Result: First real committed deep sleep + resume on J413 / 27.2 (boot object resumes 0 -> 1)
With aurora unloaded (see GPU note below) and our 27.2 DCP/DCPEXT + DART fixes below:
Dry run (apple_sleep.deep=1, untested_commit=0):apple-sleep 23b700000.sleep: dry run: every check passed; refusing before the first stop and the commit. Both 27.2 dcp (231c00000.dcp) and dcpext (271c00000.dcp) power-cycled and resumed cleanly.
rtkit-helper 24e400000.mtp + apple-dart 24e808000.iommu (#3425): live MTP survived committed S2R with 0 errors and all 3 input devices intact.
nvme-apple (ANS: on after the sleep), apple_sep (the enclave is back from its sleep request), apple-sio, apple-mca, pcie-apple (link back, PWREN and PERST# cycled as at probe), brcmfmac (Wi-Fi reconnected), and hci_bcm4377 all resumed cleanly.
Fixes needed on 27.2 J413 (dcp / dcpext / apple-dart)
dcpext + map_reg_dart in drivers/gpu/drm/apple/dcp.c and t8112.dtsi:
Added apple,display-power = <&dcp_power>; to dcpext (271c00000) in t8112.dtsi.
T8112-safe apple_dart_t8112_display_streams() in drivers/iommu/apple-dart.c:
Replaced the early-return guard with a dedicated T8112 helper covering both on == false (save TTBR/TCR/enable state, display_dark_enter, DART_T8110_DISABLE_STREAMS, TLB invalidate, host_off = true) and on == true (restore TTBR/TCR if translations were lost, clear DART_T8110_ERROR, display_tlb_stale = true, display_dark_exit, DART_T8110_ENABLE_STREAMS, host_off = false) without touching the out-of-range 0x4000/0x4060 registers on T8112's 0x4000-byte window.
Remaining issues observed on J413 / 27.2
G14G 27.2 GPU (aurora) refuses deep sleep (-EBUSY in genpd_prepare / g14_v27_2::sleep_prepare):
g14_v27_2::sleep_prepare(deep=true) gates on root.has_pwr_controller() (pwr_controller_from_dt), requiring apple,pwr-filter-time-constant, apple,pwr-integral-gain, apple,pwr-integral-min-clamp, and apple,pwr-proportional-gain.
Neither t8112.dtsi nor Apple's J413 /arm-io/sgx ADT has those four properties (only gpu-pwr-min-duty-cycle, gpu-avg-power-*, gpu-ppm-*, gpu-fast-die0-*, gpu-perf-*), so aurora currently refuses deep sleep on J413.
Wake timing / rtc1 (apple-pmu-rtc) across cycles:
Cycle 1 (rtcwake -d rtc1 -m mem -s 20) woke after ~4 s with macsmc 23e400000.smc: wake record: MBSE 0x10750, MBSW 00 00 00 00 00 00 00 00 and no named apple-sleep wake source logged.
Cycle 2 (rtcwake -d rtc1 -m mem -s 20) stayed asleep past the 20 s alarm (and past WDT_SUSPEND_SECS=120), indicating the machine entered deep sleep cleanly but the rtc1 alarm did not wake it on cycle 2 (awaiting physical lid/key/power-button wake to inspect).
@satchlj Thank you so much for offering to test on the J413 27.2 stub and for the concrete review notes!
I have rebased feat/t8112-s2r (as well as pr/t8112-aic2-s2r, pr/t8112-macsmc-s2r, and pr/t8112-dcp-s2r) onto current main (ff59991a6, which includes a40c5131071d1), updated the branches on rjianwei/linux, and addressed all three points:
Extracted apple_dart_t8112_display_streams() so both on == true and on == false stay strictly within T8112's 0x4000-byte MMIO window (avoiding 0x4060 and 0x4000 on both paths while preserving stream disable + DART_T8110_TLB_CMD0xa000 flush).
27.x.map_reg_dart and t8112-dcpext (drivers/gpu/drm/apple/dcp.c):
Kept the static dcp_s2r_t8112 / dcp_s2r_t8112_ext layouts. Since t8112-j413-fw27.dts includes t8112-j413.dts, it inherits &system_sleep { status = "okay"; }; automatically.
Verification after the rebase:
Cleanly built Image.gz, t8112-j413.dtb, t8112-j413-fw27.dtb, and modules (including appledrm.ko) with LLVM=1.
tools/asahi/pciec-policy-tests.py and tools/asahi/tb-cio-sleep-tests.py (41 native tunnel replay cases + 27 negative controls) all pass.
Follow-up from committed S2R cycle #2 on the same 7.3.0-s2r1-ARCH boot (with dynamic_debug on sleep.c and macsmc.c), pulled from journalctl -b -1 -k after recovering back into the default boot:
apple-sleep 23b700000.sleep: 162 of 213 AP pins changed by the sleep, all put back
All 7 secondary CPUs came back up cleanly (aura slot mapped flag 5 -> 7 / 6 -> 8 after 20–40 us).
apple-sleep 23b700000.sleep: back from sleep, boot object resumes 1 -> 2
apple-sleep 23b700000.sleep: PMGR: 7 words on at the commit were off at the wake: 0x110 0x338 0x380 0x388 0x3c8 0x418 0xc00
apple-sleep 23b700000.sleep: AON PMGR: 2 words on at the commit were off at the wake: 0xb0 0xb8
apple-sleep 23b700000.sleep: power words: 21 written back, 0 not on in time
Same early ~3 s wake with zero MBSW: macsmc 23e400000.smc: wake record: MBSE 0x10750, MBSW 00 00 00 00 00 00 00 00 (rtcwake -d rtc1 -m mem -s 20 exited RC=0 at 04:28:09Z, 3 s after 04:28:06Z).
27.2 dcp, dcpext, NVMe (ANS: on after the sleep), SEP, SIO, audio (apple-mca), and PCIe link recovery all completed and PM: suspend exit was logged.
Post-resume kernel panic (~1 s after PM: suspend exit, 04:28:10Z):
Immediately after PM: suspend exit, tearing down the transient systemd-run unit triggered:
WARNING: arch/arm64/net/bpf_jit_comp.c:3402 at bpf_jit_free+0x154/0x15c (WARN_ON_ONCE(!bpf_prog_kallsyms_verify_off(prog))) in kworker/1:2 (bpf_prog_free_deferred)
Oops drm/apple: release a stale DPTX link before borrowing a Type-C route #2 (console panic): NULL+0x8 dereference in rb_insert_color+0x40/0x130 <- bpf_ksym_add <- bpf_prog_kallsyms_add <- bpf_prog_load (from NetworkManager), Kernel panic - not syncing: Oops: Fatal exception in interrupt.
Root-caused and fixed the post-resume stale-DRAM / BPF corruption (bpf_jit_free / rb_insert_color) on J413 (T8112).
Root causes (two cache-coherency bugs in drivers/soc/apple/sleep-t8112.h)
t8112_deep_wfi_arm() re-enabled HID4/EHID4.DISABLE_DC_SW_L2 before t8103_cpu_off():
Live telemetry on J413 shows hid4 = 0x130800000800: both DISABLE_DC_MVA (bit 11) and DISABLE_DC_SW_L2 (bit 44) are set by default on T8112.
t8112_deep_wfi_arm() cleared T8112_HID4_DC_MASK, ran t8112_dcache_clean_all_levels() while SCTLR_EL1.C was still enabled, restored HID4 (re-enabling DISABLE_DC_SW_L2), set ACC_DIS_L2_FLUSH = 2, and then called t8103_cpu_off(). That turned t8103_cpu_off()'s L2 dc csw loop into a hardware NOP while dirty lines from C code/stack remained in L1/L2 (notably on secondary P-cores parked early via early_cpu_wfi = true).
Fix: Add a CCIDX-aware t8112_cpu_off(u64 cyc_ovrd, u64 acc_ovrd) (clears SCTLR_EL1.C first, zero stack accesses, dc cisw on L1, dc csw on L2+) and invoke it with T8112_HID4_DC_MASK left cleared (core resets on wake).
T8112 SLC was never disabled/written back before deep sleep (MCC loses power):
200100000.memory-controller (apple,t8112-mcc) is bound to apple-regview, so nothing stopped SLC allocation or wrote back dirty SLC ways before deep sleep.
On T8112's 4 MCC planes (0x200000000, stride 0x40000):
0x1c04: WAYS_STATUS (DATA = GENMASK(14, 10), TAG = GENMASK(9, 5); live value 0x4200 = 16 data + 16 tag ways; 0x0 when written back/off)
Fix: In t8112_sleep_commit_regs(), after t8112_dcache_clean_all_levels(), call t8112_slc_off() (set 0x424 = 1 on all 4 planes -> dsb(sy) -> set 0x1c00 = 0 -> poll 0x1c04 data & tag == 0), then clean critical wake state + task_stack_page(current) + final t8112_dcache_clean_all_levels(). Also clean task_stack_page(current) in t8112_sleep_pre_commit(). On wake in t8112_sleep_wake(), after clk_mux restore, call t8112_slc_on() (write saved ways to 0x1c00 -> poll 0x1c04 -> clear 0x424 = 0).
Telemetry across deep sleep confirmed ways=16 off_bad=0x0 off_st=0x0 wake_before=0x0 on_bad=0x0 wake_after=0x4200 on every cycle (wake_before=0x0 confirms MCC loses power during deep sleep).
With t8112_slc_off() writing back all dirty SLC lines cleanly and instantaneously, the t8122_clean_used_ram() walk in t8112_sleep_commit_regs() is no longer needed.
Hardware verification on J413 (MacBook Air 13" M2, T8112, macOS 27.2 stub 26B123)
Tested with sddm stopped and aurora unloaded, apple_sleep.untested_commit=1, mem_sleep=deep, rtcwake -d rtc1 -m mem -s 10, plus BPF load/attach/free stress (30xsystemd-run --quiet --wait -p IPAddressDeny=192.0.2.0/24 /bin/true before cycle 1 and after each wake):
180/180 BPF stress runs PASSED (30/30 pre + 30/30 after each of cycles 1–5)
wlan0 up on all 5 cycles; zero Oops, zero BUG, zero WARNING, zero Call trace, zero SLC timeouts.
Separate pre-existing observations (out of scope for cache coherency)
sddm + aurora GPU active during S2R: Right after boot aurora 206400000.gpu returns -16 (EBUSY) in genpd_prepare; later with sddm still running, S2R hangs/resets ~39 s into suspend. Stopping sddm and unloading aurora avoids this completely.
Post-wake EDAC event-log IRQs: Benign, exponentially ratelimited apple_soc_edac 23b700000.event-log: hardware error: event-log source 2 interrupts appear after deep S2R wake.
@satchlj Amazing root-cause analysis and testing — thank you!
I have applied your sleep-t8112.h cache-coherency fix (t8112_cpu_off() with HID4/EHID4DISABLE_DC_SW_L2 cleared, t8112_slc_off() / t8112_slc_on() across the 4 MCC planes, and task_stack_page(current) cleans) onto feat/t8112-s2r:
Commit: 7207e4b76 (soc: apple: sleep: fix T8112 SLC write-back and L2 cache clean across S2R)
Build check: Image.gz, t8112-j413.dtb, and t8112-j413-fw27.dtb built cleanly with LLVM=1.
Also noted the two separate observations (aurora + sddm-EBUSY / suspend hang when GPU is active, and the benign post-wake EDAC event-log IRQs). Once maintainers confirm the preferred PR split/landing order here, we'll be ready to proceed.
@satchlj Apologies — I missed your first 27.2 hardware report (04:32Z) when replying right after the rebase. Thank you for the thorough testing and root-cause work!
A few follow-ups to get the branch and attribution into proper shape:
Commit authorship & DCO (9ad129122 / SLC + L2 cache fix): Right now the commit carries my author/Signed-off-by with credit in the body, which isn't proper kernel authorship for your patch. Could you share the From: / Signed-off-by: line you'd like used (or let me know if you prefer to carry/open that commit directly) so I can attribute it properly?
Your tested apple_dart_t8112_display_streams(): Your version (saving/restoring TTBR/TCR, display_dark_enter/display_dark_exit, host_off, clearing DART_T8110_ERROR) is clearly stronger and actually hardware-tested on 27.2 compared to the minimal stream-only helper I wrote. If you can share that diff (with your Signed-off-by:), I'd like to replace my version with yours.
dcpext DT & test cleanup: I've added apple,display-power = <&dcp_power>; to dcpext in t8112.dtsi and restored the t8103-drop-sleep-removes-domains mutation test in tools/asahi/pciec-policy-tests.py (pushed to feat/t8112-s2r @ 9ad129122 and pr/t8112-dcp-s2r @ c1bf79526). Note that apple,t8112-dcpext S2R is still untested on a 13.5 stub.
RTC-backed wake reliability (next priority): Your observation that rtcwake -d rtc1 -m mem -s 20 woke early (~3–4 s) with zero MBSW on cycle 1 and did not wake on cycle 2 directly affects the RTC-wake verification @RyanTheTide asked for. Let's make isolating that wake source / rtc1 alarm behavior our next focus before proposing PRs.
@rjianwei Thanks for folding the fixes in so quickly! Here are the requested attribution details, the tested apple_dart_t8112_display_streams() diff, and exact rtc1 wake-timing measurements from J413 (#9):
Hardware-tested across 11 consecutive deep S2R cycles on J413 (macOS 27.2 stub 26B123). Feel free to carry with Signed-off-by: Satya Benson <satya@benson.earth>:
Exact diff against `rjianwei/linux@9ad1291` (`drivers/iommu/apple-dart.c`)
--- a/drivers/iommu/apple-dart.c+++ b/drivers/iommu/apple-dart.c@@ -8723,44 +8723,80 @@
}
EXPORT_SYMBOL_GPL(apple_dart_display_keep);
-static int apple_dart_t8112_display_streams(struct apple_dart *dart, u32 streams,- bool on, bool flush)+static int apple_dart_t8112_display_streams(struct apple_dart *dart, u32 streams, bool on,+ bool flush)
{
+ struct apple_dart_stream_map map = { .dart = dart };
unsigned long bits = streams;
- unsigned int sid;- u32 status;- int ret;+ unsigned int sid, idx;+ u32 error;+ int ret = 0;- /* T8112 display DARTs map a 0x4000-byte MMIO window; stay within it. */
if (on) {
- struct apple_dart_stream_map all = { .dart = dart };-- dart->sleep_flushed = false;- WRITE_ONCE(dart->display_tlb_stale, false);- WRITE_ONCE(dart->display_dark, false);- writel(streams, dart->regs + DART_T8110_ENABLE_STREAMS);- bitmap_fill(all.sidmap, dart->num_streams);- dart->hw->invalidate_tlb(&all);- return 0;- }-- if (flush && dart->sleep_flushed)- return 0;-- for_each_set_bit(sid, &bits, BITS_PER_TYPE(streams))- writel(BIT(sid), dart->regs + DART_T8110_DISABLE_STREAMS);- if (!flush)+ if (!READ_ONCE(dart->host_off) && !READ_ONCE(dart->display_dark))+ return 0;+ if (dart->display_saved && !apple_dart_state_retained(dart)) {+ if (apple_dart_is_locked(dart)) {+ dev_err(dart->dev, "translations lost at the power-down, and locked\n");+ return -EIO;+ }+ ret = apple_dart_hw_reset(dart);+ if (ret && ret != -EBUSY)+ dev_warn(dart->dev, "reset at power-on: %d\n", ret);+ for_each_set_bit(sid, &bits, dart->num_streams)+ writel(BIT(sid), dart->regs + DART_T8110_DISABLE_STREAMS);+ for (sid = 0; sid < dart->num_streams; sid++) {+ for (idx = 0; idx < dart->hw->ttbr_count; idx++)+ writel(dart->save_ttbr[sid][idx],+ dart->regs + DART_TTBR(dart, sid, idx));+ writel(dart->save_tcr[sid], dart->regs + DART_TCR(dart, sid));+ }+ ret = 0;+ dev_dbg(dart->dev, "translations put back at power-on\n");+ }+ error = readl(dart->regs + DART_T8110_ERROR);+ if (error & DART_T8110_ERROR_FLAG)+ writel(error, dart->regs + DART_T8110_ERROR);+ scoped_guard(spinlock_irqsave, &dart->managed_lock)+ WRITE_ONCE(dart->display_tlb_stale, true);+ ret = apple_dart_display_dark_exit(dart);+ if (ret)+ return ret;+ if (dart->display_saved)+ writel(dart->display_enable & streams,+ dart->regs + DART_T8110_ENABLE_STREAMS);+ else+ writel(streams, dart->regs + DART_T8110_ENABLE_STREAMS);+ dart->host_off_slept = false;+ dart->display_saved = false;+ dart->sleep_flushed = false;+ WRITE_ONCE(dart->host_off, false);
return 0;
+ }- writel(0xa000, dart->regs + DART_T8110_TLB_CMD);- ret = readl_poll_timeout_atomic(dart->regs + DART_T8110_TLB_CMD, status,- !(status & DART_T8110_TLB_CMD_BUSY), 1,- DART_T8110_FLUSH_BUSY_TIMEOUT);- if (ret) {- dev_err(dart->dev, "flush for a power-down didn't finish: %#x\n", status);+ if (READ_ONCE(dart->host_off))+ return 0;+ if (!READ_ONCE(dart->display_dark)) {+ apple_dart_save_state(dart);+ dart->display_enable = readl(dart->regs + DART_T8110_ENABLE_STREAMS);+ dart->display_saved = true;+ }+ ret = apple_dart_display_dark_enter(dart);+ if (ret)
return ret;
+ for_each_set_bit(sid, &bits, dart->num_streams)+ writel(BIT(sid), dart->regs + DART_T8110_DISABLE_STREAMS);+ if (flush) {+ for_each_set_bit(sid, &bits, dart->num_streams)+ set_bit(sid, map.sidmap);+ ret = dart->hw->invalidate_tlb(&map);+ if (ret) {+ dev_err(dart->dev, "flush for a power-down failed: %d\n", ret);+ return ret;+ }+ dart->sleep_flushed = true;
}
- dart->sleep_flushed = true;+ WRITE_ONCE(dart->host_off, true);
return 0;
}
3. rtc1 (apple-pmu-rtc) wake-timing measurement on J413 (#9)
Ran timed tests with pm_debug_messages=1 and dynamic_debug on sleep.c / macsmc.c:
rtc0: macsmc-rtc
rtc1: apple-pmu-rtc 23d714000.spmi:pmic@e:rtc
Results across 3 consecutive committed deep S2R cycles (boot object resumes 0 -> 1 -> 2 -> 3):
rtcwake -d rtc1 -m mem -s 15: woke early — rtc0 and rtc1 advanced 2 s (sys +3 s), macsmc 23e400000.smc: wake record: MBSE 0x10750, MBSW 00 00 00 00 00 00 00 00.
rtcwake -d rtc1 -m mem -s 25: woke early — rtc0 and rtc1 advanced 2 s (sys +2 s), MBSE 0x10750, MBSW 00 00 00 00 00 00 00 00.
Third rtcwake -d rtc1 -m mem -s 15: kernel logged Timekeeping suspended for 0.554 seconds, MBSE 0x10750, MBSW 00 00 00 00 00 00 00 00.
Two clues worth checking first:
apple-sleep printed zero wake source: ... lines on all 3 wakes (sleep.c only logs bits listed in t8112_wake_names[]). Dumping raw s->wake_status[0..6] in apple_sleep_report() (or t8112_sleep_finish()) will immediately show whether an unnamed wake bit fired or whether wake_status offset 0x24 is reading all zeros.
t8112-j413.dts mixes T8103 (5-word) and T8122 (7-word) wake IDs in apple,wake-enable = <3 12 14 54 76 81 133 134 155 184 208>; (54/76/81/133/134 are T8103 IDs while 155/184/208 are T8122 IDs). On a 7-word wake block, one of those mismatched IDs could be unmasking an unrelated source that fires immediately after ~0.5 s.
Happy to test a raw wake_status[0..6] dump / narrowed apple,wake-enable build on J413 whenever you want!
Tested apple_dart_t8112_display_streams(): Applied your exact diff as 5b52d693e on feat/t8112-s2r and e5fb38861 on pr/t8112-dcp-s2r (with your author & Signed-off-by:).
Raw wake_status[0..6] / wake_armed[0..6] logging: Added fee2927bb (t8112_sleep_finish() logs raw wake_status[0..6] and wake_armed[0..6], matching t8103_sleep_finish()). Left apple,wake-enable unchanged for this run so we can see the exact bit firing before narrowing it down (agreed that mixing T8103 5-word and T8122 7-word wake IDs in t8112-j413.dts is the prime suspect).
Image.gz, t8112-j413.dtb, and t8112-j413-fw27.dtb all built cleanly with LLVM=1. Ready for your wake_status dump on feat/t8112-s2r (fee2927bb) whenever you have a chance!
@rjianwei Timed deep S2R now works on J413 with the GPU (aurora, firmware 27.2) and sddm/Hyprland live. The fixes below are on top of your fee2927bb: one diff, three files, all hardware-tested on phellos (J413, macOS 27.2 stub 26B123). Please carry it with:
The wake controller has 8 words, not 7.wake_status[0..6] read all zeroes and wake_armed[6] read ffff0000, because on T8112 the status block starts at +0x28 (mask 0x08..0x24, status 0x28..0x44). So the profile now uses .wake_status = 0x28, .wake_words = 8, .wake_last_word = GENMASK(30, 0).
The wake IDs were a mix of T8103 and T8122 numbers. On T8112 the PMU RTC alarm (NUB.SPMI0.SW3) is ID 58; 54 is NUB.APWakeupTime. t8112_wake_names[] is rebuilt from the J413 ADT ap-wake-sources (20 entries), t8112_wake_required[] is { 58 }, and t8112-j413.dtsapple,wake-enable lists those 20 IDs.
The SPMI and PMU boot-stage order. The Gen-4 spmi_notify_sleep write at .prepare is dropped (T8112 doesn't take it). The boot stage 0x50 is written at the commit, after the RTC vector is acked and enabled. It is then stepped 0x51 at the start of the wake, 0x52 before the resume watchdog, and 0x30 at finish.
DCS (DRAM perf state) stayed at state 3 after the wake. The commit jumped 0x335 -> 0x553 and the wake never stepped back up, so DRAM ran slow until the next reboot. Now t8103_dcs_step_to() steps one state at a time, 7 -> 3 at the commit and back to the saved state at the wake. Result: dcs=0x777->0x333(ok)->0x333->0x777(ok) on every cycle. The commit watchdog also uses T8103_WDT_COMMIT_SECS.
The GPU path.g14_v27_2::sleep_prepare() already does the commit-stop and warm restart, but it is gated on pwr_controller_from_dt. t8112.dtsi was missing the four apple,pwr-* controller properties that every other SoC has (values from aura/rust/src/gpu/hw/t8112.rs), so the GPU refused the sleep with -EBUSY. With them added, sleep-t8112.h:
finds the apple,agx-t8112 device;
refuses the sleep if the GPU's driver is bound but not coproc-ready;
panics if the committed GPU stop failed or GFX doesn't power off;
saves and restores the 8 AGX fabric tunables at 0x205000000 (0x0 0x34 0x38 0x400 0x600 0x738 0x798 0x800) across the ps_gfx power cut, after PMP comes back;
reports a GFX power-on failure as the GPU coproc's wake_err.
Diagnostics. The finish log prints all 8 status/armed words, a read-only wake_entry snapshot taken just before WFI, SPMI vector/ack at the commit and at the wake, and the DCS and AGX state.
Results
Exact head: fee2927bb plus this diff. Built LLVM=1 (Image, modules, t8112-j413.dtb) and run as Trial #16 on phellos, with aurora loaded (G14G 27.2) and sddm/Hyprland active. The sleeps ran with mem_sleep=deep and apple_sleep.untested_commit=Y. Each wake was followed by 25 surfaceless GLES 3.2 FBO renders with glReadPixels.
rtcwake -d rtc1 -s
wall clock
resumes
wake source
DCS
GPU firmware back
renders
5
7.2 s
0 → 1
NUB.SPMI0.SW3
0x777->0x333(ok)->0x333->0x777(ok)
3642 us
25/25 pass
10
11.9 s
1 → 2
NUB.SPMI0.SW3
same
4360 us
25/25 pass
20
22.0 s
2 → 3
NUB.SPMI0.SW3
same
4437 us
25/25 pass
Every cycle shows agx=1 gfx_err=0, no SLC write-back or restore timeouts, 162 of 213 AP pins put back, and MBSE 0x10630 with zero MBSW. The early wakes are gone: each sleep now lasts its full alarm time. Trial #15 (the same fixes on our older base) also passed two cycles with the same results.
Still open: EDAC DEVICE1: UE ... 23b700000.event-log0 ... 'event-log source 2' fires a few times in the seconds after each wake (the post-wake event-log IRQs you noted). Nothing else misbehaves.
Diff against rjianwei/linux@fee2927bb (3 files, +152/−46)
Build check: Image.gz, t8112-j413.dtb, and t8112-j413-fw27.dtb all built cleanly with LLVM=1.
I'll also follow up with a timed rtcwake + default-boot restoration verification run on my J413 (13.5 stub) once I get Aura stage2 set up cleanly alongside stock Omarchy. Looking forward to your shutdown-stall and sleep-drain measurements!
@rjianwei Two follow-ups from the Trial #16 runs on fee2927bb + the diff above: the post-wake EDAC events, and why reboots after a deep sleep take ~2.5 min. No code change requested yet. phellos is offline until someone can press its power button (my mistake, see 2), so neither has been retested.
1. Post-wake apple_soc_edac event-log source 2
What every run shows: the first line comes about 20 ms after back from sleep, before PM: suspend exit. Then:
When it fires: never before the first deep sleep on a boot, and never across s2idle.
One line, held asserted: the repeats are 1.0 s, 2.0 s and 4.0 s apart, e.g. 28.82, 29.86, 31.90, 35.94 s on one boot. That is exactly apple_soc_edac's re-arm backoff (APPLE_SOC_EDAC_BACKOFF_MS 1000, doubling). Each re-arm finds it still asserted, so this is one source that never clears, not new events.
Across sleeps: a later sleep doesn't add bursts. The pending re-arm just fires after that resume (e.g. 94.6 s, after cycle 2). After APPLE_SOC_EDAC_MAX_RETRIES (8) the driver leaves IRQ 152 masked.
Why it can't clear:t8112_event_hw has no status registers (num_status_regs = 0, no ni). So the driver can't read or acknowledge what source 2 latched; it can only mask it.
Likely cause: something the wake does to the PMGR (the event log's first block is 0x23b700000, the PMGR itself) latches an error that nothing clears. The wake log has the candidates: PMGR: 6–8 words on at the commit were off at the wake: 0x110 0x380 0x388 0x3c8 0x418 0xc00 and AON PMGR: 0xb0 0xb8.
Impact: no functional effect seen. Display, NVMe, Wi-Fi, BT, MTP and the GPU all work, and the cycles after it pass. It does count as a UE in EDAC, though.
Next step, once phellos is back: dump the event log's raw per-source registers just before the commit and right after t8112_sleep_wake(), so we can see which block latches. Then either clear it in the wake sequence or give t8112_event_hw a status/acknowledge contract.
2. Shutdown after a deep sleep hangs in device_shutdown()
After any committed deep sleep, systemctl reboot finishes userspace in about 1.5 s. Then the kernel hangs in device_shutdown() until the 2-minute hardware watchdog that systemd-shutdown arms resets the machine. That is the ~90 s+ delay I reported earlier.
How I traced it: netconsole to a remote host, with initcall_debug, and the reboot forced with -ff so that iwd keeps Wi-Fi up.
What the trace shows:
Driver shutdowns go cleanly through brcmfmac, pcie-apple, nvme-apple and dcp-dp-audio.
Then the internal apple-dcp 231c00000.dcp component unbind starts. The panel powers off, and DPMS off re-runs the S2R firmware stop (idle status not set: 0x2d). Then RTKit: Endpoint 0x20 is not running, cannot send message, and nothing more.
afk_shutdown()'s "Timed out shutting down AFK endpoint %02x" has no \n, so a 1 s timeout there stays in the printk continuation buffer and never reaches the console. The real hang may be later in dcp_comp_unbind(): iomfb_shutdown(), or dcp_release_piodma_iommu_dev() tearing down the piodma DART while the display DARTs are dark after the stop.
I have a diagnostic build. It is built but not booted. It:
adds the \n;
logs unbind: <step> breadcrumbs while the system goes down;
when s2r_fw_down, completes each endpoint's stopped, so the unbind doesn't ask the stopped firmware.
I'll post what it shows once phellos is back.
My mistake, for anyone reproducing this: the -ff run had /dev/watchdog0 magic-closed for the sleep. -ff skips systemd-shutdown, so nothing re-armed the watchdog, and the hang left phellos down. Re-arm a watchdog before any forced reboot.
Hardware test report on J413 (MacBook Air 13" M2, T8112, OS FW 13.5 stub) running feat/t8112-s2r (4be95ff46) with Aura Stage 2 (1.0.0b17-gd833bf40) and a non-default Limine test entry (stock Omarchy 7.2.11-14-1-ARCH kept as default):
s2idle: Entered and woke cleanly via keyboard (Caps Lock), internal 13.5 panel and Wi-Fi (brcmfmac) recovered with 0 errors.
deep dry-run (untested_commit=0, aurora unloaded): Passed completely — apple-sleep 23b700000.sleep: dry run: every check passed; refusing before the first stop and the commit, dcp_poweroff() -> dcp_poweron() restored 2560x1664@60 cleanly (resume devices took 0.403 seconds).
Default-boot fallback: After watchdog resets on committed tests below, J413 automatically booted back into stock Omarchy 7.2.11-14-1-ARCH with no manual intervention.
Issues observed on 13.5 (4be95ff46)
aurora (13.5 G14G firmware) refuses deep sleep (-16 / -EBUSY):
With aurora loaded, rtcwake -d rtc1 -m mem -s 10 aborts cleanly in genpd_prepare: aurora 206400000.gpu: PM: device_prepare(): genpd_prepare returns -16.
Pre-existing UAF Oops in dpm_suspend() after modprobe -r aurora:
Unloading aurora at runtime (modprobe -r aurora) and then running rtcwake -d rtc1 -m mem -s 10 hit a kernel paging fault before apple-sleep ran (captured via console_suspend=N):
Unable to handle kernel paging request at virtual address 004656c62616e58
pc : klist_next+0x6c/0x110
lr : klist_next+0x2c/0x110
x23: 2064656c616e5d
Call trace:
klist_next+0x6c/0x110
device_find_child+0x54/0x80
dpm_suspend+0x48/0x318
dpm_suspend_start+0x54/0x90
suspend_devices_and_enter+0xfc/0x7d8
pm_suspend+0x214/0x2d0
Committed rtcwake -d rtc1 -m mem -s 10 with module_blacklist=aurora hit ~60 s WDT reset:
Booting with module_blacklist=aurora avoided the dpm_suspend UAF completely (booted straight to desktop, aurora not loaded), and rtcwake -d rtc1 -m mem -s 10 entered suspend without Oops, but did not wake at 10 s and hit a ~60 s WDT reset back to stock Omarchy.
Two suspects to isolate next on 13.5:
In 4be95ff46, sleep_ps_wait_off(s, T8112_PS_GFX) now calls panic("T8112 committed GFX power-off timed out") unconditionally even when t8112.gpu is unbound (with module_blacklist=aurora, no GPU driver has stopped GPU firmware if ps_gfx is on; gating that panic() on device_is_bound(&t8112.gpu->dev) would avoid panicking when aurora is blacklisted).
apple,t8112-dcpext (s2r_ext = true) stop/resume on a 13.5 stub (untested on 13.5 so far).
@satchlj Confirming that your Nov 29 wake/DCS/GPU diff has been carried on rjianwei/linux (feat/t8112-s2r) as 4be95ff46 with Author: Satya Benson <satya@benson.earth> and your Signed-off-by: preserved, followed by 208e2a333 (gating the T8112 committed GFX power-off timed out panic on gpu_bound).
Quick update from 13.5-stub J413 testing on 208e2a333:
module_blacklist=aurora + 208e2a333 still hits a ~60 s reset on committed rtcwake -d rtc1 -m mem -s 10.
Ruled out so far on this 13.5-stub J413:
GFX timeout panic: ruled out (208e2a333 still resets at ~60 s).
Bootloader/memory protection: aurora,s2r-mailbox (0x802d70440) is covered by EFI reserved (802c70000-8030abfff) in /proc/iomem.
Device suspend/resume: pm_test=core with mem_sleep=deep and untested_commit=1 passes cleanly (suspend devices 1.28s, resume devices 0.33s, no errors).
RTC1 alarm & dry-run: rtcwake -d rtc1 -m no -s 3 fires apple_spmi IRQ 70 (0 -> 1), and untested_commit=0 dry-run passes (dry run: every check passed, only pmp and gpu unbound).
WDT timing split: Tested both a 30s commit / 10s early-wake WDT build and a 10s / 25s / 45s WDT ladder across apple_sleep_enter_prepare() (before cpus_hold, before coprocs_stop(true), and before coprocs_stop(false)) with rtcwake -d rtc1 -m mem -s 5 — neither triggered early; both still reset at ~60–68 s, indicating apple_sleep_enter_prepare() completed and the reset is coming from the ~60 s watchdog / SMC sleep timeout rather than an early hang in apple_sleep_enter_prepare().
For comparison, which aura commit and bootloader chain are you using on your 27.2 J413? (I am on aura 1.0.0b17-gd833bf40 -> U-Boot -> Limine.)
@rjianwei Two updates from phellos (J413) since my last comment.
1. Post-sleep reboot hang: fixed, in linux#3595 (draft)
The ~2.5 min reboot after a deep sleep was not in the sleep driver.
Cause: at shutdown, drm_atomic_helper_shutdown() turns the internal panel off as DPMS off does, which lowers the display domains, display DART included. dcp_comp_unbind() then destroys the piodma device, which detaches it from that unpowered DART, and the restart hangs until the watchdog fires.
How it was found: netconsole step logs during shutdown.
It's independent of feat/t8112-s2r, so nothing for you to carry.
2. Post-wake EDAC event-log source 2: narrowed, not fixed
This is the line the earlier comment described as held asserted after each wake. It is DT index 2 of the apple,t8112-event-log node, AIC 196, whose reg is the PMGR clock-mux block at 0x23b000000.
From diagnostic rounds 20–27 (read-only AIC HW_STATE sampling of the node's own lines, at each step of t8112_sleep_wake()):
What raises it: the line is clear at the wake, and stays clear for at least 5 ms of no access. The first access of any kind to the clock-mux block raises it: a read of the SoC mux words, or the parked-mux write plus busy poll. Then it stays raised until the next sleep's power cut.
Ruled out, none of these change it:
mux writes (the generic restore loop writes none);
the order the PMGR words come back (an early sleep_ps_rewake());
restoring the AON debug_switch, debug_gated, msg and USB words before the access;
elapsed time.
The same 64 reads at the commit leave it clear.
Why the sleep driver can't fix it: the parked muxes have to be restored, so the block has to be touched, and no reordering helps.
What would fix it: the event log's per-source status and acknowledge for T8112, so apple_soc_edac can read and clear source 2. t8112_event_hw has none today, so it can only mask the line. I'm asking about that contract separately.
The diagnostic code stays local. Nothing here needs a change on feat/t8112-s2r.
@satchlj macOS 27.2 on a T8112 (Mac mini J473), traced under our hypervisor, for event-log source 2.
1. The ADT already gives source 2's log registers
/arm-io/event-log-handler has event-logs (0xd8 bytes = 18 triples of u32: line index, reg index, offset) next to interrupts (16 lines, index 2 = AIC 196) and reg (index 2 = 0x23b000000 +0x70000):
line
reg
offset
address
0
0
0x380a4, 0x76000
0x23b7380a4, 0x23b776000
1
1
0x3c23c
0x23d2bc23c
2
2
0x28000, 0x6c004
0x23b028000, 0x23b06c004
3
3
0x78000
0x23d278000
4-10
same
0x3ff0
11, 13
same
0xff0
12
12
0x2800
14, 15
same
0x400c
Lines 0 and 2 each have two log words. So t8112_event_hw doesn't need a hard-coded status table: the DT can carry this property, as it comes from the ADT, and the driver can read and acknowledge each source's words from it.
2. macOS never acknowledges the line. It never raises it.
The same node has panic-on-event-log-intr = 1: macOS treats any event-log interrupt as fatal, so there is no ack sequence to copy.
On a cold boot, macOS's whole access pattern to the 0x23b000000 window (28 pages hooked, pass-through, every access recorded) is 12 accesses at about 0.9 s: +0x400d4, +0x400d8, +0x400dc, +0x400e0, +0x400e4, +0x400e8, each written 0 and read back 0. Nothing reads or writes +0x28000 or +0x6c004. No event-log interrupt fires (the guest would have panicked).
I can't trace a macOS deep-sleep wake on T8112 under the HV: the power cut takes the HV down too (the J473 guest dies in sleepnow).
What this suggests for the wake path
Since macOS never raises source 2, the first post-wake access on Linux is probably reaching the block before something is restored that macOS has in place, rather than missing an acknowledge. Two cheap checks on your J413:
After wake, read 0x23b028000 and 0x23b06c004 before and after the first clock-mux access. The word that changes is source 2's log, and its value should say what was hit.
Try writing that value back (write-1-to-clear is the usual event-log shape), then re-sample AIC 196's HW_STATE. If the line drops, that's the acknowledge for apple_soc_edac. If it doesn't, it's latched until power-off, which fits macOS treating it as fatal.
If 0x23b028000 / 0x23b06c004 point at a specific mux, I can trace that register's macOS cold-boot sequence on the J473 on request.
@satchlj Thank you for opening #3647, rebasing onto current main, running the exact-head J413 verification, and preserving all commit authorships and Signed-off-by lines — please keep #3647 open and drive it to merge, no need to close/reopen on my behalf.
I also saw the aurora-silicon-review notes on #3647 (apple,t8140-display-power.yaml + apple,agx.yaml schema additions for dt-checks, plus the three minor cleanups in sleep-t8112.h). Happy to push a small follow-up commit on rjianwei/linux (feat/t8112-s2r) for you to cherry-pick if you haven't already fixed them on satchlj/t8112-s2r, or feel free to fold them directly on #3647 — whichever is faster for you.
J413 (M2 Air, firmware 27.2) deep-sleep drain, on the T8112 sleep series (#3647) plus #3595. 20-minute rtcwake sleeps with the GPU and desktop live, measured on the battery's energy_now, which moves in steps of about 11.4 mWh. One variable per row:
Change
Sleep drain
baseline
0.58 W
Wi-Fi and Bluetooth unbound
0.55 W: within counter resolution, ruled out
DCS floor 3 → 2 at the commit
0.51 W: about 2 steps, small real gain
plus audio domains (mca1/3/4/5, audio_p) lowered at the commit
So most of the gap was the audio domains left on through sleep. Still on just before WFI: always-on words, soc_spmi0 (the wake path), aft0, sio_busif, fpwm2, spi5, uart8, ans. Below about 0.03 W the counter cannot resolve a 20-minute row; a longer one needs a longer RTC wake (the PMU RTC refuses 3600 s).
The audio-domain and DCS changes are local for now. Next is a PR that lowers the domains through genpd and the device tree instead of a per-SoC list.
The separate EDAC follow-up #3659 passed three J413 deep wakes on top of that exact sleep stack and received independent review. Track its hosted check separately. The sleep series still needs its J473 peer evidence and the #3595 ordering gate.
Marked the open hardware check with needs hardware test. The existing owner and test request linked above remain current.
The coordinated T8112 (J413) suspend-to-RAM series has merged to main: #3647 (7711340c7aa3, drivers/soc/apple/sleep.c and sleep-t8112.h), #3595 (5f17cd312e), #3659 (45648c63f0bc), and #3786 (f21d1ed08a67, enabling deep sleep by default on t8112-j413-fw27). Closing this pre-PR coordination thread as completed.
Activity
RyanTheTide commentedon Nov 27, 2026
Keeping this as the J413 suspend-to-RAM design thread. The next step is to compare the proposed changes with the current shared sleep path and specify how an RTC-backed wake and default-boot restoration would be verified.
rjianwei commentedon Nov 27, 2026
Thanks for keeping
#3371as the J413 design thread. Here is the comparison against the current shared sleep path (main@cec0503a5a02) and the proposed verification plan for RTC-backed wake and default-boot restoration.1. Comparison with the current shared sleep path
The T8112 work is built directly on the existing
drivers/soc/apple/sleep.c+aurora,s2r-mailboxarchitecture (no EFI/PSCI conduit and no corekernel/power/suspend.chooks):sleep.ccore (2-line hook only):drivers/soc/apple/sleep.conly adds#include "sleep-t8112.h"and the"apple,t8112-sleep"entry inapple_sleep_of_match[].drivers/soc/apple/sleep-t8112.h, following the sameapple_sleep_soc/apple_sleep_opspattern assleep-t8103.handsleep-t8122.hand reusing the shared mailbox handoff,apple_sleep_read_wake_sources(), SPMI/PMU helpers, andsleep-test.cKUnit coverage.drivers/irqchip/irq-apple-aic.c: addsaic2_t8112_info("apple,t8112-aic") with.fw_suspend = trueso the existingaic_syscore_suspend/resumepath saves/restoresAIC2_CONFIG,AIC2_IRQ_CFG, and CPU0 timer FIQ state.drivers/mfd/macsmc.c: enablessmc->saved_enabled = truefor"apple,t8112-smc"alongside"apple,t8103-smc".drivers/soc/apple/pmp.rs: addsHW_CFG_T8112(sram_backup: Some((0x2f000, 0x46000))) for"apple,t8112-pmp-v2"(still overridden if the bootloader providesapple,sram-keep).drivers/thunderbolt/apple.c+tools/asahi/pciec-policy-tests.py: addsapple_cio_t8112_hwusing the same policy asapple_cio_t8122_hw(sleep_removes_domains,restart_on_wake,phy_shared_with_dwc3,apple_dpin_m1).arch/arm64/boot/dts/apple/t8112.dtsi,t8112-j413.dts, andapple,t8140-sleep.yaml: adds theapple,t8112-sleepnode/binding, enables it on J413, and wirespower-domainson&sep.drivers/gpu/drm/apple/dcp.c+drivers/iommu/apple-dart.c: addsdcp_s2r_t8112/apple_dcp_hw_t8112S2R flags and a bounds-safe"apple,t8112-dart"path inapple_dart_display_streams()(T8112 DART MMIO is0x4000bytes, avoiding an out-of-bounds access atdart->regs + 0x4060). Note: I seemainhas recently moved display DART stream / power-word handling further toward DT-driven layouts (5ff9c1c58,888805b87), so I will rebase this piece cleanly onto currentmainbefore proposing a PR.apple_rtkit_idle()currently returns-62without anA500AP-link release +disp0power cycle + RTKit warm restart, so the internal panel stays dark on wake while all other subsystems recover cleanly. Happy to keep 13.5 internal DCP warm-restart as a separate follow-up discussion if you prefer keeping the initial T8112 series focused on the core sleep path and subsystem enablement.2. Verification plan: RTC-backed wake & default-boot restoration
A. RTC-backed wake verification (unattended)
J413 already defines
rtc1 = &pmu_rtc(apple,t8112-pmu-rtcon Stowe PMICpmic@e, driven bydrivers/rtc/rtc-apple-pmu.cwithwakeup-sourceanddev_pm_set_wake_irq()), andsleep-t8112.hexplicitly acks and enablesT8103_SPMI_VEC_RTConnub-spmibefore entering sleep and restoresspmi_vec_savedon wake.Proposed verification procedure (repeatable over SSH with no manual lid/key press):
cat /sys/power/mem_sleephas[deep]selected./dev/rtc1binds toapple-pmu-rtcand/sys/class/rtc/rtc1/device/power/wakeupisenabled.date -u), currentapple-sleepboot-object resume count, and healthy device states (NVMe, Wi-Fi, BT, SEP, MCA audio, SPI-HID keyboard).rtcwake -d rtc1 -m mem -s 20for 3 consecutive cycles, followed by a longerrtcwake -d rtc1 -m mem -s 60soak.dmesglogsapple-sleep: back from sleep, boot object resumes N -> N+1and full AP pin restoration with zero errors.rtc1alarm interrupt is cleanly acknowledged/disarmed after wake (one-shot clear inrtc-apple-pmu, no IRQ storm or wedged wake source).sleep 1completes in ~1s), NVMe I/O (ANS: on after the sleep), Wi-Fi/SSH reconnection (brcmfmac), Bluetooth (hci_bcm4377), SEP (apple_sep), audio (apple-mca), and keyboard (spi-hid).B. Default-boot restoration verification
To keep J413 safely recoverable across all hardware tests:
Image.gz, initramfs, andt8112-j413.dtbunder a dedicated test boot entry and select it one-shot (e.g.grub-reboot/ one-shot menu entry), so any panic, watchdog reset, or hard power cycle automatically returns to the stock default OS.uname -rmatches the stock distro kernel./proc/cmdlinehas no leftover debug/test flags.Let me know if you want any adjustments to the shared-path split or additional checks in the RTC wake / boot-restoration matrix before I rebase onto current
mainand run the RTC-backed verification pass on J413.satchlj commentedon Nov 28, 2026
I have a J413 (MacBook Air M2) running a macOS 27.2 stub (
t8112-j413-fw27.dts, live MTP handoff, 27.2 DCP/DCPEXT, and G14G 27.2 GPU viaaurora/g14_v27_2) with Aura already publishing/chosen/aurora,s2r-mailbox.I'm happy to help test your
feat/t8112-s2r/pr/t8112-dcp-s2rbranches on the 27.2 stub once you're ready for PR review—specifically the pieces that can't be exercised on a 13.5 stub:dcpextwarm restart on T8112 (matching T8103#3172/#3178)#3413'sapple_dart_system_suspend()fix)g14_v27_2,#3171)t8112-j413-fw27.dtssleep node + SMC wake reasonsA few early notes from glancing at
pr/t8112-dcp-s2r(87fe26b1e5) against currentmain(a40c5131071d1) ahead of your rebase:apple_dart_display_streams()on == falseOOB writes:pr/t8112-dcp-s2rguards theon == truepath forapple,t8112-dart's0x4000-byte MMIO window, but theon == falsepath onmainalso writesdart->regs + 0x4060anddart->regs + 0x4000(which are past0x4000on T8112'sdisp0_dart/dcp_dart/dispext0_dart/dcpext_dart)..map_reg_dartanddcpext: Onmain,apple_dcp_hw_t8103sets.map_reg_dart = trueforDCP_FIRMWARE_V_27_0register-window DART mappings (iomfb_template.c), and#3178addedapple_dcp_hw_t8103_dcpext(dcp_s2r_t8103_ext). For T8112dcpext@271c00000,t8112-pmgr.dtsi/t8112.dtsigivedisp_cpu = 0x3c8,disp_fe = 0x388,disp_sys = 0x380,dcp_streams = BIT(5),disp_streams = BIT(0) | BIT(4).dcp_s2r_layout_from_dt()onmain: That helper currently requires bothpwrgateandapple,retention-workaround, so keeping a staticdcp_s2r_t8112(likedcp_s2r_t8103) still looks right for T8112.Let me know when you've rebased onto current
main(or if you'd like early 27.2 test results on the currentfeat/t8112-s2rhead).satchlj commentedon Nov 28, 2026
Hardware test report on J413 (MacBook Air 13" M2, T8112, macOS 27.2 stub
26B123) usingrjianwei/linuxfeat/t8112-s2r(d3fc11cd3) rebased ontomain(ff59991a6), plus#3470(J413&smcwake reasons +&hpm0/&hpm1apple,sleep-ssps) and#3425(live-MTP DART across S2R).Result: First real committed deep sleep + resume on J413 / 27.2 (
boot object resumes 0 -> 1)With
auroraunloaded (see GPU note below) and our 27.2 DCP/DCPEXT + DART fixes below:apple_sleep.deep=1,untested_commit=0):apple-sleep 23b700000.sleep: dry run: every check passed; refusing before the first stop and the commit. Both 27.2dcp(231c00000.dcp) anddcpext(271c00000.dcp) power-cycled and resumed cleanly.untested_commit=1,rtcwake -d rtc1 -m mem -s 20):apple-sleep 23b700000.sleep: 162 of 213 AP pins changed by the sleep, all put backapple-sleep 23b700000.sleep: back from sleep, boot object resumes 0 -> 1apple-dcp 231c00000.dcp(27.2 internal eDP): resumed cleanly (2560x1664@60, backlight restored todbv: 15174), 0 errors.apple-dcp 271c00000.dcp(27.2dcpext): resumed cleanly (RTKit: Initializing (protocol version 12)), 0 errors.rtkit-helper 24e400000.mtp+apple-dart 24e808000.iommu(#3425): live MTP survived committed S2R with 0 errors and all 3 input devices intact.nvme-apple(ANS: on after the sleep),apple_sep(the enclave is back from its sleep request),apple-sio,apple-mca,pcie-apple(link back, PWREN and PERST# cycled as at probe),brcmfmac(Wi-Fi reconnected), andhci_bcm4377all resumed cleanly.Fixes needed on 27.2 J413 (
dcp/dcpext/apple-dart)dcpext+map_reg_dartindrivers/gpu/drm/apple/dcp.candt8112.dtsi:apple,display-power = <&dcp_power>;todcpext(271c00000) int8112.dtsi.dcp_s2r_t8112_ext(disp_cpu = 0x3c8,disp_fe = 0x388,disp_sys = 0x380,dcp_streams = BIT(5),disp_streams = BIT(0) | BIT(4)),apple_dcp_hw_t8112_dcpext(.s2r_ext = true,.s2r_no_secure_port = true,.s2r_disp_dart_with_dcp = true,.map_reg_dart = true), and.map_reg_dart = trueonapple_dcp_hw_t8112.apple_dart_t8112_display_streams()indrivers/iommu/apple-dart.c:on == false(save TTBR/TCR/enable state,display_dark_enter,DART_T8110_DISABLE_STREAMS, TLB invalidate,host_off = true) andon == true(restore TTBR/TCR if translations were lost, clearDART_T8110_ERROR,display_tlb_stale = true,display_dark_exit,DART_T8110_ENABLE_STREAMS,host_off = false) without touching the out-of-range0x4000/0x4060registers on T8112's0x4000-byte window.Remaining issues observed on J413 / 27.2
aurora) refuses deep sleep (-EBUSYingenpd_prepare/g14_v27_2::sleep_prepare):g14_v27_2::sleep_prepare(deep=true)gates onroot.has_pwr_controller()(pwr_controller_from_dt), requiringapple,pwr-filter-time-constant,apple,pwr-integral-gain,apple,pwr-integral-min-clamp, andapple,pwr-proportional-gain.t8112.dtsinor Apple's J413/arm-io/sgxADT has those four properties (onlygpu-pwr-min-duty-cycle,gpu-avg-power-*,gpu-ppm-*,gpu-fast-die0-*,gpu-perf-*), soauroracurrently refuses deep sleep on J413.rtc1(apple-pmu-rtc) across cycles:rtcwake -d rtc1 -m mem -s 20) woke after ~4 s withmacsmc 23e400000.smc: wake record: MBSE 0x10750, MBSW 00 00 00 00 00 00 00 00and no namedapple-sleepwake source logged.rtcwake -d rtc1 -m mem -s 20) stayed asleep past the 20 s alarm (and pastWDT_SUSPEND_SECS=120), indicating the machine entered deep sleep cleanly but thertc1alarm did not wake it on cycle 2 (awaiting physical lid/key/power-button wake to inspect).apple_soc_edacerrors:apple_soc_edac 23b700000.event-loglogged repeated rate-limitedhardware error: event-log source 2 (IRQ 154, AIC2 65732)(275.9s,276.9s,278.9s,283.0s,291.4s,307.8s,340.1s).rjianwei commentedon Nov 28, 2026
@satchlj Thank you so much for offering to test on the J413 27.2 stub and for the concrete review notes!
I have rebased
feat/t8112-s2r(as well aspr/t8112-aic2-s2r,pr/t8112-macsmc-s2r, andpr/t8112-dcp-s2r) onto currentmain(ff59991a6, which includesa40c5131071d1), updated the branches onrjianwei/linux, and addressed all three points:apple_dart_display_streams()on == falseOOB writes (drivers/iommu/apple-dart.c):apple_dart_t8112_display_streams()so bothon == trueandon == falsestay strictly within T8112's0x4000-byte MMIO window (avoiding0x4060and0x4000on both paths while preserving stream disable +DART_T8110_TLB_CMD0xa000flush).27.x.map_reg_dartandt8112-dcpext(drivers/gpu/drm/apple/dcp.c):.map_reg_dart = truetoapple_dcp_hw_t8112.dcp_s2r_t8112_ext(disp_cpu = 0x3c8,disp_fe = 0x388,disp_sys = 0x380,dcp_streams = BIT(5),disp_streams = BIT(0) | BIT(4)) andapple_dcp_hw_t8112_dcpextmatching"apple,t8112-dcpext".dcp_s2r_t8112+t8112-j413-fw27.dts:dcp_s2r_t8112/dcp_s2r_t8112_extlayouts. Sincet8112-j413-fw27.dtsincludest8112-j413.dts, it inherits&system_sleep { status = "okay"; };automatically.Verification after the rebase:
Image.gz,t8112-j413.dtb,t8112-j413-fw27.dtb, andmodules(includingappledrm.ko) withLLVM=1.tools/asahi/pciec-policy-tests.pyandtools/asahi/tb-cio-sleep-tests.py(41 native tunnel replay cases + 27 negative controls) all pass.Updated branches for your 27.2 test run:
35ea67f88)d48dc0a2a)Early 27.2 test results on
feat/t8112-s2rwould be hugely appreciated whenever you have a chance!satchlj commentedon Nov 28, 2026
Follow-up from committed S2R cycle #2 on the same
7.3.0-s2r1-ARCHboot (withdynamic_debugonsleep.candmacsmc.c), pulled fromjournalctl -b -1 -kafter recovering back into the default boot:Cycle drm/apple: release a stale DPTX link before borrowing a Type-C route #2 also entered and exited deep sleep cleanly (
RC=0):apple-sleep 23b700000.sleep: 162 of 213 AP pins changed by the sleep, all put backaura slot mapped flag 5 -> 7/6 -> 8after20–40 us).apple-sleep 23b700000.sleep: back from sleep, boot object resumes 1 -> 2apple-sleep 23b700000.sleep: PMGR: 7 words on at the commit were off at the wake: 0x110 0x338 0x380 0x388 0x3c8 0x418 0xc00apple-sleep 23b700000.sleep: AON PMGR: 2 words on at the commit were off at the wake: 0xb0 0xb8apple-sleep 23b700000.sleep: power words: 21 written back, 0 not on in timeMBSW:macsmc 23e400000.smc: wake record: MBSE 0x10750, MBSW 00 00 00 00 00 00 00 00(rtcwake -d rtc1 -m mem -s 20exitedRC=0at04:28:09Z, 3 s after04:28:06Z).dcp,dcpext, NVMe (ANS: on after the sleep), SEP, SIO, audio (apple-mca), and PCIe link recovery all completed andPM: suspend exitwas logged.Post-resume kernel panic (~1 s after
PM: suspend exit,04:28:10Z):PM: suspend exit, tearing down the transientsystemd-rununit triggered:WARNING: arch/arm64/net/bpf_jit_comp.c:3402 at bpf_jit_free+0x154/0x15c(WARN_ON_ONCE(!bpf_prog_kallsyms_verify_off(prog))) inkworker/1:2(bpf_prog_free_deferred)Unable to handle kernel NULL pointer dereference at virtual address 0000000000000028infree_percpu+0xc4/0x3cc<-__bpf_prog_free<-bpf_jit_free<-bpf_prog_free_deferred(withx19 = 0x2d6f6e2d676f7270, ASCII"prog-no-")0x8dereference inrb_insert_color+0x40/0x130<-bpf_ksym_add<-bpf_prog_kallsyms_add<-bpf_prog_load(fromNetworkManager),Kernel panic - not syncing: Oops: Fatal exception in interrupt.aurorahad been reloaded (modprobe aurora, probe failed-EBUSY) between cycle mux: apple-display-crossbar: replace the T602x selector fields instead of OR-ing them #1 and cycle drm/apple: release a stale DPTX link before borrowing a Type-C route #2, though it was not bound (gpu isn't bound). Worth checking whetherCONFIG_ARM64_CTXR_EXECMEM/ BPF JIT memory or slab/vmalloc state is getting corrupted across deep sleep or repeated cycles.satchlj commentedon Nov 28, 2026
Root-caused and fixed the post-resume stale-DRAM / BPF corruption (
bpf_jit_free/rb_insert_color) on J413 (T8112).Root causes (two cache-coherency bugs in
drivers/soc/apple/sleep-t8112.h)t8112_deep_wfi_arm()re-enabledHID4/EHID4.DISABLE_DC_SW_L2beforet8103_cpu_off():hid4 = 0x130800000800: bothDISABLE_DC_MVA(bit 11) andDISABLE_DC_SW_L2(bit 44) are set by default on T8112.t8112_deep_wfi_arm()clearedT8112_HID4_DC_MASK, rant8112_dcache_clean_all_levels()whileSCTLR_EL1.Cwas still enabled, restoredHID4(re-enablingDISABLE_DC_SW_L2), setACC_DIS_L2_FLUSH = 2, and then calledt8103_cpu_off(). That turnedt8103_cpu_off()'s L2dc cswloop into a hardware NOP while dirty lines from C code/stack remained in L1/L2 (notably on secondary P-cores parked early viaearly_cpu_wfi = true).t8112_cpu_off(u64 cyc_ovrd, u64 acc_ovrd)(clearsSCTLR_EL1.Cfirst, zero stack accesses,dc ciswon L1,dc cswon L2+) and invoke it withT8112_HID4_DC_MASKleft cleared (core resets on wake).T8112 SLC was never disabled/written back before deep sleep (MCC loses power):
200100000.memory-controller(apple,t8112-mcc) is bound toapple-regview, so nothing stopped SLC allocation or wrote back dirty SLC ways before deep sleep.0x200000000, stride0x40000):0x424:CACHE_DISABLE(0= allocation enabled,1= allocation disabled)0x1c00:WAYS(16= 16 ways enabled,0= write-back & power down)0x1c04:WAYS_STATUS(DATA = GENMASK(14, 10),TAG = GENMASK(9, 5); live value0x4200= 16 data + 16 tag ways;0x0when written back/off)t8112_sleep_commit_regs(), aftert8112_dcache_clean_all_levels(), callt8112_slc_off()(set0x424 = 1on all 4 planes ->dsb(sy)-> set0x1c00 = 0-> poll0x1c04data & tag == 0), then clean critical wake state +task_stack_page(current)+ finalt8112_dcache_clean_all_levels(). Also cleantask_stack_page(current)int8112_sleep_pre_commit(). On wake int8112_sleep_wake(), afterclk_muxrestore, callt8112_slc_on()(write savedwaysto0x1c00-> poll0x1c04-> clear0x424 = 0).ways=16 off_bad=0x0 off_st=0x0 wake_before=0x0 on_bad=0x0 wake_after=0x4200on every cycle (wake_before=0x0confirms MCC loses power during deep sleep).t8112_slc_off()writing back all dirty SLC lines cleanly and instantaneously, thet8122_clean_used_ram()walk int8112_sleep_commit_regs()is no longer needed.Hardware verification on J413 (MacBook Air 13" M2, T8112, macOS 27.2 stub
26B123)Tested with
sddmstopped andauroraunloaded,apple_sleep.untested_commit=1,mem_sleep=deep,rtcwake -d rtc1 -m mem -s 10, plus BPF load/attach/free stress (30xsystemd-run --quiet --wait -p IPAddressDeny=192.0.2.0/24 /bin/truebefore cycle 1 and after each wake):boot object resumes 0 -> 6)ways=16 off_bad=0x0 off_st=0x0 wake_before=0x0 on_bad=0x0 wake_after=0x4200wlan0+ Tailscale reconnected on all 6 cycles; zero Oops/BUG/WARNING.boot object resumes 0 -> 1 -> 2 -> 3 -> 4 -> 5)30/30pre +30/30after each of cycles 1–5)wlan0up on all 5 cycles; zero Oops, zero BUG, zero WARNING, zero Call trace, zero SLC timeouts.Separate pre-existing observations (out of scope for cache coherency)
sddm+auroraGPU active during S2R: Right after bootaurora 206400000.gpureturns-16(EBUSY) ingenpd_prepare; later withsddmstill running, S2R hangs/resets ~39 s into suspend. Stoppingsddmand unloadingauroraavoids this completely.apple_soc_edac 23b700000.event-log: hardware error: event-log source 2interrupts appear after deep S2R wake.Patch (
drivers/soc/apple/sleep-t8112.h)Exact git diff (311 lines)
rjianwei commentedon Nov 28, 2026
@satchlj Amazing root-cause analysis and testing — thank you!
I have applied your
sleep-t8112.hcache-coherency fix (t8112_cpu_off()withHID4/EHID4DISABLE_DC_SW_L2cleared,t8112_slc_off()/t8112_slc_on()across the 4 MCC planes, andtask_stack_page(current)cleans) ontofeat/t8112-s2r:7207e4b76(soc: apple: sleep: fix T8112 SLC write-back and L2 cache clean across S2R)Image.gz,t8112-j413.dtb, andt8112-j413-fw27.dtbbuilt cleanly withLLVM=1.Also noted the two separate observations (
aurora+sddm-EBUSY/ suspend hang when GPU is active, and the benign post-wake EDAC event-log IRQs). Once maintainers confirm the preferred PR split/landing order here, we'll be ready to proceed.rjianwei commentedon Nov 28, 2026
@satchlj Apologies — I missed your first 27.2 hardware report (
04:32Z) when replying right after the rebase. Thank you for the thorough testing and root-cause work!A few follow-ups to get the branch and attribution into proper shape:
9ad129122/ SLC + L2 cache fix): Right now the commit carries my author/Signed-off-bywith credit in the body, which isn't proper kernel authorship for your patch. Could you share theFrom:/Signed-off-by:line you'd like used (or let me know if you prefer to carry/open that commit directly) so I can attribute it properly?apple_dart_t8112_display_streams(): Your version (saving/restoring TTBR/TCR,display_dark_enter/display_dark_exit,host_off, clearingDART_T8110_ERROR) is clearly stronger and actually hardware-tested on 27.2 compared to the minimal stream-only helper I wrote. If you can share that diff (with yourSigned-off-by:), I'd like to replace my version with yours.dcpextDT & test cleanup: I've addedapple,display-power = <&dcp_power>;todcpextint8112.dtsiand restored thet8103-drop-sleep-removes-domainsmutation test intools/asahi/pciec-policy-tests.py(pushed tofeat/t8112-s2r@9ad129122andpr/t8112-dcp-s2r@c1bf79526). Note thatapple,t8112-dcpextS2R is still untested on a 13.5 stub.rtcwake -d rtc1 -m mem -s 20woke early (~3–4 s) with zeroMBSWon cycle 1 and did not wake on cycle 2 directly affects the RTC-wake verification @RyanTheTide asked for. Let's make isolating that wake source /rtc1alarm behavior our next focus before proposing PRs.satchlj commentedon Nov 28, 2026
@rjianwei Thanks for folding the fixes in so quickly! Here are the requested attribution details, the tested
apple_dart_t8112_display_streams()diff, and exactrtc1wake-timing measurements from J413 (#9):1. Commit authorship & DCO (
sleep-t8112.hcache-coherency fix)Feel free to carry it directly in
feat/t8112-s2rwith:2. Tested
apple_dart_t8112_display_streams()diff (against9ad129122)Hardware-tested across 11 consecutive deep S2R cycles on J413 (macOS 27.2 stub
26B123). Feel free to carry withSigned-off-by: Satya Benson <satya@benson.earth>:Exact diff against `rjianwei/linux@9ad1291` (`drivers/iommu/apple-dart.c`)
3.
rtc1(apple-pmu-rtc) wake-timing measurement on J413 (#9)Ran timed tests with
pm_debug_messages=1anddynamic_debugonsleep.c/macsmc.c:rtc0:macsmc-rtcrtc1:apple-pmu-rtc 23d714000.spmi:pmic@e:rtcResults across 3 consecutive committed deep S2R cycles (
boot object resumes 0 -> 1 -> 2 -> 3):rtcwake -d rtc1 -m mem -s 15: woke early —rtc0andrtc1advanced 2 s (sys+3 s),macsmc 23e400000.smc: wake record: MBSE 0x10750, MBSW 00 00 00 00 00 00 00 00.rtcwake -d rtc1 -m mem -s 25: woke early —rtc0andrtc1advanced 2 s (sys+2 s),MBSE 0x10750, MBSW 00 00 00 00 00 00 00 00.rtcwake -d rtc1 -m mem -s 15: kernel loggedTimekeeping suspended for 0.554 seconds,MBSE 0x10750, MBSW 00 00 00 00 00 00 00 00.Two clues worth checking first:
apple-sleepprinted zerowake source: ...lines on all 3 wakes (sleep.conly logs bits listed int8112_wake_names[]). Dumping raws->wake_status[0..6]inapple_sleep_report()(ort8112_sleep_finish()) will immediately show whether an unnamed wake bit fired or whetherwake_statusoffset0x24is reading all zeros.t8112-j413.dtsmixes T8103 (5-word) and T8122 (7-word) wake IDs inapple,wake-enable = <3 12 14 54 76 81 133 134 155 184 208>;(54/76/81/133/134are T8103 IDs while155/184/208are T8122 IDs). On a 7-word wake block, one of those mismatched IDs could be unmasking an unrelated source that fires immediately after ~0.5 s.Happy to test a raw
wake_status[0..6]dump / narrowedapple,wake-enablebuild on J413 whenever you want!rjianwei commentedon Nov 28, 2026
@satchlj Thank you! All three items are now updated and pushed to
rjianwei/linux:8bf226a70(From: Satya Benson <satya@benson.earth>,Signed-off-by: Satya Benson <satya@benson.earth>).apple_dart_t8112_display_streams(): Applied your exact diff as5b52d693eonfeat/t8112-s2rande5fb38861onpr/t8112-dcp-s2r(with your author &Signed-off-by:).wake_status[0..6]/wake_armed[0..6]logging: Addedfee2927bb(t8112_sleep_finish()logs rawwake_status[0..6]andwake_armed[0..6], matchingt8103_sleep_finish()). Leftapple,wake-enableunchanged for this run so we can see the exact bit firing before narrowing it down (agreed that mixing T8103 5-word and T8122 7-word wake IDs int8112-j413.dtsis the prime suspect).Image.gz,t8112-j413.dtb, andt8112-j413-fw27.dtball built cleanly withLLVM=1. Ready for yourwake_statusdump onfeat/t8112-s2r(fee2927bb) whenever you have a chance!satchlj commentedon Nov 29, 2026
Claude Opus 5.5 on @satchlj's behalf.
@rjianwei Timed deep S2R now works on J413 with the GPU (
aurora, firmware 27.2) andsddm/Hyprland live. The fixes below are on top of yourfee2927bb: one diff, three files, all hardware-tested onphellos(J413, macOS 27.2 stub26B123). Please carry it with:What
fee2927bb's dump showed, and the fixeswake_status[0..6]read all zeroes andwake_armed[6]readffff0000, because on T8112 the status block starts at+0x28(mask0x08..0x24, status0x28..0x44). So the profile now uses.wake_status = 0x28,.wake_words = 8,.wake_last_word = GENMASK(30, 0).NUB.SPMI0.SW3) is ID 58; 54 isNUB.APWakeupTime.t8112_wake_names[]is rebuilt from the J413 ADTap-wake-sources(20 entries),t8112_wake_required[]is{ 58 }, andt8112-j413.dtsapple,wake-enablelists those 20 IDs.spmi_notify_sleepwrite at.prepareis dropped (T8112 doesn't take it). The boot stage0x50is written at the commit, after the RTC vector is acked and enabled. It is then stepped0x51at the start of the wake,0x52before the resume watchdog, and0x30at finish.0x335 -> 0x553and the wake never stepped back up, so DRAM ran slow until the next reboot. Nowt8103_dcs_step_to()steps one state at a time,7 -> 3at the commit and back to the saved state at the wake. Result:dcs=0x777->0x333(ok)->0x333->0x777(ok)on every cycle. The commit watchdog also usesT8103_WDT_COMMIT_SECS.g14_v27_2::sleep_prepare()already does the commit-stop and warm restart, but it is gated onpwr_controller_from_dt.t8112.dtsiwas missing the fourapple,pwr-*controller properties that every other SoC has (values fromaura/rust/src/gpu/hw/t8112.rs), so the GPU refused the sleep with-EBUSY. With them added,sleep-t8112.h:apple,agx-t8112device;0x205000000(0x0 0x34 0x38 0x400 0x600 0x738 0x798 0x800) across theps_gfxpower cut, after PMP comes back;wake_err.wake_entrysnapshot taken just before WFI, SPMI vector/ack at the commit and at the wake, and the DCS and AGX state.Results
Exact head:
fee2927bbplus this diff. BuiltLLVM=1(Image, modules,t8112-j413.dtb) and run as Trial#16onphellos, withauroraloaded (G14G 27.2) andsddm/Hyprland active. The sleeps ran withmem_sleep=deepandapple_sleep.untested_commit=Y. Each wake was followed by 25 surfaceless GLES 3.2 FBO renders withglReadPixels.rtcwake -d rtc1 -sNUB.SPMI0.SW30x777->0x333(ok)->0x333->0x777(ok)NUB.SPMI0.SW3NUB.SPMI0.SW3Every cycle shows
agx=1 gfx_err=0, no SLC write-back or restore timeouts, 162 of 213 AP pins put back, andMBSE 0x10630with zeroMBSW. The early wakes are gone: each sleep now lasts its full alarm time. Trial#15(the same fixes on our older base) also passed two cycles with the same results.Still open:
EDAC DEVICE1: UE ... 23b700000.event-log0 ... 'event-log source 2'fires a few times in the seconds after each wake (the post-wake event-log IRQs you noted). Nothing else misbehaves.Diff against
rjianwei/linux@fee2927bb(3 files, +152/−46)Next on our side: the ~90 s shutdown stall after a deep sleep, and sleep drain measurements.
rjianwei commentedon Nov 29, 2026
@satchlj Awesome milestone — timed
rtcwake(5s/10s/20s) withauroraGPU +sddm/Hyprland live and 25/25 GLES 3.2 renders per wake is huge!I have applied your diff onto
feat/t8112-s2rwith proper authorship & DCO:4be95ff46(From: Satya Benson <satya@benson.earth>,Signed-off-by: Satya Benson <satya@benson.earth>)Image.gz,t8112-j413.dtb, andt8112-j413-fw27.dtball built cleanly withLLVM=1.I'll also follow up with a timed
rtcwake+ default-boot restoration verification run on my J413 (13.5 stub) once I get Aura stage2 set up cleanly alongside stock Omarchy. Looking forward to your shutdown-stall and sleep-drain measurements!satchlj commentedon Nov 29, 2026
Claude Opus 5.5 on @satchlj's behalf.
@rjianwei Two follow-ups from the Trial
#16runs onfee2927bb+ the diff above: the post-wake EDAC events, and why reboots after a deep sleep take ~2.5 min. No code change requested yet. phellos is offline until someone can press its power button (my mistake, see 2), so neither has been retested.1. Post-wake
apple_soc_edacevent-log source 2What every run shows: the first line comes about 20 ms after
back from sleep, beforePM: suspend exit. Then:apple_soc_edac's re-arm backoff (APPLE_SOC_EDAC_BACKOFF_MS1000, doubling). Each re-arm finds it still asserted, so this is one source that never clears, not new events.APPLE_SOC_EDAC_MAX_RETRIES(8) the driver leaves IRQ 152 masked.t8112_event_hwhas no status registers (num_status_regs = 0, noni). So the driver can't read or acknowledge what source 2 latched; it can only mask it.0x23b700000, the PMGR itself) latches an error that nothing clears. The wake log has the candidates:PMGR: 6–8 words on at the commit were off at the wake: 0x110 0x380 0x388 0x3c8 0x418 0xc00andAON PMGR: 0xb0 0xb8.t8112_sleep_wake(), so we can see which block latches. Then either clear it in the wake sequence or givet8112_event_hwa status/acknowledge contract.2. Shutdown after a deep sleep hangs in
device_shutdown()After any committed deep sleep,
systemctl rebootfinishes userspace in about 1.5 s. Then the kernel hangs indevice_shutdown()until the 2-minute hardware watchdog that systemd-shutdown arms resets the machine. That is the ~90 s+ delay I reported earlier.How I traced it: netconsole to a remote host, with
initcall_debug, and the reboot forced with-ffso that iwd keeps Wi-Fi up.What the trace shows:
brcmfmac,pcie-apple,nvme-appleanddcp-dp-audio.apple-dcp 231c00000.dcpcomponent unbind starts. The panel powers off, and DPMS off re-runs the S2R firmware stop (idle status not set: 0x2d). ThenRTKit: Endpoint 0x20 is not running, cannot send message, and nothing more.afk_shutdown()'s"Timed out shutting down AFK endpoint %02x"has no\n, so a 1 s timeout there stays in the printk continuation buffer and never reaches the console. The real hang may be later indcp_comp_unbind():iomfb_shutdown(), ordcp_release_piodma_iommu_dev()tearing down the piodma DART while the display DARTs are dark after the stop.I have a diagnostic build. It is built but not booted. It:
\n;unbind: <step>breadcrumbs while the system goes down;s2r_fw_down, completes each endpoint'sstopped, so the unbind doesn't ask the stopped firmware.I'll post what it shows once phellos is back.
My mistake, for anyone reproducing this: the
-ffrun had/dev/watchdog0magic-closed for the sleep.-ffskips systemd-shutdown, so nothing re-armed the watchdog, and the hang left phellos down. Re-arm a watchdog before any forced reboot.rjianwei commentedon Nov 29, 2026
Hardware test report on J413 (MacBook Air 13" M2, T8112, OS FW 13.5 stub) running
feat/t8112-s2r(4be95ff46) with Aura Stage 2 (1.0.0b17-gd833bf40) and a non-default Limine test entry (stock Omarchy7.2.11-14-1-ARCHkept as default):What passed on 13.5 (
4be95ff46)/chosen/aurora,s2r-mailboxpublished,apple-sleepprobed (boot object resumes 0),apple-pmu-rtcregistered asrtc1(wakeup = enabled), both231c00000.dcpand271c00000.dcpbound cleanly (2560x1664@60),aurora 206400000.gpu(G14G) probed cleanly.s2idle: Entered and woke cleanly via keyboard (Caps Lock), internal 13.5 panel and Wi-Fi (brcmfmac) recovered with 0 errors.deepdry-run (untested_commit=0,auroraunloaded): Passed completely —apple-sleep 23b700000.sleep: dry run: every check passed; refusing before the first stop and the commit,dcp_poweroff()->dcp_poweron()restored2560x1664@60cleanly (resume devices took 0.403 seconds).7.2.11-14-1-ARCHwith no manual intervention.Issues observed on 13.5 (
4be95ff46)aurora(13.5 G14G firmware) refuses deep sleep (-16/-EBUSY):auroraloaded,rtcwake -d rtc1 -m mem -s 10aborts cleanly ingenpd_prepare:aurora 206400000.gpu: PM: device_prepare(): genpd_prepare returns -16.dpm_suspend()aftermodprobe -r aurora:auroraat runtime (modprobe -r aurora) and then runningrtcwake -d rtc1 -m mem -s 10hit a kernel paging fault beforeapple-sleepran (captured viaconsole_suspend=N):rtcwake -d rtc1 -m mem -s 10withmodule_blacklist=aurorahit ~60 s WDT reset:module_blacklist=auroraavoided thedpm_suspendUAF completely (booted straight to desktop,auroranot loaded), andrtcwake -d rtc1 -m mem -s 10entered suspend without Oops, but did not wake at 10 s and hit a ~60 s WDT reset back to stock Omarchy.4be95ff46,sleep_ps_wait_off(s, T8112_PS_GFX)now callspanic("T8112 committed GFX power-off timed out")unconditionally even whent8112.gpuis unbound (withmodule_blacklist=aurora, no GPU driver has stopped GPU firmware ifps_gfxis on; gating thatpanic()ondevice_is_bound(&t8112.gpu->dev)would avoid panicking whenaurorais blacklisted).apple,t8112-dcpext(s2r_ext = true) stop/resume on a 13.5 stub (untested on 13.5 so far).rjianwei commentedon Nov 29, 2026
@satchlj Confirming that your Nov 29 wake/DCS/GPU diff has been carried on
rjianwei/linux(feat/t8112-s2r) as4be95ff46withAuthor: Satya Benson <satya@benson.earth>and yourSigned-off-by:preserved, followed by208e2a333(gating theT8112 committed GFX power-off timed outpanic ongpu_bound).Quick update from 13.5-stub J413 testing on
208e2a333:module_blacklist=aurora+208e2a333still hits a ~60 s reset on committedrtcwake -d rtc1 -m mem -s 10.208e2a333still resets at ~60 s).aurora,s2r-mailbox(0x802d70440) is covered by EFIreserved(802c70000-8030abfff) in/proc/iomem.pm_test=corewithmem_sleep=deepanduntested_commit=1passes cleanly (suspend devices 1.28s,resume devices 0.33s, no errors).rtcwake -d rtc1 -m no -s 3firesapple_spmiIRQ 70 (0 -> 1), anduntested_commit=0dry-run passes (dry run: every check passed, onlypmpandgpuunbound).apple_sleep_enter_prepare()(beforecpus_hold, beforecoprocs_stop(true), and beforecoprocs_stop(false)) withrtcwake -d rtc1 -m mem -s 5— neither triggered early; both still reset at ~60–68 s, indicatingapple_sleep_enter_prepare()completed and the reset is coming from the ~60 s watchdog / SMC sleep timeout rather than an early hang inapple_sleep_enter_prepare().For comparison, which
auracommit and bootloader chain are you using on your 27.2 J413? (I am onaura 1.0.0b17-gd833bf40-> U-Boot -> Limine.)satchlj commentedon Nov 29, 2026
@rjianwei Two updates from phellos (J413) since my last comment.
1. Post-sleep reboot hang: fixed, in linux#3595 (draft)
The ~2.5 min reboot after a deep sleep was not in the sleep driver.
drm_atomic_helper_shutdown()turns the internal panel off as DPMS off does, which lowers the display domains, display DART included.dcp_comp_unbind()then destroys the piodma device, which detaches it from that unpowered DART, and the restart hangs until the watchdog fires.feat/t8112-s2r, so nothing for you to carry.2. Post-wake EDAC event-log source 2: narrowed, not fixed
This is the line the earlier comment described as held asserted after each wake. It is DT index 2 of the
apple,t8112-event-lognode, AIC 196, whoseregis the PMGR clock-mux block at0x23b000000.From diagnostic rounds 20–27 (read-only AIC
HW_STATEsampling of the node's own lines, at each step oft8112_sleep_wake()):sleep_ps_rewake());msgand USB words before the access;apple_soc_edaccan read and clear source 2.t8112_event_hwhas none today, so it can only mask the line. I'm asking about that contract separately.The diagnostic code stays local. Nothing here needs a change on
feat/t8112-s2r.RyanTheTide commentedon Nov 29, 2026
@satchlj macOS 27.2 on a T8112 (Mac mini J473), traced under our hypervisor, for event-log source 2.
1. The ADT already gives source 2's log registers
/arm-io/event-log-handlerhasevent-logs(0xd8 bytes = 18 triples of u32: line index,regindex, offset) next tointerrupts(16 lines, index 2 = AIC 196) andreg(index 2 = 0x23b000000 +0x70000):Lines 0 and 2 each have two log words. So
t8112_event_hwdoesn't need a hard-coded status table: the DT can carry this property, as it comes from the ADT, and the driver can read and acknowledge each source's words from it.2. macOS never acknowledges the line. It never raises it.
panic-on-event-log-intr = 1: macOS treats any event-log interrupt as fatal, so there is no ack sequence to copy.+0x400d4, +0x400d8, +0x400dc, +0x400e0, +0x400e4, +0x400e8, each written 0 and read back 0. Nothing reads or writes +0x28000 or +0x6c004. No event-log interrupt fires (the guest would have panicked).sleepnow).What this suggests for the wake path
Since macOS never raises source 2, the first post-wake access on Linux is probably reaching the block before something is restored that macOS has in place, rather than missing an acknowledge. Two cheap checks on your J413:
apple_soc_edac. If it doesn't, it's latched until power-off, which fits macOS treating it as fatal.If 0x23b028000 / 0x23b06c004 point at a specific mux, I can trace that register's macOS cold-boot sequence on the J473 on request.
satchlj commentedon Nov 29, 2026
@rjianwei Heads-up: to keep T8112 deep sleep moving, we're opening the PR for
feat/t8112-s2rourselves, fromsatchlj/t8112-s2r.208e2a333, cherry-picked onto currentmain(a03face57). No conflicts, and authorship andSigned-off-byare unchanged.If you'd rather open or own it yourself, say so and I'll close ours in favour of yours.
rjianwei commentedon Nov 29, 2026
@satchlj Thank you for opening #3647, rebasing onto current
main, running the exact-head J413 verification, and preserving all commit authorships andSigned-off-bylines — please keep #3647 open and drive it to merge, no need to close/reopen on my behalf.I also saw the
aurora-silicon-reviewnotes on #3647 (apple,t8140-display-power.yaml+apple,agx.yamlschema additions fordt-checks, plus the three minor cleanups insleep-t8112.h). Happy to push a small follow-up commit onrjianwei/linux(feat/t8112-s2r) for you to cherry-pick if you haven't already fixed them onsatchlj/t8112-s2r, or feel free to fold them directly on #3647 — whichever is faster for you.satchlj commentedon Nov 29, 2026
J413 (M2 Air, firmware 27.2) deep-sleep drain, on the T8112 sleep series (#3647) plus #3595. 20-minute
rtcwakesleeps with the GPU and desktop live, measured on the battery'senergy_now, which moves in steps of about 11.4 mWh. One variable per row:mca1/3/4/5,audio_p) lowered at the commitSo most of the gap was the audio domains left on through sleep. Still on just before WFI: always-on words,
soc_spmi0(the wake path),aft0,sio_busif,fpwm2,spi5,uart8,ans. Below about 0.03 W the counter cannot resolve a 20-minute row; a longer one needs a longer RTC wake (the PMU RTC refuses 3600 s).The audio-domain and DCS changes are local for now. Next is a PR that lowers the domains through genpd and the device tree instead of a per-SoC list.
RyanTheTide commentedon Nov 30, 2026
The J413 row on #3647 at
ec5d5289passed all three RTC deep wakes with GPU render checks. The devicetree and host checks passed at that head.The separate EDAC follow-up #3659 passed three J413 deep wakes on top of that exact sleep stack and received independent review. Track its hosted check separately. The sleep series still needs its J473 peer evidence and the #3595 ordering gate.
Marked the open hardware check with
needs hardware test. The existing owner and test request linked above remain current.RyanTheTide commentedon Dec 5, 2026
The coordinated T8112 (J413) suspend-to-RAM series has merged to
main: #3647 (7711340c7aa3,drivers/soc/apple/sleep.candsleep-t8112.h), #3595 (5f17cd312e), #3659 (45648c63f0bc), and #3786 (f21d1ed08a67, enabling deep sleep by default ont8112-j413-fw27). Closing this pre-PR coordination thread as completed.