Skip to content

Hibernation pm_test dry runs on Apple silicon - #1814

Draft
RyanTheTide wants to merge 6 commits into
mainfrom
hibernate/dry-runs
Draft

RyanTheTide wants to merge 6 commits into
mainfrom
hibernate/dry-runs

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Hibernation pm_test dry runs now complete on Apple silicon.

linux#1250 keeps real hibernation off on these machines (hibernation_available() is false and /sys/power/disk stays [disabled]) and only lets hibernate() run while pm_test is set, so no image is made. Even so, every dry run was refused somewhere:

  • apple-pmu-rtc refused every hibernation transition in .prepare with -EBUSY. Its check for "a suspend state that cannot bring the alarm back" also fires for hibernation, because pm_suspend_target_state stays PM_SUSPEND_ON there. On the M2 this stopped 20 of 20 dry runs on the current kernel.
  • mt7932 Wi-Fi (J700) returned -EOPNOTSUPP from freeze and poweroff and had no thaw or restore.
  • The M4-class DCP, an adopted RTKit helper session and a retained T8140 radio bootstrap refused the freeze.
  • The H16 and H17 ANE notifiers refuse PM_HIBERNATION_PREPARE while the firmware is retained. This stopped every dry run on the J616s.
  • brcmfmac refuses D3 entry for any state other than s2idle when WoWLAN is configured. This stopped every dry run on the M1 Pro, which has WoWLAN set.

Changes:

  • rtc: apple-pmu: refuse only real suspend states in .prepare. Hibernation needs no wake alarm.

  • mt7932: freeze and poweroff stop the host interface as suspend-to-RAM does (DMA stops and the firmware takes ownership). Thaw and restore use the resume path, which restarts the host interface. If the rings are gone after a power cycle, it hands the radio to the platform radio recovery.

  • hibernation_available() is exported.

  • The DCP, rtkit-helper and the T8140 bootstrap still refuse when an image could be made. When it can't, the DCP takes its suspend-to-idle power-down and resume brings back the same session; the helper and the bootstrap stay as they are.

  • accel/ane: while hibernation_available() is false, a dry run is handled like suspend: the engine is powered off for the freeze and booted again from the preload. Restore and real hibernation stay refused.

  • brcmfmac: hibernation leaves WoWLAN out and takes the plain D3 path. Suspend states are unchanged.

Real images stay disabled. Cold restore of each coprocessor and the resume path come in later changes with their own tests.

A dry run resumes devices with PMSG_RESTORE (in_suspend is 0 at that point), so these runs exercise .restore on warm hardware.

Results, M2 (T8112), test kernel built from this branch on integration/aurora ac601ea, SELinux enforcing:

Row Before (fleet kernel) After
pm_test devices 0/10 (apple-pmu-rtc -EBUSY) 10/10, 6.3 to 6.5 s each
pm_test platform 0/10 (apple-pmu-rtc -EBUSY) 10/10, 7.5 to 7.6 s each
s2idle, PMU RTC wake 2/2

After every run Wi-Fi was associated with the gateway reachable in 2 to 4 s, Bluetooth was powered, every device freeze and restore callback returned 0 (both DCPs, apple-drm, nvme-apple, brcmfmac, hci_bcm4377), and there were no call traces, DART faults or AVC denials.

The M1 Pro and J616s rows on the earlier test kernel (without the last two commits) stopped at brcmfmac and the ANE respectively, with no other refusal and both machines back on their defaults. Rows on the full branch for M1 Pro, J616s and J700 to follow.

The freeze and poweroff callbacks refused hibernation with -EOPNOTSUPP.
That also aborted every hibernation pm_test dry run at this device, so
the other drivers' freeze and thaw paths could not be exercised on the
machines that carry this chip.

Freeze and poweroff now stop the host interface the way suspend-to-RAM
does: DMA stops and the firmware takes ownership before the image is
made, so nothing writes to memory while it is saved. Thaw and restore
use the resume path. After a dry run or an aborted hibernation the
firmware is still running and the host interface restarts. After a
restored image the rings are gone, mt_hif_restart() reports it, and the
radio goes to the platform radio recovery as after a failed
suspend-to-RAM.

Real images stay disabled on Apple silicon by hibernation_available().

Signed-off-by: Ryan Murray <[email protected]>
Assisted-by: LLM
Drivers that refuse a hibernation freeze because their firmware state
cannot be rebuilt from an image need to tell a real hibernation from a
pm_test dry run, which never makes an image. hibernation_available()
answers that: on Apple silicon it stays false and hibernate() only
runs dry runs. Export it so modular drivers can use it.

Signed-off-by: Ryan Murray <[email protected]>
Assisted-by: LLM
The M4-class DCP, an adopted RTKit helper session and a retained T8140
radio bootstrap refuse the hibernation freeze, because an image cannot
carry their live firmware sessions across the boot that restores it.
They also refused pm_test dry runs, so the freeze and thaw paths of
every other driver on the J616s and the Neo could not be exercised.

Keep the refusal when hibernation_available() is true. While it is
false, only dry runs reach these callbacks and nothing loses power: the
DCP takes its suspend-to-idle power-down and thaw resumes the same
session, and the helper and the bootstrap stay as they are.

Signed-off-by: Ryan Murray <[email protected]>
Assisted-by: LLM
The prepare callback refuses any sleep state that is neither
suspend-to-idle nor firmware-driven, because such a state cannot bring
the PMU alarm back. It runs for hibernation too, where
pm_suspend_target_state stays PM_SUSPEND_ON, so it refused every
hibernation transition, including the pm_test dry runs. On the M2 every
devices and platform dry run stopped here with -EBUSY.

Refuse only real suspend states. Hibernation needs no wake alarm.

Signed-off-by: Ryan Murray <[email protected]>
Assisted-by: LLM
The H16 and H17 backends refuse hibernation from their PM notifiers
while the firmware is retained, because an image would carry firmware
state the restored kernel cannot match. That also refused every
hibernation pm_test dry run, so on the J616s each one stopped at the
ANE notifier with "system sleep not supported yet".

While hibernation_available() is false only dry runs reach the
notifiers. They make no image and keep the power on, so handle
PM_HIBERNATION_PREPARE and PM_POST_HIBERNATION like the suspend pair:
the engine is powered off for the freeze and booted again from the
preload afterwards, as for suspend. PM_RESTORE_PREPARE and real
hibernation stay refused.

Signed-off-by: Ryan Murray <[email protected]>
Assisted-by: LLM
With WoWLAN configured, the D3 entry refuses every sleep state other
than suspend-to-idle with -EOPNOTSUPP. Hibernation keeps
pm_suspend_target_state at PM_SUSPEND_ON, so it was refused too, and
every hibernation pm_test dry run on the M1 Pro stopped at this device
while WoWLAN was set.

Hibernation cannot wake on a packet. Leave WoWLAN out of the freeze and
take the plain D3 path, the one used without WoWLAN. Suspend states are
unchanged.

Signed-off-by: Ryan Murray <[email protected]>
Assisted-by: LLM
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Blockers: 4.

  1. CI is red because of this PR. host-tests fails every pmu-rtc case: rtc-apple-pmu.c:440 now uses PM_SUSPEND_ON, but the harness at tools/asahi/pmu-rtc-tests.py:60 defines only PM_SUSPEND_TO_IDLE, so the extracted copy does not compile. Add PM_SUSPEND_ON (and a deep value) to the harness, plus a case showing that prepare passes with the target at PM_SUSPEND_ON and still refuses deep without firmware.
  2. The PR conflicts with integration/aurora. Rebase.
  3. mt_freeze() (mt7932.c:1525-1527) returns mt_hif_suspend(), which returns 0 even when DMA did not stop (:1470) or the firmware did not take ownership (:1474). For s2idle that choice is defensible. For freeze, the comment's guarantee that "nothing writes to memory while it is saved" is exactly what fails silently. Today only dry runs get here, but this is the path a real image will take. Return the error from the freeze/poweroff path so hibernation aborts instead.
  4. Every commit carries an Assisted-by: LLM trailer. Commits should carry only the human Signed-off-by; the Assisted-by line goes at the end of the PR body (already there). The Signed-off-by also uses a GitHub noreply address, where the other series use the project address; pick one identity.
  5. Rows: only the M2 ran this head. The new paths that matter are all on other Macs and none has run there on the full branch: the M4-class DCP freeze into iomfb_m4_suspend() (dcp.c:8745) and the ANE dry-run mapping (J616s), the brcmfmac WoWLAN-to-plain-D3 path (M1 Pro), and the mt7932 freeze/thaw, adopted rtkit-helper and T8140 bootstrap (J700, never run).

Nit: ane_fw_sleep.h now has two block comments in a row. The existing one (:10-20) describes ane_fw_sleep_refused_cycle(), so move it back above that function.

HW row: rebased head on M2, M1 Pro (WoWLAN set), J616s and Neo J700. Pass criteria: pm_test devices, platform and core, 10/10 each; Wi-Fi associated and BT up after every run; one real s2idle with WoWLAN wake on the M1 Pro unchanged; /sys/power/disk still [disabled]; 0 AVC, 0 failed units, no new kernel errors.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Closing for now: real hibernation stays off and the dry-run fixes need a rebase and CI fixes; they can come back with the hibernation work.

@RyanTheTide RyanTheTide reopened this Nov 22, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Reopened and kept as a draft; the comment above lists what it still needs before review.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant