Skip to content

mfd: macsmc: give atomic writes time for the SMC to answer - #918

Merged
RyanTheTide merged 1 commit into
aurora-silicon:integration/aurorafrom
techmore:m4/macsmc-atomic-wait
Nov 5, 2026
Merged

RyanTheTide merged 1 commit into
aurora-silicon:integration/aurorafrom
techmore:m4/macsmc-atomic-wait

Conversation

@techmore

@techmore techmore commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Regression on the Mac mini M4 (J773g, T8132) since c243a5f ("mfd: macsmc: bound the atomic write poll", #368): a reboot from Linux ends in macOS.

apple_smc_write_atomic() now gives the SMC 500 ms and, with a command still pending, polls once and returns -EBUSY (03dc729). On this J773g the restart write (MBSE = 'phra' from macsmc_restart()) sometimes does not get its reply within 500 ms. macsmc_restart() only logs the failure and returns NOTIFY_OK, so the restart chain reaches apple_wdt_restart(); iBoot takes the watchdog reset as a crash (panicmedic-telemetry is set) and boots macOS instead of the Linux startup volume. The unbounded poll before #368 does not show the problem (GravityLinux's macsmc still has it and reboots fine on the same machine).

This keeps the bound that #368 introduced, but makes it 5 s in the atomic paths: wait that long for a pending earlier command before refusing, and that long for the reply. Replies slower than 100 ms, and failures, are logged so slow SMCs show up.

Tested: J773g, integration/aurora @ 19f71a1 + this change, booted via m1n1-gravity → U-Boot → Limine with GravityLinux's J773g DT plus the NVMe nvmmu window. Unpatched: reboot -f from a test initramfs → macOS (2026-11-02 23:12). Patched: the same path returned to Linux through the SMC (2026-11-03 10:59). The "reply after N us" number the patch logs has not been captured yet (no persistent console on that run); I'll add it from the next logged run.

🤖 Generated with Claude Code

Restart and power-off are issued as atomic SMC writes (MBSE = 'phra' /
'offw'). Since c243a5f ("mfd: macsmc: bound the atomic write poll"),
apple_smc_write_atomic() waits SMC_TIMEOUT_MS (500 ms) for the reply and,
with a command still pending, polls RTKit once and returns -EBUSY.

On the M4 Mac mini (J773g, T8132) that is sometimes too short for the
SMC: macsmc_restart() logs "Failed to issue MBSE = phra", the restart
chain falls through to apple_wdt_restart(), and iBoot takes the watchdog
reset as a crash (panicmedic-telemetry is set) and boots macOS instead of
the configured Linux startup volume.

Keep the bound that c243a5f introduced, but make it 5 s in the atomic
paths: wait that long for a pending earlier command before refusing, and
that long for the reply. Log replies slower than 100 ms, and failures,
so slow SMCs show up in the log.

Observed on the J773g: with the 500 ms bound a reboot from a test
initramfs landed in macOS (2026-11-02 23:12); with this change the same
path returned to Linux through the SMC (2026-11-03 10:59).

Fixes: c243a5f ("mfd: macsmc: bound the atomic write poll")
Signed-off-by: Sean Dolbec <sdolbec1@gmail.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-03T19:51:31.051070Z 67c3100 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Merge train (MTL, 06/11). Gates passed on test tree 0412501 (integration/aurora 2661d71 + this batch):

  • Signed-off-by from the author on every commit. Adversarial review done.
  • W=1 on the touched objects: 0 new warnings. KUnit: drm/apple 112/113 (1 skip), hid 19/19, SEP 158/163 (the 4 known apple_sep_host_store failures, profile tests all pass). dt_binding_check clean. apple-dcp host selftests 86/86, run-host-tests at base parity (with Merge train: G17 hang confinement (#928) plus its host-test fixture #989's fixture).
  • Regression boots of 7.3.0-aurora-mtl1106a, compared with the fleet16/fleet17 rows: M2, M1 Pro, J700 and J616s all clean (0 err-level lines, 0 AVCs, displays, Wi-Fi, BT, Touch ID, camera, speakers at minimal volume with speakerguardd, s2idle, perf at parity).
  • mfd: macsmc: give atomic writes time for the SMC to answer #918: reboots from Linux on all four Macs went through the restart path fine. Note: a timeout now logs twice (the new dev_warn and the existing dev_err).

@RyanTheTide
RyanTheTide merged commit 30065a0 into aurora-silicon:integration/aurora Nov 5, 2026
@techmore
techmore deleted the m4/macsmc-atomic-wait branch November 10, 2026 18:42
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