Skip to content

nvme-apple: issue T6050 sleep shutdown notification in suspend_late - #3780

Draft
tully-8888 wants to merge 1 commit into
aurora-silicon:mainfrom
tully-8888:fix/nvme-m5-suspend-late-shn
Draft

tully-8888 wants to merge 1 commit into
aurora-silicon:mainfrom
tully-8888:fix/nvme-m5-suspend-late-shn

Conversation

@tully-8888

@tully-8888 tully-8888 commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

What: Move T6050 (M5 Pro) ANS sleep CC.SHN from the 1 s IRQ-off atomic poll in apple_nvme_m5_final_stop() into a new apple_nvme_suspend_late() callback (sleepable, IRQs on, outside CONFIG_DPM_WATCHDOG, before SART's suspend_late snapshot), with a 35 s macOS-matched bound capped against the platform WD2 deadline (apple_sleep_ans_m5_wd2_remaining_ms()), pre-SHN readiness checks on both NVMe/NVMMU apertures, and bounded dual-window reset cleanup on sleep refusal. Related to #3338 (keeping root-cause attribution provisional until a baseline post-I/O final stop: log is captured).

Tested: J714s MacBook Pro 14" M5 Pro (Mac17,9, T6050) at 9654de6dfbec, in the batched Boot #11 kernel 7.3.0-j714s-b11+ (main 9ece2d8202d2 plus 16 open PR heads unchanged, this one included, plus local J714s patches), 2026-12-04: boots, 0 failed units, 0 new kernel warnings against the previous boot. Storage I/O runs with 0 NVMe timeout, reset or I/O error lines. The sleep path of this PR did not run: both deep sleep attempts were refused before suspend_late by the external display controller, with -16 while the TV stayed connected (V27 sleep: refused before its calls: a DPTX port still connected).

Boot #11 row

Kernel: local branch j714s-boot11-test at e7ab6d7b65c2. Its last commit is a test-only patch with runtime switches that turn single PR changes off, for same-kernel A/B runs. In an A/B row the "off" arm is that switch, which emulates the old code; it is not the old tree.

Non-default command line: nvme_apple.flush_interval=0 cpuidle.governor=teo ane_t6021.irq_wait=0 ane_t6021.irq_wait_switch=1 ane_t6021.bridge_record=1 appledrm.ext_pq_as_hlg=1 kvm.halt_poll_ns_grow_start=100000 macsmc.m5_pcio_budget=2 macsmc.m5_n1_budget=3 arm64.nowfxt zswap.enabled=0 softlockup_panic=1.

Earlier rows

Base aurora-silicon/linux main (352cd953c779):

  • Arm64 compilation (drivers/nvme/host/apple.o and drivers/soc/apple/sleep.o, Clang 23.1.5, W=1, 16 KiB pages, Apple SoC sleep + NVMe enabled): clean with zero new warnings vs base.
  • scripts/checkpatch.pl and git diff --check: 0 errors, 0 warnings.
  • Host state-machine simulation covering dual-window shared and independent NVMe/NVMMU apertures, pre-SHN readiness gates, unresolved-SHN guard at rtkit_ready, WD2 remaining-budget refusal/clamping, and owner rebuild-deadline abort before reap/queue writes.
  • Verified on J714s (7.3.0-17.v272-27-ARCH /proc/config.gz) that CONFIG_DPM_WATCHDOG=y (TIMEOUT=15, WARNING_TIMEOUT=5), confirming a 35 s wait in .suspend would panic.

Risk: two-way door · affects T6050 firmware sleep (PM_SUSPEND_MEM with pm_suspend_via_firmware()) only; s2idle, hibernation, and other SoCs are untouched (apple_nvme_suspend_late() is a no-op unless APPLE_M5_ANS_PREPARED). Kept as Draft until hardware deep-sleep and refusal-reset (pm_test=platform) testing is completed on J714s.

Not yet:

  • CI apple-build + KUnit (nvme-apple).
  • Hardware testing on J714s (T6050) across idle sleep, post-O_DIRECT stress sleep, pm_test=platform refusal-after-SHN reset + subsequent disk I/O and second sleep, and confirmation of whether mmio_nvmmu (0x41dcc0000) and mmio_nvme (0x45dcc0000) alias CC/CSTS and whether ANS storage power words stay on/auto after CC.SHN.

On T6050 (M5 Pro), apple_nvme_m5_final_stop() currently issues CC.SHN
with interrupts disabled after the point of no return and polls
CSTS.SHST atomically for only 1 s (APPLE_ANS_SLEEP_SHN_TIMEOUT). After
heavy write workloads, ANS FTL context save can exceed 1 s (macOS waits
up to 35 s), causing final_stop to time out after commit and fence ANS
on wake rather than refusing sleep cleanly.

Moving a 35 s wait into .suspend is unsafe when CONFIG_DPM_WATCHDOG=y
(15 s panic timeout on J714s kernels), because the DPM watchdog covers
.suspend/.resume. Move T6050 CC.SHN to a new apple_nvme_suspend_late()
callback, which is sleepable with interrupts enabled, outside the DPM
watchdog, and ordered before the SART supplier's suspend_late snapshot
via the managed device link in devm_apple_sart_get():

- Export apple_sleep_ans_m5_wd2_remaining_ms() from apple-sleep so
  suspend_late checks the exact remaining WD2 budget armed at .begin
  and refuses sleep before writing CC.SHN if the wait plus margin
  cannot fit inside WD2.
- Verify live CC/CSTS readiness and zero pending CQEs on both the NVMe
  and NVMMU apertures before read-modify-writing only CC.SHN on the
  NVMMU aperture.
- Verify CSTS.SHST completion in apple_nvme_m5_last_check() and keep
  apple_nvme_m5_final_stop() read-only for CC/CSTS (RTKit polled idle
  only).
- Track shn_issued so refused-sleep controller reset clears and
  verifies the NVMMU aperture within the rebuild owner's remaining
  deadline, honors rebuild_aborted/retained fences before reap or queue
  programming, and refuses queue setup if an issued shutdown remains
  unresolved.

Related: aurora-silicon#3338
Signed-off-by: vlad <tulituvlad@gmail.com>
@tully-8888

Copy link
Copy Markdown
Contributor Author

Partial live J714s hardware test row (9654de6 built into 7.3.0-j714s-test+ on a17872841, 14-inch MacBook Pro M5 Pro, T6050, system firmware 27.2 / 26B123, 45dcc0000.nvme):

  • Refusal after suspend_late SHN (pm_test=platform, mem_sleep=deep): passed .suspend() prepare, .suspend_late() SHN, 5-second platform wait, and refusal rebuild with exit code 0, zero NVMe errors, and verified post-wake root filesystem read/write I/O.
  • Refusal at apple-sleep commit gate (rtcwake -d rtc1 -m mem -s 45, mem_sleep=deep, non-boot CPUs offlined, refused before commit because apple_sep is not opted in on this image): passed .suspend_late() SHN and refusal rebuild cleanly with zero NVMe errors and verified post-wake I/O.
  • Still pending before leaving Draft: committed firmware deep-sleep row (final stop: CC ..., CSTS ... (other window ...) + post-wake I/O) on a host with apple_sep enabled.

@tully-8888

Copy link
Copy Markdown
Contributor Author

Hi, the CI runs on my open PRs are still waiting for workflow approval (action_required), so their build checks have not run yet. Could a maintainer approve the pending runs when you look at the diffs?

linux: #3780 #3784 #3840 #3843 #3946 #3947 #3964 #3978 #4229 #4230 #4231 #4282 #4283 #4284 #4286 #4314
also aurora-silicon/mil-hwx-compiler#52 and aurora-silicon/libva-v4l2_request#5

I am building one test kernel that merges all of these heads unchanged on current main, and I will post a hardware row on each PR from it. I will not open new PRs until these are merged or closed.

@RyanTheTide

Copy link
Copy Markdown
Contributor

@tully-8888 sorry for the wait: I've approved the pending workflow runs on your open PRs (#3780, #3784, #3787, #3843, #3947, #3964), so build, host tests and KUnit are running now.

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.

2 participants