Skip to content

soc: apple: sleep, rtkit-helper: keep WAKE_SLP_DDR up for adopted DRAM buffers on T8112 - #3774

Merged
RyanTheTide merged 4 commits into
mainfrom
satchlj/t8112-live-mtp-slp-ddr
Dec 1, 2026
Merged

RyanTheTide merged 4 commits into
mainfrom
satchlj/t8112-live-mtp-slp-ddr

Conversation

@satchlj

@satchlj satchlj commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

What: Keep WAKE_SLP_DDR bit 0 asserted across deep sleep on T8112 when an adopted apple,rtkit-handoff session retains DRAM buffers (such as live MTP on J413 under firmware 27.2), without changing full DRAM-off deep sleep on boards without a live DRAM handoff or on newer SoCs (T8132, T8140, T8142).

  • soc: apple: sleep: fix T8112 expectation in known_profiles KUnit test — restores apple_sleep_test_known_profiles for apple,t8112-sleep after #3647 merged main (cdbecbe2e04a).
  • soc: apple: sleep: support coprocessor SLP_DDR voters — adds refcounted apple_sleep_coproc_slp_ddr(bool up) alongside the USB voter, gated on a per-SoC coproc_slp_ddr capability flag applied in sleep_slp_ddr_bind(), with KUnit coverage (apple_sleep_test_slp_ddr_voters).
  • soc: apple: rtkit-helper: vote SLP_DDR for adopted DRAM buffers — tracks whether an adopted apple,rtkit-handoff inventory places any buffer in reserved DRAM (set atomically only after full inventory validation) and registers a devm-managed apple_sleep_coproc_slp_ddr() vote, with KUnit coverage (rtkh_inherit_dram_buffers).
  • soc: apple: sleep: wire SLP_DDR vote word on T8112 — calls sleep_slp_ddr_bind(s) in t8112_sleep_map_regs() and sets .coproc_slp_ddr = true on t8112_sleep_soc.

Tested: arm64 QEMU KUnit at f27ce29f2ecad: combined sleep + rtkit-helper config 56 passed, 1 skipped (apple-sleep-soc-data 16/16 including apple_sleep_test_known_profiles and apple_sleep_test_slp_ddr_voters, apple-rtkit-helper 37/37 including rtkh_inherit_dram_buffers, apple_mbox_g17_stall 3/3); standalone rtkit-helper.kunitconfig (CONFIG_APPLE_SOC_SLEEP=n) 40 passed, 1 skipped. Exact-head f27ce29f2ecad J413 M2 Air hardware row (macOS 27.2 stub, live MTP with 4 retained DRAM buffers, normal wake mask, apple_sleep.deep=1): PASS 5/5 consecutive 10 s deep sleeps (boot object resumes 0 -> 5, wake source: NUB.SPMI0.SW3, keyboard/trackpad kb=2 every cycle, GPU Borealis render pass before and after, Wi-Fi intact, 0 failed units). Prior 180 s live-MTP WAKE_SLP_DDR drain measurement on the same voter: 0.451 W battery drain.
Risk: two-way · T8112 (shared sleep.c and rtkit-helper.c voter paths are gated on coproc_slp_ddr, so T8132, T8140 and T8142 keep full DRAM-off deep sleep unchanged, and T8112 boards without live DRAM handoff leave WAKE_SLP_DDR bit 0 clear).
Not yet: J473 desktop row at this head (expected WAKE_SLP_DDR=0 unchanged); ~50-cycle deep-sleep reliability row before lifting T8112 out of untested.

When #3647 merged main (cdbecbe), apple,t8112-sleep remained in the
if-condition that main had narrowed to derived profiles (T8142 and T8122),
causing apple_sleep_test_known_profiles to expect soc->derived == true and
soc->untested == false for T8112.

Check apple,t8112-sleep in its own branch with soc->untested == true while
leaving the derived-profile checks for T8142 and T8122 intact.

Signed-off-by: Satya Benson <[email protected]>
Add a refcounted apple_sleep_coproc_slp_ddr() voter alongside the existing
USB voter so an always-on coprocessor that retains DRAM buffers across
system sleep can vote for WAKE_SLP_DDR bit 0.

