Skip to content

T8112 (Apple M2 / J413) suspend-to-RAM support: coordination before opening a PR #3371

Done

Description

@rjianwei

Hi maintainers,

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

  1. Is anyone already working on T8112 S2R that I should coordinate with?
  2. Should T8112 land via sleep.c (following T8103 soc: apple: sleep: add T8103 (M1 / J313) suspend-to-RAM support #3172 / T8122 soc: apple: suspend-to-RAM on M3 (T8122, J613/J615) #3140), and would you prefer the PR split or kept as a small series (irq-apple-aic, macsmc, sleep-t8112, dcp/apple-dart)?
  3. Would you like me to keep apple_sleep.untested_commit gating until OS FW 27.2 display warm restart is also verified on J413?

Thanks!

Activity

  1. added
    tracking
    on Nov 27, 2026
  2. RyanTheTide commented on Nov 27, 2026

    @RyanTheTide
    Contributor

    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.

  3. rjianwei commented on Nov 27, 2026

    @rjianwei
    ContributorAuthor

    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):

    1. 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).
    2. 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.
    3. 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:

    1. 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.
    2. 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.

  4. satchlj commented on Nov 28, 2026

    @satchlj
    Member

    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:

    • 27.2 internal DCP / dcpext warm restart on T8112 (matching T8103 #3172 / #3178)
    • 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:

    1. 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).
    2. 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).
    3. 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).

  5. satchlj commented on Nov 28, 2026

    @satchlj
    Member

    Hardware test report on J413 (MacBook Air 13" M2, T8112, macOS 27.2 stub 26B123) using rjianwei/linux feat/t8112-s2r (d3fc11cd3) rebased onto main (ff59991a6), plus #3470 (J413 &smc wake reasons + &hpm0/&hpm1 apple,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.
    • Committed S2R cycle 1 (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 back
      • apple-sleep 23b700000.sleep: back from sleep, boot object resumes 0 -> 1
      • apple-dcp 231c00000.dcp (27.2 internal eDP): resumed cleanly (2560x1664@60, backlight restored to dbv: 15174), 0 errors.
      • apple-dcp 271c00000.dcp (27.2 dcpext): 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), and hci_bcm4377 all resumed cleanly.

    Fixes needed on 27.2 J413 (dcp / dcpext / apple-dart)

    1. 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.
      • Added 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 = true on apple_dcp_hw_t8112.
    2. 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

    1. 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.
    2. 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).
    3. Post-wake apple_soc_edac errors:
      • After cycle 1 resumed, apple_soc_edac 23b700000.event-log logged repeated rate-limited hardware error: event-log source 2 (IRQ 154, AIC2 65732) (275.9s, 276.9s, 278.9s, 283.0s, 291.4s, 307.8s, 340.1s).
  6. rjianwei commented on Nov 28, 2026

    @rjianwei
    ContributorAuthor

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

    1. apple_dart_display_streams() on == false OOB writes (drivers/iommu/apple-dart.c):
      • 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_CMD 0xa000 flush).
    2. 27.x .map_reg_dart and t8112-dcpext (drivers/gpu/drm/apple/dcp.c):
      • Added .map_reg_dart = true to apple_dcp_hw_t8112.
      • Added dcp_s2r_t8112_ext (disp_cpu = 0x3c8, disp_fe = 0x388, disp_sys = 0x380, dcp_streams = BIT(5), disp_streams = BIT(0) | BIT(4)) and apple_dcp_hw_t8112_dcpext matching "apple,t8112-dcpext".
    3. Static dcp_s2r_t8112 + t8112-j413-fw27.dts:
      • 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.

    Updated branches for your 27.2 test run:

    Early 27.2 test results on feat/t8112-s2r would be hugely appreciated whenever you have a chance!

  7. satchlj commented on Nov 28, 2026

    @satchlj
    Member

    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:

    1. 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 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.
    2. Post-resume kernel panic (~1 s after PM: suspend exit, 04:28:10Z):

  8. satchlj commented on Nov 28, 2026

    @satchlj
    Member

    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)

    1. 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).
    2. 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):
        • 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 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 (30x systemd-run --quiet --wait -p IPAddressDeny=192.0.2.0/24 /bin/true before cycle 1 and after each wake):

    • Instrumented build (with per-cycle SLC telemetry):
      • 6/6 consecutive committed deep S2R cycles PASSED (boot object resumes 0 -> 6)
      • 180/180 BPF stress runs PASSED
      • SLC verified on all 6 cycles: ways=16 off_bad=0x0 off_st=0x0 wake_before=0x0 on_bad=0x0 wake_after=0x4200
      • wlan0 + Tailscale reconnected on all 6 cycles; zero Oops/BUG/WARNING.
    • Clean final patch (exact diff below):
      • 5/5 consecutive committed deep S2R cycles PASSED (boot object resumes 0 -> 1 -> 2 -> 3 -> 4 -> 5)
      • 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.

    Patch (drivers/soc/apple/sleep-t8112.h)

    Exact git diff (311 lines)
    diff --git a/drivers/soc/apple/sleep-t8112.h b/drivers/soc/apple/sleep-t8112.h
    index 03c8342c4..bbefe0d73 100644
    --- a/drivers/soc/apple/sleep-t8112.h
    +++ b/drivers/soc/apple/sleep-t8112.h
    @@ -49,6 +49,16 @@
     #define T8112_MUX_SOC		0x40000
     #define T8112_MUX_SOC_WORDS	64
     
    +#define T8112_MCC_PLANES_BASE	0x200000000ULL
    +#define T8112_MCC_PLANE_STRIDE	0x40000
    +#define T8112_MCC_NPLANES	4
    +#define T8112_MCC_CACHE_DISABLE	0x424
    +#define T8112_MCC_WAYS		0x1c00
    +#define T8112_MCC_WAYS_STATUS	0x1c04
    +#define T8112_MCC_WAYS_DATA	GENMASK(14, 10)
    +#define T8112_MCC_WAYS_TAG	GENMASK(9, 5)
    +#define T8112_MCC_TIMEOUT_US	100000
    +
     static const u32 t8112_mux_park[] = { 0x40040, 0x40048, 0x40044, 0x40038, 0x40034 };
     static const u32 t8112_tvm[] = { 0x400, 0x800, 0xc00, 0x000 };
     static const u32 t8112_auto_off[] = { 0x1b0, 0x1a8, 0x1b8 };
    @@ -147,6 +157,11 @@ static struct {
     	void __iomem *clk_mux;
     	void __iomem *mcc_ctl;
     	void __iomem *mcc[5];
    +	void __iomem *mcc_planes;
    +	u32 slc_ways;
    +	u32 slc_off_bad;
    +	u32 slc_on_bad;
    +	bool slc_disabled;
     	void __iomem *pmp_asc;
     	void __iomem *pmp_mbox;
     	void __iomem *nco;
    @@ -258,6 +273,8 @@ static int t8112_sleep_map_regs(struct apple_sleep *s)
     		t8122_write_hid4(pcore, hid4_orig);
     	}
     
    +	t8112.mcc_planes = t8103_ioremap(s, T8112_MCC_PLANES_BASE,
    +					 T8112_MCC_NPLANES * T8112_MCC_PLANE_STRIDE);
     	t8112.pmp_asc = t8103_ioremap(s, T8103_PMP_ASC, 0x100);
     	t8112.pmp_mbox = t8103_ioremap(s, T8103_PMP_MBOX, 0x1000);
     	t8112.nco = t8103_ioremap(s, T8103_NCO, T8103_NCO_CHANS * T8103_NCO_STRIDE);
    @@ -465,6 +482,89 @@ static void t8112_aon_lower(struct apple_sleep *s, u32 off)
     	writel((val & ~PS_TARGET) | PS_FLAGS, s->ps_aon + off);
     }
     
    +/*
    + * Stop SLC allocation and power down all 4 MCC planes so every dirty SLC line
    + * is written back to DRAM before deep sleep loses MCC power.
    + */
    +static void t8112_slc_off(void)
    +{
    +	unsigned int p;
    +	u32 v, ways;
    +
    +	t8112.slc_disabled = false;
    +	t8112.slc_off_bad = 0;
    +	if (!t8112.mcc_planes)
    +		return;
    +
    +	v = readl(t8112.mcc_planes + T8112_MCC_WAYS_STATUS);
    +	ways = FIELD_GET(T8112_MCC_WAYS_DATA, v);
    +	if (!ways)
    +		ways = FIELD_GET(T8112_MCC_WAYS_TAG, v);
    +	if (!ways)
    +		return;
    +
    +	t8112.slc_ways = ways;
    +	for (p = 0; p < T8112_MCC_NPLANES; p++) {
    +		void __iomem *base = t8112.mcc_planes + p * T8112_MCC_PLANE_STRIDE;
    +
    +		writel(1, base + T8112_MCC_CACHE_DISABLE);
    +	}
    +	dsb(sy);
    +
    +	for (p = 0; p < T8112_MCC_NPLANES; p++) {
    +		void __iomem *base = t8112.mcc_planes + p * T8112_MCC_PLANE_STRIDE;
    +
    +		writel(0, base + T8112_MCC_WAYS);
    +	}
    +	dsb(sy);
    +
    +	for (p = 0; p < T8112_MCC_NPLANES; p++) {
    +		void __iomem *reg = t8112.mcc_planes + p * T8112_MCC_PLANE_STRIDE +
    +				    T8112_MCC_WAYS_STATUS;
    +
    +		if (readl_poll_timeout_atomic(reg, v,
    +					      !FIELD_GET(T8112_MCC_WAYS_DATA, v) &&
    +					      !FIELD_GET(T8112_MCC_WAYS_TAG, v),
    +					      1, T8112_MCC_TIMEOUT_US))
    +			t8112.slc_off_bad |= BIT(p);
    +	}
    +	dsb(sy);
    +	t8112.slc_disabled = true;
    +}
    +
    +static void t8112_slc_on(void)
    +{
    +	unsigned int p;
    +	u32 v, ways;
    +
    +	t8112.slc_on_bad = 0;
    +	if (!t8112.mcc_planes || !t8112.slc_disabled)
    +		return;
    +
    +	t8112.slc_disabled = false;
    +	ways = t8112.slc_ways;
    +
    +	for (p = 0; p < T8112_MCC_NPLANES; p++) {
    +		void __iomem *base = t8112.mcc_planes + p * T8112_MCC_PLANE_STRIDE;
    +
    +		writel(ways, base + T8112_MCC_WAYS);
    +	}
    +	dsb(sy);
    +
    +	for (p = 0; p < T8112_MCC_NPLANES; p++) {
    +		void __iomem *base = t8112.mcc_planes + p * T8112_MCC_PLANE_STRIDE;
    +
    +		if (readl_poll_timeout_atomic(base + T8112_MCC_WAYS_STATUS, v,
    +					      FIELD_GET(T8112_MCC_WAYS_DATA, v) == ways &&
    +					      FIELD_GET(T8112_MCC_WAYS_TAG, v) == ways,
    +					      1, T8112_MCC_TIMEOUT_US))
    +			t8112.slc_on_bad |= BIT(p);
    +		else
    +			writel(0, base + T8112_MCC_CACHE_DISABLE);
    +	}
    +	dsb(sy);
    +}
    +
     static void t8112_mcc_clear_bits64(void __iomem *reg)
     {
     	u64 q = readq(reg);
    @@ -631,12 +731,9 @@ static void t8112_sleep_commit_regs(struct apple_sleep *s)
     	pcore = t8112_is_pcore();
     	hid4_orig = t8112_read_hid4(pcore);
     	t8112_write_hid4(pcore, hid4_orig & ~T8112_HID4_DC_MASK);
    -	t8122_clean_used_ram();
    -	t8122_clean_kernel_image();
    -	t8122_clean_percpu_slc();
    -	t8122_clean_all_kptables();
    -	t8122_clean_state_poc(s);
     	t8112_dcache_clean_all_levels();
    +	dsb(sy);
    +	t8112_slc_off();
     	t8112_clean_range_slc((unsigned long)t8103_pac_saved,
     			      (unsigned long)(t8103_pac_saved + ARRAY_SIZE(t8103_pac_saved)));
     	if (s->mbox)
    @@ -648,6 +745,7 @@ static void t8112_sleep_commit_regs(struct apple_sleep *s)
     			      (unsigned long)current + sizeof(*current));
     	t8112_clean_range_slc((unsigned long)task_stack_page(current),
     			      (unsigned long)task_stack_page(current) + THREAD_SIZE);
    +	t8112_dcache_clean_all_levels();
     	dsb(sy);
     	t8112_write_hid4(pcore, hid4_orig);
     
    @@ -710,6 +808,8 @@ static void t8112_sleep_pre_commit(struct apple_sleep *s)
     				      (unsigned long)(s->mbox + 1));
     	t8112_clean_range_slc((unsigned long)s, (unsigned long)(s + 1));
     	t8112_clean_range_slc((unsigned long)&t8112, (unsigned long)(&t8112 + 1));
    +	t8112_clean_range_slc((unsigned long)task_stack_page(current),
    +			      (unsigned long)task_stack_page(current) + THREAD_SIZE);
     	dsb(sy);
     	t8112_write_hid4(pcore, hid4_orig);
     }
    @@ -754,6 +854,8 @@ static void t8112_sleep_wake(struct apple_sleep *s)
     						  T8103_MUX_TIMEOUT_US);
     		}
     
    +		t8112_slc_on();
    +
     		if (t8112.nco) {
     			for (i = 0; i < T8103_NCO_CHANS; i++) {
     				if (t8112.nco_forced & BIT(i)) {
    @@ -821,6 +923,89 @@ static void t8112_aic_mask_noop(void)
     {
     }
     
    +/*
    + * void t8112_cpu_off(u64 cyc_ovrd, u64 acc_ovrd): CCIDX-aware version of
    + * t8103_cpu_off(). Must be called with HID4/EHID4 DISABLE_DC_SW_L2 cleared so
    + * L2 set/way cleans are not dropped as NOPs, and turns SCTLR_EL1.C off before
    + * cleaning+invalidating L1 and cleaning L2+ with zero stack accesses.
    + */
    +asm(
    +"	.pushsection .text, \"ax\"\n"
    +"	.type	t8112_cpu_off, %function\n"
    +"t8112_cpu_off:\n"
    +"	msr	daifset, #0xf\n"
    +"	mrs	x3, sctlr_el1\n"
    +"	bic	x3, x3, #(1 << 2)\n"
    +"	msr	sctlr_el1, x3\n"
    +"	isb\n"
    +"	dsb	sy\n"
    +"	mrs	x3, clidr_el1\n"
    +"	mrs	x4, id_aa64mmfr2_el1\n"
    +"	ubfx	x4, x4, #20, #4\n"
    +"	mov	x5, #0\n"
    +"1:	cmp	x5, #7\n"
    +"	b.hs	5f\n"
    +"	add	x6, x5, x5, lsl #1\n"
    +"	lsr	x7, x3, x6\n"
    +"	and	x7, x7, #7\n"
    +"	cbz	x7, 5f\n"
    +"	cmp	x7, #2\n"
    +"	b.lo	4f\n"
    +"	cmp	x7, #4\n"
    +"	b.hi	4f\n"
    +"	lsl	x6, x5, #1\n"
    +"	msr	csselr_el1, x6\n"
    +"	isb\n"
    +"	mrs	x8, ccsidr_el1\n"
    +"	and	x9, x8, #7\n"
    +"	add	x9, x9, #4\n"
    +"	cbnz	x4, 20f\n"
    +"	ubfx	x10, x8, #3, #10\n"
    +"	ubfx	x11, x8, #13, #15\n"
    +"	b	21f\n"
    +"20:	ubfx	x10, x8, #3, #21\n"
    +"	ubfx	x11, x8, #32, #24\n"
    +"21:	clz	w12, w10\n"
    +"2:	mov	x13, x11\n"
    +"	lsl	x14, x10, x12\n"
    +"	orr	x14, x14, x5, lsl #1\n"
    +"3:	lsl	x15, x13, x9\n"
    +"	orr	x15, x14, x15\n"
    +"	cbnz	x5, 30f\n"
    +"	dc	cisw, x15\n"
    +"	b	31f\n"
    +"30:	dc	csw, x15\n"
    +"31:	subs	x13, x13, #1\n"
    +"	b.ge	3b\n"
    +"	subs	x10, x10, #1\n"
    +"	b.ge	2b\n"
    +"	dsb	sy\n"
    +"4:	add	x5, x5, #1\n"
    +"	b	1b\n"
    +"5:	msr	csselr_el1, xzr\n"
    +"	dsb	sy\n"
    +"	isb\n"
    +"	msr	cntp_ctl_el0, xzr\n"
    +"	msr	cntv_ctl_el0, xzr\n"
    +"	mrs	x3, CurrentEL\n"
    +"	cmp	x3, #(2 << 2)\n"
    +"	b.ne	6f\n"
    +"	msr	s3_5_c14_c2_1, xzr\n"
    +"	msr	s3_5_c14_c3_1, xzr\n"
    +"6:	msr	s3_5_c15_c6_0, x1\n"
    +"	msr	s3_5_c15_c5_0, x0\n"
    +"	isb\n"
    +"	mov	x9, #1\n"
    +"7:	msr	s3_5_c15_c1_1, x9\n"
    +"	dsb	sy\n"
    +"	isb\n"
    +"	wfi\n"
    +"	b	7b\n"
    +"	.size	t8112_cpu_off, . - t8112_cpu_off\n"
    +"	.popsection\n"
    +);
    +void t8112_cpu_off(u64 cyc_ovrd, u64 acc_ovrd);
    +
     static void t8112_deep_wfi_arm(void)
     {
     	u64 mpidr = read_cpuid_mpidr();
    @@ -837,10 +1022,6 @@ static void t8112_deep_wfi_arm(void)
     		dsb(sy);
     	}
     
    -	t8112_write_hid4(pcore, hid4 & ~T8112_HID4_DC_MASK);
    -	t8112_dcache_clean_all_levels();
    -	t8112_write_hid4(pcore, hid4);
    -
     	cyc &= ~(T8103_CYC_WFI_MODE | T8103_CYC_IRQ_MODE | T8103_CYC_FIQ_MODE);
     	cyc |= FIELD_PREP(T8103_CYC_WFI_MODE, 3) | T8103_CYC_DISABLE_WFI_RET;
     	write_sysreg_s(0, T8103_PMCR0);
    @@ -851,10 +1032,27 @@ static void t8112_deep_wfi_arm(void)
     	       FIELD_PREP(T8103_ACC_TRAIN_DOWN_LINK, 3) |
     	       FIELD_PREP(T8103_ACC_POWER_DOWN_CPM, 3) |
     	       T8103_ACC_DISABLE_PIO_ON_WFI | T8103_ACC_DEEP_SLEEP;
    -	t8103_cpu_off(cyc, acc);
    +
    +	/* Leave DISABLE_DC_SW_L2 cleared across t8112_cpu_off() so L2 cleans take effect. */
    +	t8112_write_hid4(pcore, hid4 & ~T8112_HID4_DC_MASK);
    +	t8112_cpu_off(cyc, acc);
     	unreachable();
     }
     
    +static void t8112_sleep_finish(struct apple_sleep *s)
    +{
    +	if (t8112.slc_off_bad) {
    +		dev_warn(s->dev, "SLC write-back timed out on planes %#x\n",
    +			 t8112.slc_off_bad);
    +		t8112.slc_off_bad = 0;
    +	}
    +	if (t8112.slc_on_bad) {
    +		dev_warn(s->dev, "SLC restore timed out on planes %#x\n",
    +			 t8112.slc_on_bad);
    +		t8112.slc_on_bad = 0;
    +	}
    +}
    +
     static int t8112_sleep_cpu_prepare(u64 mpidr)
     {
     	return 0;
    @@ -904,6 +1102,7 @@ static const struct apple_sleep_ops t8112_sleep_ops = {
     	.pre_commit = t8112_sleep_pre_commit,
     	.post_timer = t8112_post_timer,
     	.wake = t8112_sleep_wake,
    +	.finish = t8112_sleep_finish,
     	.cpu_prepare = t8112_sleep_cpu_prepare,
     	.cpu_restore = t8112_sleep_cpu_restore,
     };
  9. rjianwei commented on Nov 28, 2026

    @rjianwei
    ContributorAuthor

    @satchlj Amazing root-cause analysis and testing — thank you!

    I have applied your sleep-t8112.h cache-coherency fix (t8112_cpu_off() with HID4/EHID4 DISABLE_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:

    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.

  10. rjianwei commented on Nov 28, 2026

    @rjianwei
    ContributorAuthor

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

    1. 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?
    2. 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.
    3. 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.
    4. 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.
  11. satchlj commented on Nov 28, 2026

    @satchlj
    Member

    @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):

    1. Commit authorship & DCO (sleep-t8112.h cache-coherency fix)

    Feel free to carry it directly in feat/t8112-s2r with:

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

    2. Tested apple_dart_t8112_display_streams() diff (against 9ad129122)

    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:

    1. 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.
    2. 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!

  12. rjianwei commented on Nov 28, 2026

    @rjianwei
    ContributorAuthor

    @satchlj Thank you! All three items are now updated and pushed to rjianwei/linux:

    1. Proper authorship & DCO on SLC + L2 cache fix: 8bf226a70 (From: Satya Benson <satya@benson.earth>, Signed-off-by: Satya Benson <satya@benson.earth>).
    2. 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:).
    3. 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!

  13. satchlj commented on Nov 29, 2026

    @satchlj
    Member

    Claude Opus 5.5 on @satchlj's behalf.

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

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

    What fee2927bb's dump showed, and the fixes

    1. 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).
    2. 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.dts apple,wake-enable lists those 20 IDs.
    3. 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.
    4. 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.
    5. 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.
    6. 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)
    diff --git a/arch/arm64/boot/dts/apple/t8112-j413.dts b/arch/arm64/boot/dts/apple/t8112-j413.dts
    index 9f3b45138..8911b6886 100644
    --- a/arch/arm64/boot/dts/apple/t8112-j413.dts
    +++ b/arch/arm64/boot/dts/apple/t8112-j413.dts
    @@ -633,6 +633,6 @@ &m2_aop_spmi1_sideband {
     };
     
     &sleep {
    -	apple,wake-enable = <3 12 14 54 76 81 133 134 155 184 208>;
    +	apple,wake-enable = <14 26 27 44 51 53 54 58 69 73 81 86 147 154 155 156 157 229 231 248>;
     	status = "okay";
     };
    diff --git a/arch/arm64/boot/dts/apple/t8112.dtsi b/arch/arm64/boot/dts/apple/t8112.dtsi
    index 56b1323ba..e42fee86e 100644
    --- a/arch/arm64/boot/dts/apple/t8112.dtsi
    +++ b/arch/arm64/boot/dts/apple/t8112.dtsi
    @@ -604,7 +604,11 @@ gpu: gpu@206400000 {
     			apple,ppm-filter-time-constant-ms = <34>;
     			apple,ppm-ki = <205.0>;
     			apple,ppm-kp = <0.75>;
    +			apple,pwr-filter-time-constant = <313>;
    +			apple,pwr-integral-gain = <0.0202129>;
    +			apple,pwr-integral-min-clamp = <0>;
     			apple,pwr-min-duty-cycle = <40>;
    +			apple,pwr-proportional-gain = <5.2831855>;
     			apple,core-leak-coef = <1920.0>;
     			apple,sram-leak-coef = <74.0>;
     		};
    diff --git a/drivers/soc/apple/sleep-t8112.h b/drivers/soc/apple/sleep-t8112.h
    index 86ba70654..33e01fec6 100644
    --- a/drivers/soc/apple/sleep-t8112.h
    +++ b/drivers/soc/apple/sleep-t8112.h
    @@ -40,8 +40,7 @@
     
     #define T8112_MUX_PARK_VAL	0x80100000
     #define T8112_DCS_PERF_OFF	0x5c000
    -#define T8112_DCS_BUSY		BIT(31)
    -#define T8112_DCS_TIMEOUT_US	10000
    +#define T8112_DCS_SLEEP		3
     #define T8112_TVM_IDLE_OFF	0x3e0
     #define T8112_TVM_BUSY		BIT(1)
     #define T8112_TVM_TIMEOUT_US	10000
    @@ -59,6 +58,10 @@
     #define T8112_MCC_WAYS_TAG	GENMASK(9, 5)
     #define T8112_MCC_TIMEOUT_US	100000
     
    +/* AGX fabric tunables programmed by the boot loader; lost when ps_gfx powers off. */
    +#define T8112_AGX_FABRIC	0x205000000ULL
    +static const u32 t8112_agx_regs[] = { 0x0, 0x34, 0x38, 0x400, 0x600, 0x738, 0x798, 0x800 };
    +
     static const u32 t8112_mux_park[] = { 0x40040, 0x40048, 0x40044, 0x40038, 0x40034 };
     static const u32 t8112_tvm[] = { 0x400, 0x800, 0xc00, 0x000 };
     static const u32 t8112_auto_off[] = { 0x1b0, 0x1a8, 0x1b8 };
    @@ -165,6 +168,11 @@ static struct {
     	void __iomem *pmp_asc;
     	void __iomem *pmp_mbox;
     	void __iomem *nco;
    +	void __iomem *agx_fabric;
    +	struct platform_device *gpu;
    +	u32 agx_saved[ARRAY_SIZE(t8112_agx_regs)];
    +	bool agx_saved_valid;
    +	int gfx_wake_err;
     	void __iomem *ed[2][4];
     	u32 notify_saved;
     	bool notify_staged;
    @@ -178,7 +186,19 @@ static struct {
     	u32 tvm_saved[ARRAY_SIZE(t8112_tvm)];
     	u32 auto_saved[ARRAY_SIZE(t8112_auto_off)];
     	u32 dcs_saved;
    +	u32 dcs_down_val;
    +	u32 dcs_wake;
    +	u32 dcs_up_val;
    +	bool dcs_down_ok;
    +	bool dcs_up_ok;
    +	u32 wake_entry[8];
    +	u32 spmi_vec_commit;
    +	u32 spmi_ack_commit;
    +	u32 spmi_notify_commit;
    +	u32 spmi_vec_wake;
    +	u32 spmi_ack_wake;
     	bool commit_saved;
    +	bool committed;
     } t8112;
     
     static void __iomem *t8112_map(struct apple_sleep *s, const char *name, struct resource *out)
    @@ -278,6 +298,17 @@ static int t8112_sleep_map_regs(struct apple_sleep *s)
     	t8112.pmp_asc = t8103_ioremap(s, T8103_PMP_ASC, 0x100);
     	t8112.pmp_mbox = t8103_ioremap(s, T8103_PMP_MBOX, 0x1000);
     	t8112.nco = t8103_ioremap(s, T8103_NCO, T8103_NCO_CHANS * T8103_NCO_STRIDE);
    +	t8112.agx_fabric = t8103_ioremap(s, T8112_AGX_FABRIC, 0x1000);
    +	{
    +		struct device_node *np = of_find_compatible_node(NULL, NULL, "apple,agx-t8112");
    +		if (np) {
    +			t8112.gpu = of_find_device_by_node(np);
    +			of_node_put(np);
    +		}
    +		if (t8112.gpu &&
    +		    devm_add_action_or_reset(s->dev, apple_sleep_put_device, &t8112.gpu->dev))
    +			return -ENOMEM;
    +	}
     	for (i = 0; i < 2; i++) {
     		unsigned int c;
     
    @@ -297,6 +328,16 @@ static int t8112_sleep_map_regs(struct apple_sleep *s)
     
     static int t8112_sleep_check(struct apple_sleep *s)
     {
    +	if (t8112.gpu && device_is_bound(&t8112.gpu->dev)) {
    +		if (!apple_sleep_coproc_ready_node(t8112.gpu->dev.of_node)) {
    +			dev_err(s->dev, "refused: the GPU's driver is bound\n");
    +			return -EBUSY;
    +		}
    +		if (!t8112.agx_fabric) {
    +			dev_err(s->dev, "refused: GPU fabric registers not mapped\n");
    +			return -ENODEV;
    +		}
    +	}
     	return 0;
     }
     
    @@ -456,19 +497,10 @@ static __always_inline void t8112_dcache_clean_all_levels(void)
     
     static void t8112_sleep_prepare_regs(struct apple_sleep *s)
     {
    -	apple_sleep_pmu_write(s->spmi, s->soc->pmu_usid,
    -			      s->soc->pmu_sleep_reg, s->soc->pmu_sleep_val);
    -	t8112.notify_saved = readl(s->spmi + SPMI_NOTIFY_ENABLE);
    -	t8112.notify_staged = true;
    -	writel(s->soc->spmi_notify_sleep, s->spmi + SPMI_NOTIFY_ENABLE);
     }
     
     static void t8112_sleep_undo_regs(struct apple_sleep *s)
     {
    -	if (!t8112.notify_staged)
    -		return;
    -	writel(t8112.notify_saved, s->spmi + SPMI_NOTIFY_ENABLE);
    -	t8112.notify_staged = false;
     }
     
     static void t8112_aon_lower(struct apple_sleep *s, u32 off)
    @@ -620,15 +652,6 @@ static void t8112_mcc_channel_stop(void)
     	t8112_mcc_clear_bits32(t8112.mcc[4] + 0x588);
     }
     
    -static void t8112_dcs_write(u32 val)
    -{
    -	u32 cur;
    -
    -	writel(val, t8112.clk_mux + T8112_DCS_PERF_OFF);
    -	readl_poll_timeout_atomic(t8112.clk_mux + T8112_DCS_PERF_OFF, cur,
    -				  !(cur & T8112_DCS_BUSY), 1, T8112_DCS_TIMEOUT_US);
    -}
    -
     static void t8112_sleep_commit_regs(struct apple_sleep *s)
     {
     	bool pcore;
    @@ -636,7 +659,7 @@ static void t8112_sleep_commit_regs(struct apple_sleep *s)
     	unsigned int i;
     	u32 val;
     
    -	apple_sleep_set_wd2(s, WDT_SUSPEND_SECS);
    +	apple_sleep_set_wd2(s, T8103_WDT_COMMIT_SECS);
     
     	sleep_ps_save(s);
     
    @@ -649,13 +672,28 @@ static void t8112_sleep_commit_regs(struct apple_sleep *s)
     					  T8103_SEP_GATE_US);
     	}
     
    -	/* Lower GFX while PMP is still running, then stop PMP. */
    +	/* Check committed GPU stop, save AGX fabric tunables, and lower GFX before PMP stop. */
     	t8112.commit_lowered = 0;
    +	t8112.agx_saved_valid = false;
    +	t8112.gfx_wake_err = 0;
    +	t8112.committed = true;
    +	if (t8112.gpu && device_is_bound(&t8112.gpu->dev)) {
    +		struct apple_sleep_coproc *gc = apple_sleep_coproc_find(&t8112.gpu->dev);
    +
    +		if (gc && gc->stop_ret)
    +			panic("T8112 committed GPU stop failed: %d", gc->stop_ret);
    +	}
     	if (sleep_ps_on(s, t8112_commit_off[0])) {
    +		if (t8112.agx_fabric) {
    +			for (i = 0; i < ARRAY_SIZE(t8112_agx_regs); i++)
    +				t8112.agx_saved[i] = readl(t8112.agx_fabric + t8112_agx_regs[i]);
    +			t8112.agx_saved_valid = true;
    +		}
     		t8112.commit_saved_ps[0] = readl(s->ps + t8112_commit_off[0]);
     		t8112.commit_lowered |= BIT(0);
     		sleep_ps_lower(s, t8112_commit_off[0]);
    -		sleep_ps_wait_off(s, t8112_commit_off[0]);
    +		if (sleep_ps_wait_off(s, t8112_commit_off[0]))
    +			panic("T8112 committed GFX power-off timed out");
     	}
     	t8103_asc_stop(t8112.pmp_asc, t8112.pmp_mbox);
     
    @@ -761,8 +799,8 @@ static void t8112_sleep_commit_regs(struct apple_sleep *s)
     					  T8112_TVM_TIMEOUT_US);
     	}
     
    -	t8112_dcs_write(0x335);
    -	t8112_dcs_write(0x553);
    +	t8112.dcs_down_ok = t8103_dcs_step_to(t8112.clk_mux + T8112_DCS_PERF_OFF,
    +					      T8112_DCS_SLEEP, &t8112.dcs_down_val);
     
     	writel(PWRGATE_ON, s->pwrgate + T8112_PWRGATE_E);
     	writel(PWRGATE_ON, s->pwrgate + T8112_PWRGATE_P);
    @@ -777,9 +815,19 @@ static void t8112_sleep_commit_regs(struct apple_sleep *s)
     			writel(val & ~PS_AUTO_ENABLE, s->ps + t8112_auto_off[i]);
     	}
     
    -	/* Ack and enable PMU RTC alarm SPMI vector so rtcwake reaches wake source 54. */
    +	/* Ack and enable PMU RTC alarm SPMI vector so rtcwake reaches wake source 58. */
     	writel(T8103_SPMI_VEC_RTC, s->spmi + T8103_SPMI_VEC_ACK);
     	writel(t8112.spmi_vec_saved | T8103_SPMI_VEC_RTC, s->spmi + T8103_SPMI_VEC_ENABLE);
    +	apple_sleep_pmu_write(s->spmi, s->soc->pmu_usid,
    +			      s->soc->pmu_sleep_reg, s->soc->pmu_sleep_val);
    +
    +	t8112.spmi_vec_commit = readl(s->spmi + T8103_SPMI_VEC_ENABLE);
    +	t8112.spmi_ack_commit = readl(s->spmi + T8103_SPMI_VEC_ACK);
    +	t8112.spmi_notify_commit = readl(s->spmi + SPMI_NOTIFY_ENABLE);
    +
    +	/* Snapshot wake status before committing WFI (read-only). */
    +	for (i = 0; i < s->soc->wake_words; i++)
    +		t8112.wake_entry[i] = readl(s->wake + s->soc->wake_status + i * 4);
     
     	aic_sleep_ack();
     	dsb(sy);
    @@ -817,7 +865,9 @@ static void t8112_sleep_pre_commit(struct apple_sleep *s)
     static void t8112_sleep_wake(struct apple_sleep *s)
     {
     	u32 val;
    -	int i;
    +	int i, pmp_ret = 0;
    +
    +	apple_sleep_pmu_write(s->spmi, s->soc->pmu_usid, s->soc->pmu_sleep_reg, 0x51);
     
     	writel(CLUSTER_ON, s->cluster + T8112_CLUSTER_E);
     	s->cluster_e_ret = readl_poll_timeout_atomic(s->cluster + T8112_CLUSTER_E, val,
    @@ -855,6 +905,10 @@ static void t8112_sleep_wake(struct apple_sleep *s)
     		}
     
     		t8112_slc_on();
    +		t8112.dcs_wake = readl(t8112.clk_mux + T8112_DCS_PERF_OFF);
    +		t8112.dcs_up_ok = t8103_dcs_step_to(t8112.clk_mux + T8112_DCS_PERF_OFF,
    +						    t8112.dcs_saved & 0xf,
    +						    &t8112.dcs_up_val);
     
     		if (t8112.nco) {
     			for (i = 0; i < T8103_NCO_CHANS; i++) {
    @@ -867,6 +921,8 @@ static void t8112_sleep_wake(struct apple_sleep *s)
     			t8112.nco_forced = 0;
     		}
     
    +		t8112.spmi_vec_wake = readl(s->spmi + T8103_SPMI_VEC_ENABLE);
    +		t8112.spmi_ack_wake = readl(s->spmi + T8103_SPMI_VEC_ACK);
     		writel(t8112.spmi_vec_saved, s->spmi + T8103_SPMI_VEC_ENABLE);
     
     		if (apple_sleep_enclave.stop) {
    @@ -888,7 +944,30 @@ static void t8112_sleep_wake(struct apple_sleep *s)
     			    off == T8112_PS_DISPEXT_FE || off == T8112_PS_DISPEXT_SYS ||
     			    off == T8112_PS_ISP_SYS)
     				continue;
    -			sleep_ps_restore(s->ps + off, t8112.commit_saved_ps[i]);
    +			if (off == T8112_PS_PMP) {
    +				pmp_ret = sleep_ps_restore(s->ps + off, t8112.commit_saved_ps[i]);
    +			} else if (off == T8112_PS_GFX) {
    +				int gfx_ret = pmp_ret ? pmp_ret :
    +					sleep_ps_restore(s->ps + off, t8112.commit_saved_ps[i]);
    +
    +				if (!gfx_ret && t8112.agx_saved_valid && t8112.agx_fabric) {
    +					unsigned int j;
    +
    +					for (j = 0; j < ARRAY_SIZE(t8112_agx_regs); j++)
    +						writel(t8112.agx_saved[j],
    +						       t8112.agx_fabric + t8112_agx_regs[j]);
    +				}
    +				t8112.gfx_wake_err = gfx_ret;
    +				if (gfx_ret && t8112.gpu) {
    +					struct apple_sleep_coproc *gc =
    +						apple_sleep_coproc_find(&t8112.gpu->dev);
    +
    +					if (gc)
    +						gc->wake_err = gfx_ret;
    +				}
    +			} else {
    +				sleep_ps_restore(s->ps + off, t8112.commit_saved_ps[i]);
    +			}
     		}
     		t8112.commit_lowered = 0;
     
    @@ -916,6 +995,7 @@ static void t8112_sleep_wake(struct apple_sleep *s)
     	writel(PWRGATE_ON, s->pwrgate + T8112_PWRGATE_E);
     	writel(PWRGATE_ON, s->pwrgate + T8112_PWRGATE_P);
     
    +	apple_sleep_pmu_write(s->spmi, s->soc->pmu_usid, s->soc->pmu_sleep_reg, 0x52);
     	apple_sleep_set_wd2(s, T8103_WDT_RESUME_SECS);
     }
     
    @@ -1041,13 +1121,26 @@ static void t8112_deep_wfi_arm(void)
     
     static void t8112_sleep_finish(struct apple_sleep *s)
     {
    -	dev_info(s->dev, "T8112: wake status %08x %08x %08x %08x %08x %08x %08x (armed %08x %08x %08x %08x %08x %08x %08x)\n",
    +	if (!t8112.committed)
    +		return;
    +	t8112.committed = false;
    +	apple_sleep_pmu_write(s->spmi, s->soc->pmu_usid, s->soc->pmu_sleep_reg, 0x30);
    +	dev_info(s->dev, "T8112: wake status %08x %08x %08x %08x %08x %08x %08x %08x (armed %08x %08x %08x %08x %08x %08x %08x %08x, entry %08x %08x %08x %08x %08x %08x %08x %08x)\n",
     		 s->wake_status[0], s->wake_status[1], s->wake_status[2],
     		 s->wake_status[3], s->wake_status[4], s->wake_status[5],
    -		 s->wake_status[6],
    +		 s->wake_status[6], s->wake_status[7],
     		 s->wake_armed[0], s->wake_armed[1], s->wake_armed[2],
     		 s->wake_armed[3], s->wake_armed[4], s->wake_armed[5],
    -		 s->wake_armed[6]);
    +		 s->wake_armed[6], s->wake_armed[7],
    +		 t8112.wake_entry[0], t8112.wake_entry[1], t8112.wake_entry[2],
    +		 t8112.wake_entry[3], t8112.wake_entry[4], t8112.wake_entry[5],
    +		 t8112.wake_entry[6], t8112.wake_entry[7]);
    +	dev_info(s->dev, "T8112: spmi vec=%#x->%#x wake=%#x ack=%#x->%#x dcs=%#x->%#x(%s)->%#x->%#x(%s) agx=%u gfx_err=%d\n",
    +		 t8112.spmi_vec_saved, t8112.spmi_vec_commit, t8112.spmi_vec_wake,
    +		 t8112.spmi_ack_commit, t8112.spmi_ack_wake,
    +		 t8112.dcs_saved, t8112.dcs_down_val, t8112.dcs_down_ok ? "ok" : "stuck",
    +		 t8112.dcs_wake, t8112.dcs_up_val, t8112.dcs_up_ok ? "ok" : "stuck",
    +		 t8112.agx_saved_valid, t8112.gfx_wake_err);
     	if (t8112.slc_off_bad) {
     		dev_warn(s->dev, "SLC write-back timed out on planes %#x\n",
     			 t8112.slc_off_bad);
    @@ -1079,20 +1172,29 @@ static const struct apple_sleep_gate_coproc t8112_gate_coprocs[] = {
     };
     
     static const struct apple_sleep_wake_name t8112_wake_names[] = {
    -	{ 3, "AOP.CPUWakeupAP" },
    -	{ 12, "AOP.GPIO.IRQ4" },
     	{ 14, "AOP.GPIO.IRQ6" },
    -	{ 54, "NUB.SPMI0Sw3IRQ" },
    -	{ 76, "SMC.CPUWakeupAP" },
    -	{ 81, "SMC.OutboxNotEmpty" },
    -	{ 133, "ATC0.USBWakeup" },
    -	{ 134, "ATC1.USBWakeup" },
    -	{ 155, "NUB.SPMI0.SW3" },
    -	{ 184, "SMC.CPUWakeupAP.M3" },
    -	{ 208, "SMC.OutboxNotEmpty.M3" },
    +	{ 26, "AOP.OutboxNotEmpty" },
    +	{ 27, "AOP.CPUWakeupAP" },
    +	{ 44, "NUB.WakeupAP" },
    +	{ 51, "NUB.GPIO.IRQ6" },
    +	{ 53, "NUB.APWatchdog" },
    +	{ 54, "NUB.APWakeupTime" },
    +	{ 58, "NUB.SPMI0.SW3" },
    +	{ 69, "AOP.SPMI0.SW3" },
    +	{ 73, "AOP.SPMI1.SW3" },
    +	{ 81, "SMC.CPUWakeupAP" },
    +	{ 86, "SMC.OutboxNotEmpty" },
    +	{ 147, "NUB.SPMI1.SW3" },
    +	{ 154, "ATC0.CIOWakeup" },
    +	{ 155, "ATC1.CIOWakeup" },
    +	{ 156, "ATC0.USBWakeup" },
    +	{ 157, "ATC1.USBWakeup" },
    +	{ 229, "MTP.GPIO.IRQ4" },
    +	{ 231, "MTP.GPIO.IRQ6" },
    +	{ 248, "MTP.DOCK.CHANNELS.AP0.IRQ" },
     };
     
    -static const u32 t8112_wake_required[] = { 54 };
    +static const u32 t8112_wake_required[] = { 58 };
     
     static const struct apple_sleep_ops t8112_sleep_ops = {
     	.deep_wfi_arm = t8112_deep_wfi_arm,
    @@ -1140,9 +1242,9 @@ static const struct apple_sleep_soc t8112_sleep_soc = {
     	.pmu_sleep_val = 0x50,
     	.spmi_notify_sleep = 0x2000001,
     	.wake_mask = 0x08,
    -	.wake_status = 0x24,
    -	.wake_words = 7,
    -	.wake_last_word = GENMASK(16, 0),
    +	.wake_status = 0x28,
    +	.wake_words = 8,
    +	.wake_last_word = GENMASK(30, 0),
     	.wake_names = t8112_wake_names,
     	.nwake_names = ARRAY_SIZE(t8112_wake_names),
     	.wake_required = t8112_wake_required,
    

    Next on our side: the ~90 s shutdown stall after a deep sleep, and sleep drain measurements.

  14. rjianwei commented on Nov 29, 2026

    @rjianwei
    ContributorAuthor

    @satchlj Awesome milestone — timed rtcwake (5s/10s/20s) with aurora GPU + sddm/Hyprland live and 25/25 GLES 3.2 renders per wake is huge!

    I have applied your diff onto feat/t8112-s2r with proper authorship & DCO:

    • Commit: 4be95ff46 (From: Satya Benson <satya@benson.earth>, Signed-off-by: Satya Benson <satya@benson.earth>)
    • Branch: https://github.com/rjianwei/linux/tree/feat/t8112-s2r
    • 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!

  15. satchlj commented on Nov 29, 2026

    @satchlj
    Member

    Claude Opus 5.5 on @satchlj's behalf.

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

    EDAC DEVICE1: UE: apple_soc_edac instance: 23b700000.event-log0 block: platform0 count: 1 'event-log source 2'
    apple_soc_edac 23b700000.event-log: hardware error: event-log source 2 (IRQ 152)
    
    • 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.

  16. rjianwei commented on Nov 29, 2026

    @rjianwei
    ContributorAuthor

    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):

    What passed on 13.5 (4be95ff46)

    • Boot + runtime DTB handoff: /chosen/aurora,s2r-mailbox published, apple-sleep probed (boot object resumes 0), apple-pmu-rtc registered as rtc1 (wakeup = enabled), both 231c00000.dcp and 271c00000.dcp bound 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.
    • 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)

    1. 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.
    2. 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
        
    3. 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).
  17. rjianwei commented on Nov 29, 2026

    @rjianwei
    ContributorAuthor

    @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:
      1. GFX timeout panic: ruled out (208e2a333 still resets at ~60 s).
      2. Bootloader/memory protection: aurora,s2r-mailbox (0x802d70440) is covered by EFI reserved (802c70000-8030abfff) in /proc/iomem.
      3. 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).
      4. 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).
      5. 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.)

  18. satchlj commented on Nov 29, 2026

    @satchlj
    Member

    @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.
    • Fix: drm/apple: dcp: leave the piodma DART alone at shutdown after DPMS off #3595 leaves piodma alone at shutdown once DPMS off has powered the display down. With it, the reboot after a deep sleep takes about 10 s.
    • 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.

  19. RyanTheTide commented on Nov 29, 2026

    @RyanTheTide
    Contributor

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

    1. 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.
    2. 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.

  20. satchlj commented on Nov 29, 2026

    @satchlj
    Member

    @rjianwei Heads-up: to keep T8112 deep sleep moving, we're opening the PR for feat/t8112-s2r ourselves, from satchlj/t8112-s2r.

    • Branch: your 21 commits at 208e2a333, cherry-picked onto current main (a03face57). No conflicts, and authorship and Signed-off-by are unchanged.
    • Testing: I'm running a J413 row at that exact head now and will post it on the PR.
    • Credit: your commits stay yours, and the PR body says the series is yours.

    If you'd rather open or own it yourself, say so and I'll close ours in favour of yours.

  21. rjianwei commented on Nov 29, 2026

    @rjianwei
    ContributorAuthor

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

  22. satchlj commented on Nov 29, 2026

    @satchlj
    Member

    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 about 0.03 W: one step in 1202 s
    same, repeated (with #3659 added) under 0.034 W: no step in 1202 s

    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.

  23. RyanTheTide commented on Nov 30, 2026

    @RyanTheTide
    Contributor

    The J413 row on #3647 at ec5d5289 passed 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.

  24. RyanTheTide commented on Dec 5, 2026

    @RyanTheTide
    Contributor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs hardware testtracking

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions