Repository navigation
Conversation
|
@fbalazsy checking open drafts today. To come out of draft, this still needs:
If it's no longer needed, say so here and we'll close it. Otherwise it stays open as a draft until these are done. |
|
Merged forward without a force push, as suggested: #2215 at 48a9c70 (which carries main) and then main at 00fbe80 are merged in. The merge commit lists the conflicts and how each was resolved. Since then main has moved by 6 commits (t6050 DisplayPort audio DT, macsmc restart priority); they merge without conflicts. f43d634 adapts eight host-test harnesses that stopped compiling because of new hibernation calls and fields (DCP hibernation gates, the in-place IOMFB restart arena, Local results at f43d634:
f43d634 J616s (M4 Pro, T6040), test kernel built from d9b8558 (the same kernel tree; f43d634 only changes test files): cold boot, then 2 suspend/wake cycles, both rc=0 with no new warnings. eDP, DP and HDMI were connected and enabled after each wake, the USB tree was unchanged and dock Ethernet came back. The hibernation Not tested at this head: a real hibernation image (power-off cycle or |
|
Status, still a draft. Head Build and tests at this head
Hardware (J616s, T6040,
Correction to the first version of this comment: I wrote that hibernation stays blocked. That is only so without the fixed layout. With It stays a draft. Next: the full cycles on this head, then the lab row. |
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: fbalazsy <frantisekbalazsy@gmail.com> (cherry picked from commit c2119e1)
A REQ_SYNC write can sit in a volatile device cache, so the signature reset at resume and the end of the image are not on the medium when the write completes. A power loss after the restore then resumes the same image again, or the image is incomplete. Write the signature reset with FUA, flush the image in swap_writer_finish() and fail the hibernation (dropping the signature) when the flush fails. Once the image is in memory, clear the signature again before the devices are restored, so a restore that hangs cannot be resumed into a second time. Signed-off-by: fbalazsy <frantisekbalazsy@gmail.com> (cherry picked from commit faaf017)
The devices of a kernel restored from an image get PMSG_RESTORE whether the image was loaded by another boot (the firmware and the boot loader reset the hardware) or by the kernel that wrote it (test_resume: the hardware kept its state). Drivers of devices that a boot resets need to tell the two apart. The kernel that loads an image leaves a record in the no-save section, which the image neither saves nor overwrites, and the restored kernel reads it: pm_hibernate_restored_cold() returns 1 after a load by another boot, 0 after a load of the own image. pm_hibernate_is_restored() says whether the kernel was restored at all, and pm_hibernate_is_loading() whether this kernel is loading an image, so freeze callbacks can tell a quiesce for the jump into an image from a freeze for an image of their own. A hibernation aborted before the image exists resumes the devices with PMSG_RECOVER. Signed-off-by: fbalazsy <frantisekbalazsy@gmail.com> (cherry picked from commit 394d4a1)
Hibernation is refused on every Apple platform, because the drivers of their co-processors have no path to rebuild their state after the cold boot of a restore. Add hibernation_set_platform_check() so platform code can tell when that is handled for the running boot. Without a registered check Apple platforms keep refusing images as before. Signed-off-by: fbalazsy <frantisekbalazsy@gmail.com> (cherry picked from commit 3891bc4)
Most image pages are loaded straight into their original frames through the cacheable linear map, not through the copy loop. Add an architecture hook, called for every valid image frame once the whole image is loaded and while the list of those frames is still intact, and implement it on arm64 by cleaning and invalidating the page to the PoC. Frames outside the boot kernel's linear map are left to the copy, which cleans them. Signed-off-by: fbalazsy <frantisekbalazsy@gmail.com> (cherry picked from commit 7089f48)
swsusp_arch_suspend_exit() cleans every copied page to the PoU, which is enough for instruction fetch but not for DMA masters that do not snoop the CPU caches. A later eviction of a dirty line can then overwrite what such a device wrote since the restore. Clean to the PoC instead. Signed-off-by: fbalazsy <frantisekbalazsy@gmail.com> (cherry picked from commit d98e601)
…ayout The image restores every page to the frame it came from, so the boot that resumes it must give the kernel what the boot that wrote it did: the same RAM, the same CPUs started the same way, and any fixed layout of the boot loader. The kernel build check of the image header cannot see these. Let one platform register hooks: pfn_nosave() keeps ranges that the boot owns out of the image, and layout() mixes the platform's boot facts into a boot layout cookie that is stored in the image header next to the memory regions and the spin-table release addresses. A restore under another layout is refused. Signed-off-by: fbalazsy <frantisekbalazsy@gmail.com> (cherry picked from commit 54d9b8e)
…ernation Spin-table CPUs cannot be powered off; a parked CPU spins in kernel text that the boot kernel overwrites while it loads an image. Let them wait in a small pen outside the image instead, entered with the image's page tables, and have the restored kernel release them from it. A boot CPU whose node has no enable-method is treated as one that can leave the kernel. Signed-off-by: fbalazsy <frantisekbalazsy@gmail.com> (cherry picked from commit b6838fb)
… sleep A guest's counters are the physical counter minus an offset fixed when the VM is made. The physical counter starts again across a resume from disk, which is a cold boot, so the guest's counters fall back and its clock stands still until the counter has caught up. Record the counter at syscore suspend and, if it went backwards at resume, move the offsets of every VM by what it lost, so the guest's counters continue as for a VM that was stopped that long. A counter that keeps running through the sleep is left alone. Signed-off-by: fbalazsy <frantisekbalazsy@gmail.com> (cherry picked from commit ac2fa3d)
A co-processor that stays up across a resume from disk keeps the shared buffers of its session, which the restored kernel has to adopt. Add apple_rtkit_describe_buffers() and a small hand-over area in the no-save section in which the boot kernel leaves, per tagged session, what the restored kernel needs to take it over. Also let the polled power-state exchange used with interrupts off put the co-processor to idle for clients that stay up, and add apple_rtkit_reinit() to the Rust bindings. Signed-off-by: fbalazsy <frantisekbalazsy@gmail.com> (cherry picked from commit f986895)
The boot kernel of a resume from disk holds RX of an adopted session and hands it over with its buffers; the restored kernel adopts it again in .restore. A self-started session is left for a reload, and a co-processor that the boot left halted is released without a handshake. Add .thaw and .restore callbacks and apple_rtkit_helper_readopted(). Signed-off-by: fbalazsy <frantisekbalazsy@gmail.com> (cherry picked from commit c8d3761)
aura publishes /chosen/aura,hibernate-layout on a boot whose memory layout below Linux is the same on every boot, and copies the device tree of each boot to the slot named by /chosen/aura,hibernate-dt. On such a boot, keep every /memreserve/ and non-reusable /reserved-memory range except the kernel image out of the image, add the layout and the boot facts of /chosen to the boot layout cookie, and let hibernation through. Without the property hibernation and resume stay refused on Apple platforms. Also provide this boot's /chosen values and a deferred re-probe for drivers whose co-processor the resuming boot left halted. Signed-off-by: fbalazsy <frantisekbalazsy@gmail.com> (cherry picked from commit 74accee)
After a resume from disk through a boot the boot loader has cold-restarted the PMP (its image resident in SRAM, the co-processor halted) and nothing replays the probe-time bring-up, so the firmware stays down: the display gate and cpufreq wait for a PMP that never reports running. The module cannot be reloaded, since the power-vote bridge is retained until reboot. Rebuild the session in place on PM_POST_HIBERNATION, the event the restored kernel sends (PM_POST_RESTORE only reaches the loading kernel when it fails to restore), from a notifier registered ahead of every consumer's restore notifier (ANE, DCP, GPU). The decision follows the co-processor's run bit, the state the loading kernel or the boot left: a running firmware (restored by the kernel that wrote the image, or an aborted hibernation) is left alone; a halted one gets its RTKit session reinitialised, its SRAM boot arguments patched again and the boot handshake driven as at probe. The notifier is registered outside pmp_lock, since the notifier chain lock is taken around the callback, which takes pmp_lock. The revocable MMIO guards are held only around the register accesses: they hold an RCU read-side lock, which must not be kept across the sleeping RTKit handshake. Signed-off-by: fbalazsy <frantisekbalazsy@gmail.com> (cherry picked from commit 0833903)
…m disk A resume from disk through a boot finds every locked DART locked again by the boot loader with fresh firmware-owned roots, while the restored kernel still describes the roots of the image (their mapping, their firmware snapshot and the slots it had published). Every publication then fails with -EBUSY, and with it every DMA mapping through the DART; on the M4 Pro the PMP and every DCP failed their buffer requests with -ENOMEM. Remember the physical address of each mapped locked root and the page table configuration last published into each locked stream. In .restore, read the live roots back: a root that moved is re-imported the way attach maps it, in two passes as attach does (every stream's roots are re-read and snapshotted before any of them is republished, so a root shared by several streams is snapshotted before Linux slots enter it), then the stream's page tables are published into it again. A root that did not move, as when the kernel that wrote the image loads it, is the one the image describes and is kept. Firmware-owned memory is never written: the old roots' published slots are forgotten, not retired. A failed stream is logged and does not fail the whole restore. Signed-off-by: fbalazsy <frantisekbalazsy@gmail.com> (cherry picked from commit b7fa3a1)
After a resume from disk the RTKit session the restored driver describes is not the one the SMC is in, and every SMC command times out (battery, keyboard and trackpad preflight, power-off). The kernel that loads the image binds this driver like any boot and holds a live session when it jumps into the image; the restored kernel then asks the firmware to start and waits for a HELLO that a firmware already in a session never sends. Following Documentation/driver-api/pm/devices.rst, leave the restored kernel a defined state: - the loading kernel (pm_hibernate_is_loading()) quiesces the SMC in .freeze, the state the normal teardown leaves it in, from which a wake starts a new session. A failed quiesce still enters the image, whose signature is already gone; its restore tries a new session; - .restore reinitialises the RTKit transport, replays probe's bring-up handshake, re-reads the key count and re-arms the notification flag, the same whether the loading kernel wrote the image or was booted; - .thaw after a hand-over that could not enter the image starts a new session the same way. Probe's handshake and key count read move into helpers both use. Signed-off-by: fbalazsy <frantisekbalazsy@gmail.com> (cherry picked from commit 216072f)
…effect The next power-off handler is PSCI SYSTEM_OFF. Under a boot monitor without a power-off path it resets the machine instead, so a slow or refused off1 must not fall through after only 100 ms: the image written for hibernation would be resumed at once, or the machine would reboot instead of powering off. Retry a refused off1 up to three times, and give an accepted one five seconds before warning and falling through. Signed-off-by: fbalazsy <frantisekbalazsy@gmail.com> (cherry picked from commit 6ea1f04)
The prepare callback refuses every transition that is neither
suspend-to-idle nor a firmware-driven suspend, because only those keep
a way to bring the alarm back. Hibernation runs the same callback for
its freeze, but with no suspend target set, so it is refused as well:
on the M4 Pro (J616s) a hibernation pm_test run stops at this device
("apple_pmu_rtc_prepare returns -16") before any device is frozen.
A hibernated machine comes back through a cold boot, which needs
nothing from the alarm. Refuse only a suspend state that cannot keep
the alarm, and let a transition without a suspend target through.
Signed-off-by: fbalazsy <frantisekbalazsy@gmail.com>
(cherry picked from commit 0c1fbf5)
…P stops A resume from disk restarts the PMP after it had run. The fast die-temperature wait then reported the PMP as late, measured from the first boot. Start the wait, and its warning, over when the PMP stops. Signed-off-by: fbalazsy <frantisekbalazsy@gmail.com> (cherry picked from commit 0148e6b)
On post-M4 ANS a resume from disk through a boot is a cold boot: the boot firmware restarted ANS, the boot stages kept it running, and the loading kernel adopted that session to read the image. In the restored kernel anv->rtk describes a firmware instance that no longer exists, and the live session on the mailbox has never been adopted by this kernel. Give the driver explicit hibernation callbacks: freeze and poweroff disable the controller and keep the session like suspend, thaw resumes. A .restore through a boot (pm_hibernate_restored_cold()) stops the controller first (until CC.EN is clear the firmware may fetch from the loading kernel's queues), releases the stale session without a shutdown handshake (the new instance would receive it), checks that a running, booted, enabled-off controller is there and adopts it, as probe adopts the boot loader's session, before the usual resume. A failure quarantines the controller. A .restore from the kernel that wrote the image finds the controller as its .freeze left it and resumes. Signed-off-by: fbalazsy <frantisekbalazsy@gmail.com> (cherry picked from commit 594d672)
An H16 engine whose firmware has been started refuses hibernation and
restore from its PM notifier, even on a platform that sleeps it cold.
On the M4 Pro (J616s) that refusal is the first thing that stops a
hibernation pm_test run, before the freezer level is reached.
The cold cycle leaves nothing of the old firmware behind: the engine is
powered off with nothing in flight, and after the transition the
firmware boots again from the preload and every open program is
replayed. Across suspend this already runs on the J616s ("powered down
for system sleep", then "resume ok: cold" after every wake). An image
needs no more than that, so on a platform without a warm sleep map
PM_HIBERNATION_PREPARE and PM_RESTORE_PREPARE to the suspend prepare
step and PM_POST_HIBERNATION and PM_POST_RESTORE to the wake step.
A platform that sleeps the engine warm keeps firmware state across the
transition that an image cannot carry; there both stay refused.
Signed-off-by: fbalazsy <frantisekbalazsy@gmail.com>
(cherry picked from commit 78dac96)
The DCPs freeze and thaw through their system sleep callbacks, but the DRM device had only .suspend and .resume. A hibernation freeze therefore stopped the display firmware under an active mode configuration: the HDMI link of the external DCP went down in .freeze, the CRTC was never committed again on .thaw, and the HDMI output stayed disconnected until the next suspend and resume. Use the system sleep callbacks for the hibernation phases as well, so the DRM state is saved before the DCPs stop and committed again after they restart, as for suspend to RAM. Signed-off-by: fbalazsy <frantisekbalazsy@gmail.com> (cherry picked from commit 1d4dbc5)
Only the H17P handler marked a buffer mapped for piodma. On desktop 26.x the mark was never set, so neither a release nor the session drop after a resume from disk took the translation down, and the second resume from disk in one boot failed every piodma mapping with -EEXIST: no picture on the internal panel. Mark it there too, and refuse an unmap of a buffer that is not mapped, as on H17P, instead of reaching the page table. Signed-off-by: fbalazsy <frantisekbalazsy@gmail.com> (cherry picked from commit dbbd96e)
…ttached Without a sink the firmware's probing of a DP port fails by design, which logged a warning on every external processor start, including each restart after a resume from disk. Log those at debug level and keep the warning when a sink is attached. Signed-off-by: fbalazsy <frantisekbalazsy@gmail.com> (cherry picked from commit 4e27f7d)
…from disk A resume from disk is a cold boot: the boot loader restarts the DCP firmware and lights the panel with its boot framebuffer, while the restored driver still holds the session of the previous firmware instance. Until now the driver had no hibernation callbacks, and the display was lost until a reboot. Rebuild the session in place, the way probe builds it, for the desktop 26.x internal DCP and for the T6041 external display processors: - prepare (hibernation only): stop the link work and the HDMI HPD interrupt, stop a merged dual pipe as a pair, and give the external display link and the DP PHYs back as at a runtime unplug, since the cold boot resets the PHY and the image must record it off; - freeze: hold RTKit receive, so whatever the new firmware sends before .restore stays in the mailbox instead of reaching the old session; - restore_early/restore: drop the old session on the host side (mode invalid, endpoints quiesced, IOMFB channels, firmware mappings, retained framebuffers and pending flips released; DMA only after the DARTs are restored). From here the DRM entry points leave the firmware alone and a flip completes without a swap; a shown external display is reported gone so that its return is a hotplug; - PM_POST_HIBERNATION, after the PMP is rebuilt and before the GPU drain, in a work item: run the co-processor, reinitialise RTKit and start the firmware as probe does, power the pipe on and commit the current DRM state. External processors with a display wait until every external processor runs, so a display wider than one pipe finds its peer, and then connect their link through the runtime hotplug path; the HDMI converter is powered again when the link comes back. Every devm allocation, the DMA arena (cleaned to the PoC before the restart), the IOMMU mappings, clocks and registers are reused; no probe primitive runs again. The old endpoint objects stay allocated until unbind (a bounded leak per resume) because their services may still be referenced. Any failing step falls back to the previous behaviour: IOMFB traffic stopped, display left to the boot loader, until the reboot. The teardown at the hibernation power-off is skipped, since the firmware's own power sequence may crash the DCP; the panel keeps the last frame until the machine powers off. If the hibernation fails, PM_POST_HIBERNATION replays the external links once every DCP is thawed. Signed-off-by: fbalazsy <frantisekbalazsy@gmail.com> (cherry picked from commit 0dfc337)
A sink that drops its link and raises IRQ_HPD after every training (seen with a dual-pipe monitor after a modeset from the kernel console during a hibernation entry) turns each hotplug into a retrain and each retrain into a hotplug, every 0.4-1.2 s, until the Type-C controller gives up on the cable. Retrain at most DCP_HOTPLUG_RETRAIN_MAX times in a DCP_HOTPLUG_RETRAIN_WINDOW that starts with the first retrain and is not extended by refused requests; at the end of the window one more retrain is tried. A real replug resets the bound. Past the limit the link status stays as it is and userspace still gets the hotplug events. Signed-off-by: fbalazsy <frantisekbalazsy@gmail.com> (cherry picked from commit 1836402)
Hibernation restored the display firmware with a new handshake only, which assumes the boot loader started it anew. A restore by the kernel that wrote the image (test_resume) finds the firmware still in the session it ran on after the image was taken, and the handshake times out on every DCP: RTKit: endpoint discovery failed: -62 hibernation restore: firmware restart failed at start (-62) Per Documentation/driver-api/pm/devices.rst, .restore has to cope with whatever state the loading kernel left. Stop the display firmware at .freeze with the stop the suspend-to-RAM path already uses on the T604x display complex (dcp_t6041_s2r_all(), selected by the apple,display-power node), so the image holds it stopped by Linux, and keep it stopped through the image write, as amdgpu's .thaw does: .thaw brings it back only when the hibernation failed (pm_hibernate_is_recovering()) or the machine suspends instead (pm_hibernation_mode_is_suspend()), and PM_POST_HIBERNATION does when this kernel goes on after anything else. The firmware then is in exactly the state the image describes: - a .restore by the kernel that wrote the image (test_resume), or after a failed power-off, takes the sleep's warm return; - a .restore through a boot (pm_hibernate_restored_cold()) powers the domains and DARTs the same way, then gives the firmware the boot loader started the new handshake after PM_POST_HIBERNATION. A thaw that restarted the firmware for the image write left it in a newer session than the image: the restored kernel's warm return then crashed all three DCPs with ASSERT afk_messenger_common.c:67. The link release at hibernation prepare is not needed then, as the stop takes the external links down itself. Factor the host-side session drop into dcp_hib_drop_session() for both restore paths. Signed-off-by: fbalazsy <frantisekbalazsy@gmail.com> (cherry picked from commit 223277a)
A test_resume load restores the image in the kernel that wrote it: the SoC was not powered down and the PHY, its coprocessor and the DP and USB sides its consumers kept are as the image records them. Resetting that state, as after a resume through a boot, made the DP side of a Type-C display look down while the display controller still held it, and the next mode set of that display failed. Only reset the state, and the coprocessor's RTKit session, when pm_hibernate_restored_cold() says the restore went through a boot (or cannot tell), as a resume from a sleep does only after the firmware took the SoC down (pm_resume_via_firmware()). Signed-off-by: fbalazsy <frantisekbalazsy@gmail.com> (cherry picked from commit 2786460)
447633d to
5f4a9fa
Compare
|
History cleanup: the branch was rewritten once and force-pushed ( Anyone who based work on this branch should rebase onto |
|
Pushed
Hardware row: J616s (T6040) at |
When the host controller goes away while a device below a hub is being reset (the UAS error handler resets the device after a command that failed because the controller is being removed), every port reset request fails with -ESHUTDOWN. hub_port_reset() logs each try and retries, and usb_reset_and_verify_device() repeats the whole sequence, so a device that is already gone produces dozens of "cannot reset (err = -108)", "Cannot enable" and "cannot disable" lines. Treat -ESHUTDOWN like -ENODEV in these paths: the controller does not come back for this device. Signed-off-by: fbalazsy <frantisekbalazsy@gmail.com>
… disk
The boot kernel of a resume from disk hands the running MTP firmware to
the image. The receive ring indices in memory are then the image's,
while the firmware carries on from the position of the boot kernel's
session, so the first drain after the restore fails with -EPROTO and
the frames in between are lost ("Receive ring failed: -71").
Mark the ring on restore and, on the first drain that does not add up,
drop everything up to the producer the firmware published last and go
on from there. A drain that reads a frame clears the mark.
Signed-off-by: fbalazsy <frantisekbalazsy@gmail.com>
|
Pushed
Hardware rows: J616s (T6040), Stage 2 from aurora-silicon/aura#653 at |
…ernation pm_hibernate_restored_cold() is already set before syscore_resume() runs in create_image(), yet aic_syscore_resume() only restored AIC2_TIMEOUT, AIC2_CLUSTER_PRIO, AIC2_CONFIG, and aic_resume_boot_cpu() for pm_resume_via_firmware(). Include pm_hibernate_restored_cold() so CPU 0's VM timer FIQ mask stays synchronized with per-CPU state after a cold hibernation restore. In apple-sleep, also clear mbox_lost once a valid S2R mailbox is re-mapped on restore and re-validate if mbox_lost was previously set. Signed-off-by: Nick <nekreshen@yandex.ru> (cherry picked from commit 388fdad) Signed-off-by: fbalazsy <frantisekbalazsy@gmail.com>
…r cold hibernation After a cold hibernation restore, the boot ROM leaves the boot CPU's cluster power-gate word clear (preventing CPU 0's cluster from gating and causing subsequent suspend-to-RAM to hang in the sleep sequencer), and iBoot leaves MCC system-level cache allocation disabled. - apple-cluster-pwrgate: retain the mapped gate registers and register a syscore resume callback to re-set CLUSTER_PWRGATE_EN before secondary CPUs online. - apple-mcc: add .restore_noirq to restore ways and re-enable system level cache allocation on cold hibernation restore. Signed-off-by: Nick <nekreshen@yandex.ru> (cherry picked from commit 738126b) Signed-off-by: fbalazsy <frantisekbalazsy@gmail.com>
…er cold hibernation In apple-soc-cpufreq, refresh expected_pstate from APPLE_DVFS_CMD after a cold hibernation restore (pm_hibernate_restored_cold()) just like firmware-driven sleep, and restart the fast die-temperature grace timer on hibernation restore while PMP re-initializes in PM_POST_HIBERNATION. In macsmc-power, save CHLS/CHWA on freeze/poweroff and restore the charge limit on cold hibernation restore so standard hibernation preserves the configured battery charge limit without userspace help. Signed-off-by: Nick <nekreshen@yandex.ru> (cherry picked from commit cc5ba7f) Signed-off-by: fbalazsy <frantisekbalazsy@gmail.com>
… PWM Three Apple peripheral bus drivers lacked system sleep / hibernation restore coverage for registers lost across a cold reboot: - i2c-pasemi-platform: add LATE_SYSTEM_SLEEP_PM_OPS using pm_runtime_force_suspend/resume so buses that were runtime-active at freeze re-run pasemi_i2c_init() in restore_early before I2C clients (such as audio codecs and speaker amplifiers) issue restore transfers. - spi-apple: add runtime_resume calling apple_spi_init() and system sleep callbacks wrapping spi_controller_suspend/resume with pm_runtime_force_suspend/resume so SPI buses re-initialize PIN/CFG registers after domain power loss or cold hibernation restore. - pwm-apple: add LATE_SYSTEM_SLEEP_PM_OPS using pm_runtime_force_suspend/resume so active PWM outputs (keyboard backlight) restore ON_CYCLES/OFF_CYCLES/CTRL after cold reboot, and set APPLE_PWM_CTRL_UPDATE when re-enabling to latch shadowed cycles. Signed-off-by: Nick <nekreshen@yandex.ru> (cherry picked from commit af9bdf6) Signed-off-by: fbalazsy <frantisekbalazsy@gmail.com>
On cold hibernation restore the bootloader re-trains the PCIe port without programming PORT_MSIADDR, PORT_MSIMAP, or PORT_MSICFG_EN. Add a .restore_noirq callback that calls apple_msi_hw_init() when pm_hibernate_restored_cold() is set, before PCI devices resume and before any port cycle saves the MSI table. Signed-off-by: Nick <nekreshen@yandex.ru> (cherry picked from commit 9381eb6) Signed-off-by: fbalazsy <frantisekbalazsy@gmail.com>
After a cold hibernation restore, the boot loader has reset the CIO controller and host router. Add .restore_noirq that clears any QUIRK_NO_SYSTEM_SLEEP and QUIRK_KEEP_TUNNELS flags left from an earlier s2idle when pm_hibernate_restored_cold() is true, so tb_domain_resume_noirq() restarts the NHI rings cleanly. Signed-off-by: Nick <nekreshen@yandex.ru> (cherry picked from commit 2b71613) Signed-off-by: fbalazsy <frantisekbalazsy@gmail.com>
An in-place test_resume sets pm_hibernate_is_restored() without restarting the enclave. Gate the hibernation rebind phase on pm_hibernate_restored_cold() so test_resume keeps the live SEP session while real cold restores still rebind the driver. Signed-off-by: Nick <nekreshen@yandex.ru> (cherry picked from commit abc4e03) Signed-off-by: fbalazsy <frantisekbalazsy@gmail.com>
admac_resume_early() only marks controller and channel register state lost when pm_suspend_via_firmware() is true. Add .restore_early that marks them lost when pm_hibernate_restored_cold() is true so active audio DMA channels are cleanly reprogrammed after a cold boot. Signed-off-by: Nick <nekreshen@yandex.ru> (cherry picked from commit 23d1f70) Signed-off-by: fbalazsy <frantisekbalazsy@gmail.com>
Cold boot resets the NCO audio clock channels while MCA and ASoC resume expect enabled channels to keep their programmed divisor and increments. Save each channel's control, divisor, and increment registers on .freeze_noirq/.poweroff_noirq and reprogram them on .restore_noirq when pm_hibernate_restored_cold() is true. Signed-off-by: Nick <nekreshen@yandex.ru> (cherry picked from commit 4edc6aa) Signed-off-by: fbalazsy <frantisekbalazsy@gmail.com>
…ss test_resume On live-session DCPs that cannot restart in place (such as T8142 v27), hold presentation and flush RTKit RX during .freeze/.poweroff and release them on .thaw. On an in-place test_resume (!pm_hibernate_restored_cold()), the boot loader never restarted the firmware, so thaw instead of marking the display dead. On a cold restore, mark both crashed and ext_dead so IOMFB traffic stops cleanly. Signed-off-by: Nick <nekreshen@yandex.ru> (cherry picked from commit 2ab4584) Signed-off-by: fbalazsy <frantisekbalazsy@gmail.com>
Like the H16 backend, the cold-cycling H17 ANE backend powers the engine off cleanly before sleep and boots the firmware again from the preload (or parks it until the next request) after wake. Nothing of the old firmware has to survive the transition, so map hibernation and restore PM notifier events to the suspend/post-suspend path when sleep_warm is false while keeping warm-sleep platforms refused. Extend ane_cold_sleep_test() to verify cold vs warm hibernation event mapping. Signed-off-by: Nick <nekreshen@yandex.ru> (cherry picked from commit 84b488d) Signed-off-by: fbalazsy <frantisekbalazsy@gmail.com>
…rnation restore On a cold hibernation restore, the resuming boot resets the SN201202x port controller (clearing any liquid-detection mitigation) and the loading kernel puts it to sleep at its freeze. Add a .restore callback that invalidates cached LDCM mitigation state when pm_hibernate_restored_cold() is true before waking the controller via sn201202x_resume(), so complete() reads the detector afresh. Signed-off-by: Nick <nekreshen@yandex.ru> (cherry picked from commit 744af9e) Signed-off-by: fbalazsy <frantisekbalazsy@gmail.com>
A kernel restored from a hibernation image runs after a cold boot that started from a reset PMC with every agent disabled on every rail. The early resume callback skips restoring when pm_resume_via_firmware() is false, leaving agent enables, floors, DCS vote, and interfaces cleared. Add a dedicated .restore_early callback that always restores the tracked PMC state across hibernation. Signed-off-by: Nick <nekreshen@yandex.ru> (cherry picked from commit 3126883) Signed-off-by: fbalazsy <frantisekbalazsy@gmail.com>
…d hibernation cs42l84 gated its suspend/reset sequence on pm_suspend_via_firmware(), skipping cache-only reset and post-resume re-init across hibernation. Spell out freeze/thaw/poweroff/restore so cs42l84 resets cleanly before the image and re-initializes + re-detects the jack on restore. tas2764 gated power-on reset recovery on pm_resume_via_firmware(); also treat pm_hibernate_restored_cold() as a power-on reset so the amps run the full SW_RST, regcache_sync, init quirks, and fail-closed restore check after a cold boot. Signed-off-by: Nick <nekreshen@yandex.ru> (cherry picked from commit 851e410) Signed-off-by: fbalazsy <frantisekbalazsy@gmail.com>
apple_mca_suspend_late() and apple_mca_resume_early() gate on pm_suspend_via_firmware() / pm_resume_via_firmware(), skipping register save/restore across hibernation. Add .freeze_late/.poweroff_late, .thaw_early, and .restore_early (gated on pm_hibernate_restored_cold()) so active MCA clusters and SERDES settings survive a cold restore. Signed-off-by: Nick <nekreshen@yandex.ru> (cherry picked from commit 5d0565a) Signed-off-by: fbalazsy <frantisekbalazsy@gmail.com>
After apple_pmp_restore() restarts a cold-booted PMP at PM_POST_HIBERNATION, call apple_pmp_report_wake(pmp_device, false) so all driver-owned power votes and DVFS floors are re-asserted onto the freshly booted PMP before display and GPU consumers wake up. Restrict apple_pmp_report_entry_pm_ops to .suspend_noirq/.resume_noirq so release-for-sleep entries do not poll a still-halted PMP during hibernation .restore_noirq, and remember pio_mapped on PmpData so apple,pio-ranges are not re-mapped with -EEXIST across cold restore. Signed-off-by: Nick <nekreshen@yandex.ru> (cherry picked from commit e93ba18) Signed-off-by: fbalazsy <frantisekbalazsy@gmail.com>
|
Pushed
Not taken yet:
Host tests: same as before (only the three environment-dependent failures). |
…P restore apple_platform_thaw() keeps outputs suspended (hib_thaw_skipped) while writing the hibernation image, so wiring .poweroff directly to apple_platform_freeze() called drm_mode_config_helper_suspend() a second time while suspend_state was already populated. Add an explicit apple_platform_poweroff() (and guard apple_platform_freeze()) to return early when outputs are already suspended. In dcp.c, also clear secure_answered when dcp_hib_quiesce() drops the old session, clear hib_poweroff_entered in dcp_platform_thaw(), and skip dcp_platform_restore_early() session teardown on warm in-place test_resume restores. Signed-off-by: Nick <nekreshen@yandex.ru> (cherry picked from commit dd4b1cd) Signed-off-by: fbalazsy <frantisekbalazsy@gmail.com>
|
Pushed
|
What: hibernation (suspend-to-disk) on the T6040 (M4 Pro, J616s), on top of the suspend-to-RAM work in #2215 (merged in): the PM core and arm64 restore path, a reset backstop the platform provides for the time the machine is off, and the Apple co-processors, display, GPU, radios and USB brought back after a restore. Current
mainis merged in.Tested: J616s (T6040) at
ee3faca0f8c0and1c1f3522ce39(same tree but the last commit),8d5d52f55c0d(two cycles in a row) and5f4a9facdab3, Stage 2 from aurora-silicon/aura#653 at32ad0c30andf3e85867with this head's DTB, a full power-off cycle (systemctl hibernate, power-off, cold boot, image load): the restore completed (rc 0, 37.9 s from the hibernate call to the restored desktop), the backstop disarmed after the restore and the normal watchdog running, no oops, the SIO firmware booted again (DP and HDMI audio play), OpenGL renders, Wi-Fi, wired network, Bluetooth and the three displays (panel, HDMI, DP over Type-C) back, USB camera frames before and after. The SIO and r8152 changes were also run at the head before the history cleanup (same tree for them). Builds without new warnings,checkpatch.pl --strictclean on the kernel commits,dt_binding_checkanddtbs_checkclean for the watchdog binding and the T604x boards, the host tests fail only wheremainfails on the same toolchain.Risk: one-way (adds DT bindings and properties) · M4 Pro; the shared parts (PM core hibernation, arm64 hibernate, RTKit, DART, DCP, SIO, GPU, brcmfmac, hci_bcm4377, xhci, the Apple watchdog) run on all Macs. The Apple watchdog's T6041/T6050/T8142 match-data fallback for the reconfig and deadline registers is gone: they now come only from the DT, so a DT without them keeps the old watchdog behaviour and has no hibernation backstop. The SIO firmware comes back after a restore only when the boot that loads the image did not bind the SIO (it has no users there); otherwise the SIO stays off until the next boot, with one warning.
Not yet:
Details
PM core / arm64.
get_safe_page()trampoline);PM: hibernate: take the reset backstop from the platform: a platform driver registers arm/disarm callbacks for a reset backstop that covers the power-off and the image load; arming failures are logged and the hibernation continues;test_resumeclears a latched wakeup before the restore and frees the image's swap pages when a restore fails.Watchdog (restore backstop). The Apple watchdog provides the backstop: before the image is written it programs the SMC AP deadline (150 s), which resets the machine if the restored kernel never comes back, and disarms it after the restore. The reconfig and deadline registers are described in the DT (
reg-names"reconfig" and "deadline" inapple,wdt, set int604x.dtsi) instead of per-SoC match data; the deadline is used only with the reconfig register present. The backstop is kept running only across.freeze/.poweroff; a suspend-to-RAM stops the watchdog as before.Apple SoC. A fixed boot layout under aura (DT binding
aura,hibernate); RTKit sessions handed over or re-adopted after a resume; PMP, DART locked roots, SMC, macsmc-reboot, RTC, cpufreq, ANS NVMe, ANE, AOP (started again after a resume from disk).Display (DCP). DRM state suspended for hibernation, in-place firmware restart, bounded retrains, T604x displays taken down for hibernation, PHY state kept in a restore without power loss; a DCP's DART restore is deferred to its firmware restart.
GPU and SIO. The GPU firmware is started again by the restored kernel. The SIO firmware boots after a restore only when the boot loader staged it and left it halted: a firmware that the loading kernel started does not take a second boot, so that kernel idles it before the jump and leaves its run bit set, and the restored kernel then leaves the SIO off. The kernel-window tables are copied in one pass after the restore.
Camera (ISP). A firmware that can restart (
apple,dapf-rangeson its DART) is no longer marked dead by hibernation; the text CRC of the resident firmware is recorded at the freeze and the restore starts it again unless the loading boot left different firmware text there.Sleep after a restore. aura's S2R mailbox moves with the boot object on every boot; after a resume from disk the sleep driver takes the running boot's mailbox from aura's DT, or refuses deep sleep until the next boot.
Radios and USB. brcmfmac PCIe keeps the D3 handshake on freeze and probes the chip again on restore; hci_bcm4377 quiesces and rebinds; r8152 stops resubmitting rx on
-ESHUTDOWN; xhci skips the ep0 max-packet check while a slot is only enabled (theinvalid context state for evaluate context commandWARN on every restore is gone).Merges of
main.mainis merged in twice. The second merge had one conflict, in the display26 host test, where both sides' new assertions are kept.Since the last push.
dmaengine: apple-sio: boot the firmware after a restore only if staged(see above);net: usb: r8152: treat -ESHUTDOWN like -ENODEV on tx and interrupt resubmission: no morefailed tx_urb -108andcan't resubmit intrfloods when the hosts stop for the image;usb: hub: stop resetting a port once its host controller is gone(nocannot reset (err = -108)bursts when the hosts stop for the image);HID: dockchannel: resynchronise the receive ring after a restore from disk(noReceive ring failed: -71after a restore).Known. Touch ID matching is unavailable after a restore as after any cold boot on this branch (it is not a hibernation change). A UAS disk on a Type-C port logs
Synchronize Cache(10) failed: ... DID_ERROR(info level) when the hosts stop for the image, as for a cable unplug of that disk.This series includes #2215 and the commits from #1664 by @AxxzyWasTaken and the PHY commit by @RyanTheTide that #2215 carries, with their original authorship.
Evidence (earlier rows,
test_resume).test_resumetest_resumeafter S2R (with the CTXR fix)8e9af804)test_resume(6cf6a028)test_resume(6cf6a028)test_resume, S2R 5/5,test_resumeagain (718c3ceb)