Gate coprocessor votes on a per-SoC capability flag (coproc_slp_ddr) set
when sleep_slp_ddr_bind() maps WAKE_SLP_DDR, so SoCs whose live
coprocessors already survive full DRAM-off deep sleep (T8132, T8140,
T8142) keep their existing behavior unchanged. Votes recorded before
apple-sleep probes are applied when sleep_slp_ddr_bind() runs, and both
deep_once and crashed-coprocessor overrides continue to clear bit 0.

Add a KUnit test covering deferred binding, per-SoC gating, refcounting,
USB OR-ing, deep_once and crash overrides.

Signed-off-by: Satya Benson <[email protected]>
When a boot stage hands over a running RTKit session via
apple,rtkit-handoff whose retained buffers live in reserved DRAM outside
on-chip SRAM, the coprocessor remains running across system sleep and
requires DRAM retention on SoCs whose sleep engine drops DRAM power.

Record whether the inherited buffer inventory placed any buffer in
reserved DRAM (only after the full inventory validates) and register a
devm-managed apple_sleep_coproc_slp_ddr() vote when adopting the session.
Sessions whose buffers all sit in SRAM, or cold-started helpers without a
live handoff, do not vote.

Add KUnit coverage for SRAM-only, DRAM-only, mixed and failed-inventory
rollback tracking of dram_buffers.

Signed-off-by: Satya Benson <[email protected]>
T8112 uses its own map_regs callback and never bound sleep_slp_ddr_word
to wake + WAKE_SLP_DDR (0x00). On a T8112 laptop with an adopted live
MTP session retaining DRAM buffers behind its bypass DART, committing
deep sleep with WAKE_SLP_DDR clear drops DRAM power out from under the
running MTP and hangs the commit until the watchdog resets.

Bind sleep_slp_ddr_word in t8112_sleep_map_regs() and enable
coproc_slp_ddr on t8112_sleep_soc so an adopted helper with DRAM buffers
sets WAKE_SLP_DDR bit 0 while boards without one (such as T8112 desktops
or boots without a live DRAM handoff) leave bit 0 clear for full
DRAM-off deep sleep.

Signed-off-by: Satya Benson <[email protected]>
@satchlj

satchlj commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

Exact-head J413 hardware verification row at f27ce29f2ecad:

  • Machine: MacBook Air 13" M2 (J413, T8112), macOS 27.2 stub (26B123), live MTP handoff (rtkit-helper 24e400000.mtp: adopted the running RTKit session (4 retained buffers)), default wake mask (armed 0c004000 04681000 00420220 00000000 3c080000 00000000 00000000 810000a0), apple_sleep.deep=1.
  • Result: PASS (5/5 consecutive 10 s deep sleeps):
    • CYCLE 1..5: rc=0, wall_s=12..14, kb=2 (MTP keyboard + trackpad intact every cycle).
    • apple-sleep: boot object resumes 0 -> 1 -> 2 -> 3 -> 4 -> 5, wake source: NUB.SPMI0.SW3 on all 5 wakes.
    • GPU rendering (Borealis): PRE_RENDER_25_PASS before sleep, POST5_RENDER_25_PASS after cycle 5.
    • Wi-Fi connected before and after; 0 failed systemd units; clean reboot back to default kernel.
  • CI note: pr-text and readiness passed; apple-build and KUnit plan are queued on runners (arm64 QEMU KUnit passed locally at f27ce29f2ecad: 56/56 combined, 40/40 standalone). host-tests failed in an unrelated GPU host test (tools/asahi/g17-render-owed-stamp-tests.py: no method named forfeit_blocker found for struct Queues), which is also failing on main (4e4603f31864).

@satchlj
satchlj marked this pull request as ready for review December 1, 2026 11:48
@satchlj
satchlj requested review from a team as code owners December 1, 2026 11:48
@satchlj
satchlj requested review from LiamRay11 and maralcbr December 1, 2026 11:48

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

The vote is taken after the retained-buffer inventory is validated, released with the device, and applied only where the sleep profile supports it. The exact-head J413 row preserved MTP across five deep sleeps. The sleep and RTKit helper KUnit results cover the voter and the corrected T8112 profile.

@github-actions github-actions Bot added area:platform Area from CODEOWNERS (bot) blast:m2 Macs affected, from Merge risk (bot) blast:m4 Macs affected, from Merge risk (bot) blast:m5 Macs affected, from Merge risk (bot) blast:neo 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) labels Dec 1, 2026
@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Merge readiness at f27ce29f: not ready yet

