Repository navigation
WIP: T8142 (M5 Air: J813, J815) suspend-to-RAM: first real sleep and wake on J815 - #2043
Closed
m0d16l14n1 wants to merge 19 commits into
Closed
m0d16l14n1 wants to merge 19 commits into
m0d16l14n1 wants to merge 19 commits into
Conversation
This was referenced Nov 16, 2026
m0d16l14n1
added a commit
to m0d16l14n1/linux
that referenced
this pull request
Nov 16, 2026
J813: T8142 S2R on aurora-silicon#2043: PMU post-timer, DCP 27.2, test changes (the commit still resets)
As on T8132: the SoC's power goes in a suspend-to-RAM, so the AIC needs the firmware-suspend save and restore. Assisted-by: Claude Opus 5.5 Signed-off-by: Nick <nekreshen@yandex.ru>
The sleep commit zeroes the AP agent's whole voter word (T8132, and now T8142), which holds its DCS vote as well as its floors. resume_early only put the floors back. Cast the DCS vote again too; it's a no-op if the word survived. Only after a real commit (pm_resume_via_firmware()). Assisted-by: Claude Opus 5.5 Signed-off-by: Nick <nekreshen@yandex.ru>
The slice's boot value was read at probe. A derived slice address (T8142) would then be touched on every boot. Read it before the first write instead, which only a sleep does, and protect it again only once it has been read. Assisted-by: Claude Opus 5.5 Signed-off-by: Nick <nekreshen@yandex.ru>
T8142 gets T8140's firmware-stop values, as T8132 runs them, untraced. Without nvme_apple.sleep_untested=1 ANS isn't registered with the sleep controller, so a dry run never idles the root disk. Assisted-by: Claude Opus 5.5 Signed-off-by: Nick <nekreshen@yandex.ru>
AppleT8142MCC (macOS 27.2.1) runs mccEnableCacheMode(0) as its platform sleep action. J815 has no skip-mcc-off-to-s2r; only T8140's J700 does. For each plane it writes way count 0 to 0x2800 (plane stride 0x40000), waits for the data ways (0x2804 [30:24]) and then the tag ways ([14:8]) to reach it, and writes 0x82c = 0. Its platform active action runs mode 1, which puts the way count back the same way. aura's cold-boot enable does that too, with 16 ways. The kext's cacheFlush (0x82c = 1, 0x2844 = 1, poll 0x2844 bit 0 per plane) is the sequence the T8140 path already uses at suspend_noirq. Keep it as the write-back, and then turn the ways off as macOS does before S2R. A timeout there loses nothing, since the flush already wrote everything back. At resume_noirq, if the boot's way count (read at probe) is not what plane 0 reads, put it back and wait for both counts before allocation is enabled again. Without this, the cache would stay off after a real wake. T8132's measured lane/AMCC step in the sleep driver has no counterpart in this kext. Its 0x220400580/0x220800580 blocks are outside J815's MCC window (0x220000000 + 0x140000), so T8142 leaves it out. Derived from the binaries, never run on an M5. Assisted-by: Claude Opus 5.5 Signed-off-by: Nick <nekreshen@yandex.ru>
…eep's commit A core that the SoC restarts at its reset vector after a system sleep's commit comes back through the boot object into secondary_holding_pen and spins there on WFE. Its cluster can't power down with it running, and the SoC's sleep sequencer waits on that with no timeout. Once a sleep has committed, have such a core take the Apple deep-sleep bits and WFI in the pen instead, as macOS's parked cores do. The flag is read with the MMU off, set at spin_table_release_stopped() only where the sleep driver armed it, and cleared before any CPU is started again after the wake. T8142 arms it. From aurora-silicon#1773 (T6050), where the cores a cluster round restarted had to take this WFI before the first engine sequence completed. Assisted-by: Claude Opus 5.5 Signed-off-by: Nick <nekreshen@yandex.ru>
aurora-silicon#1963 drains a generation 4 controller's late reply after a failed exchange, on the J714s only. The J813 and J815 (MacBook Air, M5) have the same generation 4 nub-spmi controllers, and their deep sleep writes the PMU on the same queue, so a stray reply there would refuse every later command in the sleep. Take the J714s's recovery on both. Assisted-by: Claude Opus 5.5 Signed-off-by: Nick <nekreshen@yandex.ru>
macOS 27.2.1's sleep entry on the J815 sends the system power state command (SSPS, S3) to both port controllers over nub-spmi-a0, as on the J714s (26B131 trace: usid 10 and 8; the third port is the debug link). The J813 and J815 SN201202x controllers sit on the same generation 4 SPMI, and their sleep node asks for the command (apple,sleep-ssps), so apply the J714s's rules there as well. Only a firmware-driven sleep sends it. Assisted-by: Claude Opus 5.5 Signed-off-by: Nick <nekreshen@yandex.ru>
Add T8142 (J813, J815) to the sleep driver as its own apple_sleep_ops and match data, on aurora-silicon#1963's coprocessor stops. The steps follow macOS 27.2.1 (26B131) as two traces of its sleep entry under aura's virtualized SPTM show them: a J815 one (two cores, the whole entry to the S2R timer) and gig3m's J813 one (ten cores, the memory controller hooked). Where both hooked a block, they agree write for write. - lower_io: the RAM clean, ATC0 with T8142's words, the radio's port stopped, then ANS's PCIe block in AppleT8142PCIe's order (APCIECoreRCGen4: PHY_SW before SYS_ST, the AUS5 pair inside an UP-bit window, the PLLs, the AXI enables, the gate loop). - last_mile: AppleT8142PMGR::quiescePerfState (SoC to 3, DCS to 3 through 5), the CPM gates around the AP's PMC vote, the complexes off, the quiesce read, then the memory side as the J813 trace has it, 4.6 to 2.7 ms before the S2R timer: each AMCC plane's +0x28000 word cleared two bits at a time, the six SoC NI tables zeroed, the eight DCS channels' enables stepped down and their lanes strobed, the clock word 0x380038000 <- 0x30000, and the CLLT "sleep hack" (EARLY_WAKEUP_CFG bits 17:16) right before the timer. - SPTM's per-DART PS write-disable bits (/chosen/dart-ps-wr-dis-entries): while one is set, the PMGR drops writes to that DART's power word. The four macOS's SPTM clears during its entry (SEP, centauri, PMP, SIO DMA; the DCP's stays with the DART driver) are cleared, only where set, and reported after the wake. The watchdog's page 2 (+0x2c |= 0x20) before WD2, restored at the wake. - wake: restoreHW, each complex on with its bit-4 wait, pwrgate +0x0/+0x60, the words back, ATC0, SEP, the CPM gates, WD2, ANS's block, and the radio's link trained again as aura trains it at boot. - resume and pre_commit: T8132's (WD2 is at the same address). Generic parts it needs, each a no-op on the other SoCs: - SPMI generation 4's queue on the sleep's bus (status +0x200, FIFOs +0x210/+0x220, notification enable/ack +0x420/+0x620), with bounded drains around a PMU write. - Register blocks a SoC doesn't have: T8142 has no pmc-dcp, clock muxes, PTD, cluster DCS or DVFM blocks. - An untested SoC: deep sleep only with apple_sleep.deep=1, never the default; each sleep a dry run that refuses after every check unless apple_sleep.untested_commit=1; each step noted in PMU scratch (0x8308) for the boot after a reset (apple_sleep_note_sub() for a coprocessor's own steps). - A radio link with no restore (apple,radio-host without trainable port data) refuses a real sleep while its host is bound. The complexes' ACC word 0x40f8, which restoreHW writes, is only written with apple_sleep.acc_wake=1: every Linux access to it has hung a J815 so far. The SoC data test accepts a matched SoC that is untested but gated, and checks the SoC NI and PS write-disable tables. Derived from the binaries, the traces and T8132's measurements; no M5 has gone through a full sleep and wake with it yet. Assisted-by: Claude Opus 5.5 Signed-off-by: Nick <nekreshen@yandex.ru>
J815's first real sleep past every check reset the Mac in the first coprocessor stop pass (PMU note 0x44, boot 3c93d5a2), whose only member is the GPU. Its domain read 0x244 at .enter (actual 4: the GPU gates itself between frames, about 95 times a second on J815), and the stop went straight to the RTKit idle poll and the coprocessor's and mailbox's registers, which may not answer below full power; with interrupts off a stalled read ends at WD2. Bring the domain to full power first, as asahi_g17_power_raise() does, keep the word from before for the resume, and touch nothing of the GPU but its domain if the raise times out. Each step is noted in PMU scratch with apple_sleep_note_sub(). Assisted-by: Claude Opus 5.5 Signed-off-by: Nick <nekreshen@yandex.ru>
T8142 (M5: the J813 and J815 MacBook Airs) has its own sleep controller layout: no pmc-dcp, clock mux, PTD, cluster DCS or DVFM blocks, but the memory side macOS steps down last (four AMCC planes, six SoC NI tables, eight DCS channels and a clock word), the SPMI generation 4 queue, and the complexes' ACC words. Its radio's PCIe link, which the boot loader trains, is trained again after a wake: apple,radio-host and apple,radio-perst name the host and the PERST# GPIO. Assisted-by: Claude Opus 5.5 Signed-off-by: Nick <nekreshen@yandex.ru>
Add the T8142 sleep controller, the shared PCIe block whose ANS side the wake brings back, and the port controllers' sleep power state, in a dtsi shared by the 13- and 15-inch M5 Airs: their ADTs (27.0) differ only in audio, product and CLPC power-limit properties. J813 includes it; J815 can once its board file describes the display, USB and radio nodes it refers to. The wake sources are the J815 ADT's /arm-io/pmgr ap-wake-sources, the same as T8132's by name. The memory-side regions are the J813 trace's (gig3m), with the same /arm-io/mcc layout on J815. The driver stops every sleep at a dry run unless booted with apple_sleep.untested_commit=1, and uses deep sleep only when asked for. Assisted-by: Claude Opus 5.5 Signed-off-by: Nick <nekreshen@yandex.ru>
27.2 moved the unnamed A500 (the AP link's release, which only a firmware sleep sends) to A550, with the IOMFB calls around it: t8142dcp 26B123 compares 'A550' and 'A550' | 1 at 0x1df68c in the dispatch whose 26A428 copy at 0x1de0dc compares 'A500' and 'A501'. Without the entry dcp_s2r_capable() is false on 27.2 and the DCP never stops for a sleep. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
… macOS sends it macOS 27.2 on the J813 sends the PMU four commands 0.11 to 0.25 ms after the S2R timer (traced under aura's virtualized SPTM, run g01): RTC_CTL read (0x41), the 4-byte compare at 0x2008, 0x200e <- 0, RTC_CTL <- 0x41 -- T6050's post-timer step at the same addresses. The T8142 ops had no post_timer: the timer started (PMU note 0x67) and WD2 reset the SoC. TEST: the compare is now + apple_sleep.t8142_wake_s (default 30), which doubles as a wake source. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
t6050_sleep_pmu_xfer_post() takes the opcode with the byte count in its low bits, as t6050_sleep_pmu_xfer() builds it (macOS sends 0x33 for the 4-byte compare). The post-timer step passed the bare opcode, so the alarm read before the commit failed and nothing was sent after the timer (J813: PMU note detail 0xc3, -ENODATA). Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The PMP firmware was idled and its RUN bit cleared, but its always-on power domain stayed at target f. macOS lowers the AP-owned PMP domain after the final idle and SRAM backup. PMS_SRAM then gates automatically while retaining target f. Do the same before the final memory and CPU sequence. On the combined J813 test stack this permits a real physical sleep and return, with the boot ID preserved and /sys/power/state returning 0. Device recovery and the other local preparation changes are still under investigation. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
After a J813 deep-sleep wake, headphone GPIO 100 can be in level-low interrupt mode while its Linux IRQ is disabled and marked masked. The generic mask_ack_irq() fallback skips irq_mask() in that state, leaving the asserted input to repeatedly trigger AP GPIO parent IRQ 347. CPU0 can stay in IRQ dispatch and starve I2C completions and resume timers. Provide irq_mask_ack so the pin is always masked in hardware before acknowledging it. A clean-module hardware repeat completed parallel device resume, with CS42L84 and AOP resume succeeding, without the diagnostic interrupt or polling used to investigate the stall. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
…d-out core again A platform sleep driver can ask for the parked cores' last deep WFI at EL1 (spin_table_pen_deep_el1()), with the MMU off, every exception masked and stage 2 off, instead of at the kernel's EL. A core powered on again after a sleep stays in spin_table_cpus_off until its own cpu_postboot. Before, the bit was cleared before the start, so a core whose start timed out was never pulsed again on the next online attempt. Assisted-by: Claude Opus 5.5 Signed-off-by: Nick <nekreshen@yandex.ru>
On J815 (boot e1d118f8) T8142 now goes past the commit, sleeps and comes back through the boot loader's resume entry (boot object resumes 0 -> 1), with the display and NVMe back. Before, every committed sleep ended in a WD2 reset about five seconds after the commit. The work below compared every power word Linux leaves on with macOS's own entry (J815 26B131 trace) and with macOS's state at its commit (J813 end state from Thomas Glanzmann's trace), using the J815 ADT's PMGR parent tree. Entry, what got the sleep engine past the commit: - apple_sleep.dispext (default Y): the external DCPs are lowered with the display, in macOS's order (DISPEXT0, DISPEXT1, DISP). Their DARTs' PS write-disable bits read set on J815 and are cleared first, a running firmware is stopped cold, and the words come back after a refusal and at the wake. An external DCP whose domain is up but which the device tree doesn't list in apple,display-coprocessors refuses the sleep instead of letting the engine wait on it. - apple_sleep.extra_off (default Y): the OS-managed words macOS has off at its commit that no other step lowered (SIO_CPU, left up by iBoot with no driver; GLOBAL_AUX_CTRL0/1; FPWM0; the PCIe OCLAs under APCIE_SYS_GP/ST; ATC2/3; the displays' ADMA words), children first, each only if on, and back at the wake once its parent is on. - apple_sleep.pmp_off (default Y): PMP's domain stays off after its final stop, with its word saved and restored at the wake (Thomas's finding on J813, made switchable). - The PMU's RTC alarm after the S2R timer as a switchable step (apple_sleep.pmu_alarm), XNU's boot-time AUTO_ENABLE words (apple_sleep.boot_auto), the parked cores' deep WFI before the boot core's last mile (apple_sleep.early_wfi), and the clkgen and memory-side restores at the wake (sleep-t8142-mem.h). ps_keep, mem_boot and mem_floor are experiments, mem_boot/mem_floor off by default. Diagnostics: a commit digest in PMU scratch, written only to 0x8308..0x831e (from 0x831f the scratch holds data that isn't Linux's), the dry run's full list of power words on, marked against macOS's commit state, and one line per core start after a wake (apple_sleep.cpu_on_trace). Still open: after the wake only the first core started in each complex comes up; the external DCPs' firmware isn't restarted; the SMC woke this sleep after 0.46 s. Still gated by apple_sleep.untested_commit. Assisted-by: Claude Opus 5.5 Signed-off-by: Nick <nekreshen@yandex.ru>
m0d16l14n1
force-pushed
the
j815/t8142-s2r
branch
from
November 16, 2026 11:26
e95ff7b to
64720d1
Compare
Contributor
Author
Update (2026-11-16): longer sleeps work; CPU and N1 restart after the wakeTested on J815 (kernel 38e28450 = the tree before the commits below marked untested):
What changed since the PR's head (on
Two problems still visible in the tested runs, fixed but not yet booted:
These come into this PR after a test boot. Also still open: Assisted-by: Claude Opus 5.5 |
DjDeveloperr
pushed a commit
to aurora-silicon/aura
that referenced
this pull request
Nov 17, 2026
… sleep controller The T8142 sleep controller (aurora-silicon/linux#2043) brings ANS's half of the shared APCIe block back after a real sleep and trains the radio's port 0 again through its pcie-shared node. Copy iBoot's tables from /arm-io/apcie (axi2af, phy, phy-ip-pll, phy-ip-auspma) and its pci-bridge0 (apcie-config, pcie-rc, -gen3-shadow, -gen4-shadow) onto that node, bounded by its windows, as j813_n1.c applies them at boot. Nothing is published unless all eight are valid. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Suspend-to-RAM for T8142 (M5 MacBook Air: J813, J815), on top of #1963's per-SoC sleep framework. Only the T8142 sleep work: no hibernation, and none of the pending sleep refactors.
Status: first real deep sleep and wake on J815
On J815 boot e1d118f8 the SoC went past the commit, slept, and came back through the boot loader's resume entry (
boot object resumes 0 -> 1, PMU stage 0x52). The sysfs write returned 0,PM: suspend exitfollowed, and the display and NVMe came back. Before this, every committed T8142 sleep ended in a WD2 reset about five seconds after the commit.Still gated. Deep sleep is offered only with
apple_sleep.deep=1, and every sleep refuses after its last check unless booted withapple_sleep.untested_commit=1.Open:
apple_sleep.cpu_on_trace) is in to find out why.What got it past the commit
Every power word Linux leaves on was compared with macOS's own entry (J815, 26B131 trace) and with macOS's state at its commit (J813 end state from Thomas's trace), using the J815 ADT's PMGR parent tree:
apple_sleep.dispext). Only the internal DCP was being lowered. On J815 both DISPEXT complexes were up, and their DARTs' PS write-disable bits were set. They're now lowered in macOS's order (DISPEXT0, DISPEXT1, DISP), with the write-disable bits cleared first and a running firmware stopped cold. They come back after a refusal and at the wake. An external DCP that's up but not listed inapple,display-coprocessorsnow refuses the sleep instead of leaving the engine to wait on it.apple_sleep.extra_off). SIO_CPU (left up by iBoot, no driver on the Airs) and GLOBAL_AUX_CTRL0/1 were on. FPWM0, the PCIe OCLAs, ATC2/3 and the displays' ADMA words are covered too, children first, each only if on, and they come back at the wake once the parent is on.apple_sleep.pmp_off), from Thomas's J813 finding, now switchable and restored at the wake.Commits (on integration/aurora d5a8a25)
nvme_apple.sleep_untestedThe first 12 are this PR's earlier commits, replayed unchanged onto today's integration/aurora. Thomas's five are cherry-picked with his authorship. His TEST ONLY commits (extra PMU notes, J813 SEP test DT, AON-audio and SEP-retention experiments) and the GitHub merge commits that had landed on this branch are left out. The previous head is kept at
m0d16l14n1/linux:backup/t8142-s2r-20261116(e95ff7b).Depends on, at runtime (not to build)
apple,display-coprocessorsafter&dcp. Without them, a sleep with an external DCP still up is refused.Not here
appledrm.s2r_untested/nvme_apple.sleep_untested. Both stay 0 here; the J815 run had them on.Tested
m0d16l14n1/linuxj815/test-next8d0f252). Its T8142 sleep code is the same as this branch's (all 82 T8142 functions and tables compared). That tree also has the SMC last-stop sequence, drm/apple: T8142: stop the DCP firmware on DPMS off (firmware 27.2) #1941, arm64: dts: apple: t8142-j813: Add the cluster power gates #1942, WIP: T8142 MacBook Airs (J813, J815): external displays over USB-C (on #1532) #1806 and J616s (M4 Pro) at EL2: hibernation and suspend-to-RAM #1477's sleep registry, which this branch doesn't. This exact branch hasn't been booted.Acknowledgements
Assisted-by: Claude Opus 5.5