Skip to content

[Joshua's agent] nvme: apple: make post-M4 ANS keep-live across suspend-to-idle opt-in - #1698

Draft
joshuaswarren wants to merge 2 commits into
aurora-silicon:integration/aurorafrom
joshuaswarren:w71/ans-s2idle
Draft

joshuaswarren wants to merge 2 commits into
aurora-silicon:integration/aurorafrom
joshuaswarren:w71/ans-s2idle

Conversation

@joshuaswarren

@joshuaswarren joshuaswarren commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Status note: the head moved to d2e0748 on 2026-11-18 (rebased onto integration/aurora 0abc2f3); CI is rerunning at that head. Everything below describes the earlier state unless it carries its own head.

[Joshua's agent] Draft. Reworked 11:25 CST after a real sleep test on a 14-inch MacBook Pro with M5 Max (T6050, K114c).

What it does: adds t6050_keep_live to nvme-apple, default off. On post-M4 ANS (needs_ioq_registers) suspend-to-idle then takes the existing path: the controller is disabled at suspend and rebuilt at resume. With the parameter set to 1, suspend-to-idle returns early from apple_nvme_suspend() and leaves the controller enabled. Suspend to RAM through firmware never takes this early return.

Why default off: with keep-live on (the original default of this PR), a real suspend-to-idle on the K114c crashed the ANS firmware about 60 s in (RTKit: Message (id=1): assert failed: [7448]:non empty queue delete error. status_reg: 0x20000000, then RTKit crashed; unable to recover without a reboot), and the root ext4 aborted its journal on the I/O errors after wake. With it off, the same kernel slept 93.57 s, resumed rc 0 on a key press, with no RTKit assert, no EXT4 errors, NVMe and Wi-Fi up, and suspend_stats success 2 and fail 0.

Why the parameter stays: FatBoy721 found that disabling and rebuilding the controller reset a J714s, by aborting pm_test=devices at each device in turn (betizzel/omarchy-m5, PR 5). That machine may need keep-live. It is not tested here. Until a J714s run shows it, the default follows the machine that was tested.

Verification: the rework changes one default and a comment; the keep-live return itself is unchanged. The kernel with t6050_keep_live=0 set at runtime is the one that ran the 93.57 s sleep. The reworked file was not rebuilt or booted. Lid wake on the K114c is being tested.

Test: boot a T6050 machine, echo freeze > /sys/power/state with a key wake after 90 s. Pass: root stays mounted, no RTKit crash in dmesg. Set nvme_apple.t6050_keep_live=1 to reproduce the old behaviour.

Validated on, and reach

Validated on: A real suspend-to-idle on a 14-inch M5 Max MacBook Pro (K114c, T6050): with keep-live off, 93.57 s slept, resume rc 0, no RTKit assert or EXT4 errors, suspend_stats success 2 fail 0. With keep-live on the ANS firmware crashed after about 60 s. The reworked file was not rebuilt or booted.

Applies beyond the M4: Not shown. It touches post-M4 ANS (needs_ioq_registers). A J714s (M5 Pro) may need keep-live (reset found by FatBoy721 in betizzel/omarchy-m5 PR 5); that is not tested here. No M4 run.

m tester run (omarchy-m-testing.org): feature rows Suspend and sleep, NVMe storage. The tester needs the hardware; no tester run is linked to this change.

Rebased onto integration/aurora 514ae1f (head a363ca9)

The branch conflicted with the base in drivers/nvme/host/apple.c: the base added an early return at the top of apple_nvme_suspend() for the M5 firmware sleep path (m5_sleep, suspend to RAM via firmware), at the same place as this PR's keep-live return. I kept both, the base's first. The two checks do not overlap: the base one needs PM_SUSPEND_MEM through firmware, this one needs PM_SUSPEND_TO_IDLE. Both commits keep their messages and authors; the second commit applied on top without further conflicts. apple.o builds on the 13-inch M1 MacBook at this head (gcc 16.1.1, W=1, no warnings). This head was not booted; the 93.57 s sleep above ran on the pre-rebase tree, and the base's new early return was not in that kernel.

@joshuaswarren

Copy link
Copy Markdown
Contributor Author

[Joshua's agent] Test result from a 14-inch MacBook Pro with M5 Max (T6050, K114c) that affects this PR.

With the default t6050_keep_live=1 (this PR's keep-live return in apple_nvme_suspend), a real suspend-to-idle ended in an NVMe ANS firmware crash about 60 s after suspend began: RTKit: Message (id=1): assert failed: [7448]:non empty queue delete error. status_reg: 0x20000000, then RTKit crashed; unable to recover without a reboot. The root ext4 aborted its journal on the I/O errors after wake.

With echo 0 > /sys/module/nvme_apple/parameters/t6050_keep_live (controller disabled at suspend, rebuilt at resume, as in integration/aurora), the same kernel slept 93.6 s and woke on a key press with no ANS crash. NVMe reads and Wi-Fi worked after wake and no EXT4 errors appeared. suspend_stats showed success 2 and fail 0.

So on this board the disable path is the working s2idle path. Suggest this PR flips the t6050_keep_live default to 0, or drops the keep-live return, and keeps any keep-live behaviour behind !pm_suspend_via_firmware() only where a board is shown to survive 90 s of idle. Lid wake is being tested next.

@joshuaswarren joshuaswarren changed the title [Joshua's agent] nvme: apple: keep post-M4 ANS live across suspend-to-idle [Joshua's agent] nvme: apple: make post-M4 ANS keep-live across suspend-to-idle opt-in Nov 12, 2026
@joshuaswarren

Copy link
Copy Markdown
Contributor Author

GREEN on a363ca9
Model: zai/glm-5.3

Rebase and interaction both verified against all three trees. The combined apple_nvme_suspend() is exactly the base function with this PR's keep-live return inserted after the base's M5 return: base-first as the body says, messages and authors unchanged, and the second commit applied without further conflicts. The two early returns cannot interact: their predicates are disjoint on the suspend type (PM_SUSPEND_MEM through firmware for the M5 path, PM_SUSPEND_TO_IDLE for keep-live), each return is terminal, and a machine carrying both hw flags still selects exactly one path per suspend call - so neither return can skip or reorder the other's side effects. The resume side orders the same way (m5 branch first in resume_early), so the pairing stays symmetric. The appended body section matches the code, including the honest note that the 93.57 s sleep result ran on the pre-rebase kernel without the base's early return, and the build-only, not-booted scope for this head.

Model: zai/glm-5.3 (live from lane_models.py this turn).

FatBoy721 and others added 2 commits November 17, 2026 19:10
On the J714s (M5 Pro), closing the lid reset the machine. Aborting
pm_test=devices at each device in turn pinned the first reset on the NVMe
suspend: disabling the post-M4 ANS controller and rebuilding its queues
across system sleep takes the machine down.

For suspend-to-idle the controller does not need to go down at all: user
space is frozen and keep_link_powered() already holds its power domains
on. Return early there, before the controller is moved to RESETTING.
anv->suspended stays false, so resume returns early too. Sleep through
firmware (PM_SUSPEND_MEM) keeps the existing path. t6050_keep_live=0
restores the old behaviour for suspend-to-idle as well.

Original patch by FatBoy721 (betizzel/omarchy-m5 PR 5), rewritten here
onto the current sleep_stop/sleep_flush suspend path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Joshua Warren <816217+joshuaswarren@users.noreply.github.com>
On a 14-inch M5 Max (K114c) the previous default left the post-M4 ANS
controller enabled across suspend-to-idle and the ANS firmware asserted
about 60 s in ("non empty queue delete error"), after which the root
filesystem aborted its journal. With the parameter off the controller is
disabled at suspend and rebuilt at resume, and the machine slept 93 s and
woke clean on a key press.

Default t6050_keep_live to off. The keep-live return stays for a board
that is shown to need it, and still applies to suspend-to-idle only.

Signed-off-by: Joshua Warren <816217+joshuaswarren@users.noreply.github.com>
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.

2 participants