Check Detail
CI at head no failing: host-tests
Review ok approved by RyanTheTide
Requested changes ok none
Hardware row at head ok in the PR body at f27ce29f
Conflicts ok none
PR text ok Risk: two-way · T8112 (shared sleep.c and rtkit-helper.c voter paths are gated on coprocslpddr, so T8132, T8140 and T8142 keep full DRAM-off deep sleep unchanged, and T8112 boards without live DRAM handoff leave WAKESLPDDR bit 0 clear).

Areas: area:platform

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

@satchlj

satchlj commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

Additional 50-cycle J413 reliability row at exact head f27ce29f2ecad (macOS 27.2 stub, live MTP handoff with 4 retained buffers, normal wake mask, apple_sleep.deep=1):

  • Result: PASS (50/50 consecutive deep sleeps) cycling 10 s / 15 s / 20 s RTC wakes (wall_s = 12 / 17 / 22 s on every cycle; boot object resumes advanced monotonically to 49 -> 50; wake source: NUB.SPMI0.SW3).
  • Input: MTP keyboard + trackpad (kb=2) intact on all 50/50 wakes.
  • GPU (Borealis): 3D render check passed before sleep and after cycles 10, 20, 30, 40, and 50 (6/6 RENDER_25_PASS).
  • Wi-Fi, desktop, services, errors: Wi-Fi reconnected on 50/50 wakes (0 misses), sddm desktop active before and after, 0 failed systemd units, 0 EDAC/kernel/MTP errors, clean reboot back to default kernel.

@RyanTheTide

Copy link
Copy Markdown
Contributor

J473 row at f27ce29f (exact head): J473 (T8112, Mac mini M2, 27.2): boots, DPMS off/on pass, s2idle pass, reboot pass; deep sleep refused 3/3 by the pre-existing dcpext suspend -110, same as at #3647's head.

  • Trial Stage 2 = production aura and U-Boot bytes with the production J473 DTB plus soc: apple: sleep: T8112 (M2) suspend-to-RAM, enabled on J413 #3647's DT delta (this PR changes no DT). Cmdline = production + apple_sleep.deep=1 apple_sleep.untested_commit=1. Both monitors attached.
  • Boot: apple-sleep probed, Enforcing, 0 failed units, Vulkan triangle passes.
  • DPMS off/on: both displays back.
  • s2idle (RTC, 20 s): 22.3 s wall; USB 10/10, displays, GPU and audio back.
  • Deep (mem_sleep=deep) 3/3: refused before commit and recovered awake every time. apple-dcp 271c00000.dcp (dcpext, USB-C) fails suspend with -110 after AFK[ep:2a]: AppleDCPDPTXRemotePort (chan:5) command type 0xc0 ... timed out after 1000 ms. This is identical to the J473 row on soc: apple: sleep: T8112 (M2) suspend-to-RAM, enabled on J413 #3647 and isn't caused by this PR. So on the J473 the SLP_DDR voter path only runs up to device suspend.
  • The J473 has no MTP (Mac mini), so there's no adopted DRAM handoff and the T8112 voter should leave WAKE_SLP_DDR untouched. That isn't directly readable here; there were no new sleep-driver errors.
  • Reboot from this kernel (DPMS on; drm/apple: dcp: leave the piodma DART alone at shutdown after DPMS off #3595 isn't in this tree because it conflicts with main in dcp.c): back in 41 s. J473 restored to production and verified.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Merging at f27ce29f2eca (B2 merge train, 12-01 merge bar). Approval at this head: RyanTheTide. Row: in the PR body at f27ce29. CI: train L11 = main 684a4a4 + #3774 #3772 #3305: Apple build pass, KUnit dcp-fabric/dcp-topology/dcp-display/macsmc/asahi pass, host tests apple-dcp/dcp/g17 420 ok; hosted host-tests reds (ave-recovery-old + brcmf-ps-nap) are on main too Revert: git revert -m 1 <merge commit>.

@RyanTheTide
RyanTheTide merged commit f9604f2 into main Dec 1, 2026
9 of 15 checks passed
@RyanTheTide
RyanTheTide deleted the satchlj/t8112-live-mtp-slp-ddr branch December 1, 2026 14:12
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) blast:m4 Macs affected, from Merge risk (bot) blast:m5 Macs affected, from Merge risk (bot) blast:neo 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)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants