Repository navigation
Conversation
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>
The driver wrote MBSE = slpw at .prepare and, when the suspend was called off before the commit, MBSE = waka at .complete. The SMC does not take the warning back. On a J616s, after a suspend that stopped before the commit (the SMC got slpw and then waka, about a second apart), the SMC no longer ran the fans: both stood at 0 rpm with the CPU die at 100 to 113 C under load, and a fan request was refused, until the reboot. Before that suspend, in the same boot, the SMC had started the fans by itself and had taken a request. The sensor reports stayed live, so this is not the standstill a refused commit leaves. A device that refuses and a wake event during the device suspend are ordinary ends of a suspend, and each left the machine without its fan policy. Send the warning in the noirq suspend, right before the commit and only when the suspend goes on to the power loss, which is the path a sleep that cuts the debug link already takes: slpw, 200 ms of polling, then the WKTP key, slpa and the AP idle notice. A suspend that ends before that sends the SMC nothing. What can refuse after the commit still leaves the SMC in its sleep state; the message for that case stays. The KUnit case for a suspend that stops short of the power loss now expects no command at all. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
A T6041 SMC takes neither MBSE = slpw nor the commit after it back, and
only a completed sleep or a reboot brings it out again. The driver sends
both in its noirq suspend. A sleep can still be refused after that: a
wake event that the PM core finds pending after the noirq phase, a CPU
that does not park, the sleep controller's checks at its commit, the
enclave before it sends its sleep request. The SMC then has slpw, WKTP,
slpa and the AP idle notice and no power loss, and its driver can only
say so ("sleep refused after the SMC's commit").
The T6040 sleep controller stops coprocessors at its commit: with
interrupts off, one CPU up and every refusal behind it, the enclave's
sleep request being the last of them. Register the SMC there, among the
stops that run first, and send the whole sequence from that stop: slpw,
200 ms in which the mailbox is polled, WKTP = 2, slpa, 6 ms, the AP
idle notice and 30 ms, as the noirq suspend sends them. The noirq
suspend then sends nothing, so a sleep refused anywhere before the last
stops leaves the SMC as it was, and so does a dry run, which never
reaches them. The wake is unchanged: it follows ap_notified, which the
last stop sets.
Against the noirq suspend the sequence now comes after the enclave's
sleep request instead of before it, because that request can still be
refused. It stays ahead of the other coprocessors' stops: those
registered as first run in the order of the registry's table, where the
SMC takes its place at probe and the only other one, the GPU, takes a
free place for each sleep. That place is a later one unless a driver
that registered before the SMC has been unbound since.
Nothing can sleep at the last stop and the RTKit worker does not run,
so the keys go through apple_smc_write_atomic() and the notice through
apple_rtkit_ap_idle_polled(). Atomic mode was only ever entered for a
shutdown; the last stop enters it and leaves it again, giving up an
answer that is still missing, so that the wake's commands are the usual
ones. apple_smc_write_atomic() timed its poll with ktime_get(), which
warns while timekeeping is suspended, as it is here: it reads the fast
monotonic clock instead. An event the SMC sends during the sequence is
taken from its outbox and reaches its handler after the wake.
A last stop cannot refuse, and the sleep goes on whatever it returns.
If the SMC fails a step, the step is logged and the rest is sent all
the same: an SMC that took the warning leaves its sleep state only
through the rest of the sequence and the power loss. The wake then
sends its part as after any sleep. With an SMC that answers nothing,
each write waits out its 5 s timeout with interrupts off.
Only the T6041 SMC registers. Every other SoC, a kernel that does not
run the last stops (below EL2, or without the sleep controller) and a
full registry keep the noirq suspend exactly as it is; T8140's order,
with the debug link's cut before the warning, was measured there. The
cut and its outbox poll stay in the noirq suspend for both paths: the
cut sleeps, and it has to precede the warning. The T6040 controller
has no cut, so that call does nothing there.
The existing KUnit cases describe the noirq path and pass unchanged.
New cases cover the last stop: nothing is sent in the noirq suspend
and the whole sequence comes from the stop, once; a refusal before the
stop sends nothing at the suspend and nothing at the resume; the wake's
sequence follows a stop, also one in which every step failed.
J616s, one boot: a dry run and a sleep refused before the enclave's
request leave the SMC without a single message, with its sensor
reports live and the fans under its control; four sleeps, one of them
right after the refusal and one after a hibernation, go through the
last stop (no message from the SMC in the 200 ms) and wake with the
usual record. A wake event during the entry was not tried.
Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The T6041 driver idled the SIO firmware in the late phase of a suspend to RAM. An idled firmware does not come back with its power kept, so a sleep refused after that phase left it stopped until the next sleep that went through: on a J616s a refusal of the enclave's sleep request logged "sleep refused: firmware not back after a reset (-19), stopped until a real sleep", and the DMA service and the AES engine behind it were gone. Register the stop for the sleep's last step, as the T8140 does: the AP and IOP power idle with interrupts off, after the last refusal. A sleep refused before that finds the firmware running. A dry run of the T6040 sleep stops no coprocessor, and counted a registered one that was not ready as a check that a real commit would fail. Report the firmware ready in a dry run as well. On a J616s: after a sleep refused at the enclave's request and after a dry run the engine still encrypts and decrypts 16 MiB in each of CBC, CTR and ECB equal to the software implementation, the dry run reports no failed check, and suspends to RAM and to idle after them complete with the firmware back. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
… not answer The sleep controller's last stop sends the SMC four commands with interrupts off: the sleep warning, WKTP, the sleep arm and the AP idle notice. A command waits up to 5 s for its answer, and the next one waits as long again for an answer still missing from the one before. An SMC that does not answer at all therefore held the CPU for up to 15 s with interrupts off before the sleep went on. Stop after the first command that gets no answer (timeout, or the answer to the one before still missing) and return the failure. The sleep goes on as before, and no idle notice is owed to the wake. An SMC that does answer gets the whole sequence unchanged. The KUnit case for an SMC that answers nothing now expects the warning only; a second case covers the answer that is still missing. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
…xport The coprocessors registered first (the SMC and the GPU) ran their last stops in the order of their slots in the registry table, which follows the order of their probes. The SMC's warning and commit have to come before the GPU's stop, so name the order: apple_sleep_coproc_register_first() takes an APPLE_SLEEP_FIRST_* value and the first pass runs the stops by it. The order on the J616s is the one the table gave so far. The G16 GPU of the T8132 registers in the GPU's place. apple_sleep_debug_link_up() has no caller since the debug link is cut and read back inside the sleep controller; remove it with its stub. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
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>
A suspend to RAM that is refused for a live blocker returned only after .begin had saved the AOP island power words, written the SMC rail request, set the DCS blocks to dynamic power gating and raised their power words to automatic mode. None of that is undone when the suspend is refused, so a refused "mem" changed the hardware it was refusing to suspend. Take the refusal decision first: with a non-display blocker left and no dry run, log the blockers and return -EOPNOTSUPP before any of those writes. A suspend that proceeds and a dry run make the same writes in the same order as before, and the commit point is untouched. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The sleep node of every T6040 board (J614s, J616s, J773s, through t6040.dtsi) lists all eleven register blocks, and a suspend cannot be entered or undone without any of them: the commit would not arm the deep wait for interrupt and the wake could not restore the SoC. The driver nevertheless took each block as optional, guarded every access with a NULL test, and only refused the suspend at the commit point for six of them. Map the blocks first in probe and fail the probe when one is missing, so a node without them never offers a suspend, and drop the NULL tests and the now unreachable refusal. The accesses, their order and the commit point are unchanged. The binding already requires all eleven. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The driver mapped the SOC-East page (0x502280000) twice, as soc-east for its first 0x1000 bytes and at a fixed address for 0xd000 bytes, and the SOC page (0x502800000) twice, as soc-ps and for 0x9000 bytes. Both pairs are the same non-posted window. Take the extent from the node now that it describes the whole page, and use soc-east and soc-ps for every power word. A node whose window is smaller than the pages the driver accesses fails the probe instead of leaving later accesses outside the mapping. Only base pointers change; the accesses and their order are the same. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The coprocessor and enclave table lives in sleep-registry.c, but the functions that walk it at the commit point sat in sleep.c, the controller of one SoC. Every controller that is bound on a SoC uses them, so they belong with the table. Move the readiness refusal, the last checks, the stop passes, the enclave's stop and the debugfs listing, together with the helpers they alone use, and declare the one that sleep.c still calls. The code is unchanged. sleep.c's enter function now calls the check for a power word that a coprocessor's last stop lowers where it had it inlined. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
Each sleep controller handed the registry a table of two callbacks, whether its commit stops the registered coprocessors and whether an enclave may register. Both answers follow from three facts the registry can hold itself: a controller is bound, its probe is complete, and a suspend goes through firmware without being a dry run. The only difference between the SoCs is that T6040 takes every enclave registration, a dry run included, and T8140 only while such a commit is the case. Have the controller bind with a flag for that, tell the registry when its probe is complete, and drop struct apple_sleep_ctl and the callbacks. T8140 needs no dry-run test because its dry-run level is never raised, and it binds only at EL2. The answers are the same at every point of the probe and of a suspend. The SEP host test now extracts apple_sleep_power_loss() instead of the two callbacks and models the registry's state; all of its mutations still fail. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The lid's state and the radio's wake answer, the USB wake ports and the sleep's decision to take none of them were kept in sleep.c, the controller of one SoC, and a part that declined them called a setter at the start of its probe. They are answers any controller gives, so move them next to the registry, and have a controller say what it takes when it binds, as it already does for enclaves. A controller bound without the lid or the USB wake ports gets the answers of a kernel with no sleep driver, and so does a kernel with no controller bound. apple_sleep_set_part_plain_wake() goes, and with it the state that was set before the probe could fail. A T6040 probe that fails after that point used to leave the lid and USB wake ports declined with no controller bound; they now answer as they do with none, which is what their description says. Nothing else changes: T8140 binds with both capabilities, T6040 with neither, and the answers while bound are the same. The T8140 sleep's start forgets the two wake answers through one call. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
APPLE_SLEEP_REGISTRY has only one selector, APPLE_SOC_SLEEP, and the registry is linked into the same object as the controller, so the symbol selects nothing a user could choose. APPLE_T6040_SLEEP exists for the dependency of the T6040 sleep on the SMC driver and for MFD_SYSCON, but a board that has no T6040 sleep controller already gets none: the node's status in the device tree is the switch. Link the registry into apple-sleep, build the T6040 sleep wherever the SMC driver is built in, as before, and select MFD_SYSCON in that case. The T6040 documentation moves to APPLE_SOC_SLEEP. A kernel with APPLE_SOC_SLEEP and the SMC driver as a module still builds the T8140 sleep alone; with both built in it now also carries the T6040 sleep. The asahi config fragment no longer sets the removed symbol. 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>
fbalazsy
force-pushed
the
j616s/split-sleep
branch
from
November 14, 2026 18:21
816f456 to
7fbe928
Compare
AxxzyWasTaken
added a commit
to AxxzyWasTaken/linux
that referenced
this pull request
Nov 15, 2026
The sleep commit writes WKTP = 2 on T6041, but nothing wrote it back.
With the key left at 2 the SMC treats all the time awake after the first
sleep as a power nap: it keeps its own fan policy against a fan request
(on the J616c every fan target write timed out after about 10 s and the
fans stayed at 0 rpm under load), and under thermal load it requests a
sleep once a second ("SMC Thermal pressure requested Sleep during power
nap" in its syslog), slowing the machine down. Only a reboot cleared it.
Write WKTP = 0 after a full wake, and when the sleep ends in a refusal
(apple_smc_complete), as the M4 Pro sleep series in aurora-silicon#1910 does. A dark
wake keeps the key: it sleeps again, and the next commit writes it anyway.
Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
AxxzyWasTaken
added a commit
to AxxzyWasTaken/linux
that referenced
this pull request
Nov 17, 2026
The sleep commit writes WKTP = 2 on T6041, but nothing wrote it back.
With the key left at 2 the SMC treats all the time awake after the first
sleep as a power nap: it keeps its own fan policy against a fan request
(on the J616c every fan target write timed out after about 10 s and the
fans stayed at 0 rpm under load), and under thermal load it requests a
sleep once a second ("SMC Thermal pressure requested Sleep during power
nap" in its syslog), slowing the machine down. Only a reboot cleared it.
Write WKTP = 0 after a full wake, and when the sleep ends in a refusal
(apple_smc_complete), as the M4 Pro sleep series in aurora-silicon#1910 does. A dark
wake keeps the key: it sleeps again, and the next commit writes it anyway.
Assisted-by: LLM
Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
AxxzyWasTaken
added a commit
to AxxzyWasTaken/linux
that referenced
this pull request
Nov 17, 2026
The sleep commit writes WKTP = 2 on T6041, but nothing wrote it back.
With the key left at 2 the SMC treats all the time awake after the first
sleep as a power nap: it keeps its own fan policy against a fan request
(on the J616c every fan target write timed out after about 10 s and the
fans stayed at 0 rpm under load), and under thermal load it requests a
sleep once a second ("SMC Thermal pressure requested Sleep during power
nap" in its syslog), slowing the machine down. Only a reboot cleared it.
Write WKTP = 0 after a full wake, and when the sleep ends in a refusal
(apple_smc_complete), as the M4 Pro sleep series in aurora-silicon#1910 does. A dark
wake keeps the key: it sleeps again, and the next commit writes it anyway.
Assisted-by: LLM
Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part 3/9 of the split of #1477 into smaller pull requests. Depends on #1909: GitHub cannot stack pull requests from a fork, so this one also carries the commits of #1903, #1904, #1909; its own are the last 113, from af65ee2 on (29 files changed, 5963 insertions(+), 759 deletions(-)).
The T6040 (M4 Pro) part of the Apple sleep controller and the platform drivers whose state it needs across hibernation and suspend-to-RAM:
soc: apple: sleep,sleep-t6040t6040_sleep.allow_entry=1, see Kconfig)mfd: macsmc,power: resetspmi,rtc: apple-pmupinctrl: appleirqchip/apple-aic,pmdomain: apple,dmaengine: apple-sio,cpufreqsoc: apple: sep(C shim)The one-line update of the G17 GPU's caller of
apple_sleep_coproc_register_first()is here, with the API change it follows.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.