Skip to content

soc: apple: sleep: add T8103 (M1 / J313) suspend-to-RAM support - #3172

Merged
DjDeveloperr merged 34 commits into
mainfrom
feat/t8103-s2r
Nov 26, 2026
Merged

DjDeveloperr merged 34 commits into
mainfrom
feat/t8103-s2r

Conversation

@erikwb

@erikwb erikwb commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

What: Add T8103 (M1 / J313) suspend-to-RAM support across the sleep controller, AIC1, DCP/display DART, ANS/SART/RTKit, AOP, PMGR, SMC, DT bindings/DTS, GPU commit-stop/wake-restore gates, NCO sleep-commit audio clock handling, conventional PCIe chained-IRQ masking across firmware sleep, and BCM4377/BCM4378 BAR0 window / needs_reset recovery on S2R power loss.
Tested: J313 (M1 MacBook Air, exact head 697fc879d990 merged unchanged with #3171 3577ce0e4885 at c808a9c12341 + companion aura-silicon/aura#529 f5ddfff2, live accelerated Hyprland): pre-sleep audio + Borealis compute (4460/0) & render (200/0), s2idle (4459/0), pm_test=core (4497/0), and 3 consecutive physical S2R wakes (boot object resumes 0 -> 1 -> 2 -> 3) with Wi-Fi (BCM4378), Bluetooth (hci_bcm4377 clean rebind to MGMT ver 1.23), audio playback (exercising NCO disable/enable across every cycle), NVMe, live Hyprland (PID 4646), and Borealis passing on every wake. Host tests (bcm4377-resume-tests.py 46/46, aop-bootargs-tests.py, sep-suspend-errors-tests.py 7/7 + C controls) pass.
Risk: two-way door · M1 (T8103 / J313) S2R bring-up plus shared pcie-apple conventional host IRQ masking, hci_bcm4377 power-loss rebind, nvme-apple non-warm-sleep firmware sleep path, and apple-sleep core hooks.
Not yet: Other T8103 boards beyond J313 (only J313 DTS enables S2R), SLP_DDR=0 (AOP-unbound) deep-sleep path on J313, and non-M1 conventional-PCIe Macs on 7b54ee43d0bb / 73c532b7f830.

Details

Companion PRs:

Key components:

  • T8103 sleep controller (drivers/soc/apple/sleep-t8103.h, sleep.c, sleep-perf-step.S, DT bindings + t8103.dtsi / t8103-j313.dts): T8103 register map, power-domain / clock-mux / AP-pin / AGX-fabric / SEP / SMC sleep commit and wake sequence, GPU commit-stop and wake-restore gates (dee9cd36cfff, 835b40a4a1cd), and enabling disabled NCO0..4 channels across sleep commit so apple,externally-clocked ps_mca0..5 domains do not stall the sleep sequencer after ALSA stream close (22073d0c4f76).
  • Subsystem S2R support for T8103: AIC1 config/target/CPU-number restore (irq-apple-aic.c), T8020 display DART + DCP firmware 27 stop/restart (apple-dart.c, dcp.c, iomfb_template.c), ANS idle + SART/RTKit mailbox restore (nvme/host/apple.c, sart.c, rtkit.c), AOP bootargs/sleep policy (aop.rs), PMGR apple,min-state restore (pmgr-pwrstate.c), SMC late notice and arbitrary-length saved-transport key writes (macsmc.c), SEP actual-state check (pm_shim.c), and CD321x apple,sleep-ssps binding.
  • Conventional PCIe & Bluetooth S2R hardening (7b54ee43d0bb, 73c532b7f830):
    • Mask and gate each conventional port's chained IRQ at AIC across firmware sleep (apple_pcie_hib_save / apple_pcie_resume_noirq / apple_pcie_resume) so a complex whose boot-time reinit leaves PORT_INTMSK clear on T8103 cannot storm CPU0 on wake before apple_pcie_resume() restores the port.
    • Set bcm4377->needs_reset = true and call bcm4377_init_cfg() in bcm4377_resume() before queueing device_reprobe() on firmware-sleep power loss so bcm4377_hci_close() does not write the BAR0 doorbell through uninitialized reset windows (0x19328000).
Evidence
  • J313 (ewb-m1, M1 MacBook Air) at exact head 697fc879d990 (combined test merge c808a9c12341 with drm/asahi: enable T8103 (G13G) on GPU firmware 27.2 and support g14_v27_2 deep sleep warm restart #3171 3577ce0e4885, BIOS aura 1.0.0b17-gf5ddfff2 from kboot, pcie, smp: T8103 (G13G) GPU 27.2 handoff and S2R wake PCIe/exception restore aura#529, stock mesa-aurora):
    • Cold boot: apple-sleep 23b700000.sleep-controller: deep sleep is the default: boot object resumes 0, G13 firmware 27.2 running, live accelerated Hyprland PID 4646 on Apple M1 (G13G B1).
    • Pre-sleep: pw-play OK; Borealis compute-check 5 4460 runs / 0 bad; render-check 200 200/200.
    • s2idle: Borealis compute-check 5 4459 runs / 0 bad.
    • pm_test=core: Borealis compute-check 5 4497 runs / 0 bad (verifying refused-sleep unwind of pcie-apple IRQ gating, ANS/SART, and GPU rollback).
    • 3 consecutive physical S2R wakes (rtcwake -d /dev/rtc1 -m mem -s 6, boot object resumes 0 -> 1 -> 2 -> 3, wake source: NUB.SPMI0Sw3IRQ):
      • Cycle 1 (0 -> 1): pcie-apple link back, BCM4378 Wi-Fi reconnected, hci_bcm4377 cleanly rebound (Bluetooth: MGMT ver 1.23, Controller D4:57:63:D3:68:98), pw-play OK, GPU back in 5071 us, Borealis 4203/0 + 200/200, Hyprland PID 4646 unchanged.
      • Cycle 2 (1 -> 2): pcie-apple link back, Wi-Fi reconnected, BT MGMT ver 1.23, pw-play OK, GPU back in 4031 us, Borealis 4167/0 + 200/200, Hyprland PID 4646 unchanged.
      • Cycle 3 (2 -> 3): pcie-apple link back, Wi-Fi reconnected, BT MGMT ver 1.23, pw-play OK, GPU back in 2800 us, Borealis 4174/0 + 200/200, Hyprland PID 4646 unchanged.
    • Regression counts: SELinux disabled (0 denials); aurora-sep.service failed (expected after cold boot before first interactive Touch ID password unlock, same as daily boot); 0 new S2R/PCIe/BT/NVMe/GPU kernel errors.
  • Host tests:

…e sleep

The minimum state of a power state word (bits 19:16) comes from the
apple,min-state property and is written once, at probe. A firmware-driven
system sleep resets the word, so after the wake a domain with AUTO_ENABLE
set comes back with a minimum of 0. The hardware is then free to
power-gate the domain whenever its consumer idles.

On the M1 (T8103) this hits DISP0's CPU domain, which has a minimum of 4
so the display coprocessor keeps its state while it waits in WFI. After a
real sleep the restarted firmware went into WFI while waiting for a reply
during the panel's power-on, the domain was power-gated under it, and the
display never came back.

Put the configured minimum back in the noirq resume of every domain that
has one, before the other resync and before any consumer resumes. Domains
owned by firmware are left alone, as at probe.

Tested on a MacBook Air (M1, J313): two back-to-back real
suspend-to-RAM cycles with the display coprocessor bound now bring the
internal panel back each time; DISP0's CPU word reads minimum 4 after the
wake (0x1404034f) where it read 0 before (0x1f0003ff).

Signed-off-by: Erik Bourget <[email protected]>
…ter an aborted sleep

Some coprocessors gate their SART themselves as they go idle for a
firmware-driven sleep: ANS on the M1 does once its RTKit IOP state is
IDLE, and a read of the SART after that faults. The late suspend can then
no longer read the entries it restores at the wake.

Add apple_sart_save_now() for the coprocessor's driver to call before it
idles the coprocessor. The late suspend keeps that snapshot instead of
reading the SART again, and the noirq resume writes it back after a real
sleep as before.

If the sleep is refused after the snapshot, there is no firmware wake to
write the entries back, but the coprocessor has still gated the SART.
apple_sart_restore_early() lets the driver write them back itself once
the SART answers again. It does nothing when the wake already restored
them.

The entry write loop moves into a helper used by both paths.

Tested on a MacBook Air (M1, J313): real suspend-to-RAM cycles with ANS
idled keep storage working, and a sleep refused after ANS was idled now
recovers storage ("8 entries written back after a sleep that didn't
happen").

Signed-off-by: Erik Bourget <[email protected]>
…hat lost power

When a firmware-driven sleep takes a coprocessor's power, its mailbox
loses its configuration with it, including the receive enable. On the M1
the boot loader sets that enable for ANS, and nothing in Linux sets it
again, so after the wake none of the coprocessor's messages reach the AP
and its RTKit handshake times out.

Add apple_rtkit_mbox_restore(), for a driver that starts its coprocessor
cold after such a sleep: it restores the mailbox and sets the receive
enable, before the coprocessor runs.

Tested on a MacBook Air (M1, J313) with the NVMe driver calling it after
real suspend-to-RAM cycles: ANS's handshake completes with no retries.

Signed-off-by: Erik Bourget <[email protected]>
… wake

On controllers whose RTKit session doesn't stay up across a sleep (no
I/O queue registers, the M1 class), a firmware-driven suspend shut ANS
down with AP QUIESCED and IOP SLEEP. Measured on the M1 (J313), ANS then
doesn't bring its flash links back after the power-on, and storage is
gone after the wake.

For a firmware sleep, put ANS in IDLE instead, its AP and its IOP state,
as for a sleep it is woken from; it then brings its flash links back
itself after its power-on. In IDLE it gates its SART, so its entries
(apple_sart_save_now()) and the NVMe block's word that gates it are
saved first.

After a real sleep the reset work starts ANS from its power-on: out of
reset, it puts the SART power word back, restores the mailbox's enables
(apple_rtkit_mbox_restore()) and sets the run bit, then runs the normal
boot handshake.

A sleep refused after ANS was idled leaves it idle with its SART gated
and no firmware wake follows. The resume takes the same cold start, and
writes the SART entries back itself (apple_sart_restore_early()). If the
idle itself fails, the suspend fails and no resume follows, so the cold
start is queued at once.

Other sleeps (suspend-to-idle) keep apple_rtkit_shutdown().

Tested on a MacBook Air (M1, J313): two back-to-back real suspend-to-RAM
cycles bring storage back each time (ANS's handshake with no retries,
rootfs read-write, 16 MiB write and read), and a sleep refused after ANS
was idled recovers storage.

Signed-off-by: Erik Bourget <[email protected]>
apple_dart_display_streams() is what a DCP driver calls around its
firmware stop and restart, but it only knows the T8110 layout: on a
T8020-type DART (the M1's) it writes registers that don't exist there.

Add the T8020 counterpart, selected by the DART's type. At the power-down
it saves the DART's translations and enabled streams, turns the given
streams off, flushes their TLB entries when asked to, and marks the DART
off (host_off), so neither its interrupt handler nor its suspend reads a
block whose power is about to go: on the M1 both display DARTs sit in
the DCP's CPU domain and share one interrupt line.

At the power-up it clears any latched error, writes the translations back
if they were lost and the DART isn't locked (it refuses if it is),
re-enables the saved streams and invalidates every TLB entry, since maps
made while it was off only reached memory.

The DCP's own power cycle resets the display DART, lock included, so the
write-back runs at every DPMS power-up there; after a real sleep the boot
loader's wake has set it up locked again and the translations are found
intact.

Tested on a MacBook Air (M1, J313): DPMS off and on with the DCP's
firmware stop and restart, twice, and two back-to-back real
suspend-to-RAM cycles, with no DART faults.

Signed-off-by: Erik Bourget <[email protected]>
The M1's display has a power state block only for its display power
words: no retention words, and its PMC keeps no count of the powered
coprocessors. Add apple,t8103-display-power with a single "ps" region,
and allow one to three reg entries.

Signed-off-by: Erik Bourget <[email protected]>
…RTKit session

Unbinding one DCP from the display subsystem unbinds the whole aggregate,
and with it every DCP component's resources: the RTKit session of a DCP
whose platform device stays bound is freed and dcp->rtk is NULL. Its
system sleep callbacks still run, and after the next wake the queued
firmware restart dereferenced the NULL session in
apple_rtkit_detach_rx().

Without an RTKit session there is no firmware of this driver's to stop or
start: the system suspend and resume paths return early, the prewarm
work doesn't run, and the warm restart refuses.

Seen on a MacBook Air (M1, J313) with the external DCP unbound before a
real suspend-to-RAM: an oops in the prewarm work after the wake. With
this change that sequence resumes without one.

Signed-off-by: Erik Bourget <[email protected]>
…on words

The firmware stop lowers and raises a SoC's display domains from its
dcp_s2r_layout: CPU, front end and system words, and retention words in
the power gate block. Some SoCs have neither a system word for the
display nor retention words for its CPU.

A layout with no system word has 0 there, which is another domain's word:
skip it when lowering, raising or logging. Map the "pwrgate" region only
for a layout with retention words, and don't require it otherwise.

Signed-off-by: Erik Bourget <[email protected]>
…where needed

The DCP asks for its display register windows with map_reg. For firmware
27 the reply hands back their physical addresses as the device address,
since the H17P firmware reaches them physically. On the M1 the 27.2
firmware reaches them through its DART instead: at its first power-down
it faulted on an unmapped window (stream 0, a disp-4 address) and
crashed.

Let a SoC say so with hw.map_reg_dart: the window is then mapped in the
DCP's DART with dma_map_resource(), once per window, and that mapping is
the reply's device address. The physical address stays in the reply's
address field.

Tested on a MacBook Air (M1, J313) with the T8103 DCP data that sets it:
the firmware's DPMS power-down and restart run twice with no DART fault.

Signed-off-by: Erik Bourget <[email protected]>
…or where asked

The firmware stop expects the firmware to turn the display DART's streams
off itself (D572) before the DCP's domains go down, and on again after
its restart. On the M1 no such call reaches the driver, and the DCP's
power-down resets the display DART, so after a restart its streams had no
translations and the firmware crashed on its first PIODMA transfer.

With hw.s2r_disp_dart_with_dcp the driver does it itself: the display
DART goes down with the DCP's own DART at the firmware stop, and comes
back, with its translations, right after the domains are raised and
before the firmware runs.

Tested on a MacBook Air (M1, J313) with the T8103 DCP data that sets it:
two DPMS power cycles and two real suspend-to-RAM cycles with the DCP
restarting each time, and no DART fault.

Signed-off-by: Erik Bourget <[email protected]>
… off and sleep

Add T8103 (M1) match data with the firmware stop (hw.s2r): DPMS off and a
firmware-driven system sleep stop the DCP's firmware and lower its
display domains, and DPMS on or the wake restarts it warm, as on T8140.

The layout is T8103's display power words: DISP0's CPU (0x10018) and
front end (0x360), no system word and no retention words. The DCP's own
DART stream is 0; the display DART's are 0 (the display) and 4 (its
PIODMA). The SoC has no secure DCP mailbox, its firmware 27 reaches its
register windows through the DART, and the display DART goes down and up
with the coprocessor.

The stop needs firmware 27, whose 27.2 method table has the AP link's
release, and apple,display-power in the device tree; without either the
DCP keeps its firmware running across DPMS and sleep, as before.

Tested on a MacBook Air (M1, J313, firmware 27.2): DPMS off and on twice,
and two back-to-back real suspend-to-RAM cycles with both DCPs bound, the
internal panel coming back each time with its backlight and SDDM.

Signed-off-by: Erik Bourget <[email protected]>
From macOS 27 on, the M1's AOP firmware runs its external code and data
from DRAM, and stops before its RTKit HELLO unless the OS maps them and
writes ED0p. The M1's 13.5 firmware has no such regions.

Mark the T8103 AOP as a firmware-region block, with its current
configuration as the one to start with when the bootloader reserved no
regions, as T8122 does. On the J313 with macOS 27.2.1 firmware the AOP
comes up: microphones, ambient light sensor and voice trigger.

Signed-off-by: Erik Bourget <[email protected]>
Around a firmware-driven system sleep the driver stops the AOP's
endpoints and sends it the AP's idle notice, then the reverse after the
wake, as measured on T8140.

Make that a per-SoC setting: bit 0 for the endpoint stops, bit 1 for the
AP idle and on notices. Every SoC keeps both, except T8103 (M1), which
was run across real sleeps with its endpoints stopped only: the ambient
light sensor and both sound cards come back after the wake.

Tested on a MacBook Air (M1, J313): two back-to-back real
suspend-to-RAM cycles with the AOP bound.

Signed-off-by: Erik Bourget <[email protected]>
An AIC1 line's target is a bitmap of AIC's own CPU numbers, the number
each core reads from WHOAMI. The driver used the logical CPU id, and
warned when the two differed. They do differ when the device tree lists
the cores in another order than AIC numbers them: an M1 device tree that
puts the P-cores between the E-cores sends every line meant for one CPU
to another.

Record each CPU's WHOAMI when it starts and target lines by that number.
Until a CPU has started, its logical id stands in, as before. A
difference is reported once instead of warned about.

Tested on a MacBook Air (M1, J313) with such a device tree: no WHOAMI
warnings, and interrupts reach the CPUs their affinity names.

Signed-off-by: Erik Bourget <[email protected]>
… numbers after a firmware sleep

On the M1 (AIC1) a firmware-driven sleep power-cycles AIC along with the
rest of the SoC. The masks were already saved and restored around it,
but the wake also loses what the boot loader set up: the global
configuration words, each line's target CPUs, and the CPU number in each
CPU's block that WHOAMI reports. With those gone, no interrupt reached a
CPU after the wake.

Where AIC has per-line targets, save the targets with the masks before
the sleep, along with the global configuration (0x10..0x3c) and each
CPU block's first word, and write back whatever differs at the wake:
the configuration first, then the CPU numbers before any CPU reads its
own, then each line's targets before its mask.

Tested on a MacBook Air (M1, J313): interrupts (the RTC alarm, storage,
Wi-Fi, Bluetooth) are delivered after real suspend-to-RAM cycles.

Signed-off-by: Erik Bourget <[email protected]>
…he complex's power

On the M1 a firmware-driven system sleep takes the whole PCIe complex's
power, and the boot loader brings the complex and its links up again at
the wake, as at boot. What Linux set up on top of that is lost: the
ports' reference and application clocks, their interrupt masks and MSI
setup, and the RID to SID map. Wi-Fi and Bluetooth never came back.

For controllers whose data says so (sleep_loader_reinit, set on the
generic apple,pcie data), save each port's interrupt mask and RID to SID
entries when a firmware sleep suspends the controller, with its port
interrupts off. After a real wake, check each port is ready, ungate its
clocks, restore its interrupt and MSI setup and RID to SID map, train a
link the boot loader didn't bring up, and enable its interrupts again.
A sleep that was refused lost nothing, and only the interrupts are
enabled again. The root ports and functions are suspended and resumed by
the PCI core as before.

Tested on a MacBook Air (M1, J313): Wi-Fi (BCM4378) and Bluetooth come
back after two back-to-back real suspend-to-RAM cycles.

Signed-off-by: Erik Bourget <[email protected]>
…function's power

Outside the radio sleep transaction, the noirq resume returned early, so
after a firmware-driven sleep that took the function's power (the M1's
real suspend-to-RAM, with PERST at the wake) its private BAR windows were
left at their reset values and its firmware was gone. The resume then
read through the unprogrammed windows.

After a firmware wake, read the BAR0 window from config space. If it no
longer holds the value the driver programs, the function lost its state:
program the windows again so nothing faults, skip the unquiesce, and
rebind the driver once the resume is over, which boots the firmware from
scratch. A function that kept its state is left as it is.

Tested on a MacBook Air (M1, J313): hci0 comes back after two
back-to-back real suspend-to-RAM cycles.

Signed-off-by: Erik Bourget <[email protected]>
apple_smc_saved_write_u32() is the only key write on the saved
transport, and it only takes a 32-bit value. Split out
apple_smc_saved_write(), which takes a buffer and its size, and keep the
u32 helper on top of it. No change in behaviour.

Signed-off-by: Erik Bourget <[email protected]>
After the SEP's SLEEP request is answered, the commit waits for the
enclave's power state word to show it went down, by DEV_DISABLE. The
M1's enclave never sets DEV_DISABLE (measured on J313): its actual state
goes to 0 instead, and the wait panicked.

Once the enclave was asked to sleep, take an actual state of 0 as down
as well, as the SoC's own sleep sequence polls it. DEV_DISABLE still
counts wherever the firmware sets it.

Tested on a MacBook Air (M1, J313) across real suspend-to-RAM cycles.

Signed-off-by: Erik Bourget <[email protected]>
Add the T8103 (M1) sleep controller. Its SoC steps are the driver's own
operations, so it maps only seven blocks: the main and always-on PMGR,
the SoC clock muxes, the AOP's wake block, the CPU start block, the
watchdog and nub-spmi0. It needs the wake sources to leave on and the
AP pin controller, whose pins a sleep resets.

Signed-off-by: Erik Bourget <[email protected]>
Add a T8103 profile to the Apple SoC sleep driver: suspend-to-RAM
through the PMGR's S2R timer, on the early-context entry, with the
SoC's own steps as its operations.

At .prepare, after SEP's sleep and before the SMC's last keys:
 - SEP's domain is forced off and waited for;
 - the PMP, the SIO and both display coprocessors are idled over their
   RTKit management endpoint and stopped (a commit with the PMP running
   resets the SoC);
 - the domains Linux leaves on that the sleep needs off are lowered:
   the stopped GPU, display, ATC and PCIe blocks (the fabric bridges'
   handshake first), the USB and debug domains of the always-on PMGR
   and the clock-gated SPMI and FPWM domains;
 - the always-on domains meant to run with AUTO_ENABLE get it.

At the commit:
 - the memory clock steps down one performance state at a time (a
   larger step leaves DRAM unusable), from a routine that fits in one
   cache line;
 - the memory controller's error reporting goes off, its and the DCS
   channels' dynamic gating on, the DCS write queues are flushed and
   the memory cache's ways turned off;
 - DRAM is kept up through the sleep while the AOP's driver is bound
   (SLP_DDR), since the AOP runs through it;
 - the AOP wake mask is armed and its latched sources cleared;
 - the SoC clock muxes are parked;
 - the CPU complexes and voltage monitors are quiesced, CPM power
   gating is turned on, both clusters' targets go to 0 and AUTO_ENABLE
   comes off on three always-on words;
 - SEP's power-gate wait is cleared unless SEP gated;
 - the watchdog (WD1) is armed, the PMU RTC alarm's SPMI vector
   enabled and the PMU's boot stage set to sleep;
 - every AIC line and each CPU's IPIs are masked.
Then the S2R timer is written, and written again after the AIC mask.

The cores power down without retention through CYC_OVRD and ACC_OVRD
after writing back their L1 and L2 data caches, as on the other
Firestorm/Icestorm SoCs. A resume stub puts back the cores' PAC
controls, which a wake resets, before cpu_resume.

The wake undoes each step in reverse, puts back every SoC clock mux the
sleep's own sequence changed and every AP pin the gpio domain's power
cut reset, before any driver resumes.

The SoC's watchdog is WD1, which apple_wdt also drives: the sleep saves
it at .begin, uses it from the suspend to .end and puts it back after
apple_wdt's resume. Its SMC is gen 1: it hears last, after SEP and the
other coprocessors stopped, with WKTP between slpw and slpa.

The sleep node's blocks are mapped non-posted where the bus says so:
on T8103 a posted write to them is an SError.

A timed wake is the PMU RTC's alarm, wake source 54
(NUB.SPMI0Sw3IRQ), set by its RTC driver.

Based on the t6000 suspend-to-RAM reference by Andreas Fernandez.

Signed-off-by: Erik Bourget <[email protected]>
…ocessors

On T8103 the SMC is gen 1: as on t6000, it hears of the sleep last,
after SEP and the other coprocessors stopped, so its late notice is sent
with interrupts off, over the bounded saved transport J813 already uses.
Enable that transport for the T8103 SMC.

Gen 1 takes WKTP = 2 between slpw and slpa, and has no pmVC: write it on
the saved transport before slpa when the sleep driver says the SoC uses
gen 1 keys. Once the AP's power-down is answered, drain what the SMC
posted with it, so nothing is left in the mailbox through the sleep.

J813's sequence doesn't change.

Signed-off-by: Erik Bourget <[email protected]>
The DCP's driver lowers and raises DISP0's CPU and front-end power words
around a stop of its firmware, for DPMS off and for suspend-to-RAM. On
T8103 both are in the PMGR's power state block: describe it as the DCP's
display power, with only its "ps" range.

Signed-off-by: Erik Bourget <[email protected]>
The enclave's sleep looks up its power domain to wait for its gate, as
on t600x. Its domain is locked on, so that changes nothing at runtime.

The enclave also stops reading its mailbox for good once the GPIO power
state is switched off under it, so hold that one for it too, as T8140
does.

Signed-off-by: Erik Bourget <[email protected]>
Describe the T8103 sleep controller: the seven blocks its suspend-to-RAM
writes, each shared with its own driver, the wake source it leaves on
(54, the PMU RTC's alarm on nub-spmi0), the DCP that must be off before
the commit and the AP pin controller, whose pins the sleep puts back.

Disabled until a board that sleeps enables it.

Signed-off-by: Erik Bourget <[email protected]>
The tipd driver tells a CD321x the system's power state (SSPS) around a
firmware-driven suspend when its node has apple,sleep-ssps, as it does
for the SN201202x. Allow the property on apple,cd321x.

Signed-off-by: Erik Bourget <[email protected]>
Enable the sleep controller on the MacBook Air (M1, 2020), and have both
USB-C port controllers told the system's power state around the sleep,
S3 before it and S0 after it, as the sleep was brought up with.

Signed-off-by: Erik Bourget <[email protected]>
…unables

Allow T8103 deep sleep when the GPU driver has registered a ready
commit-time stop callback (apple_sleep_coproc_ready_node()).

When ps_gfx is powered at commit time, save the seven boot-programmed AGX
fabric tunable registers (0x205000000), drain bridges[0], and lower
ps_gfx before stopping PMP so GFX powers down while PMP is still running.
On wake, restore ps_gfx and the saved AGX fabric tunables before returning
to the OS so the GPU firmware can warm-restart cleanly.

Signed-off-by: Erik Bourget <[email protected]>
Tighten error handling around the T8103 GPU deep-sleep commit and wake
paths:

- Export apple_sleep_coproc_wake_error() and record per-coprocessor wake
  errors (reset alongside stop_ret when readied).
- In t8103_sleep_check(), refuse sleep when a bound GPU lacks either the
  AGX fabric or bridge[0] MMIO mapping.
- In t8103_pre_smc_down(), treat a failed GPU commit stop (stop_ret != 0)
  or a timed-out GFX domain power-off past the point of no return as fatal
  instead of stopping PMP while GFX is still active.
- In t8103_sleep_wake(), check both PMP and GFX sleep_ps_restore() results
  before touching AGX fabric registers and propagate any failure to the
  GPU coprocessor's wake_err.

Signed-off-by: Erik Bourget <[email protected]>
T8103's MCA audio power domains (ps_mca0..5) are externally clocked by
NCO channels 0..4. When an ALSA stream closes, apple-mca disables its
parent NCO clock, clearing CTRL_ENABLE. During suspend-to-RAM entry,
the hardware sleep sequencer writes and polls ps_mca0..5, which hang
busy without a running NCO clock and trigger a SoC reset.

Map the NCO register block in the T8103 sleep profile, enable any
disabled NCO channel before the sleep commit, and clear CTRL_ENABLE
again on wake so clk-apple-nco's software state stays consistent.

Signed-off-by: Erik Bourget <[email protected]>
…S2R power loss

After a firmware-driven sleep on a conventional PCIe host, PERST#
resets BCM4377/BCM4378's private BAR0 backplane windows to their
hardware defaults (e.g. 0x19328000 on BCM4378). When bcm4377_resume()
queues device_reprobe() without setting needs_reset or restoring the
BAR0 windows, bcm4377_hci_close() during hci_unregister_dev() still
attempts to destroy transfer rings by writing the BAR0 doorbell through
the unconfigured window, faulting the PCIe/AXI bus on T8103.

Set needs_reset and call bcm4377_init_cfg() before queueing the rebind
so teardown skips ring destruction on dead firmware and any interim BAR0
access lands on valid backplane windows.

Signed-off-by: Erik Bourget <[email protected]>
Signed-off-by: Erik Bourget <[email protected]>

# Conflicts:
#	Documentation/devicetree/bindings/soc/apple/apple,t8140-sleep.yaml
#	drivers/nvme/host/apple.c
#	drivers/soc/apple/sleep-test.c
#	drivers/soc/apple/sleep.c
@erikwb
erikwb requested review from a team and DjDeveloperr as code owners November 25, 2026 18:50
@github-actions github-actions Bot added area:display Area from CODEOWNERS (bot) area:gpu Area from CODEOWNERS (bot) area:platform Area from CODEOWNERS (bot) area:power Area from CODEOWNERS (bot) area:wireless Area from CODEOWNERS (bot) blast:m1 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 25, 2026
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Merge readiness at 697fc879: ready to merge

Check Detail
CI at head ok 28 checks passed
Review ok approved by DjDeveloperr, satchlj
Requested changes ok none
Hardware row at head ok in the PR body at 697fc879
Conflicts ok none
PR text ok Risk: two-way · M1 (T8103 / J313) S2R bring-up plus shared pcie-apple conventional host IRQ masking, hcibcm4377 power-loss rebind, nvme-apple non-warm-sleep firmware sleep path, and apple-sleep core hooks.

Areas: area:display, area:gpu, area:platform, area:power, area:wireless
Merge: gh pr merge 3172 --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.

@satchlj satchlj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Verdict: MERGE at 697fc879d990

Blockers: none

Checked: Full 31-file diff audit across the T8103 S2R bindings/DTS (apple,t8103-sleep, apple,t8103-display-power, apple,sleep-ssps, t8103.dtsi, t8103-j313.dts), T8103 sleep controller (sleep-t8103.h, sleep.c, single-cache-line sleep-perf-step.S, sleep-test.c), and subsystem S2R hooks (irq-apple-aic.c, apple-dart.c, dcp.c, iomfb_template.c, nvme/host/apple.c, sart.c, rtkit.c, pcie-apple.c, hci_bcm4377.c, pmgr-pwrstate.c, macsmc.c, aop.rs, pm_shim.c, and host test fixtures — verified balanced pcie-apple port IRQ disable/enable across refused and real sleeps, bcm4377 BAR0 window reinit before rebind, apple-nvme/sart/rtkit early-save and refused-sleep restore pairing, apple-dart T8020 reset/locked-lost handling, aic target/global/CPU-id restore and WHOAMI affinity mapping, non-posted ioremap_np, and 52-byte .balign 64 perf-step routine); no Apple material, no new model/board gates (DT/SoC match driven), human DCO across all 34 commits; exact-head J313 hardware verification row (cold boot, s2idle, pm_test=core, 3 consecutive S2R wakes with live Hyprland, Borealis, Wi-Fi, Bluetooth, and audio); all 29 CI check-runs green with zero active checks.

Evidence
  • Head: 697fc879d990a6e4fa29c9a10977da749071d245 (34 commits, all signed off by Erik Bourget).
  • Diff audited: 31 files, all rollback/refusal/restore invariants verified across sleep-t8103.h, sleep.c, pcie-apple.c, hci_bcm4377.c, nvme/host/apple.c, sart.c, dcp.c, apple-dart.c, irq-apple-aic.c, macsmc.c, aop.rs, and pm_shim.c.
  • Author hardware evidence at exact head 697fc879d990: M1 MacBook Air (J313, G13G B1) cold boot, s2idle, pm_test=core, and 3 consecutive physical S2R wakes (0 -> 1 -> 2 -> 3) with PCIe/Wi-Fi/Bluetooth/audio/GPU warm restart and Borealis compute+render passing on every wake; host tests (bcm4377-resume-tests.py, aop-bootargs-tests.py, sep-suspend-errors-tests.py) passing.
  • CI: 29/29 check-runs completed and passing (0 active, 0 failing).

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

LGTM — audited the full 31-file diff across the T8103 sleep controller (sleep-t8103.h, sleep-perf-step.S, sleep.c), AIC1 config/target/WHOAMI restore, T8020 display DART + DCP firmware 27 stop/restart, ANS/SART/RTKit wake restore, AOP/PMGR/SMC/SEP hooks, conventional pcie-apple chained-IRQ gating (hib_saved matched across refused-before-commit and real wake), hci_bcm4377 BAR0 window / needs_reset recovery, DT bindings/DTS, and host test updates. All 25 CI jobs are green with 3-cycle physical S2R verification on J313; holding merge for a 2nd-gen non-M1 regression row covering the shared driver changes.

@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 Nov 25, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor

697fc87 J616s (T6040, M4 Pro, non-M1 PCIe NVMe) PASS: guarded one-shot combined batch (0d2ac928b426 over main 5a4b951, 0 merge-tree diffs on 31 changed files, default cmdline, stock Stage 2 1.0.0b17, boot 3b6ced23-015d-4775-897b-81a51be1de72): pre-sleep 128 MiB NVMe direct dd write (841 MB/s) + read (5.1 GB/s) SHA256-verified, 2/2 real rtc1 s2idle wakes, post-sleep SHA256 re-verified + fresh 128 MiB direct write (769 MB/s) + read (4.6 GB/s) SHA256-verified, 0 NVMe/PCIe errors, 0 GPU faults, 0 failed units, Enforcing, 0 new AVC, 0 new kernel errors, Borealis VK api.smoke 8/8 pre/post, Wi-Fi 3/3; stock 7.3.0-aurora-fleet89 restored.

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:power Area from CODEOWNERS (bot) area:wireless Area from CODEOWNERS (bot) blast:m1 Macs affected, from Merge risk (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.

4 participants