Skip to content

J616s (M4 Pro) sleep, 4/9: PMP, AOP, SEP, DockChannel, keyboard, light sensor, headset codec - #1911

Closed
fbalazsy wants to merge 179 commits into
aurora-silicon:integration/aurorafrom
fbalazsy:j616s/split-coproc
Closed

fbalazsy wants to merge 179 commits into
aurora-silicon:integration/aurorafrom
fbalazsy:j616s/split-coproc

Conversation

@fbalazsy

@fbalazsy fbalazsy commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Part 4/9 of the split of #1477 into smaller pull requests. Depends on #1910: GitHub cannot stack pull requests from a fork, so this one also carries the commits of #1903, #1904, #1909, #1910; its own are the last 17, from 852b403 on (12 files changed, 1772 insertions(+), 168 deletions(-)).

Coprocessors and their clients across hibernation and suspend-to-RAM on T6040/T6041:

Area What
soc: apple: pmp The PMP kept bound as on T8140, the T6041 PMP's data SRAM kept across S2R
soc: apple: aop, iio: aop_als AOP cold restart; the light sensor stops its reports for a system sleep (see #1876 for the related unbind change)
soc: apple: sep (Rust driver) Probe again through the aura reprobe helper (the C shim is in the sleep controller part)
soc: apple: dockchannel, HID: dockchannel J616s keyboard and trackpad across sleep
ASoC: cs42l84 The jack interrupt kept quiet across system sleep

Tested: the stack as a whole on the J616s (hibernation and suspend-to-RAM; results in #1477, whose tree is the tree at the top of this stack). Each part of the stack was built on its own (asahi config, LLVM, Rust) for the directories the series touches, and runs the host tests, KUnit and the other checks here. The commits are those of #1477 restricted to this part's files, in the same order; where a commit of #1477 spanned parts, each piece says in its message which commit it comes from.

Not tested: this part on hardware without the parts above it in the stack; T8140 and the other SoCs whose paths these commits share; a dock on the current base; the KVM guest across the sleeps; a USB4/Thunderbolt device.

fbalazsy and others added 30 commits November 14, 2026 17:41
A "does not match any of the regexes" message lists every pattern the
schema allows, vendor-prefixes.yaml included. A change that adds a vendor
prefix lengthens that list, so each such warning the base already has is
reported once as removed and once as new, and the check fails although no
device tree changed. Mask the list the way phandle values already are.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
… audio and USB4 properties

Describe what the J616s (M4 Pro, T6040) sleep and restore paths read from the
device tree: the T6040 sleep controller node, the T6041 ProRes compatible, the
PCIe and ATC PHY properties used after a power loss, the DP audio and USB4 ACIO
additions, nonposted-mmio on a PMGR block and the pin controller's
apple,resume-restore-all.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
… audio

Describe the T6040 sleep controller and enable ProRes, JPEG and DP audio on the
J616s.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The T6040 ACIO driver starts a router only over its port's Type-C PHY in
CIO mode and refuses to probe without apple,atc-phy, but the routers'
nodes never named their PHY. With the J616s left back port's router
enabled, ACIO0 failed to probe ("Missing apple,atc-phy"), and the
three of them would on any board that enables them.

Name atcphy0..2, the PHY at the same port as the router (ADT acioN
atc-phy-parent), and make the property required for the T6040 router.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The arch/arm64/boot/dts/apple/t604x.dtsi part of "pinctrl: apple: put
every AP pin back after a T6040 S2R", which goes with the device tree
changes; the rest of that commit is with the sleep controller changes.

The AP GPIO block needs the saved configuration of every pin back on
the system wake, except the pins the ADT lists in
no-restore-gpio-pins (190-192 on J616s). Linux put back
only the pins it set up itself. A sleep that cuts the block's power then
left the pins the boot loader set up for others at their reset values,
among them the chip select of the internal panel's TCON bus; after the
wake the display firmware powered the panel's rails and never saw it
come up ("No device added after powering on the rails. HPD=0").

Mark the AP block apple,resume-restore-all with the ADT's no-restore
list, snapshot every readable pin from the hardware at suspend_noirq
and write back the ones that changed at resume_noirq, logging the pins
that were not Linux's.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The arch/arm64/boot/dts/apple/t6040.dtsi part of "soc: apple:
t6040-sleep: name the T8140 driver instead of its pull request", which
goes with the device tree changes; the rest of that commit is with the
sleep controller changes.

Comments in the T6040 sleep code, the display driver and the T6040
device tree pointed at the T8140 sleep driver by a pull request number.
Name the driver (sleep.c) or the T8140 instead, and drop the
"currently unreachable" note on the sleep controller node.

No functional change.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The arch/arm64/boot/dts/apple/t6040-j616s.dts,
arch/arm64/boot/dts/apple/t6040.dtsi part of "arm64: dts: apple: t6040:
enable the sleep controller per board", which goes with the device tree
changes; the rest of that commit is with the sleep controller changes.

The T6040 sleep controller's node is in the SoC's file, so every T6040
board has it, while its sleep has been run on the J616s alone. It maps
fixed T6040 blocks and installs suspend operations that make deep the
default state and then refuse it without t6040_sleep.allow_entry, which
is of no use on a board nobody has tested, and distribution kernels
build the controller.

Disable the node in t6040.dtsi and enable it in t6040-j616s.dts. On the
J614s and the J773s the controller no longer binds: suspend-to-idle
stays their sleep, and the debugfs preflight file is gone there.

The interrupt controller saved its configuration for a sleep on every
apple,t6041-aic3 whenever the controller was built. Key that on the
enabled node as well, so that the other machines with this AIC keep
their suspend and hibernation paths as they were.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
…e,apcie

The description spoke of what a driver does with the node. Say what the
node is: the blocks an operating system at EL2 drives itself to suspend
the T6040 to RAM, and the display power states that have to be off
before it.

The boot loader adds apple,apcie to the node, the PCIe host whose shared
registers and tunables the storage controller's link needs after a
sleep, as on the T8140. The binding did not allow it. The pipe list also
lacked the description a vendor property needs, which the binding check
reported.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The MAINTAINERS part of "soc: apple: sleep: describe the T6040 part as
it is", which goes with the device tree changes; the rest of that commit
is with the sleep controller changes.

The file's opening comment still explained why the T6040 controller was
a driver of its own next to the generic one, and several comments named
functions the generic driver no longer has. Describe the part as it is
now, with suspend-to-RAM offered only to a system booted with
t6040_sleep.allow_entry=1, name the generic driver's functions, and say
in sleep.c that a SoC may bring a part.

List the private header next to the driver's sources.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The T6041 display coprocessors (apple,t6041-dcp, apple,t6041-dcpext)
name an apple,display-power node whose "ps" and "pmc-dcp" windows hold
the power-state words their driver lowers after it stops the firmware
for a suspend-to-RAM and raises on the wake, and the display PMC word
that counts the powered coprocessors. The boot loader publishes it with
the compatible apple,t6041-display-power: one node over the east power
manager block for the internal coprocessor, one over the west block
that both external coprocessors name. Describe it, as
apple,t8140-display-power.yaml does for T8140.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The comment on the sleep controller's storage link described how the
boot loader's publish behaves and recalled what a static property had
done on a J616s. Say what the tree has to give and what the boot loader
adds: apple,apcie and the PCIe host's windows and tunables come from
the boot loader, which leaves a node that has apple,apcie alone, so
the tree gives neither.

Comment only; the DTBs are unchanged.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The sleep controller has registers but its node had no unit address,
which dtc reports (unit_address_vs_reg). Name it after its first
register block, as the T8140 tree does. The boot loader and the kernel
find the node by its compatible, not by its path.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The T6040 sleep controller binding sat under power/, the T8140 one
under soc/apple/, for the same kind of block. Move it next to the
T8140 one, give apple,check-ps-b4-sleep-names its string-array type,
and list the file under the Apple SoC entry in MAINTAINERS.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The boot object publishes /chosen/aurora,s2r-mailbox, and the arm64
CPU ops, the spin-table hibernation and the Apple sleep driver read
it, but no binding described it. Document what its presence means and
the layout of the mailbox it points at.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The kernel hibernates on Apple silicon only where the boot object says,
in /chosen, that it keeps the same memory layout on every boot, and it
reads the device tree of the resuming boot at the address the boot
object gives there. Neither property had a binding, and their prefix
was not a registered one.

Register the prefix and describe the two properties. The prefix is the
name of the boot loader that defined them, as u-boot's is: its released
versions publish the properties under this name, so a kernel that
looked for another one would not hibernate with any of them.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The sleep controller cannot enter a suspend or undo one without any of its
eleven register blocks, and every T6040 board lists all of them. Make reg
and reg-names required with all eleven entries instead of accepting a node
with only the first two, and give the example the node it describes.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The soc-east and soc-ps windows are the SOC-East and SOC power word pages,
which the driver reads and writes as one range each: 0xd000 and 0x9000
bytes. Describe them as the pages they are, so that one mapping of each
serves every power word in them.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
Give the soc-east and soc-ps windows of the sleep controller the extent of
the SOC-East (0x502280000) and SOC (0x502800000) power word pages, 0xd000
and 0x9000 bytes, instead of the first 0x1000 of each. The addresses are
unchanged.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The T6040, T8132 and T8140 sleep controllers do the same job and were
described by two schemas that named the same blocks differently. Describe
them in apple,sleep.yaml, with the register names per compatible, and give
the blocks the T6040 shares with the T8140 the T8140's names: cluster for
the CPU complexes' control words, pwrgate for the power-gate and voter
block, spmi for the PMU's SPMI controller and wake for the AOP block with
the wake masks.

The schema keeps what each SoC requires and refuses: the T6040 needs all
eleven of its register blocks, the SOC-East and SOC pages sized as the
driver maps them, and the display power-state table; the T8140 needs its
28 blocks, the wake sources and the display coprocessors; the T8132 its
25 blocks, the clock protection page as an optional 26th, and the display
coprocessors. The controllers are listed in MAINTAINERS under the one file.

The T6040 device tree and driver follow in the next two patches.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
…8140's

Give the register blocks of the T6040 sleep controller that the T8140's
controller has too the names the schema uses for both: cluster, pwrgate,
spmi and wake. The addresses, sizes and order are unchanged; the compiled
tree differs only in those four names.

The driver looks the blocks up by these names and follows in the next
patch.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The T6040 USB4 router runs only over its port's Type-C PHY and tells
the PHY when it starts and stops. The PHY was named in a vendor phandle,
which the router resolved to a device node and looked up by hand for
each call.

Describe it with the standard phys property and the "cio" name the T8132
routers already use for the same PHY, so the PHY framework resolves it
and orders the router after the PHY. The T6040 routers require both.

Not run on a USB4/Thunderbolt device.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
Name each router's Type-C PHY with phys, as the binding now describes,
instead of the vendor phandle. The routers stay disabled here, so no
default board changes. The built J616s device tree passes the router
schema.

Not run on a USB4/Thunderbolt device.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
…llow a platform-fixed layout

Drivers that hand a coprocessor over across hibernation need to know, in their
restore callbacks, whether the image was really restored or the PM core is
unwinding an aborted hibernation. Add pm_hibernate_is_restored() (with a Rust
helper) and let a boot chain that keeps the memory layout fixed (aura hib=1)
admit hibernation where the platform would otherwise be refused.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
With Linux at EL2 under aura, secondary CPUs come up from a spin table and the
boot CPU has no enable-method. Let the spin-table CPUs be parked and released
again across hibernation and suspend-to-RAM (a pen in the kernel image the
locked RVBAR relay returns to), restore the EL2 state the hibernation resume
needs, and keep the T6040 errata on the restored CPUs.

An offlined RVBAR spin-table CPU waits in the kernel's own text, so
spin_table_cpus_stuck() refuses kexec and hibernation for it. For a hibernation
the pen is what takes those CPUs out of the memory the restore overwrites: a
kernel that has it (KEXEC_CORE, for cpu_soft_restart()) is not stuck there, and
swsusp_arch_suspend() asks spin_table_hibernate_cpus_stuck() instead. kexec
keeps the check.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
…or handoff

aura-hibernate reads the fixed boot layout aura publishes (hib=1) and refuses
hibernation without it. RTKit gains a cold-restart/re-adopt path for a
coprocessor the restored kernel finds running (or halted) under it, used by
the DCP, AOP, SEP, ANE and SMC drivers after S4 and S2R.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
…s again in a sleep

A guest's virtual and physical counters are the host's physical counter
minus an offset that is fixed when the VM is created. A resume from disk
is a cold boot: the physical counter has started again, and with the old
offsets the guests' counters read less than before the hibernation. A
Linux guest takes a clocksource that went backwards for no time passed.
It still gets its timer interrupts, but its clock stands still until the
host's counter has caught up with the old value, which takes as long as
the host had been up.

J616s, a guest with two vCPUs that prints its uptime every second, host
up for an hour, hibernation and resume: the guest's CVAL went from
0x2076a3246c to 0xfffffce7b9ce8d2f, the guest took a timer interrupt
every half second and printed nothing more.

Keep the counter's value in a syscore suspend callback. If it reads less
in the resume, move every VM's virtual and physical offset by the
difference: the guests' counters go on from the value they had when the
system went down, as for a VM that was stopped for that long. The time
the machine was off is not shown to the guests. A counter that keeps
running through a sleep is left alone, and the guests see that sleep as
time that passed, as before.

The same guest with this change: "the counter started again in the
sleep (446875224457 -> 92491224896): the counters of 1 VM(s) kept", and
the guest prints on after the resume with its uptime continuous. A
suspend to RAM before and one after that hibernation leave it running
too; the counter runs through those and the guest's uptime steps by the
25 s of the sleep.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The arch/arm64/configs/asahi.config part of "soc: apple: share the sleep
registry so one kernel builds both controllers", which goes with the
hibernation core changes; the rest of that commit is with the sleep
controller changes.

The T8140 sleep driver (sleep.c) and the T6040 one (t6040-sleep.c) each
defined the coprocessor and enclave registry that drivers reach through
<linux/soc/apple/sleep.h>, so the two exported the same nine symbols and
APPLE_T6040_SLEEP had to depend on !APPLE_SOC_SLEEP. The universal
config sets APPLE_SOC_SLEEP, so it never built the T6040 controller.

Move the registry into sleep-registry.c behind a hidden
APPLE_SLEEP_REGISTRY that both options select. The table holds six
entries and the superset of the two records. Each controller binds to
the registry in its probe with two answers of its own: whether this
sleep's commit stops the registered coprocessors, and whether an
enclave registration is taken. Both keep their earlier rules: T8140
answers from its own state and pm_suspend_via_firmware() and takes an
enclave only when its commit stops coprocessors; T6040 answers as
before and takes every enclave. With no controller bound the commit
stops nothing and an enclave registration is refused. The controllers
bind only to their own compatibles (apple,t8140-sleep,
apple,t6040-sleep), so at most one is bound and installs suspend_ops.

Drop the dependency, give the registry prototypes their own guard in
sleep.h so every combination compiles, and enable APPLE_T6040_SLEEP in
asahi.config.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
create_image() sets hibernate_restored inside if (!in_suspend), which
is reached only in a kernel restored from an image: there the arch
code has cleared in_suspend and swsusp_arch_suspend() returned 0. So
!error is always true at that point; store true.

No functional change.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The comment that explains what hibernate_boot_layout() covers sat above
hibernate_mix_span(), directly on top of that function's own comment.
Move it to hibernate_boot_layout().

Comment move only, no functional change.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The comment over the parking spin table said that CPU hotplug fails
until a platform driver provides the power ops. Since the parked CPU
comes back through cpu_soft_restart(), only stopping the parked CPUs
for a suspend needs them (spin_table_hold_parked() refuses without);
hotplug needs KEXEC_CORE. Say so, and rejoin a line break in the pen
comment.

Comments only, no functional change.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
…yout and ops tests

The T6040 sleep controller is always in the match table now, and it keeps
its sequences in a part of its own: its SoC data carries no cluster, MCC or
wake word counts and no operations table. The books and wake-name tests
already pass over such an entry; the layout and operations tests did not
and failed on it.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The device tree names the T6040 sleep controller's cluster, power-gate,
SPMI and wake blocks as the schema names them for the T8140's: cluster,
pwrgate, spmi and wake. Map them under those names, and name them so in
the probe message and the comments. The blocks, their order and every
access to them are unchanged.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The GP PCIe host's ports are stopped, and its power states lowered, only
while its system domain is still on, and both places read the domain's
power word and test the same field on their own. Put the test in one
helper so the two cannot drift apart; each user still reads the word where
it did before, and the lowering stays in its one function.

The object code is identical to the one before.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The drivers/mfd/macsmc.c part of "PM: hibernate: tell drivers that an
image is being loaded", which goes with the sleep controller changes;
the rest of that commit is with the hibernation core changes.

A driver that must treat the kernel loading a hibernation image
differently from a kernel that freezes for an image of its own has no
way to ask: the freeze callbacks run the same in both. The SMC driver
and the RTKit hand-off each registered a PM notifier that sets a flag on
PM_RESTORE_PREPARE and clears it on PM_POST_RESTORE, and the hand-off
copy is read by two more drivers.

Keep the flag in the PM core, next to the restored flag, and have the
two notifier helpers set it around the PM_RESTORE_PREPARE and
PM_POST_RESTORE notifications, whether the load starts from the resume
path or from the snapshot device. pm_hibernate_is_loading() reads it.
It is true from before the first notifier runs (the copies became true
only when their own notifier was reached) until PM_POST_RESTORE has been
delivered, and it is cleared again when a notifier refuses the load,
where the copies of the notifiers not reached never became true. It is
saved in an image as false, like the notifier copies, so the restored
kernel reads false.

The SMC driver reads the core flag in its freeze callback and drops its
notifier, which also removes the registration at probe. The RTKit
hand-off keeps apple_rtkit_hib_restoring() for its callers and answers
it from the core flag.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The drivers/soc/apple/Kconfig part of "PM: hibernate: let the platform
refuse hibernation through a hook", which goes with the sleep controller
changes; the rest of that commit is with the hibernation core changes.

hibernation_available() asked of_machine_is_compatible("apple,arm-platform")
and aura_hibernate_layout_fixed() in the generic hibernation code, and the
log line carried the reason of one platform.

Add hibernation_set_platform_check(): platform code registers a function
that is true while hibernation must stay refused, with the reason that is
logged at the end of the boot when it is. hibernation_available() asks it
where it asked the two Apple conditions. The aura hibernation code
registers aura_hibernate_blocked(), which is the same expression
(Apple platform and no fixed layout), evaluated at the same moments, and
the same reason text; the explanation of why the machines refuse moves
with it.

The check is registered from the init of that code on every boot of a
kernel that has it, where the Apple condition used to be compiled into the
core unconditionally. To keep that fail-closed, APPLE_AURA_HIBERNATE is no
longer a prompt: it is always on with ARCH_APPLE and HIBERNATION, as the
refusal belongs to it. Nothing registers before that init runs, which
precedes the first possible hibernation (the resume check is a later
initcall level and user space starts after all of them).

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
iBoot boots sepOS anew on every boot and the SEP has no run bit the AP
can read, so its resume from disk asked the PMP: the PMP's restore counted
the resumes that found the PMP halted, and the SEP's notifier, one
priority below the PMP's, compared the count taken at registration and at
each hibernation's prepare and end. That tied the SEP to the PMP driver
(a Kconfig dependency, a count, an export and a call from the PMP's
restore) and to the order of two notifiers.

pm_hibernate_restored_cold() answers the same question in the one place
that knows it: whether another boot loaded the image. The notifier asks it
where it compared the counts. Not restored (aborted hibernation, wake of a
hybrid sleep): warm, as before. Restored and loaded by another boot: the
cold path, the session is dropped and the device probed again. Restored by
the kernel that wrote the image (test_resume): warm; the PMP found itself
running there too. No record: the session is dropped without a probe,
which is what a missing PMP count did.

On the J616s the boot that loads an image always restarts the PMP, so
the two signals agree on a resume, a test resume and an aborted
hibernation. They differ where a boot that loaded an image did not restart
the firmware (a kexec-style resume), and for a machine without a bound
PMP, which can now tell. The PMP's own restore is unchanged: it still
reads the ASC run bit and only stops reporting a count.

The host test now drives the end of a hibernation through the notifier
for an aborted hibernation, a resume after another boot, a test resume and
a missing record, with three mutations that each fail it.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
…nation

An abandoned hibernation resumed its devices with PMSG_RESTORE, so every
restore callback that must not act on a state it never lost began with a
pm_hibernate_is_restored() check, and most forwarded to their thaw. The PM
core now sends PMSG_RECOVER there, which reaches the thaw callbacks, so the
check and the forward go from macsmc, the RTKit helper, apple-dart, the
sn201202x Type-C controller, the SPMI, GPIO and NVMe restore paths, both
PCIe restore callbacks, the DCP and AOP restores, the t6040 USB2 PHY's two
and the RTC; cs42l84's restore passes that the codec lost its state.

Each callback runs for a restored kernel exactly as before. For an abandoned
hibernation the old path was already the thaw or nothing, and the thaw now
runs on its own: macsmc, the RTKit helper, apple-dart, sn201202x, NVMe and
cs42l84 forwarded to the same function (cs42l84's resume asks
pm_resume_via_firmware(), which hibernation_snapshot() has cleared); PCIe's
restore_noirq did for a bridge without hibernation tunnelling what its
thaw_noirq does, and the same call with it; the AOP, t6040, RTC, GPIO and SPMI
restores did nothing and have no thaw. DCP keeps its power-off-failed branch
(PMSG_RESTORE after a failed platform power-off, which only a platform with
hibernation ops reaches) and loses the abandoned one, whose only other
effect was a log line.

One path changes: macsmc's thaw, after the SMC was handed over and the image
could not be entered, calls apple_smc_restore() to start a new session, and
its own check sent that back to the thaw, which did nothing. It now
starts the session as the comment says it should.

The flag keeps its other users, which are not restore callbacks: the AIC
syscore resume, the dockchannel receive interrupt, the SEP's PM notifier.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The T6040 sleep controller wrote the SMC key pmVC itself, with the key,
the value 0x101 (the J616s enable mask | 0x100) and the failure text
all living in sleep-t6040.c. The SMC key space belongs to the SMC
driver, so move that knowledge here: apple_smc_request_pmvc() performs
the same u32 write of 0x101 to pmVC and warns with the same text when
it fails. include/linux/mfd/macsmc.h declares it, with a -ENODEV stub
when the SMC driver is not reachable.

The moment of the write is unchanged. It is deliberately not made a
suspend callback of the SMC driver: that would run relative to the
USB-C controller's prepare step, which hands the port controller to the
S3 state, in a device-list order rather than the order the sleep
controller has today. sleep-t6040 still looks the SMC up by its
compatible as before and calls the helper from the same point of its
.begin, after the AOP island save and before the DCS power setup, with
the same warning when no SMC is there (now logged without the value).
The write reaches the SMC with the same key, size and value.

Hardware test: one suspend to RAM with a USB-C device attached and
powered; the log shows no "pmVC:" warning, the ATC port hand-over
completes, and the device is still present after the wake.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
…disk

The PMC's early resume writes the agent enables and the floors back from
the driver's books, but only when pm_resume_via_firmware() is set, which
the S2R path does. The same callback is the restore_early callback, and
a kernel restored from a hibernation image never sets it, so the restore
skipped it. That kernel runs after a boot loader that started from a
reset PMC, which leaves every agent disabled on every rail: the floors
are still written, but none is honoured.

On the J616s (T6040) after a resume from disk the PMC reads 0 in every
rail enable word and "honoured" 0 for the PMP's and the performance
controller's DCS 5 / fabric 2 floors, so the memory clock stays at its
lowest state until the next boot. Memory-bound GPU work is the visible
part: token generation of a 4B language model ran at 36 instead of 55
tokens per second, while compute-bound prefill was unchanged.

Split the restore out of the resume callback and run it from a
restore_early callback of its own without the check. The S2R resume
path is unchanged. A KUnit case clears the enable words after an agent
enable and checks that the restore writes them back.

Hardware test on the J616s, one resume from disk from the desktop: the
DCS and SOC enable words read 0xb, both floors are honoured, a CPU memory
copy runs at 123 GB/s (31 GB/s without the fix) and the same model
decodes at 58.6 tokens per second.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
…nd S2R

Restore or re-adopt the platform coprocessors after a power loss: PMP report
export, AOP with its firmware-driven sleep (run bit taken over cold when
halted), the SEP and its enclave store, DockChannel.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
…nsor across sleep

Re-open the DockChannel HID transport and the AOP light sensor after S4 and S2R.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
After a real T6040 S2R the PMP never answered its restart (endpoint
discovery -62), and the GPU, whose wake asks the PMP, was lost with it:
T6041 kept no SRAM across the sleep, its sram_backup was None.

The ADT's segment-ranges place the PMP firmware in its SRAM region:
__TEXT at 0x500700000 (0x61000 bytes), __DATA at 0x500761000 (0x7d000
bytes). Keep __DATA, the segment T8140's kept range covers, through
the commit's existing copy and the wake's write-back.

To tell whether the text, which nothing keeps, survives the sleep, the
commit reads one text word per 4 KiB and the wake compares them before
the restart (T6040 only, read only, inside __TEXT).

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The codec had no PM callbacks. Its level-low interrupt thread kept
running over the sleep and read the codec over I2C while the bus and the
codec went down, and after a T6040 S2R, which cuts the codec's power,
the codec came back with its reset defaults: no plug detection set up,
and its interrupt thread was found stuck after the wake.

Disable the interrupt and the remote-button polling from the suspend to
the resume. After a sleep that cut the power, reset the codec as probe
does, write its registers back from the cache (LATCH_TO_VP first, as the
plug detection set-up does) and report a jack that was seen before as
gone: one still plugged in raises the plug interrupt again. After a
sleep that kept it powered, poll a headset's buttons again.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The PMP registers its stop with the sleep controller once and never
undoes it. On T8140 that is why its driver cannot be unbound: an unbound
PMP still runs, its stale registration is never readied again and
refuses every sleep until reboot. The T6040 sleep controller keeps the
same registration, so the same holds there.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
On T6040 the stop at the sleep's commit read one word per 4 KiB of the
PMP firmware's text, the resume read them again and logged how many had
changed. That answered whether the sleep keeps the text; nothing acted
on the result.

Drop the sampling, its log line and the offset that only it took from
the commit stop's description. The SRAM range kept across the sleep is
saved and restored as before.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
Two comments on the cold restart cited a test: an unverified
measurement on T8140 and a firmware crash seen on J616s. Say instead
what the hardware does: a co-processor that keeps running through the
sleep has its run bit set, and a firmware started under doorbells left
in the mailbox takes them as its own first messages, which it does not
survive while its endpoints come up.

Comments only, no functional change.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The restore comment quoted two log lines and the T6041 SRAM comment an
error code from a test. Say what happens instead: without the restore
the firmware stays down and its clients wait for it, and without the
SRAM kept the PMP does not answer its endpoint discovery after a sleep
that powered the SoC down.

Comments only, no functional change.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The comment told the writes step by step. Say what the sensor
takes instead: a zero interval when the system sleeps, the previous
interval when it wakes.

Comment only, no functional change.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The restore callback, its dev_pm_ops and the driver's .pm pointer were
in #ifdef CONFIG_HIBERNATION blocks. Build them unconditionally and
use pm_sleep_ptr(), the usual idiom; without CONFIG_HIBERNATION the PM
core never calls .restore_noirq.

With CONFIG_HIBERNATION the object code is unchanged.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The hibernation callbacks sat in an #ifdef CONFIG_HIBERNATION block,
and the #else defined simple PM ops instead. Without
CONFIG_HIBERNATION the PM core never calls .freeze, .thaw or .restore,
so one dev_pm_ops with pm_sleep_ptr() serves both configurations;
the #else goes.

With CONFIG_HIBERNATION the object code is unchanged.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
A resume from disk goes through a boot. The codec then holds its reset
defaults, or what the kernel that loaded the image wrote, while the
restored kernel's register cache holds the state of the image. The
restore callback was the resume one, which writes the registers back
only after a firmware-driven suspend: after a hibernation the codec
kept the wrong registers, the plug detection and the interrupt masks
among them, and a jack plugged before the hibernation stayed reported
although nothing drove it any more.

Give the restore its own callback: after a real restore it resets the
codec, writes the cache back and reports a jack gone, as the resume
does after a suspend that cut the power. A hibernation given up before
its image goes on as before.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The receive interrupt handler first reads the FIFO count and, below
the programmed threshold, writes the threshold again and treats the
interrupt as spurious. That repairs one situation: after a resume from
disk the threshold register holds what the boot left, while the
restored interrupt state says that receive is armed. But it ran on
every receive interrupt of every SoC, with a register read of its own,
and it held back an interrupt that came early for any other reason,
which the clients have always handled by reading what is there.

Run it only in a kernel that was restored from an image. Elsewhere the
handler takes every receive interrupt as it did.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The FIFO interrupt chip passed a wake request on to its parent
interrupt at the AIC, on the grounds that a suspend to RAM masks every
AIC interrupt that is not a wakeup source. Nothing does: the AIC chips
skip set_wake themselves, and a firmware-driven suspend masks every
AIC interrupt and brings the masks back from the IRQ core's books. No
client arms a FIFO interrupt for wake either: data that has to wake
the system is reported with pm_wakeup_hard_event().

Put IRQCHIP_SKIP_SET_WAKE and its comment back. No functional change:
nothing called the callback.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The drivers/soc/apple/pm.rs, drivers/soc/apple/sep.rs part of "soc:
apple: sep: probe again through the aura reprobe helper", which goes
with the coprocessor changes; the rest of that commit is with the sleep
controller changes.

After a resume from disk on a cold boot the SEP is unbound and probed
again once the tasks are thawed, to register with the restarted
enclave. The driver carried its own work item, spinlock, pending-device
pointer and a module-exit guard to cancel the work.

aura_hibernate_reprobe_after_thaw() does the same unbind and probe from
the freezable workqueue, which the restore finds frozen, so the probe
cannot start before every device's restore has completed. The helper is
built in, so a module going away in the meantime leaves no work behind
and needs no cancel.

The registration marker is still removed before the probe is queued,
and only once a cold boot is established, as before. A probe that
leaves the device without a driver is not reported by device_reprobe();
the helper now logs that case too, as the SEP's own work item did.

Without CONFIG_APPLE_AURA_HIBERNATE the probe is not queued and the
driver says so, as the AOP does.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The drivers/soc/apple/pmp-export.c, drivers/soc/apple/pmp.rs,
include/linux/soc/apple/pmp.h part of "soc: apple: sep: learn a cold
resume from the PM core, not from the PMP", which goes with the
coprocessor changes; the rest of that commit is with the sleep
controller changes.

iBoot boots sepOS anew on every boot and the SEP has no run bit the AP
can read, so its resume from disk asked the PMP: the PMP's restore counted
the resumes that found the PMP halted, and the SEP's notifier, one
priority below the PMP's, compared the count taken at registration and at
each hibernation's prepare and end. That tied the SEP to the PMP driver
(a Kconfig dependency, a count, an export and a call from the PMP's
restore) and to the order of two notifiers.

pm_hibernate_restored_cold() answers the same question in the one place
that knows it: whether another boot loaded the image. The notifier asks it
where it compared the counts. Not restored (aborted hibernation, wake of a
hybrid sleep): warm, as before. Restored and loaded by another boot: the
cold path, the session is dropped and the device probed again. Restored by
the kernel that wrote the image (test_resume): warm; the PMP found itself
running there too. No record: the session is dropped without a probe,
which is what a missing PMP count did.

On the J616s the boot that loads an image always restarts the PMP, so
the two signals agree on a resume, a test resume and an aborted
hibernation. They differ where a boot that loaded an image did not restart
the firmware (a kexec-style resume), and for a machine without a bound
PMP, which can now tell. The PMP's own restore is unchanged: it still
reads the ASC run bit and only stops reporting a count.

The host test now drives the end of a hibernation through the notifier
for an aborted hibernation, a resume after another boot, a test resume and
a missing record, with three mutations that each fail it.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
…abandoned hibernation

The drivers/soc/apple/aop.rs, sound/soc/codecs/cs42l84.c part of "soc:
apple: drop the restore callbacks' checks for an abandoned hibernation",
which goes with the coprocessor changes; the rest of that commit is with
the sleep controller changes.

An abandoned hibernation resumed its devices with PMSG_RESTORE, so every
restore callback that must not act on a state it never lost began with a
pm_hibernate_is_restored() check, and most forwarded to their thaw. The PM
core now sends PMSG_RECOVER there, which reaches the thaw callbacks, so the
check and the forward go from macsmc, the RTKit helper, apple-dart, the
sn201202x Type-C controller, the SPMI, GPIO and NVMe restore paths, both
PCIe restore callbacks, the DCP and AOP restores, the t6040 USB2 PHY's two
and the RTC; cs42l84's restore passes that the codec lost its state.

Each callback runs for a restored kernel exactly as before. For an abandoned
hibernation the old path was already the thaw or nothing, and the thaw now
runs on its own: macsmc, the RTKit helper, apple-dart, sn201202x, NVMe and
cs42l84 forwarded to the same function (cs42l84's resume asks
pm_resume_via_firmware(), which hibernation_snapshot() has cleared); PCIe's
restore_noirq did for a bridge without hibernation tunnelling what its
thaw_noirq does, and the same call with it; the AOP, t6040, RTC, GPIO and SPMI
restores did nothing and have no thaw. DCP keeps its power-off-failed branch
(PMSG_RESTORE after a failed platform power-off, which only a platform with
hibernation ops reaches) and loses the abandoned one, whose only other
effect was a log line.

One path changes: macsmc's thaw, after the SMC was handed over and the image
could not be entered, calls apple_smc_restore() to start a new session, and
its own check sent that back to the thaw, which did nothing. It now
starts the session as the comment says it should.

The flag keeps its other users, which are not restore callbacks: the AIC
syscore resume, the dockchannel receive interrupt, the SEP's PM notifier.

Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
@fbalazsy

Copy link
Copy Markdown
Contributor Author

Closing: this stack is based on integration/aurora from 2026-11-14 and now conflicts with the sleep and spin-table work that landed since. I will rework the J616s (T6040) support on top of the current tree and open a new, smaller series.

@fbalazsy fbalazsy closed this Nov 18, 2026
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