Repository navigation
nvme: apple: give every ANS the longer RTKit handshake timeout - #2475
Conversation
nvme-apple raised the RTKit handshake timeout to 10 s only for the apple,t6050-nvme-ans2 ANS, because its iBoot-handed firmware can take about 3 s to answer the power-state and endpoint-map handshake. That is firmware behaviour, not a T6050 property: any ANS firmware handed over by iBoot can be slow, and a newer SoC would fail to boot with "ANS did not boot" before anyone added its compatible. The wait ends as soon as the reply arrives, so a fast ANS is not slowed down; only a dead ANS is reported later. Set the timeout for every ANS. The post-sleep "ANS on" loop retried apple_rtkit_boot() 15 times, a budget written for the 1 s timeout. Bound it by time since the run bit (15 s) instead, so a longer timeout does not stretch the wait for a dead ANS to 150 s. Fixes: 0630fab ("soc: apple: rtkit: wait up to 10 s for a handshake reply") Suggested-by: Rolando Trevino <[email protected]> Signed-off-by: Ryan Murray <[email protected]>
apple_nvme_m5_sleep() required the T6050 sleep policy from the match data and then also apple,t6050-nvme-ans2. The policy is only in apple_nvme_t6050_hw, which only that compatible matches. Drop the second check. No behaviour change. Signed-off-by: Ryan Murray <[email protected]>
|
J616s row (MacBook Pro 16" M4 Pro, T6040). One-shot test kernel: integration 2c35f50 + this PR's two commits, fleet75 config. The loaded nvme-apple build-id matches that build.
|
|
Rows on the J413, J316s and J616s are clean. Still needed: a Neo J700 row (NVMe root boots clean, and one sleep cycle shows "ANS: on N ms after the run bit" well under 1000 ms, since the post-sleep retry loop changed), and a review. |
RyanTheTide
left a comment
There was a problem hiding this comment.
Review at c967739. The ANS allocation change extends the same handshake to every controller. Normal replies still end the wait immediately. The sleep restart change compares elapsed time only between apple_rtkit_boot() attempts, so the last attempt can run past the stated 15 s budget. Please pass the remaining budget to the blocking attempt or describe the actual upper bound and prove that it fits the resume watchdog. Include missing-reply and slow-reply host cases and the J413/J473 NVMe resume row.
There was a problem hiding this comment.
Formal §1–§6 pre-PR checklist review at c9677392918b298ab3fd4efd8788d3ff86cf840f:
- §1 No model gating: Pass — removes two
of_device_is_compatible(..., "apple,t6050-nvme-ans2")gates (drivers/nvme/host/apple.c:2776anddrivers/nvme/host/apple-m5-sleep.h:196). Commit 2 is verified equivalent since onlyapple_nvme_t6050_hwsetsm5_sleep = &apple_nvme_t6050_sleep_policy. - §3 Safety, §4 Clean-room & attribution, §6 Naming: Pass. Both commits have human author/committer and human
Signed-off-by:only (zero AI commit trailers); PR body hasAssisted-by:;host-testsCI passes.
Blockers
-
§2 / Correctness —
apple_nvme_sleep_wait_on()overshoots the stated 15 s budget (drivers/nvme/host/apple.c:3004-3065):apple_nvme_sleep_wait_on()only checksktime_ms_delta(ktime_get(), anv->sleep_run_time) < APPLE_NVME_SLEEP_ON_MS(15 s) betweenapple_rtkit_boot()attempts.- Because
apple_rtkit_boot()now usesAPPLE_NVME_HANDSHAKE_TIMEOUT_MS(10 s) on every ANS at each blocking handshake step (epmap_completion,iop_pwr_ack_completion,apple_rtkit_set_ap_power_state), a dead ANS always runs at least two full 10 s iterations (~20 s), and an ANS that partially progresses and fails near 14.9 s triggers another full 10–30 sapple_rtkit_boot()call — overshooting the documented 15 s cap to 20–35+ s. - Please pass/clamp the remaining time budget into the wait (or add a deadline-bounded RTKit boot helper) so the 15 s limit is actually enforced, or explicitly document and prove the real worst-case upper bound against the resume path/watchdog.
-
§5 Evidence — modified post-sleep retry path (
apple_nvme_sleep_wait_on()) has no hardware run:apple_nvme_sleep_wait_on()is only entered on controllers withsleep_traced = true(T8132,T8140Neo/J700,T8142). None of the tested Macs (J413T8112,J316sT6000,J616sT6040) exercise that path, and commit 2 (apple_nvme_m5_sleep()) is T6050-only with no T6050 row.- Please add at least a hardware sleep-resume row on a
sleep_tracedMac (e.g., Neo J700 / T8132) confirming"ANS: on N ms after the run bit"with 0 kernel errors, 0 AVC denials, and 0 failed units (as noted in "Still to run").
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Verdict: FINISH, then merge at c9677392918b
Blockers:
drivers/nvme/host/apple.c:3022-3065,apple_nvme_sleep_wait_on(): the 15 sAPPLE_NVME_SLEEP_ON_MSbudget is only checked betweenapple_rtkit_boot()attempts, and each attempt can now wait the 10 s handshake timeout at every step on every ANS. A dead ANS therefore takes at least two full attempts (about 20 s), and one that fails near 14.9 s starts another full attempt, so the wake can hang for 20–35 s against the stated 15 s. Fix: pass the remaining budget into the boot (a deadline-bounded RTKit boot helper), or stop when the remaining time is shorter than one handshake.
Checked: no Apple material. This removes a chip gate: every ANS gets the longer RTKit handshake timeout. The J413 and other combined-kernel boots (3 s2idle cycles, 0 NVMe timeout lines) show no regression. CI green. This replaces my earlier review.
Evidence
Read c9677392 (apple.c, apple-m5-sleep.h).
Superseded by the review at c967739
Review follow-up. apple_nvme_sleep_wait_on() checked its 15 s budget only between apple_rtkit_boot() attempts, and with the longer handshake timeout on every ANS each attempt can wait 10 s at every handshake step. A dead ANS took at least two full attempts, and one that failed near the end of the budget started another, so a wake could hang for 20-35 s. Add apple_rtkit_boot_by(), which runs apple_rtkit_boot() with no handshake wait past a deadline, and give each attempt the time left in the budget, at least 1 s so a late attempt still gets a chance. The whole wait now ends within about 16 s. Other RTKit users are unchanged: without a deadline each wait still takes the handshake timeout. Signed-off-by: Ryan Murray <[email protected]>
|
Fixed at 958951f (fix commit 38531c4 plus a merge of Blocker 1 (15 s budget overrun): a new |
|
Row at ANS comes back from s2idle on T6000 and T8112 with 0 "not on" lines. The deadline bound itself only matters for a dead ANS, which can't be produced on demand. DetailBoth rows ran on the default cmdline with the kernel booted once as a non-default entry, then back to fleet89, which was verified afterwards (saved entry, empty next_entry, kernel removed, 0 failed, Enforcing). Per Mac: SELinux Enforcing, 0 failed units, 0 AVC, 0 err-level kernel lines, 0 oops; Wi-Fi ping OK; s2idle (rtc1, 15 s) rc=0 with ping and a 64 MiB direct NVMe read after the wake; Apple SoC watchdog armed with time left counting (44 s and 58 s of systemd's 60 s); dEQP-VK |
|
Row at Third family: ANS comes back from s2idle on T8140 too, with 0 "not on" lines. DetailNeo (J700, T8140/G17P), fixa2 booted once as a non-default BLS entry, then back to fleet89, verified afterwards (saved entry, empty next_entry, kernel removed, 0 failed, Enforcing). SELinux Enforcing, 0 failed units, 0 AVC, 0 oops, 0 err-level kernel lines; Wi-Fi up; G17P Vulkan device; dEQP-VK api.smoke 8/8 and draw.renderpass.simple_draw 4/4; watchdog armed (57 s left of 60); s2idle on rtc0 rc=0 with a 64 MiB direct NVMe read after the wake. Two lines are the same on fleet89 (baseline traced): the boot-time "G17: crash logs from the firmware data segment" note, and Wi-Fi needing ~9 s after the wake before ping answers. Logs: traces/kernel/20261127-fixa2-rows/neo/ (store). |
There was a problem hiding this comment.
Verdict: MERGE at 958951f6
Blockers: none (27/27 CI green and 3-family exact-head rows PASS; ready to merge).
Checked:
drivers/nvme/host/apple.c,apple-m5-sleep.h,drivers/soc/apple/rtkit*: commit38531c49resolves the prior dead-ANS timeout-budget blocker cleanly by computing remaining budgetAPPLE_NVME_SLEEP_ON_MS - elapsed(clamped byAPPLE_NVME_SLEEP_TRY_MIN_MS) and bounding each retry withapple_rtkit_boot_by(anv->rtk, jiffies + msecs_to_jiffies(left)).- Removes two
of_device_is_compatible(..., "apple,t6050-nvme-ans2")gates so every ANS shares the longer RTKit handshake timeout andm5_sleepmatch-data path. - Hardware rows & CI: 27/27 CI checks green (
SUCCESS),MERGEABLEonmain, and exact-head s2idle rows PASS across three families (J316s M1 Pro, J413 M2 Air, J700 Neo, 0 "not on" errors). - Checked for Apple material, tool attribution, private serials, and gating: clean; human
Signed-off-bypresent.
Evidence
- Head:
958951f6e26a(base: main,mergeable: MERGEABLE,+66/-16across 5 files).
|
code-owner ping <@422957901716652033> / @DjDeveloperr: merge train at |
|
Merging under the 6-point rule (Ryan 09:29, permanent), at |
Problem
nvme-apple raised the RTKit handshake timeout to 10 s only for
apple,t6050-nvme-ans2(drivers/nvme/host/apple.c:2743, 0630fab), because iBoot-handed ANS firmware can take about 3 s to answer. That is firmware behaviour, not a T6050 property. A new SoC would fail with "ANS did not boot" until someone added its compatible. Separately,apple_nvme_m5_sleep()checked the T6050 compatible next to match data that already implies it.Change
Testing
Built with the lane release config (arm64, LLVM=1):
drivers/nvme/host/apple.owith W=1, no new warnings.Hardware (one-shot test kernel 7.3.0-aurora-swl1 or -swl2 = integration 0abc2f3 + this and the other open sweep PRs, 2026-11-20):
Hardware (one-shot test kernel 7.3.0-aurora-swl1 or -swl2 = integration 0abc2f3 + this and the other open sweep PRs, 2026-11-20):
Still to run
dmesg | grep -iE 'ANS|nvme'shows no timeout. Hardware rows: pending.Credit and reach
Rolando Trevino found and fixed the slow handshake on T6050. The change reaches T8103/T8112/T600x/T602x/T603x/T604x/T8122/T8132/T8140/T8142/T6050 ANS. On all of them, success returns at the first reply, so the change only matters when the ANS fails.