Skip to content

soc: apple: sleep: T8112: enable deep sleep by default - #3786

Draft
satchlj wants to merge 1 commit into
mainfrom
satchlj/t8112-deep-default
Draft

satchlj wants to merge 1 commit into
mainfrom
satchlj/t8112-deep-default

Conversation

@satchlj

@satchlj satchlj commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

What: Drop the untested flag from t8112_sleep_soc so deep sleep is offered and selected as the default mem_sleep state (s2idle [deep]) on T8112 on the default kernel command line, without apple_sleep.deep=1 or apple_sleep.untested_commit=1.

  • soc: apple: sleep: T8112: enable deep sleep by default — removes .untested = true from t8112_sleep_soc in drivers/soc/apple/sleep-t8112.h and updates apple_sleep_test_known_profiles in drivers/soc/apple/sleep-test.c.

Rebased cleanly onto main (645b086d9989) after #3774 (WAKE_SLP_DDR voter for adopted RTKit DRAM buffers on T8112) merged.

Tested:

  • Exact-head default-command-line J413 (M2 Air, macOS 27.2 stub) row at 8c8cce32b0e0 (--volatile, live MTP with 4 retained DRAM buffers, normal wake mask, no apple_sleep.deep=1, no apple_sleep.untested_commit=1): /sys/power/mem_sleep = s2idle [deep] out of the box (untested_commit=N, deep=N), 10/10 consecutive 10 s RTC deep sleeps PASS (wall_s=12..14 s, boot object resumes 0 -> 10, NUB.SPMI0.SW3 10/10, keyboard/trackpad kb=2 10/10, Borealis GPU PRE/POST10 RENDER_25_PASS, Wi-Fi 10/10, sddm active, 0 failed units).
  • arm64 QEMU KUnit at 8c8cce32b0e0: combined sleep + rtkit-helper config 56 passed, 1 skipped (apple-sleep-soc-data 16/16 including updated apple_sleep_test_known_profiles, apple-rtkit-helper 37/37, apple_mbox_g17_stall 3/3). checkpatch.pl --strict clean (0 errors, 0 warnings).
  • Prior 50-cycle hardware reliability row on soc: apple: sleep, rtkit-helper: keep WAKE_SLP_DDR up for adopted DRAM buffers on T8112 #3774 (f27ce29f2ecad) with apple_sleep.deep=1 + untested_commit=Y on J413: 50/50 consecutive deep sleeps PASS (10 s / 15 s / 20 s RTC wakes, boot object resumes -> 50, NUB.SPMI0.SW3, kb=2 50/50, Borealis GPU 6/6 RENDER_25_PASS, Wi-Fi 50/50, 0 failed units, 0 EDAC/MTP errors).

Risk: two-way · T8112 (a revert restores the untested opt-ins; mem_sleep_default=s2idle continues to select s2idle).

Not yet: J473 desktop row on the default command line at 8c8cce32b0e0; lid and AC-unplug wake rows (require physical hands); external display across deep sleep.

@RyanTheTide
RyanTheTide changed the base branch from satchlj/t8112-live-mtp-slp-ddr to main December 1, 2026 14:12
Drop the untested flag from t8112_sleep_soc so deep sleep is offered
and selected as the default mem_sleep state on T8112 without
apple_sleep.deep=1 or apple_sleep.untested_commit=1.

With WAKE_SLP_DDR driven by live adopted RTKit DRAM buffers, both
desktop (J473) and laptop (J413, firmware 27.2 live MTP) T8112 boards
commit and resume reliably across repeated deep sleeps. Update
apple_sleep_test_known_profiles to expect soc->untested == false for
apple,t8112-sleep.

Signed-off-by: Satya Benson <satya@benson.earth>
@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 8c8cce32: not ready yet

Check Detail
CI at head running running: apple-build, KUnit plan
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok in the PR body at 8c8cce32
Conflicts ok none
PR text ok Risk: two-way · T8112 (a revert restores the untested opt-ins; memsleepdefault=s2idle continues to select s2idle).

Areas: area:platform

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.

This branch has not been deployed

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

Labels

area:platform Area from CODEOWNERS (bot) blast:m2 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants