Skip to content

Hibernation pm_test dry runs on Apple silicon - #1814

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

RyanTheTide wants to merge 10 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 <81541646+RyanTheTide@users.noreply.github.com>
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 <81541646+RyanTheTide@users.noreply.github.com>
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 <81541646+RyanTheTide@users.noreply.github.com>
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 <81541646+RyanTheTide@users.noreply.github.com>
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 <81541646+RyanTheTide@users.noreply.github.com>
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 <81541646+RyanTheTide@users.noreply.github.com>
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.

Conflicts: the ANE notifiers keep main's early return before anything is
retained or pinned, then map a dry run's events; brcmfmac keeps main's
radio sleep lease and this branch's hibernation D3 path.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
- mt7932: mt_hif_suspend() now returns the first failure to stop the
  host interface (firmware stop, DMA stop, ownership). Suspend-to-RAM
  still only logs it, as before. Hibernation freeze and poweroff return
  it after bringing the host interface back, so the PM core aborts the
  hibernation instead of saving an image while the firmware may still
  write to memory.
- pmu-rtc host test: define PM_SUSPEND_ON and PM_SUSPEND_MEM; prepare
  passes with the target at PM_SUSPEND_ON (hibernation) and still
  refuses deep sleep without firmware.
- ane_fw_sleep.h: the block comment that describes
  ane_fw_sleep_refused_cycle() sits above it again.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Updated to 6b2d380:

  • Merged main (21fd6e9). In the ANE notifiers main's early return (nothing retained/pinned) comes first, then the dry-run event mapping. brcmfmac keeps main's radio sleep lease and this branch's hibernation D3 path.
  • Blocker 1: tools/asahi/pmu-rtc-tests.py now defines PM_SUSPEND_ON and PM_SUSPEND_MEM. It checks that prepare passes with the target at PM_SUSPEND_ON and still returns -EBUSY for deep sleep without firmware. Local run passes.
  • Blocker 3: mt_hif_suspend() returns the first failure (firmware stop, DMA stop or ownership). Suspend-to-RAM still only logs it. freeze and poweroff bring the host interface back (no .thaw follows a failed freeze) and return the error, so the hibernation aborts.
  • Nit: the ane_fw_sleep.h block comment is back above ane_fw_sleep_refused_cycle().
  • Blocker 4 (trailers on the old commits): those commits are already pushed and stay as they are (no force push). Please drop the trailers in the squash message.
    Build: all touched objects (ane_fw_cold, ane_h16_backend, dcp, brcmfmac pcie, mt7932, pcie-apple-t8140-bootstrap, rtc-apple-pmu, rtkit-helper, kernel/power/hibernate) build with aurora_defconfig, LLVM and W=1, with no warnings.
    Still draft: needs the pm_test rows on M2, M1 Pro (WoWLAN set), J616s and Neo J700 (queued).

brcmf_pcie_pm_enter_D3() now compares pm_suspend_target_state with
PM_SUSPEND_ON (hibernation takes the plain D3 path), and the fixture
that compiles it had only PM_SUSPEND_TO_IDLE and PM_SUSPEND_MEM, so
host-tests failed to build it. Add the kernel's value.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Hardware row at exact head 775f31d230cd on the M1 Pro (J316s, WoWLAN set): PARTIAL.

  • pm_test dry runs with echo disk > /sys/power/state: devices 10/10, platform 10/10, core 10/10, all rc=0. Base kernel: 10/10 refused with -EBUSY from apple_pmu_rtc_prepare.
  • Wi-Fi associated and gateway ping ok + BT powered after every run (at the core level, 2 of 10 checks 4 s after the run still saw wlan down; it was back by the next check).
  • /sys/power/disk stays [disabled]; one real s2idle afterwards with WoWLAN (magic packet) set woke normally.
  • Gap: every core-level run logs Error taking CPU9 down: -95 and Non-boot CPUs are not disabled, so the core level stops at CPU offline on this Mac (not code from this PR, but the core dry run is not complete here).

How: one combined test kernel for six PRs, not this PR alone. Kernel 7.3.0-aurora-ci = main d0684a06 + merge commits of linux#2804 95b14b2c, #3913 35141126, #2802 fd2472c2, #2403 aca4e954, #1814 775f31d2, #2398 75b30c6c (all merged clean, test commit 837c6334, cloud build https://github.com/aurora-silicon/linux/actions/runs/47474056828). Booted as a one-shot on the lab M1 Pro (J316s, T6000, 13.5 stub) with this kernel's own DTBs in a trial Stage 2 (live aura 1.0.0b19 + U-Boot, only the DTBs swapped), default cmdline. Boot health on the test kernel: 0 error-level kernel lines (base 0), 0 AVC, 0 failed units. Saved default restored after.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Hardware row at exact head 775f31d230cd on the Neo (J700): FAIL on this Mac.

  • echo core > /sys/power/pm_test; echo disk > /sys/power/state: 10/10 refused with -EOPNOTSUPP. Each run logs apple-t8140-bootstrap 390030000.piodma: sleep refused: Neo guard active during radio admission or retained DMA lifetime.
  • So the retained T8140 radio bootstrap still refuses the hibernation freeze on the Neo. Wi-Fi + BT stayed up, /sys/power/disk stays [disabled].
  • For comparison, the M1 Pro run of the same head passed all three levels: Hibernation pm_test dry runs on Apple silicon #1814 (comment)

How: one combined test kernel for eight PRs, not this PR alone. Kernel 7.3.0-aurora-ci = main d0684a06 + merge commits of linux#2712 b6887f88, #2300 c1d351d2, #1990 83ef8b0f, #3742 798c2cde, #2350 5f18911e, #2398 75b30c6c, #1814 775f31d2, #2402 07660961 (all merged clean, test commit 03a571ef, cloud build https://github.com/aurora-silicon/linux/actions/runs/47474056726). Booted as a one-shot on the lab Neo (J700, T8140, 26.6.2 stub) with this kernel's own t8140-j700.dtb in a trial Stage 2 (live aura 1.0.0b19 + U-Boot, only the DTB swapped), default cmdline, silent (no audio playback). Boot health on the test kernel: 0 error-level kernel lines, 0 AVC, 0 failed units. Saved default restored after.

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