Skip to content

soc: apple: sleep: add T6000 (M1 Pro / J314s) suspend-to-RAM support (on #3381) - #3534

Draft
olivergreg wants to merge 34 commits into
aurora-silicon:mainfrom
olivergreg:feat/t6000-suspend-to-ram
Draft

olivergreg wants to merge 34 commits into
aurora-silicon:mainfrom
olivergreg:feat/t6000-suspend-to-ram

Conversation

@olivergreg

@olivergreg olivergreg commented Nov 28, 2026 •

Copy link
Copy Markdown

What: Adds suspend-to-RAM for T6000 (M1 Pro) and enables it on J314s.

Tested: J314s (MacBook Pro 14" M1 Pro) at 305ef36c, default command line: 25/25 deep sleeps on one boot.

  • 0 SELinux denials, no Oops, BUG or SError.
  • After each wake the PCIe link power settings are back and a 64 MiB O_DIRECT write reads back intact.
  • Before main was merged in, at 6c8d7e7c: an 8 s RTC sleep takes 10.0 s end to end, and a sleep refused at .enter returns to a running system with the panel back, 8 of 8.
  • Overnight lid-closed sleep (7 h 34 min): no unexpected wakes; energy_now dropped 0.67 Wh (15.73 -> 15.06 Wh, 89 mW) and charge_now dropped 60–70 mAh (90–105 mW at 11.4 V; s2idle measured 1.8 W).
  • An earlier commit of the series ran 29/29 (25 back-to-back RTC wakes, 3 lid wakes, one 20-minute sleep), including an 8-hour overnight sleep with no unexpected wakes.
  • Most wakes log one EDAC event-log source 19 report (see Not yet).

Risk: one-way (adds DT bindings; deep becomes the default sleep state on J314s) · M1 Pro J314s.

  • The shared drivers it changes (sleep core, RTKit, AIC2, DART, SEP, SMC, DCP, PCIe host, NVMe, GPU) run on other Macs too.
  • T8103 (J313) is the one whose sleep path they touch.

Not yet:

  • Stage 2 device tree. The runs used a test-only overlay for the new J314s nodes. A run with a rebuilt Stage 2 device tree is still to do.
  • A second Mac. I only have a J314s, so the shared changes need a regression row elsewhere, J313 first.
  • Log lines on each wake.
    • The EDAC event-log source 19 report. It comes from the clock mux switch before sleep and needs a fix in the EDAC driver.
    • Three PCIe Unable to change power state from D3hot to D0, device inaccessible lines.
    • On about a quarter of wakes, mmc0: Card is consuming too much power! with no card in the reader.
  • Untested. External USB-C and HDMI displays, audio or GPU load across a sleep, and T600x boards other than J314s.
Details

Stack

Needs aura Stage 2 from main at 3526be04 or later. The 1.0.0~b17 release hangs on every wake.

What changes

  • Sleep controller and device tree (sleep-t6000.h, sleep.c, bindings, t600x-die0.dtsi, t6000-j314s.dts): the T6000 profile, a hook that lets a profile order SEP's sleep and the CPU stop, and the sleep controller node, disabled in the SoC file and enabled on J314s only. Pins are saved and restored through apple,pinctrl.
  • A refused sleep: SEP's stop is the last refusal, the GPU and SIO firmware stop at the sleep's commit, and the panel firmware is power-cycled and started again in the resume.
  • PCIe (pcie-apple.c): one 100 ms wait after the last retrained link on resume (PCIe r5.0, 6.6.1).
  • RTKit and NVMe: the nvme: apple: keep the RTKit buffers of ANS across a firmware sleep #3381 commit, a split endpoint start, mailbox enables restored after a firmware sleep, apple_rtkit_sleep_return_with_init() and its Rust wrapper.
  • irq-apple-aic.c: keep AIC2's configuration across a firmware suspend.
  • apple-dart.c: restore a locked DART after a firmware sleep.
  • pm_shim.c: accept a power-gated SEP as a taken sleep request. DEV_DISABLE stays fatal.
  • macsmc.c: the sleep notice, with the GPIOs to lower taken from the new apple,sleep-low-pins.
  • Display and GPU: crossbar routes restored, panel firmware stopped, DP-to-HDMI converter powered down, G13S firmware parked and restarted.
  • spi-hid-apple, apple-sio, aop.rs: small sleep fixes.

Chip checks: the profile is selected by the apple,t6000-sleep compatible, as for T8103. macsmc.c enables the saved command lane for apple,t6000-smc only where the device tree enables that sleep controller, so T6001 and T6002 keep the ordinary transport.

Evidence

J314s, kernel 7.3.0-t6000-s2r28 at 593a4c61 plus a test-only DT overlay, one boot, default command line (mem_sleep: s2idle [deep])

Run Result Notes
s2idle, 8 s pass
25 × rtcwake -d rtc1 -m mem -s 8 25/25 boot object resumes 0 -> 25, wake source NUB.SPMISw3IRQ
3 × lid close and open 3/3 25 -> 28, wake source SMC.OutboxNotEmpty
One of those: overnight, lid closed, 8 h 05 min pass 0 unexpected wakes, battery 47% to 46% of a 57 Wh pack
s2idle, 5 min 1,826 mW from the charge counter
deep, 20 min pass 28 -> 29; the charge counter moves too little at this draw to give a figure

After the 29th wake: suspend_stats success=31 fail=0, 193 of 252 AP pins changed by the sleep, all put back, Wi-Fi up, Bluetooth powered, audio cards present, Borealis enumerates the GPU, NVMe healthy.

Overnight power check (J314s, 7.3.0-t6000-s2r46, default command line)

  • 7 h 34 min lid-closed deep sleep (boot object resumes 3 -> 4, wake source SMC.OutboxNotEmpty, 0 unexpected wakes): energy_now 15.732 -> 15.059 Wh (89 mW), charge_now 1381 -> 1321 mAh immediate / 1381 -> 1311 mAh 3-sample median (90–105 mW at 11.4 V).

Build and host tests at 305ef36c, with main 37a9d681 merged in

  • checkpatch.pl: 0 errors over the series' commits
  • The kernel, modules and device trees build.
  • tools/asahi/run-host-tests.py: 756 jobs pass. 8 did not run: they read old commits that my shallow clone does not have.

For a suspend-to-RAM that goes through firmware, a controller without
the warm sleep sequence is put in IDLE, not shut down:
apple_nvme_suspend() saves the SART's entries, calls
apple_rtkit_idle() and then apple_rtkit_reinit(). The reinit frees
every buffer the firmware was given (syslog, crash log, ioreport,
oslog) with dma_free_coherent() and takes its range out of the SART.
On the wake the reset work calls apple_rtkit_reinit() once more,
writes the saved SART entries back, the freed ranges among them, and
starts ANS.

An idled ANS keeps its state. On T6000 (M1 Pro, J314s), after the
wake it sends HELLO, the kernel logs "RTKit: Initializing (protocol
version 12)", the endpoints are started, and the firmware then sends
syslog records without a buffer request or a SYSLOG_INIT before them:

  RTKit: received syslog message but no syslog_msg_buffer

logged at each sleep and each wake. The firmware still writes the
records' text to the buffer it had before the sleep, which the page
allocator has handed to someone else by then, and which the SART
admits again. With an out-of-tree T6000 sleep sequence that freed and
re-admitted the buffers the same way, ANS's syslog text was found in
a process's page tables ("Bad page map"), followed by an oops.

Keep the buffers for as long as the firmware may use them. Add
apple_rtkit_reinit_retaining_buffers(), which resets a session's
handshake state as apple_rtkit_reinit() does and leaves the shared
buffers, their SART ranges and the syslog geometry alone, and use it
for the idle before the sleep and for the restart after it.

Both ways the firmware can come back are then served by the code
that is there:

 - a firmware that resumes with its state never asks, keeps writing
   to memory that is still its own, and its syslog records are read
   and printed again;
 - a firmware that starts from scratch asks again. A request of the
   same size for an endpoint that has a buffer is answered with that
   buffer by apple_rtkit_common_rx_get_buffer(), and a SYSLOG_INIT
   replaces the geometry.

Nothing is allocated per sleep. The buffers are released as before
by apple_rtkit_free(), or by the apple_rtkit_reinit() of a
controller reset, which follows a shutdown the firmware
acknowledged.

The path is not specific to T6000: T8103 (M1) takes it as well. The
T8122 warm sequence does not reinitialize and is unchanged.

Fixes: 7dfc208 ("nvme-apple: idle ANS for a firmware sleep and start it cold after the wake")
Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
apple_pcie_hib_port_up() slept 100 ms after each link it retrained, the
time PCIe r5.0 section 6.6.1 requires before the first configuration
request. No configuration request is sent until every port is up, so
one wait after the last retrained link covers them all.

On a MacBook Pro 14" (M1 Pro, J314s), where the radio and the card
reader ports both come back cold, this takes 100 ms off each wake.

Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
On conventional Apple PCIe hosts that reinitialize their links after a
firmware-driven suspend-to-RAM (apple_pcie_s2r_reinit()), endpoints such
as the Wi-Fi/Bluetooth and SD card reader links on T6000 (M1 Pro) can
run with ASPM L1, ClockPM and L1.1/L1.2 substates enabled on the default
kernel command line. When those endpoints transition to D3hot during
suspend, the link can drop CLKREQ# ahead of the sleep commit's APCIe
bridge quiesce and hang suspend entry unless pcie_aspm=off is passed.

Save and clear ASPM, ClockPM and L1SS on each downstream link of a
reinit host in apple_pcie_prepare() for firmware-driven sleeps, and
restore them in apple_pcie_complete() after resume or on rollback.

Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
A firmware sleep (suspend-to-RAM) cuts the power of the SoC, the pin
controller and the SPI controller. Keys and the trackpad wake the
machine through the SMC there, not through the controller's interrupt.

The interrupt armed for wake is still pending when the AIC comes back
and is counted as a wakeup event after every wake, so a wake the SMC
took for the lid or the charger alone cannot go back to sleep.

Arm it only when the suspend does not go through firmware. For a
firmware sleep the controller is powered off and booted again on
resume, as for a device that may not wake the system.

Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
A SoC whose commit does not stop SIO has its firmware stopped at the
late suspend with apple_rtkit_sleep_stop(). A dry run of the sleep
refuses before the commit, so the firmware was stopped for a sleep that
never happened.

Return before the stop when apple_sleep_dry_run() holds. The
busy-channel check and the refusal for a SoC that needs the stop at its
commit still run, so the dry run reports what a real sleep would
refuse.

Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
Before its sleep notice to the SMC, macOS switches off supplies that
are wired to SMC GPIOs and that no driver switches at that point. On
the J314s (MacBook Pro 14", M1 Pro) it is GPIO 26, the SD card reader's
power enable.

Which SMC GPIO powers what is board wiring. apple,sleep-low-pins lists
the SMC GPIO numbers to drive low before the sleep notice and high
again after the wake.

Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
Add "apple,t6000-sleep" for the M1 Pro, with the 22 register blocks its
suspend-to-RAM sequence writes. Its wake sources are armed from
apple,wake-enable, which is required.

Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
A firmware-driven suspend powers the interrupt controller down with the
rest of the SoC. AIC2 comes back with its global configuration, its
per-interrupt target words and its masks at their reset values.

The AIC3 variants already save and restore that state through
aic_syscore_ops, selected by .fw_suspend. The saved registers are
AIC2's own layout, which AIC3 inherited, so set .fw_suspend for AIC2 as
well.

Both operations do nothing unless the suspend goes through firmware, so
an AIC2 SoC without a sleep driver only allocates the save array.

Needed for suspend-to-RAM on T6000 (M1 Pro).

Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
apple_rtkit_start_ep() refuses an application endpoint unless the
firmware is running. A restart through the full boot handshake has to
start the application endpoints before that state is reached.

Move the message into apple_rtkit_start_announced_ep(), which checks
only that the endpoint map announced the endpoint, and keep the state
check in apple_rtkit_start_ep(). No functional change.

Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
apple_rtkit_sleep_return() restarts a coprocessor parked by
apple_rtkit_sleep_stop(). The mailbox is not stopped on that path, so
apple_mbox_start() finds it started and writes nothing.

Where the mailbox's block lost power in the sleep, its interrupt
enables and outbox enable are back at their reset values, the
firmware's HELLO raises no interrupt and the handshake times out. That
is the case for SIO and the PMP on T6000 (M1 Pro).

Call apple_rtkit_mbox_restore() before the run bit is set. It writes
the enables apple_mbox_start() wrote at the first start, so a mailbox
that kept them is unchanged.

Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
apple_rtkit_sleep_return() expects a firmware that restarts warm, with
its buffers and endpoints kept.

On T6000 (M1 Pro) the display coprocessor and the GPU, both on firmware
13.5, boot from scratch after a sleep that took their power: they wait
for IOP power state INIT before HELLO, send the endpoint map again and
have every application endpoint closed. Treated as a warm restart they
never answer.

Add apple_rtkit_sleep_return_with_init() for them. It resets the
session expecting a new endpoint map, restores the mailbox's enables,
sets the run bit, sends IOP power state INIT and waits for the map and
the power state acknowledgment as at a first boot. It then starts
every application endpoint that was started before the sleep and sets
the AP power state on.

The restart preparation is shared with apple_rtkit_warm_restart()
through apple_rtkit_prepare_restart(); the warm case is unchanged.

Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
After the sleep request is sent, the enclave's answer is polled for
until it arrives, the power word shows DEV_DISABLE, or 5 s pass. The M1
generation never sets DEV_DISABLE: an enclave that is down shows an
actual state of 0, which the wait after the poll already accepts
through sep_ps_down().

An enclave that gated before its answer was read ran the poll to its
timeout, and the request was treated as failed, which is fatal after
the send. T6000 (M1 Pro) was brought up with this case accepted.

Use sep_ps_down() for the poll as well, and accept a request with no
answer read and the domain off. An answer that reports an error still
fails, and so does a timeout with the domain on.

Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
For a system sleep the AOP driver sends each started AFK endpoint a
sleep message and, after the wake, a wake message. The T6000 profile
left both lists empty, which addresses every endpoint from 0x20 to
0x30.

The profiles whose order was traced on macOS (T6041, T8142, T6050)
address the twelve endpoints 0x20 to 0x2b and nothing above. Name the
same twelve for T6000, in endpoint order both ways. The order has not
been traced on this SoC; apple,sleep-endpoints and apple,wake-endpoints
can still override it.

Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
The boot loader locks some DARTs before it hands over, and the driver
neither saves nor restores a locked DART around system sleep.

On T6000 (M1 Pro) suspend-to-RAM powers the DARTs down. A locked DART
comes back with every register at its reset value, the lock bit
included, while its page tables are still in DRAM. The first DMA of its
consumer after the wake faults.

Mark the T6000 DART type with sleep_clears_lock. Such a DART has its
lock word and stream enables saved at suspend with the TCR and TTBR
registers. After a wake through firmware, if the registers no longer
hold the saved translations, they are written back, then the stream
enables, then the lock word, and the TLBs are flushed.

A locked DART whose registers survived, and the other DART types, are
left alone as before.

Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
T6000 (M1 Pro) has a first-generation SMC like T8103: it is told of a
suspend-to-RAM last, with interrupts off and one CPU left, which needs
the saved command lane the driver uses for T8103 and J813. Enable the
lane for "apple,t6000-smc" where the device tree has an enabled T6000
sleep controller, so the T6001 and T6002 machines that share the
compatible keep the ordinary transport.

Between slpw and slpa macOS writes, in this order:

 - gP1a = 0, the SMC GPIO that powers the SD card reader on the J314s;
 - pmVC, the VDD_CIO rail mask, which T8103's SMC does not have;
 - WKTP = 2, as on T8103.

Take the GPIOs from apple,sleep-low-pins. Each is written 0 before the
other keys and switched on again after waka, if this sleep lowered it.
pmVC is written from the existing apple,sleep-pmvc, before WKTP. T8103
sets neither property and sends what it sent before.

Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
Suspend-to-RAM on T6000 (M1 Pro) powers the display crossbar down. It
comes back with its tunable gone and every output unrouted, while the
mux core and the driver still hold the selections made before the
sleep. A display connected over USB-C before the sleep stays dark.

Mark the T6000 crossbar as reset by a firmware sleep. On resume after
such a sleep, write the probe-time tunable and run the ordinary
selection for each output that has one.

Suspend-to-idle, a refused sleep and the other crossbar variants are
not affected.

Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
macOS sends the display firmware the unnamed A500 call before it stops
the coprocessor for a sleep. The H17P and 26.6 tables carry it as
dcpep_unnamed_500 with iomfb_s2r_500().

The 13.5 firmware, which T6000 (M1 Pro) runs, dispatches the same call
under the same tag. Add it to the 13.5 method table with
iomfb_s2r_500_v13_3(). The argument is zero, the form the T6000 sleep
was brought up with, and the firmware is given 2 s to answer.

No caller yet; the T6000 stop that sends it follows.

Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
The internal display coprocessor of T6000 (M1 Pro) runs firmware 13.5,
for which the driver has no stop: across a system sleep the firmware is
left running with its domains held on. Suspend-to-RAM takes the
coprocessor's power regardless, and afterwards the driver waits on a
session that no longer exists and the panel stays dark.

Give "apple,t6000-dcp" its own match data with hw.sleep_13_5. For a
sleep that goes through firmware, the internal processor on 13.5 is:

 - sent A500, as macOS sends it before the stop;
 - parked and stopped with apple_rtkit_sleep_stop();
 - restarted on resume with apple_rtkit_sleep_return_with_init(), since
   this firmware boots from scratch after losing power.

A dry run of the sleep leaves the firmware running. After a sleep
refused with the firmware already parked, apple_rtkit_sleep_return() is
used.

The later firmwares have their own stop under hw.s2r, and no other SoC
on 13.5 sets the flag.

Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
The HDMI port of the 14" and 16" MacBook Pro sits behind a DP-to-HDMI
converter whose supply is an SMC GPIO (dp2hdmi-pwren-gpios). The driver
switches it on at probe and leaves it on.

The SMC keeps its GPIOs through a suspend-to-RAM, so the converter
stays powered while the SoC is off and draws several hundred
milliwatts, more than the rest of the machine in that state. macOS has
it off.

Switch the supply off in the suspend path when the sleep goes through
firmware, and on again first thing on resume, before the port's
hot-plug state is sampled.

The converter's draw was first measured by Andreas Fernandez.

Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
Two points of the early-context entry are fixed in the core and differ
on T6000 (M1 Pro), whose sequence follows macOS:

 - SEP is asked to sleep after the display blocks are down. On T6000
   macOS asks SEP first, and the display blocks' lowering waits for
   SEP's power gate. With .enclave_first, SEP's stop runs right after
   the other cores are held, with ops->before_enclave ahead of it.

 - apple_sleep_commit() stops the parked cores before ops->commit_regs.
   T6000's commit stops them in the middle of its own sequence, after
   PLL0 is off and before the last cluster's target goes to 0. With
   .commit_stops_cpus the core leaves the stop to commit_regs.

No profile sets either yet.

Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
Add the T6000 (M1 Pro) sleep profile to the Apple SoC sleep driver,
following the PMGR S2R timer commit path used on Firestorm/Icestorm SoCs
(based on the T6000 suspend-to-RAM reference by Andreas Fernandez).

The profile:
- arms wake sources from the device tree's apple,wake-enable property and
  reports T6000 wake source names from the ADT wake map;
- waits for SEP to power-gate, saves PMGR domain state, quiesces the GPU
  and display fabric bridges (using the same 4-word bridge handshake as
  T8103) and drops PMP requests before lowering display and GPU domains;
- quiesces the four AMCCs and their DCS channels (RMW low-power gating),
  the PCIe bridge, CPU complex counters/throttlers/APSC, DCS clock state,
  cluster targets, SoC clock muxes and PLL0, dcs_* domain words, NCO
  channels, and the final PMGR, clock, fabric p-state and SIO commit
  state before arming the PMU RTC SPMI vector, AIC mask and S2R timer;
- restores clocks, clusters, AMCC/DCS state, PMGR domains, PMP DAPF and
  IORVBAR, NCO channels, SEP/SIO/GPIO domains, and all AP pins via the
  shared apple_sleep_restore_pins() path on wake, and reports any entry
  step that timed out or was left incomplete.

Deep sleep is enabled by default on boards that enable the sleep node.

Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
Add the two calls a Rust driver needs to take its coprocessor through a
sleep that cuts its power: apple_rtkit_sleep_stop() and
apple_rtkit_sleep_return_with_init(). Both take the mapped CPU control
word of the coprocessor's ASC and are unsafe for that reason.

Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
The first-generation driver, which runs the G13 GPUs on firmware 13.5,
refuses every sleep that goes through firmware: the sleep takes the
GPU's power and the driver could not bring its firmware back.

On T6000 (M1 Pro) it can:

 - at .suspend, submissions still in flight get 500 ms to finish, then
   the firmware is parked and its CPU stopped with
   apple_rtkit_sleep_stop(). A submission still pending refuses the
   sleep;
 - at .resume it is restarted with
   apple_rtkit_sleep_return_with_init(). The firmware boots from
   scratch; the driver keeps the state it had in DRAM and kicks the
   firmware once it is up.

Select this with a new HwConfig field, sleep_restart, set for T6000
alone. The driver keeps the GPU object and its ASC block for the two
callbacks.

A dry run of the sleep leaves the firmware running. A sleep refused
after the park leaves the GPU down until the next sleep that happens,
and says so.

Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
Describe the register blocks the T6000 suspend-to-RAM profile writes,
and name the internal display coprocessor for the core's display check.

The node sits in the die 0 include that T6000, T6001 and T6002 share,
since the blocks are the die's. The sequence has only been qualified on
T6000 (M1 Pro), so the node is disabled here and a board that sleeps
enables it.

Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
Enable the sleep controller on the MacBook Pro 14" with M1 Pro, the
board its sequence was brought up on, and describe what the sequence
needs from the other devices:

 - the SMC writes pmVC = 0x100 before its sleep notice and switches SMC
   GPIO 26, the SD card reader's power enable, off for the sleep;
 - the PMP's firmware SRAM is kept across the sleep, which takes its
   power;
 - the AP pin controller has every pin restored except 114, 115 and
   119;
 - the four USB-C port controllers are told the system power state, S3
   before the sleep and S0 after it.

The profile is not marked untested in the driver, so deep sleep is the
default sleep state on the default kernel command line, with no
apple_sleep parameter. The J316s and the T6001 and T6002 machines keep
the node disabled.

Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
With .enclave_first, SEP is asked to sleep right after the other cores
are held, and ops->display_off follows. Neither can be taken back, but
the coprocessors' last checks, the SMC scope check, the SoC's final
check and the pending-wakeup check still came after them. A sleep
refused there returned with SEP asleep and, on T6000, with the display
and GPU domains down, and the resume that followed hung.

Run every other check first. SEP's request is then the last refusal, as
it is without .enclave_first, and ops->display_off runs past it, where
a failure can no longer be returned.

On J314s a sleep refused at the last check hung the machine before
this, and returns to a running system with it.

Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
T6000 matched the generic data, so its firmware was idled and stopped
in the late suspend. A firmware-driven sleep can still be refused after
that, and an idled firmware does not come back with its power kept: the
sleep engine has no reset for it on T6000 (-ENODEV), so it stayed
stopped until a sleep that happened.

Give "apple,t6000-sio" the generic words with .stop_at_commit. Where
the board has a sleep controller the firmware then runs until the
sleep's commit idles it, past the last refusal, as on T6041 and T8140.
T6001 and T6002 share the compatible and have no firmware-driven
sleep, so nothing changes for them.

Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
The legacy GPU's .suspend parked the firmware and stopped its CPU. A
firmware-driven sleep can still be refused after the devices have
suspended, and a parked firmware only comes back through a sleep that
takes its power. After a refused sleep the GPU stayed down, and every
later sleep failed in .suspend, which tried to park it again ("AP idle
not acknowledged: -62"), so it never came back.

Leave the stop to the sleep's commit instead. .suspend drains what is
in flight and registers a first-pass stop with the sleep core, which
runs it with interrupts off once nothing can refuse any more:
apple_rtkit_sleep_idle_polled(), the mailbox's receive off, and the run
bit cleared twice, as apple_rtkit_sleep_stop() does. The firmware runs
until then, so the GPU's domain is held up across the noirq phase as it
is across a suspend-to-idle.

On an .enclave_first SoC ops->display_off now runs after the first-pass
stops: T6000's takes the GPU's domain down with the display's.

.resume restarts a firmware the commit parked after a sleep that
happened. After a sleep refused before the commit there is nothing to
do: the firmware never stopped. One parked by a commit whose sleep did
not happen stays parked, and the next sleep neither parks it again nor
refuses, and restarts it at its wake.

Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
The late commit waited 2 ms after two power-state writes, 2 ms after
the fabric's sleep state, 100 us after the clock muxes went off, and
200 ms before the wake timer was written. None of them waits for
anything: the fabric state is already polled for, and J314s sleeps and
wakes the same without the others (25 of 25).

Drop the two 2 ms waits and the 200 ms one. Poll each clock mux for its
busy bit in place of the 100 us, and report one that stays busy with
the other incomplete steps.

Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
After a refused sleep the display coprocessor's firmware has idled with
its power kept, and it only starts again from a power loss. The words
that take its CPU domain down are in the sleep's entry, and nothing
could run them outside a sleep.

Add apple_sleep_display_power_cycle() for the coprocessor's driver. On
T6000 it lowers the CPU domain's word with the two writes of the entry
and raises it to the word it held, in the wake's order. The front end
stays on, and the entry is not changed.

The coprocessor's request to the PMP is withdrawn around the cycle. A
running PMP takes a block whose request it holds as active, the entry
withdraws the request before it lowers the word, and the request's
power domain, a child of the CPU domain's, keeps that order everywhere
else. Nothing in the report's driver raises or reports a domain lowered
under a held request, so only the withdrawal keeps the PMP's view true.

On J314s, with the front end on, the word read 0x1f0403ff before,
0x0f040100 off and 0x1f0403ff again in under 1 ms, with the PMP's
requests at 0x7200 and acknowledged before it. The firmware then
started in about 2 ms, 5 of 5 times with the request withdrawn, and in
about 3 ms the one time it was held.

Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
Without the queue, a call the firmware never answers stays on its
channel. After a restart every later command then goes out on the
callback context, and an ack can be paired with a call slot that holds
no record: dcpep_handle_ack() derives the record's address from a NULL
output pointer and reads it.

Seen once on T6000, after a restart that followed calls to a stopped
firmware: an Oops in iomfb_recv_message() at 0xfffffffffffffff8, the
in_len of a record 12 bytes below NULL.

Add iomfb_channels_reset() to empty the call stacks before such a
firmware starts again. An ack for an empty slot is ignored with a
warning, and one on a call stack deeper than its slots marks the
firmware crashed.

Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
A sleep refused after the T6000 display coprocessor's stop left the
panel dark until a reboot. Firmware 13.5 does not start from an idle
with its power kept, and after A500 it completes no page flip even if it
is never stopped. The resume cleared s2r_fw_down all the same, and the
calls that followed timed out against a firmware that was down.

Give a panel's firmware the power loss a real sleep gives it: its CPU
domain is power-cycled through the sleep driver, and the firmware
starts as after a wake, with its call stacks emptied. Its DARTs are
not touched. Both kept their lock word, their stream enables and all
16 translation register pairs across the cycle, and the display
subsystem, which maps through them, resumes after the coprocessor.

A firmware that does not start, after a refusal or a real sleep, is left
stopped and marked crashed, so that nothing calls it. It stays down for
the next suspend, and the next sleep that happens starts it again.

On J314s, 4 of 4 refused sleeps, two at each of two points of the
entry, came back from the resume with the panel lit: about 1 ms for the
cycle, 2 ms for the firmware's start and 0.5 s for the whole resume.
After 6 refusals in one boot, 10 deep sleeps passed.

Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
…nnot follow

t6000_domains_restore() raises every PMGR domain that was on before the
sleep, waits up to 20 ms for each, and repeats the whole pass up to 30
times while any has not followed. On J314s ten never do, so every wake
spent 6.5 s there:

 - nine are words of the cores and their managers (ecpu0_1, pcpu0_0-2,
   pcpu1_0-2, pcpm0, pcpm1). They read on with a target of 0: their
   power is their complex's, not this word's to ask for, and they come
   back when the cores are started;
 - one (afnc1_lw1) has AUTO_ENABLE and gates itself as soon as that is
   written back, which was before the check. The later passes then left
   it on with AUTO_ENABLE cleared.

Skip a domain that was on with no target, and judge whether a domain
followed before AUTO_ENABLE goes back.

J314s, 25 deep sleeps: the step takes 60 ms (6522 ms before) in one
pass with no domain left behind, and the resume ends 0.8 to 1.0 s after
the first code that runs at the wake (7.2 to 7.5 s before).

Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
main now carries 4f3e0d2 ("PCI: apple: disable L1SS around deep sleep
on reinit hosts"), which handles the same links as 1c3375c ("PCI:
apple: disable ASPM and L1SS across firmware sleep on reinit hosts").

Conflicts in drivers/pci/controller/pcie-apple.c and
tools/asahi/pciec-policy-tests.py: main's version is taken and
1c3375c is dropped. 2f60f7d (one wait after the last retrained
link) is kept.

Signed-off-by: Oliver Gregory <59419317+olivergreg@users.noreply.github.com>
@CoreyH

CoreyH commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

A row from a second J314s: 16 of 17 deep sleeps woke, 12 of them back to back in one boot.

(Edited 30 Nov. This replaces three earlier comments of mine. The first two reported mostly failures, and those runs were invalid: the distribution's linux-modules-cleanup.service had removed my test kernel's module tree between runs, so it was sleeping with nothing built =m loaded. My setup, not this PR. Sorry for the noise.)

Setup — MacBook Pro 14" M1 Pro, J314s, the 8-core chip (2 E + 6 P), 32 GB; iBoot2 iBoot-8422.141.2, OS firmware 13.5.

  • Kernel: this PR at 305ef36c, the distribution's linux-aurora 7.3.0.aurora1 configuration, default command line. One local change, diagnostic only: the PMU step notes switched on for T6000, with the incomplete mask added to the note at 0x7a.
  • Stage 1: stock m1n1 v1.6.1. Stage 2: aura built unchanged from aurora-nightly-20261128 (26c1a85b), with t6000-j314s.dtb from this kernel build appended, no overlay, then U-Boot 2026.07 (uboot-asahi).
  • Each sleep: rtcwake -d rtc1 -m no -s N, then mem to /sys/power/state.

One boot, twelve sleeps (regular root, nothing masked)

Sleeps N Result
1 60 s woke
5, a few seconds apart 30 s 5/5
5, a few seconds apart 15 s 5/5
1 300 s woke

boot object resumes 0 -> 12, every wake wake source: NUB.SPMISw3IRQ, nothing reported incomplete. Afterwards Wi-Fi is associated again, Bluetooth powered, and a 64 MiB O_DIRECT write runs at full speed. The battery's charge and energy counters did not move across the 302 s sleep.

First sleep of a boot, five boots: woke (120 s), reset (60 s), woke, woke, woke (60 s each).

  • The one reset came before the alarm, with the modules loaded. PMU notes after it: step 0x7a, incomplete = 0, no 0x7b. That boot had a local debug build of aura as Stage 2 (extra SPMI writes on its wake path); so did the first wake, and the three after it ran unmodified aura. I can't say more about it than that, and it hasn't come back.

Log lines on each wake

  • event-log source 19, as you describe.
  • Unable to change power state from D3hot to D0, device inaccessible for sdhci-pci 0000:02:00.0, hci_bcm4377 0000:01:00.1 and brcmfmac 0000:01:00.0.
  • Bluetooth: hci0: power lost in the sleep, rebinding the driver, every wake.
  • No mmc0: Card is consuming too much power! in twelve wakes.

Not yet here: a lid wake, a night for a power figure, external displays (none to test with).

@olivergreg

Copy link
Copy Markdown
Author

Very interesting, yesterday I changed most of the fixed waits to polls or dropped them entirely (including the 200 ms wait right after 0x7a before the timer write, leaving the PMGR writes unpolled) to try and clean the code up for merge. I have a feeling that this has caused issues. Looking at the reference sequence Ante gave, this is the main difference I can see.

I've not had issues with normal sleep myself, but an event triggered right at the last stage of entering sleep (everything is powered down and mailboxes cleared) re-wakes and causes a hang that needs a force reboot. So the only way I can trigger a fault is by plugging/unplugging a charger right as it enters sleep, and the timing has to be very tight to get it to do so.

Other than that I've had many working sleeps on that same code over the weekend (with an older DTB + minimal test overlay), measuring about 90-110mW so it's definitely looking promising once we've got these last issues sorted.

Setup wise: Mine is also an 8 core, but 16GB not 32GB. Same stage 2 also on aura 1.0.0b17-g26c1a85b / U-Boot 2026.07, stage 1 is aura 1.0.0b13. So the differences are memory, stage 1, and the extra nodes enabled in the rebuilt DTB (i2c5, aux spmi, ane0_dma/ave0_dma, etc.).

I'm going to test putting the post-0x7a waits, PMP/SMC order, omitted late clock muxes, and a late pending-IRQ guard/AIC drain back in, plus a 0x7c note right after the late commit settles. I'll push to olivergreg/linux:test/t6000-s2r-commit-fixes if you want to try, seeing whether it reaches 0x7c (and any logs) would be really helpful. I've not yet tested myself and probably won't be able to until tomorrow.

@CoreyH

CoreyH commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Thanks, that helps a lot.

Our comments crossed: I rewrote my row a minute before your reply. The early resets were my setup, not your code (the test kernel's modules were being removed between boots). With that fixed, the PR as it is at 305ef36 is at 21 wakes in 22 sleeps here, so I have nothing against the dropped waits. The one reset I can't explain (first sleep of a boot, 60 s alarm, last note 0x7a, nothing incomplete) could well be your late-event case: I can't rule out an event in that window.

The PR at 305ef36, ordinary boots, stage 2 aura 26c1a85, stage 1 m1n1 v1.6.1:

  • Two nights on a lid close through systemd: 17 h 7 min and 21 h 33 min, both woke on the lid (wake source: SMC.OutboxNotEmpty, wake record: MBSE 0x10030, MBSW 00 01 00 00 00 00 00 00). By the battery gauge about 100 to 125 mW the first night and about 55 mW the second; the gauge is too coarse for me to say which is right. s2idle on this Mac was about 1.9 W.

test/t6000-s2r-commit-fixes at c02b26e, built with the notes on, same loader: 17 wakes in 18 sleeps.

  • 15 sleeps with the RTC alarm armed, 20 s to 59 min, written straight to /sys/power/state: all came back. Ten by the alarm (NUB.SPMISw3IRQ; MBSE 0x10630, MBSW all zero), five by a key (... MBSW 00 10 ...: trackpadkeyboard), one of those 22 minutes into a sleep. 0x7c is overwritten by the wake path's notes, so I only ever read 0x7e after these.
  • A 72-minute lid close through systemd woke on the lid (MBSW 00 01 ...: lid).
  • One hang, on an earlier lid close (through systemd, on battery at 14%, fifth sleep of that boot). On opening the lid some minutes later: no display, no caps lock light, power key needed. The notes afterwards read a5 7e 03 05, nothing incomplete: attempt 5 got to 0x7e, so the wake path ran back into Linux and it stopped somewhere after that. The journal has nothing after systemd's "Performing sleep operation". The battery gained about 20 Wh in the 24 minutes around it, so the charger probably went in under the closed lid, but I can't confirm that.
  • So I tried that: lid closed on battery, charger plugged in a minute later. No hang this time, but the dark wake's re-entry was refused and the Mac stayed awake under the closed lid:
macsmc 290400000.smc: wake record: MBSE 0x10030, MBSW 00 00 00 00 00 04 00 00: USB-C_plug
apple-sleep 28e080000.sleep-controller: woken for a port with the lid closed: dark wake
apple-drm soc:display-subsystem: dark wake: outputs stay off
PM: dark wake: suspending again (deep)
macsmc 290400000.smc: PM: device_prepare(): apple_smc_prepare returns -16
macsmc 290400000.smc: PM: not prepared for power transition: code -16
PM: Some devices failed to suspend, or early wake event detected
apple-drm soc:display-subsystem: dark wake over without a resume: outputs back now
PM: suspend exit
PM: suspend entry (s2idle)
systemd-sleep: Failed to put system to sleep. System resumed again: Device or resource busy
PM: suspend exit

All of that in one second. Neither macsmc's "dark wake N" line nor its "SMC was busy for N ms" line was printed, so my guess is that apple_smc_prepare_guard didn't wait because smc->dark_wakes was still zero for a dark wake the sleep driver set. systemd-sleep then fell back from mem to freeze. Whether the hang above is this same path ending worse I can't say; a plain freeze with the alarm armed did wake on this kernel.

One small thing: rtc-apple-pmu refuses an alarm more than 3600 s ahead on T600x (APPLE_PMU_RTC_MAX_DELAY, "the suspend-to-idle limit"), so rtcwake -s 3600 fails. With deep sleep working, is that limit still wanted?

I can repeat the charger-under-a-closed-lid run, or plug it in right at the entry, on either build. If there is something you'd like read out after a hang, say so and I'll add it.

@RyanTheTide

Copy link
Copy Markdown
Contributor

@olivergreg We have a J316s (16-inch M1 Pro, T6000) on the lab bench running aura v1.0.0b18 Stage 2 (past 3526be04). Would you like a J316s &sleep DT node in this PR or as a follow-up? Once a J316s node is wired we can run committed deep-sleep rows on it (RTC wake, multi-cycle, displays, storage).

In the meantime, we're queuing an exact-head 305ef36c s2idle no-regression row on our J316s to exercise the shared driver changes here and will post the receipt once it finishes.

@RyanTheTide

Copy link
Copy Markdown
Contributor

J316s (16-inch M1 Pro, T6000) exact-head 305ef36c s2idle no-regression row: PASS (3/3)

  • Setup: J316s (headless bench unit), saved Stage 2 aura 1.0.0b18 (boot.bin 37fb91e3, past 3526be04), kernel 7.3.0-b7p3534+ built at exact head 305ef36c23b1700a, default cmdline, Enforcing, failed=0.
  • mem_sleep: [s2idle] (expected since &sleep is enabled on J314s only).
  • RTC wake (PMU RTC by name, grep -l apple-pmu /sys/class/rtc/rtc*/name -> rtc1 apple-pmu-rtc 2920a1300.spmi:pmic@f:rtc):
    • Cycle 1: rtcwake -d rtc1 -m freeze -s 15 -> rc=0, 16s, success 0->1, fail=0, Wi-Fi wld0 back in 3 s, 3/3 ping 0% loss (avg 4.8 ms).
    • Cycle 2: rc=0, 16s, success 1->2, fail=0, Wi-Fi wld0 back in 1 s, 3/3 ping 0% loss (avg 2.5 ms).
    • Cycle 3: rc=0, 16s, success 2->3, fail=0, Wi-Fi wld0 back in 1 s, 3/3 ping 0% loss (avg 2.6 ms).
  • Post-s2idle: Enforcing, failed=0, 0 WARN/BUG/Oops/SError, 0 DCP crashes (3/3 DCPs), spi2.0 SPI-HID present, apple_sep ready (12 endpoints), 16 MiB O_DIRECT NVMe readback bit-identical.

No regressions from the shared driver changes on J316s s2idle. Ready to run committed deep-sleep rows here whenever a J316s &sleep DT node is added.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants