Skip to content

arm64: dts: apple: t8112-j413-fw27: enable deep sleep by default with PCIe-C s2idle fallback - #3786

Merged
satchlj merged 2 commits into
mainfrom
satchlj/t8112-deep-default
Dec 4, 2026
Merged

satchlj merged 2 commits into
mainfrom
satchlj/t8112-deep-default

Conversation

@satchlj

@satchlj satchlj commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

What: Narrow the T8112 default deep-sleep flip to J413 (MacBook Air 13" M2, macOS 27.2 firmware) via the per-board apple,sleep-tested devicetree property—keeping J473 (#4226), J415, J493, and legacy 13.5 J413 on s2idle by default—and add an automatic fallback to s2idle when deep sleep is refused for a retained Thunderbolt PCIe-C tunnel (such as an attached eGPU or open removable disk).

  • 30eef1aaf6a8 — PM: suspend: fall back to s2idle when deep sleep is refused for retained PCIe-C:
    • Adds PM_SUSPEND_FLAG_FALLBACK_S2IDLE (pm_set_suspend_fallback_s2idle() / pm_suspend_fallback_s2idle()) in include/linux/suspend.h and retry-as-PM_SUSPEND_TO_IDLE with pm_set_suspend_no_platform() in kernel/power/suspend.c (enter_state()).
    • Factors apple_pcie_tunnel_check_removable() and exports non-destructive apple_pcie_tunnel_can_remove_orderly() in drivers/pci/controller/pcie-apple.c + include/linux/pci-apple.h.
    • Adds a priority-120 apple_cio_pm_check_notify() pre-check (ahead of CD321x at 100 and port teardown at 40) plus a race-window fallback in apple_cio_sleep_teardown() in drivers/thunderbolt/apple.c.
    • Guards platform-sleep paths with pm_suspend_no_platform() in drivers/gpu/drm/apple/dcp.c, drivers/pci/controller/pcie-apple.c, drivers/phy/apple/atc-t6050-combo.h, and drivers/thunderbolt/apple.c.
    • Adds host + mutation tests in tools/asahi/sleep-s2idle-fallback-tests.{c,py} and registers them in tools/asahi/run-host-tests.py.
  • 1f7f71c8cdf1 — arm64: dts: apple: t8112-j413-fw27: Enable deep sleep by default:
    • Adds &sleep { apple,sleep-tested; }; to arch/arm64/boot/dts/apple/t8112-j413-fw27.dts, leaving t8112_sleep_soc.untested = true so other T8112 boards remain on s2idle until qualified.

Rebased cleanly onto main (7303d70ea68d).

Tested:

  • Exact-head default-command-line J413 (MacBook Air 13" M2, macOS 27.2 firmware, LLVM=1 kernel build + t8112-j413-fw27.dtb + upstream Aura 06c581d1 Stage 2, no apple_sleep.* or mem_sleep_default overrides) at 1f7f71c8cdf1:
    • /proc/device-tree/soc/sleep@23b700000/apple,sleep-tested present; /sys/power/mem_sleep as booted = s2idle [deep]; apple-sleep reports sleep data derived for this SoC, through full sleeps and wakes on this machine (apple,sleep-tested) and deep sleep is the default: boot object resumes 0.
    • 3/3 consecutive 15 s RTC deep sleeps (rtcwake -d /dev/rtc1 -m mem -s 15) PASS (rc=0): boot object resumes 0 -> 1 -> 2 -> 3, wake source: NUB.SPMI0.SW3 3/3, device suspend 0.522 s / 0.495 s / 0.489 s.
    • 1/1 explicit 15 s s2idle freeze (rtcwake -d /dev/rtc1 -m freeze -s 15) PASS (rc=0): PM: suspend entry (s2idle) -> PM: suspend exit (0.316 s), suspend_stats/success:4, fail:0, mem_sleep remains s2idle [deep].
    • Post-wake regression check after every cycle: NVMe O_DIRECT OK, Wi-Fi (wlan0) up, Borealis Vulkan (Apple M2 (G14G B0), Mesa 26.3.0-devel, /dev/dri/renderD128) active, live MTP keyboard + multi-touch + Force Click intact, 0 DCP crashes, 0 kernel panics/warnings/call traces, 0 failed units.
  • DTB & binding check at 1f7f71c8cdf1: make ARCH=arm64 LLVM=1 W=1 clean; dtc confirms apple,sleep-tested present only in t8112-j413-fw27.dtb (1) and absent in t8112-j413.dtb (0), t8112-j473-fw27.dtb (0), and t8112-j473.dtb (0).
  • Host & mutation tests at 1f7f71c8cdf1: sleep-s2idle-fallback-tests 5/5 PASS (control + 4 mutations killed under both gcc and clang), run-host-tests.py --only sleep 59/59 PASS, run-host-tests.py --only pcie 10/10 PASS (including pciec-policy-tests). scripts/checkpatch.pl --strict 0 errors on both commits.
  • Prior J413 hardware reliability baseline: 10/10 default-cmdline deep sleeps at 8c8cce32b0e0 and 50/50 deep sleeps on soc: apple: sleep, rtkit-helper: keep WAKE_SLP_DDR up for adopted DRAM buffers on T8112 #3774 (f27ce29f2ecad).

Risk: two-way · J413 (macOS 27.2 firmware) and the PCIe-C deep-refused -> s2idle fallback path (mem_sleep_default=s2idle continues to select s2idle; J473 stays on s2idle until #4226 is resolved; reverting restores the previous behavior).

Not yet: Physical Thunderbolt eGPU hardware was not attached on this J413 (the eGPU and open-disk deep-refused -> s2idle fallback paths are verified by host + mutation tests in tools/asahi/sleep-s2idle-fallback-tests.{c,py} and pciec-policy-tests.py, and are ready for a live check on a Thunderbolt eGPU J413); lid and AC-unplug wake rows.

@RyanTheTide
RyanTheTide changed the base branch from satchlj/t8112-live-mtp-slp-ddr to main December 1, 2026 14:12
@satchlj
satchlj force-pushed the satchlj/t8112-deep-default branch from 5a03cf5 to 8c8cce3 Compare December 1, 2026 15:05
@satchlj

satchlj commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

Rebased onto current main (645b086d9989) after #3774 merged: old head 5a03cf529bd3 -> new head 8c8cce32b0e0 (single commit, identical diff).

Verified at 8c8cce32b0e0:

  • checkpatch.pl --strict: 0 errors, 0 warnings.
  • arm64 QEMU KUnit: 56 passed, 1 skipped (apple-sleep-soc-data 16/16, apple-rtkit-helper 37/37, apple_mbox_g17_stall 3/3).

Keeping as draft until an exact-head default-command-line T8112 verification row runs.

@satchlj

satchlj commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

Exact-head default-command-line J413 (M2 Air, macOS 27.2 stub) verification row at 8c8cce32b0e0 (--volatile read-only root, live MTP handoff with 4 retained DRAM buffers, normal wake mask, no apple_sleep.deep=1 and no apple_sleep.untested_commit=1):

  • Command line check: no apple_sleep.* override parameters (untested_commit=N, deep=N).
  • Out-of-the-box defaults: /sys/power/mem_sleep = s2idle [deep], dmesg: apple-sleep 23b700000.sleep: deep sleep is the default: boot object resumes 0, rtkit-helper 24e400000.mtp: adopted the running RTKit session (4 retained buffers).
  • Pre-sleep: failed_units=0, sddm active, keyboard/trackpad kb=2, Wi-Fi connected, Borealis GPU PRE_RENDER_25_PASS.
  • Deep sleep loop (10×10 s rtcwake -d rtc1 -m mem -s 10, without touching /sys/power/mem_sleep or untested_commit): 10/10 PASS (wall_s=12..14 s, boot object resumes 0 -> 10, wake source: NUB.SPMI0.SW3 10/10, kb=2 10/10, Wi-Fi connected 10/10).
  • Post-sleep: Borealis GPU POST10_RENDER_25_PASS, Wi-Fi connected, sddm active, failed_units=0, clean reboot back to default.

@satchlj
satchlj marked this pull request as ready for review December 1, 2026 16:15
@satchlj
satchlj requested review from a team as code owners December 1, 2026 16:15
@satchlj
satchlj requested review from LiamRay11 and malik-na December 1, 2026 16:15
@github-actions github-actions Bot added area:platform Area from CODEOWNERS (bot) blast:m2 Macs affected, from Merge risk (bot) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Dec 1, 2026
@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Merge readiness at 1f7f71c8: ready to merge

Check Detail
CI at head ok 18 checks passed
Review ok approved by RyanTheTide
Requested changes ok none
Hardware row at head ok comment at 1f7f71c8
Conflicts ok none
PR text ok Risk: two-way · J413 (macOS 27.2 firmware) and the PCIe-C deep-refused -> s2idle fallback path (memsleepdefault=s2idle continues to select s2idle; J473 stays on s2idle until #4226 is resolved; reverting restores the previous behavior).

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

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

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verdict: MERGE at 8c8cce3

Checked:

  • Diff is one line in the profile, .untested = true dropped from t8112_sleep_soc, plus its KUnit expectation. In sleep.c the untested flag only gates the dry run and the commit (s->soc->untested && !sleep_untested_commit), so with it cleared T8112 takes the same commit path that #3774's 50/50 J413 row exercised with untested_commit=Y. Nothing else changes.
  • apple_sleep_test_known_profiles: the new EXPECT_FALSE sits in a branch for apple,t8112-sleep only. T8122 keeps its own untested == 1 expectation and T8142 its 0, so the test can't pass by accident for another SoC.
  • Exact-head J413 default-cmdline row: s2idle [deep] out of the box, 10/10 RTC deep sleeps with keyboard, GPU and Wi-Fi back. That's the merge gate's one row on one Mac.

Follow-ups (not blocking):

  • This makes deep sleep the default on every T8112 Mac, including the J473 desktop, which sleeps on its own and has had s2idle/display regressions before (#2953, #2853). A J473 default-cmdline row with the monitor attached is the most valuable next check. mem_sleep_default=s2idle remains the per-Mac escape hatch.
  • Lid / AC-unplug wake and external display across deep sleep, as the PR lists.

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

Copy link
Copy Markdown
Contributor

Row: 8c8cce3 + J473 (Mac mini M2, 27.2 stub, USB-C + HDMI monitors) + default is deep as claimed; every deep suspend aborts on the existing linux#3790.

So on J473 the new default lands on #3790. This PR doesn't cause it, but with it, J473 suspend now fails outright where it used to fall back to s2idle. Your call whether #3786 waits for #3790 or #3790 follows it.

@satchlj
satchlj marked this pull request as draft December 1, 2026 17:03
@satchlj

satchlj commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

@RyanTheTide Thanks for the exact-head J473 row — that is a clear regression in default suspend on J473 (and likely any T8112 with a USB-C display attached, going from working s2idle to a latched -110 for the rest of the boot). Converting #3786 back to draft so it waits for #3790.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Row: 8c8cce3 + #3822 5e7dcf8 on main fe7d114 + J473 + FAIL. With #3822 the -110 is gone, but dcpext then doesn't go idle (-62), crashes on the next cycle, and the third suspend reset the Mac. Details on #3822. So on J473, deep-by-default still waits on a working #3790 fix.

@satchlj

satchlj commented Dec 2, 2026

Copy link
Copy Markdown
Member Author

J413 (MacBook Air 13" M2, T8112, 27.2 stub) steady-state deep-sleep power measurement on main + #3865 (f14fa751845f, now merged as 71565fddc90d) with unmodified post-#3789 t8112-j413-fw27.dtb:

  • Setup: Mid-charge (~81%, ~36.5 Wh, USB-C power connected with charge_behaviour=force-discharge during the run so wall power did not charge the pack; [auto] restored afterward). Live BAAC (charge_counter) calibration over 50 s idle measured 7535 / 50 s = 150.70/s against current_now = -151..-148 mA (1 BAAC unit = 1 mA·s).
  • Back-to-back committed deep sleeps (NUB.SPMI0.SW3, agx=1 gfx_err=0):
    • Cycle 1 (1204 s, boot object resumes 0 -> 1, GPU firmware 27.2 back in 4881 us): BAAC delta 21,731 mAs (74.6 mWh, 223.0 mW average). energy_now moved +821 mWh on OCV relaxation after pre-discharge.
    • Cycle 2 (3541 s, boot object resumes 1 -> 2, GPU firmware 27.2 back in 5243 us): BAAC delta 62,124 mAs (213.1 mWh, 216.6 mW average; settled energy_now 214.7 mW).
  • Differential (Cycle 2 - Cycle 1, 2337 s): steady-state committed deep-sleep draw = 213.3 mW (~17.3 mA at 12.35 V), with 3.22 mWh (11.6 J) entry+exit overhead (caveat: USB-C cable remained plugged with force-discharge). Borealis GPU render passed before and after both cycles; all 3 MTP input devices preserved; 0 failed units.

Note: #3786 (8c8cce32) still merges cleanly onto current main (cf03d96bf209, which now includes #3865 and #3825), so keeping the tested head SHA intact in draft while J473 #3790/#3822 is resolved.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Row: 8c8cce3 on main cf03d96b (includes #3865) + J473 (Mac mini M2, 27.2 stub) + default cmdline + FAIL: cycle 2 reset the Mac.

  • Kernel = main cf03d96b + this PR cherry-picked, fleet94 config, production b18 Stage 2 (no T8112 DT change since). Production boot options unchanged; /sys/power/mem_sleep as booted: s2idle [deep].
  • This time only the HDMI monitor was connected (USB-C monitor unplugged), displays DPMS-off, USB4 peer link up.
  • Cycle 1 (rtc1, 20 s): PM: suspend entry (deep) aborted after 2.2 s on the primary DCP:
apple-dcp 231c00000.dcp: scanout stop was not confirmed
apple-dcp 231c00000.dcp: dcp_poweroff() done
apple-dcp 271c00000.dcp: RTKit: idle, but not stopped: status 0x2d
apple-dcp 231c00000.dcp: no D572 1049 ms after set_power_state(0)
apple-dcp 231c00000.dcp: PM: dpm_run_callback(): dcp_platform_suspend [appledrm] returns -16
apple-dcp 271c00000.dcp: RTKit: Initializing (protocol version 12)
apple-dcp 271c00000.dcp: sleep refused: firmware back after a power cycle: 0
aurora 206400000.gpu: GPU: deep sleep refused before commit

USB, network, NVMe and GPU (deqp triangle) were fine after it; no DCP crash lines.

  • Cycle 2: the Mac reset during the suspend (nothing logged past the cycle 2 entry) and came back on the production kernel.

On the J473 today, deep by default turns a working s2idle into an abort and then a reset, so this still waits on the J473 DCP deep-sleep fix (#3790 / #3822). Next I run #3822 875c1cec + this PR on the J473 (both DCPs).

@satchlj

satchlj commented Dec 2, 2026

Copy link
Copy Markdown
Member Author

Following up on @RyanTheTide's J473 bisection on #3822 (pm_test=devices/platform/core and apple_sleep.refuse_late=1 all PASS with 0 resets and HDMI reconnecting cleanly), which narrows the J473 Cycle-1 deep-sleep reset strictly to the post-refuse_late commit path (apple_sleep_enclave_stop() -> t8112_sleep_commit_regs() -> WFI/wake).

Auditing drivers/soc/apple/sleep-t8112.h (t8112_commit_off[]) against arch/arm64/boot/dts/apple/t8112-pmgr.dtsi, t8112-j473.dts, and the active J473 pm_genpd_summary domains compared with J413 (where deep sleep passes 3/3) turns up concrete missing child/board domains in t8112_commit_off[]:

  1. ps_dptx_ext_phy (0x3d8) — J473-only (OFF on J413):
    • Held on by &framebuffer0 { power-domains = <&ps_disp0_cpu0>, <&ps_dptx_ext_phy>; }; in t8112-j473.dts.
    • Not in t8112_commit_off[], so it stays powered across WFI.
  2. ps_atc0_cio_usb (0x478), ps_atc0_cio_pcie (0x470), ps_atc0_cio (0x468) and ps_atc1_cio_usb (0x4a0), ps_atc1_cio_pcie (0x498), ps_atc1_cio (0x490) — active on J473 with thunderbolt0 USB4 peer up (OFF on J413 without USB4 peer):
    • t8112-pmgr.dtsi makes ps_atc0_cio a child of ps_atc0_common (0x458), and ps_atc0_cio_pcie/ps_atc0_cio_usb children of ps_atc0_cio (same for atc1).
    • t8112_commit_off[] lowers atc0_pcie (0x460) and atc0_common (0x458), never lowering the CIO children first — so atc0_common cannot power off while the USB4 peer's CIO domains are active.
  3. ps_scodec (0x4b0, child of ps_rmx0 0x350) — and note ps_dispdfr_fe (0x3e0, child of ps_rmx0) / ps_venc_sys (0x440, child of ps_rmx1 0x358):
    • ps_scodec is on before suspend while its parent ps_rmx0 (0x350) is in t8112_commit_off[]; lowering rmx0 without lowering scodec first leaves rmx0 blocked.
    • Note also t8112.commit_lowered is currently u32 (20 entries today); adding these domains brings t8112_commit_off[] to 28+ entries, so widening commit_lowered to u64 (BIT_ULL(i)) is worth doing at the same time.

Proposed next step:

  • Add ps_dptx_ext_phy (0x3d8), ps_atc1_cio_usb/pcie/cio (0x4a0/0x498/0x490, before ps_atc1_common), ps_atc0_cio_usb/pcie/cio (0x478/0x470/0x468, before ps_atc0_common), and ps_scodec (0x4b0, before ps_rmx0) to t8112_commit_off[] (children before parents, restored parents-first in t8112_sleep_wake() so genpd stays in sync for &framebuffer0 and USB4/CIO).
  • Secondary J473-vs-J413 delta to check if lowering those domains isn't sufficient on its own: J473 enables pcie port01 (USB-A xHCI) and port02 (ethernet0) in addition to port00 (Wi-Fi/BT), whereas J413 only has port00, and t8112_sleep_commit_regs() lowers apcie_st/apcie_gp/apcie/pcie_ref directly without a port-stop pass.

I will put together a patch for the missing t8112_commit_off[] domains and verify no regression on J413 next; if you have a quick cycle on J473 to test lowering dptx_ext_phy + atc*_cio* + scodec (or testing with the USB4 peer unplugged as a quick A/B), that will immediately tell us whether the missing domains are the whole J473 Cycle-1 reset or if port01/port02 also need port teardown.

@satchlj

satchlj commented Dec 3, 2026

Copy link
Copy Markdown
Member Author

Quick follow-up on the missing T8112 domain patch idea: tested a prototype adding dptx_ext_phy / dispdfr_* / mipi_dsi / atc*_cio* to t8112_commit_off[] and adding t8112_stray[] (including ane_sys and mmx) on top of origin/main (1ab453e8b404) on J413 (apple_sleep.deep=1 apple_sleep.untested_commit=1). It passed KUnit (18/18) and checkpatch, booted cleanly, and then hit the 60 s commit watchdog reset on Cycle 1 of deep sleep.

Looking at active genpd domains on J413, the only two domains from that patch that were powered on at idle were ane_sys (0x4a8) and mmx (0x368) — and unlike T8122's t8122_stray[], putting the top-level mmx media fabric in t8112_stray[] lowers it in apple_sleep_refuse() before coprocessor stops and t8112_sleep_commit_regs(). Holding that patch out of a PR until we separate mmx out of stray[] and verify an unpatched origin/main control row + dry-run first.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Row: #3786 8c8cce32 on main d6e13dec (with #3822 merged, plus #4207 d11e3303) + J473 (Mac mini M2, 27.2 OS/system firmware) + default cmdline + FAIL: the first committed deep sleep resets the Mac, 4 of 4 boots.

  • Kernel 7.3.0-aurora-m1m2d, fleet94 config, booted once with its own t8112-j473.dtb through an aura-try trial Stage 2: live aura 1.0.0b18 with only the board DTB swapped, chosen/aurora,trial confirmed. Boot ids aa2d2c0c, 5ab7b13e, dd65c5ce, e7630753.
  • mem_sleep as booted: s2idle [deep] ("deep sleep is the default: boot object resumes 0"). Wake through rtc1 = apple-pmu-rtc, picked by name.
  • The Mac hangs in the commit, and the 60 s commit watchdog resets it about 70 s after entry (1 s ping log; a plain reboot takes 33 s to answer ping).
  • Ruled out, each on its own boot: USB4 peer CIO domains plus dptx_ext_phy added to t8112_commit_off[] (lab patch), and the two J473-only PCIe endpoints (ASM2142 xHCI, BCM57762 Ethernet) removed before the sleep. All still reset. Details and the list of domains that are on at idle: soc: apple: sleep: J473 (Mac mini M2) deep sleep hangs in the commit, 60 s watchdog reset #4226.
  • J473 restored to its saved default afterwards and verified.

So on the J473, deep-by-default still waits on #4226. Since the J413 passes, one way forward is to land the J413 default first, keyed on a DT property of the boards that have been tested, and keep the J473 on s2idle until #4226 is fixed. That's your call, @satchlj.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Row: #3786 8c8cce32 on main d6e13dec (+ #4207 d11e3303) + J413 (MacBook Air M2, 27.2 OS/system firmware) + PASS: 3/3 committed deep sleeps + s2idle, with one setup note below.

  • Kernel 7.3.0-aurora-m1m2d, fleet94 config. Booted once through an aura-try trial Stage 2 with this tree's own t8112-j413.dtb and t8112-j413-fw27.dtb (both variants in the live b18 image replaced, nothing else changed). Boot 118935c2.
  • mem_sleep as booted: s2idle [deep] ("deep sleep is the default"). Wake through rtc1 = apple-pmu-rtc, picked by name.
  • 3x rtcwake -m mem -s 15: rc 0, 17.0 / 17.0 / 17.2 s, back from sleep, boot object resumes 0 -> 1 -> 2 -> 3, wake source: NUB.SPMI0.SW3. After each wake: Wi-Fi up and the gateway answering, 16 MiB O_DIRECT NVMe readback matches, eDP-1 and the external DP-2 both connected and enabled, 12 input devices, 0 DCP crash lines. s2idle 1/1 rc 0.
  • New kernel error lines after the sleeps: only brcmfmac/hci_bcm4377 Unable to change power state from D3hot to D0, device inaccessible, which other T8112/T8122 rows show too. Wi-Fi recovered every time.

Setup note: this J413 has a GTX 1080 in a Thunderbolt enclosure. With its drivers bound, every deep sleep is refused cleanly (the Mac stays up):

pcie-apple 530000000.pcie: PCIe-C: a function driven by nouveau is not removed for the sleep
thunderbolt-apple-acio 501ac0000.cio: PCIe devices behind this port stay for the sleep (-95): the port is not powered off

With only nouveau blacklisted, the GPU's HDMI-audio function (snd_hda_intel) is refused the same way. The pass above used modprobe.blacklist=nouveau,snd_hda_intel on the trial boot only, which makes it the same setup as your eGPU-less J413. Since deep is now the default, a user with a TB eGPU gets a failed suspend instead of a fallback to s2idle. That probably wants its own follow-up (fall back to s2idle when a PCIe-C function can't be removed), not a blocker here.

The J413 was restored to its saved default afterwards and verified. The J473 desktop still fails (#4226), as posted above.

…ned PCIe-C

When deep sleep is the default mem_sleep mode on Apple Silicon Macs whose
deep sleep powers off CIO domains, a connected Thunderbolt device whose
PCIe-C functions cannot be removed cleanly before sleep (such as an eGPU
driven by nouveau, amdgpu, or snd_hda_intel, or an open external NVMe
disk) causes apple_cio_pm_notify() to refuse PM_SUSPEND_PREPARE with
-EOPNOTSUPP or -EBUSY. With s2idle as the default the same suspend
succeeds because the USB4 router and PCIe-C link stay powered across
s2idle.

Add a PM_SUSPEND_FLAG_FALLBACK_S2IDLE flag checked by enter_state() when
suspend_prepare(PM_SUSPEND_MEM) fails: if a notifier explicitly asked for
an s2idle fallback, retry suspend_prepare() as PM_SUSPEND_TO_IDLE with
PM_SUSPEND_FLAG_NO_PLATFORM set so the system suspends cleanly in s2idle
while keeping mem_sleep_current at deep for subsequent suspends once the
device is unplugged. Unflagged PM_SUSPEND_PREPARE errors are still
returned unchanged.

Add a non-destructive apple_pcie_tunnel_can_remove_orderly() pre-check
invoked from a priority-120 ACIO PM notifier (ahead of CD321x at 100 and
port teardown at 40) so sibling ports are never torn down before
discovering that another port must stay up. Also ensure the remaining
Apple PM_SUSPEND_PREPARE notifiers that test pm_suspend_default_s2idle()
respect pm_suspend_no_platform() for both explicit freeze and s2idle
fallback.

Add host tests and mutation negative controls in
tools/asahi/sleep-s2idle-fallback-tests.{c,py}.

Signed-off-by: Satya Benson <satya@benson.earth>
Add apple,sleep-tested to the 27.2 J413 (MacBook Air 13" M2) &sleep node
so deep sleep is offered and selected by default without apple_sleep.deep=1
or apple_sleep.untested_commit=1, following the J414s/J613/J615 per-board
pattern.

Keep t8112_sleep_soc.untested set so J473 (Mac mini M2, where deep sleep
commit resets in #4226), J415, J493, and legacy 13.5 J413 firmware stay
on s2idle by default.

Signed-off-by: Satya Benson <satya@benson.earth>
@satchlj
satchlj force-pushed the satchlj/t8112-deep-default branch from 8c8cce3 to 1f7f71c Compare December 3, 2026 23:47
@satchlj satchlj changed the title soc: apple: sleep: T8112: enable deep sleep by default arm64: dts: apple: t8112-j413-fw27: enable deep sleep by default with PCIe-C s2idle fallback Dec 3, 2026
@satchlj

satchlj commented Dec 3, 2026

Copy link
Copy Markdown
Member Author

Rebased onto main (7303d70ea68d), narrowed to J413 via apple,sleep-tested, added the PCIe-C deep-refused -> s2idle fallback, and force-pushed:

  • Old head: 8c8cce32b0e0d5d723b7f9a43344ce2ece438986
  • New head: 1f7f71c8cdf153d9fff106019de18dccb7e17b47

Summary of changes:

  1. 30eef1aaf6a8: PM: suspend: fall back to s2idle when deep sleep is refused for retained PCIe-C — non-destructive priority-120 PCIe-C removability pre-check (plus teardown race fallback) sets PM_SUSPEND_FLAG_FALLBACK_S2IDLE, causing enter_state() to retry as PM_SUSPEND_TO_IDLE with pm_set_suspend_no_platform() so retained tunnels (eGPU / open disk) suspend via s2idle instead of failing deep suspend; includes pm_suspend_no_platform() guards across dcp, pcie-apple, atc-t6050-combo, and thunderbolt/apple, plus tools/asahi/sleep-s2idle-fallback-tests.{c,py}.
  2. 1f7f71c8cdf1: arm64: dts: apple: t8112-j413-fw27: Enable deep sleep by default — adds &sleep { apple,sleep-tested; }; to t8112-j413-fw27.dts only, keeping t8112_sleep_soc.untested = true so J473 (soc: apple: sleep: J473 (Mac mini M2) deep sleep hangs in the commit, 60 s watchdog reset #4226), J415, J493, and 13.5 J413 remain on s2idle.

Exact-head hardware verification on J413 (MacBook Air 13" M2, macOS 27.2 firmware, default cmdline, upstream Aura 06c581d1 Stage 2 + t8112-j413-fw27.dtb) at 1f7f71c8cdf1:

  • /sys/power/mem_sleep = s2idle [deep] out of the box (apple,sleep-tested present).
  • 3/3 15 s RTC deep sleeps PASS (boot object resumes 0 -> 3, NUB.SPMI0.SW3, device suspend 0.489–0.522 s).
  • 1/1 15 s explicit s2idle freeze PASS (suspend_stats/success:4, fail:0).
  • Post-wake checks clean across every cycle (NVMe O_DIRECT, Wi-Fi, Borealis Vulkan, live MTP keyboard/trackpad, 0 DCP crashes, 0 kernel warnings/panics, 0 failed units).
  • DTB check: apple,sleep-tested present only in t8112-j413-fw27.dtb (0 in t8112-j413.dtb, t8112-j473-fw27.dtb, t8112-j473.dtb).
  • Host tests: sleep-s2idle-fallback-tests 5/5 (gcc + clang), sleep 59/59, pcie 10/10.

Note: physical Thunderbolt eGPU hardware was not attached on this J413; the deep-refused -> s2idle fallback path is verified by host/mutation tests and ready for a live TB eGPU check. Marking ready for review.

@satchlj
satchlj marked this pull request as ready for review December 3, 2026 23:49
@satchlj
satchlj requested a review from DjDeveloperr as a code owner December 3, 2026 23:49
@github-actions github-actions Bot added area:display Area from CODEOWNERS (bot) area:gpu Area from CODEOWNERS (bot) area:usb Area from CODEOWNERS (bot) ci-failing A check failed at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) and removed blast:m2 Macs affected, from Merge risk (bot) ci-failing A check failed at the PR head (bot) labels Dec 3, 2026

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verdict: MERGE at 1f7f71c

Checked: The existing sleep binding provides the boolean apple,sleep-tested. This head adds it only to the firmware-27 J413 DT and leaves the T8112-wide untested setting in place. The reported exact-head J413 row shows three committed deep wakes and one explicit s2idle cycle. The author also verified that the flag is absent in the legacy J413 and both J473 DTBs.

Checked: The non-destructive PCIe-C notifier runs before the PD and port-teardown notifiers. A retained device requests one retry at s2idle after the failed suspend preparation unwinds. Before the retry's notifiers, the core clears the original flags and sets the no-platform flag. The deep-only paths honor it and errors without the fallback flag return normally.

Checked: Ran the exact-head fallback harness locally. Its control passed for the retained eGPU, open disk, multi-port and other-error paths. It caught all four mutations covering the fallback branch, no-platform flag, unrelated refusal and notifier priority.

@RyanTheTide RyanTheTide left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approving at 1f7f71c. Review-bot approval at this exact head covers the code (deep only for J413 via apple,sleep-tested; J473 stays s2idle; PCIe-C deep-refused falls back to s2idle). Hardware: J413 3/3 committed deep + s2idle (27.2), J473 control. Adds the code-owner approval.

@github-actions github-actions Bot added ready-to-merge Meets the merge policy: merge it (bot) and removed needs-review No approving review from Core or Omarchy Mac yet (bot) labels Dec 4, 2026
@satchlj
satchlj merged commit f21d1ed into main Dec 4, 2026
22 of 23 checks passed
@satchlj
satchlj deleted the satchlj/t8112-deep-default branch December 4, 2026 00:39
DjDeveloperr added a commit that referenced this pull request Dec 4, 2026
Brings the branch up to main after #3786 (s2idle fallback when deep
sleep is refused for retained PCIe-C, J413 fw27 deep by default) and
#3540 (thunderbolt: apple: lost-link recheck).

Conflicts:
- drivers/pci/controller/pcie-apple.c: both sides split the checks out of
  apple_pcie_tunnel_remove_orderly(). Main's helper,
  apple_pcie_tunnel_can_remove_orderly() and remove_orderly() are taken
  as they are. This branch's apple_pcie_tunnel_kept() and
  apple_pcie_tunnel_removable() stay for now; the next commit drops them.
- tools/asahi/run-host-tests.py: both test entries kept.

kernel/power/suspend.c merged without a conflict: the platform veto in
pm_suspend() runs before enter_state(), and main's fallback in
enter_state() still covers a deep sleep refused at PM_SUSPEND_PREPARE.

Signed-off-by: DjDeveloperr <hey@djdev.me>
DjDeveloperr added a commit that referenced this pull request Dec 4, 2026
Main gained apple_pcie_tunnel_can_remove_orderly() with #3786: the same
non-destructive check as this branch's apple_pcie_tunnel_removable(),
with the same returns (0 when removable or already stopped, -EOPNOTSUPP
for a driver the teardown doesn't remove, -EBUSY for a disk in use,
-ENODEV/-EINVAL for no tunnelled host). Use it for the port's deep
veto and drop the copy, so pcie-apple.c and pci-apple.h are main's
again. The only difference is that the PCIe host now logs why the
hierarchy stays, as it does when the teardown asks.

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

Copy link
Copy Markdown
Contributor

Post-merge receipt, J413 (MacBook Air M2, OS/system firmware 27.2): deep sleep PASS 3/3 on main 1675a62307d2. That is the saved edge kernel 7.3.0-1675a62307d2-47318133913.1-aurora-edge, which has this PR.

  • Boot 2121b2ab, no one-shot. The probe log says deep sleep is the default (apple,sleep-tested from t8112-j413-fw27). mem_sleep is s2idle [deep].
  • 3x rtcwake -m mem with a 15 s alarm on apple-pmu-rtc: rc 0 each, 16.9-17.5 s. Boot object resumes 0 -> 3, wake source NUB.SPMI0.SW3. Wi-Fi back with ping OK, NVMe O_DIRECT read matches, 0 DCP crash lines. s2idle also PASS.
  • New error lines: the ane_base power state, and brcmfmac + hci_bcm D3hot->D0. All already known, and all recover.

Evidence: traces/power/20261204-m1m2deep-m2/r6-edge.

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

Labels

area:display Area from CODEOWNERS (bot) area:gpu Area from CODEOWNERS (bot) area:platform Area from CODEOWNERS (bot) area:usb Area from CODEOWNERS (bot) door:two-way Revertible or not, from Merge risk (bot) ready-to-merge Meets the merge policy: merge it (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants