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 drivers/nvme/host/apple.c part of "soc: apple: sleep: t6040: one prefix rule for the step functions", which goes with the PCIe, storage and radio changes; the rest of that commit is with the sleep controller changes. Steps on one block were named both t6040_sleep_<verb>_<block>() and t6040_<block>_<verb>(). Keep t6040_sleep_* for the driver's own frame (suspend operations, probe, mapping, blockers, the commit and the wake return) and name each step on a block t6040_<block>_<verb>(), as most of them already were. No functional change: the object is unchanged but for the symbol names. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The comment over apple_dart_reimport_locked() quoted a client's error message and named where it was seen. The failure it describes, every DMA mapping through the DART, says enough. Comment only, no functional change. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
Every resume from disk printed an info line per locked DART, ending in an unexplained number. Print it at debug level and say that the number is the first error. Only a log call changes. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The restore callback and the re-import sat in an #ifdef CONFIG_HIBERNATION block, with an #else in the dev_pm_ops that pointed .restore at the resume callback. Without CONFIG_HIBERNATION the PM core never calls .restore, and pm_hibernate_is_restored() is false there, so the restore callback falls back to the resume one by itself. Build it unconditionally and set it with pm_sleep_ptr(). With CONFIG_HIBERNATION the object code is unchanged. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
A BCM4388 that a suspend to RAM left without its firmware cannot answer a command until the function was reset and the firmware booted. The resume still called hci_resume_dev() on it: the core sent the commands of its resume, the send callback refused each one, and every wake logged them at error level before the transport was restarted: Bluetooth: hci0: sending frame failed (-19) Bluetooth: hci0: Opcode 0x0c01 failed: -19 Bluetooth: hci0: sending frame failed (-19) Bluetooth: hci0: Opcode 0x0c1a failed: -19 hci_bcm4377 0000:01:00.1: transport needs hardware reset on next open A controller with a scan filter, advertising or a discovery to restore gets more of these. The restart is a close and an open of the transport, and the open programs all of that again, so nothing was lost; but the commands were sent to a function that was known not to answer, and a wake that worked as designed read like a failure. The core's resume cannot simply be left out. It is what clears the core's suspended state, which a close and an open do not touch: without it the controller comes back with page scan, advertising and discovery paused for good. So the resume of a cold function now only queues the reset and leaves the core suspended. The open that booted the firmware queues the core's resume, which then finds a controller that answers: the event mask and the scan state are written once, to a running firmware. This holds for any open: after a reset that failed, or a power-off between the wake and the queued reset, the core resumes behind the next open that succeeds. The next suspend fences that work like the recovery itself. A cold function without a queued reset (a controller that was not powered) is resumed at once, as before; the core does nothing for it. The close of that restart no longer warns that the transport needs a hardware reset: the driver has just said why it restarts it. The core's own PM notifier calls hci_resume_dev() as well, once tasks are thawed. The queued reset is thawed with them and normally holds the request lock by then: the notifier waits for the open or finds the controller down, and either way the core resumes only once the firmware answers. Should the notifier run first, its commands fail as before. tools/asahi: the fixture models the core's suspended mark, the cold cases hold that no frame reaches a cold function, and new cases and mutations cover the resume behind the open, the failed reset, the power-off in between and both fences. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
Probe tells its RTKit object two things about the controller: the longer handshake timeout of the T6050 ANS and, for a controller the sleep controller stops, the last endpoint map reply of a warm restart. A resume from hibernation on a controller with separate I/O queue registers frees that object and creates one for the session the boot loader started, and the new object got neither. T6040 needs neither (its mask is the default and it is no T6050), so nothing changes there; on T8140 the next warm restart after a restore would have answered the endpoint map with the default, and on T6050 the adoption would have run with the short timeout. Put both into apple_nvme_rtkit_configure() and call it for every object, before it is used. Both calls only store a value in the object; no controller or coprocessor register access moves. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
T8140 registers its ANS with the sleep controller through sleep_traced. T6040 got a second flag for the same registration, sleep_untraced, with a comment that said the sequence was not measured there; the T6040 table says a few lines further down that the ANS came back from the suspends to RAM that cut the power. The two flags were tested together in the one place that reads them. Keep one flag and name it for what it does, sleep_coproc: the sleep controller takes this ANS through a firmware-driven suspend. T8132, T8140 and T6040 set it. The probe condition is the same for every table, so no register access changes. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The comment of the T6040 table named functions of the sleep controller, its test modes and the runs the values were confirmed in. Describe the contract with the firmware instead: what the sleep controller does to this ANS and when, how the firmware takes the shutdown notification, which namespaces are its own, and what it expects of the warm restart. pm_hibernate_is_restored() is false without CONFIG_HIBERNATION, so the IS_ENABLED() test in front of it goes. No change to the object code. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The boards whose transport is restarted in place after a resume were one expression that grew by an OR with the second board, with the chip IDs repeated in it. Make it a table of chip and machine pairs that the admission function walks; the next board is a row. The probe of a function the sleep reset compared the boot stage and the RTI status with a bare 2. Name the two values a running firmware shows. No change in behaviour: the same two pairs are admitted and the same values are compared. tools/asahi: the identity test takes the table with the function and gets a row on the other row's board as mutants, and the resume test compiles the table ahead of the functions. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The HCI core suspends and resumes every controller from a PM notifier of its own, before tasks are frozen and after they are thawed. The system sleep callbacks of this driver call hci_suspend_dev() and hci_resume_dev() too, so each ran twice per sleep, the second time without commands but with its management events sent again. Where a suspend to RAM takes the firmware, the notifier's resume races with the driver: the driver leaves the core suspended until the queued reset has booted the firmware, and the notifier resumes it as soon as tasks are thawed. The reset is queued on a freezable workqueue and normally has the request lock by then, so the notifier waits for it or finds the controller down and does nothing. If the notifier ever gets there first, it sends the core's resume commands to a function without firmware, which fails each of them at error level. Give the board table a property for such a board and set HCI_QUIRK_NO_SUSPEND_NOTIFIER for it, as the MT7932 driver does for the same reason: the driver's callbacks are then the only ones. The core is suspended from the device suspend callback, after the freeze, and resumed from the device resume callback or, after a cold wake, behind the reset. Userspace sees one suspend and one resume event per sleep. The BCM4378 on a J493 keeps the notifier. tools/asahi: the identity test holds the quirk to the BCM4388 on a J616s, with the property moved and removed as mutants. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
On a board whose suspend to RAM takes the firmware, every wake printed the window and the two status words it found. That is the expected state there, and the restart that follows says why it runs; keep the values for debugging. The comment names the chip the values were read on instead of the machine. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
A T6040 or T6041 PCIe-C DART that lost its state lost its probe tunables with it, and the resume applies them again before the reset. It found those DARTs by testing the compatible on every resume. Like the other per-SoC properties of a DART, record it in a flag at probe, where the tunables are applied the first time. No functional change: the flag is set exactly where the three conditions of the resume held. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
After a suspend-to-RAM the ports of the T6040 controller come back one after the other in the noirq resume, and each takes two waits of 100 ms: after the release of PERST# and after its link has trained. With two ports (Wi-Fi/Bluetooth and the card reader on a J616s) that is 414 ms of the 423 ms the whole noirq phase takes. Bring every port up to the release of PERST# first, wait once, then restore and train each, and wait once more. Each port still gets at least the same two waits; the phase loses about 200 ms. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The second 100 ms of a port's wake from suspend-to-RAM follows the link training. PCIe r5.0, 6.6.1 asks for it on a link that runs above 5 GT/s; up to 5 GT/s the 100 ms since PERST# are the whole requirement, and the ports have waited those. Both ports of a J616s have a target speed of 5 GT/s. Take the wait only when a trained port's target speed is above 5 GT/s. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
…d the resume A function that lost its power in a firmware suspend is found cold at the resume (interrupt mask 0), and the resume callback removes and probes it. On a J616s that takes 619 ms of the callback, about 550 ms of it for taking the interfaces and the wiphy down. Every device that follows in the resume order waits for it, and without USB devices it is what the whole resume phase ends with. Queue the remove and probe instead and return, on a freezable workqueue, so that the work starts once the resume of every device is over: run during it, the removal of the wiphy only moved the wait to the wiphy's own resume (522 ms there). The work takes the device lock, which an unbind holds too, and does nothing for a function that has no driver data any more. A PM notifier flushes the queue before the next suspend or hibernation, so that one never meets a function in the middle of its restart. User space sees what it saw before, the wiphy going away and a new one coming, a little later: after it is thawed. Hibernation and a suspend to idle keep the restart in the callback. J616s, suspend-to-RAM with the function associated, no USB hub attached: the callback returns after 24 us, the resume of the devices takes 453 ms, against 542 with the restart running during it, and the interface associates again. With the restart in the callback the callback alone took 619 ms. The host test of the PM callbacks gets the two new calls and a case for the queued restart and for the one that cannot be queued. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The MSI slice table is reached for the t8122, t8132 and t6040 PCIe-C
controllers. The T6040 bridges are described only by "apple,t6040-pciec",
which selects t6040_pciec_hw, and that case is handled first. The later
of_machine_is_compatible("apple,t6040") arm would need a T6040 machine
whose controller node binds to the t8122 or t8132 data instead, which
no devicetree has. It repeated the vector base and ECAM table of the
first arm.
Remove it. The T6040 slice layout is unchanged.
Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The S2R port and root-complex tunables are optional, so a missing property (-ENOENT) means nothing to restore after a sleep. Any other parse error (-EINVAL for a malformed property, -ENOMEM) was dropped the same way, and the port then came back from a sleep without the calibration the firmware had published. Only treat -ENOENT as "no tunable"; return the other errors from the port setup so the probe fails with the property named. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
Several comments in the PCIe host and the NVMe driver explain a register, a bring-up order or a timeout by what another operating system does. State what the block needs or does instead: the bits and their order, the wait for RUN, the shutdown notification timeout, the time ANS firmware takes to report on. The shutdown notification timeout macro loses the name of the other system. Comment and macro name only; the object code of both files is unchanged. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The helpers that save the port state for a sleep and bring a conventional host back after one are named after hibernation, although a real suspend-to-RAM uses them the same way. Call them restore_*, and define the S2R and restore helpers before their users so that the forward declarations go. No functional change: every function is identical apart from its symbol name. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
The restore of an internal host (radio and SD reader behind a down link after a restored image or a real suspend-to-RAM) was selected by exclusion: not tunneled, no managed SIDs, no PIODMA supplier, not root bus only. A supplier is only taken on a root bus only host, so that term was implied. Set one hw_info flag on the four conventional controllers instead (T8103, T602x, T8152 and T6050 adopt); only the managed SID list, which comes from the board and not from the controller, stays a run-time test. The two bring-ups that bring a restored port back end in the same five steps: gate the clocks, restore the interrupt routing, program the RID-to-SID table, train the link, unmask what the kernel had. Make them one helper instead of two copies. The same set of controllers selects the restore as before. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
A restore writes the whole RID-to-SID table back, every other entry cleared, on a block that has just come back from a power cycle or a reset. The write already reads each word back for completion; compare it with what was written and warn once per port, with the first word that differs, when the table did not take. The restore carries on either way: a table that did not stick shows up as DART faults of the affected function, and the warning names the cause. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
… checks for an abandoned hibernation The drivers/iommu/apple-dart.c, drivers/nvme/host/apple.c, drivers/pci/controller/pcie-apple.c part of "soc: apple: drop the restore callbacks' checks for an abandoned hibernation", which goes with the PCIe, storage and radio 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>
The words a sleep that powers the port block down has to put back (link capabilities, Link Control 2, the link mode and width, port word 0x130) are read at every sleep. They cannot be read once at probe: a cold initialization of the port writes them again, the PCI core changes the target speed through the root port's config space, and a tunnel's setup writes 0x130, so a copy from probe can differ from the state the restore has to reproduce. Say so where they are read. No functional change. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
…me from disk A resume from disk finds the conventional host's ports reset by the boot that loaded the image, and sets each one up again as probe did: PWREN, 100 ms before PERST# is released, 100 ms before the link, the link trained, 100 ms before the first configuration request. On the J616s that is 0.31 s per port, done one port after the other (0.62 s of the restore for the radio and the SD reader). The bring-up of a port touches only that port's registers and PHY, its own PERST# and PWREN GPIOs and its slots of the RID-to-SID table, which are written under the host's lock. Run the ports' bring-ups as async work and wait for all of them before the saved configurations of the functions are taken back, so that their waits overlap. Failures are reported per port as before. Hardware test: resume from disk; both ports report "link back, PWREN and PERST# cycled as at probe", Wi-Fi, Bluetooth and the SD reader work after the resume, and the device restore takes about 0.3 s less. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
…disk too A function that comes back from a firmware suspend without its firmware is removed and probed again from a work item, so that the resume of the devices behind it does not wait for that. The restore of a hibernation image finds the function in the same state (the boot that loaded the image reset it) but still removes and probes it in the restore callback: 0.61 s of the device restore on a J616s. Queue the restart for the restore of a loaded image as well. The PM notifier that flushes the queue before the next suspend, hibernation or restore already covers it. Hardware test: resume from disk; the device restore no longer shows brcmfmac in its slowest callbacks, Wi-Fi reconnects on its own after the resume, and a suspend to RAM right after it finds the function probed. tools/asahi: the suspend test models the restore of an image as well, and its queued restart. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
A suspend without wake-on-WLAN disassociates every ready interface and then sleeps 500 ms per interface, "so that wpa_supplicant receives the events the DISASSOC generates". That sleep is paid on every suspend and hibernation (0.58 s of wiphy_suspend on a J616s with one interface). It delivers nothing: brcmf_link_down() already reports the disconnect to cfg80211, and so to wpa_supplicant, before it returns. Of the events the firmware may send for the DISASSOC, a DISASSOC completion has no handler, so it is not enabled in the firmware's event mask and is dropped on arrival, and a link down or deauthentication finds the interface no longer connected and is ignored. Traced on a BCM4387 (PCIe) across a suspend-to-idle: no firmware event reaches the host in the 500 ms after the DISASSOC. Drop the sleep. Hardware test: suspend-to-idle and suspend-to-RAM with Wi-Fi associated; wiphy_suspend takes a few milliseconds instead of 0.58 s, NetworkManager shows the disconnect before the sleep and Wi-Fi reassociates after the wake. Signed-off-by: František Balázsy <frantisekbalazsy@gmail.com>
fbalazsy
force-pushed
the
j616s/split-pci
branch
from
November 14, 2026 18:21
a822d0b to
151cfbb
Compare
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 5/9 of the split of #1477 into smaller pull requests. Depends on #1911: GitHub cannot stack pull requests from a fork, so this one also carries the commits of #1903, #1904, #1909, #1910, #1911; its own are the last 32, from 282f733 on (12 files changed, 1993 insertions(+), 138 deletions(-)).
Storage and radios after hibernation and suspend-to-RAM on T6040, where the PCIe link and its functions lose power:
PCI: applenvme-apple,iommu/apple-dartwifi: brcmfmacBluetooth: hci_bcm4377Tested: 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.