Skip to content

mfd: macsmc: send the final power command after a protocol fault - #3000

Draft
Alyx-ML wants to merge 1 commit into
aurora-silicon:mainfrom
Alyx-ML:aurora/macsmc-fault-poweroff
Draft

Alyx-ML wants to merge 1 commit into
aurora-silicon:mainfrom
Alyx-ML:aurora/macsmc-fault-poweroff

Conversation

@Alyx-ML

@Alyx-ML Alyx-ML commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Part of the #2755 split. Draft: it needs a power-off and reboot row.

Summary

 apple_smc_enter_atomic() / apple_smc_write_atomic()
-  saved fault -> refuse, so power-off sends no MBSE
+  saved fault -> still enter atomic mode and send the final power command
   ordinary writes after a fault -> still -EPROTO

Evidence

  • Before: after a fault, power-off and restart could not send MBSE off1 or phra, so the
    machine stayed on (found by reading).
  • After: a KUnit case in the macsmc suite: without a fault, notifications go off before
    atomic mode; with a saved fault, atomic mode is still entered and no command is sent; an
    ordinary write is still refused with -EPROTO. macsmc-reboot now prints the error code. Build
    and KUnit: passed, Apple build and KUnit.
  • Needed before merging: a power-off and a reboot after a real SMC fault, on a T6050 or J714s.

Merge Danger

Door: two-way

Blast Radius: power-off and reboot

@RyanTheTide

Copy link
Copy Markdown
Contributor

@Alyx-ML checking open drafts today. To come out of draft, this still needs:

  • It conflicts with main. Merge main in or rebase (no force push needed: a merge commit is fine).
  • Then a test run at the final head on a Mac with the hardware it touches, and mark it ready for review.

If it's no longer needed, say so here and we'll close it. Otherwise it stays open as a draft until these are done.

On the T6050 and J714s profiles, the saved-state guard refuses every SMC
command once an unexpected reply sets saved_fault. Nothing clears the
fault. apple_smc_enter_atomic() and apple_smc_write_atomic() used the
same guard, so after a fault the power-off and restart handlers could
not send MBSE = off1 or phra. The machine then stayed on, and
macsmc-reboot only logged the failure without its cause.

Only the power-off and restart handlers enter atomic mode, and only the
final MBSE write follows. So apple_smc_enter_atomic() now still enters
atomic mode when the guard refuses commands. It skips the NTAP write and
warns. apple_smc_write_atomic() sends the final command and warns. It
stops routing replies to a saved-state command that is still marked
pending, so this command's reply is taken as this command's. Every other
command still goes through the guard. Atomic mode already refuses them
all.

macsmc-reboot now prints the error code. It also says that the next
power-off or restart handler is tried, which the notifier chain does on
NOTIFY_OK.

A KUnit case in the macsmc suite checks the guard paths. Without a
fault, notifications are turned off before atomic mode. With saved_fault
set, atomic mode is still entered and no command is sent. An ordinary
write is still refused with -EPROTO.

The kernel and the KUnit case were not compiled or run here (macOS host,
no arm64 kernel toolchain). A power-off and a reboot after a real SMC
fault, on a T6050 or J714s, are needed before this is merged.

Signed-off-by: Alyx-ML <[email protected]>
@Alyx-ML

Alyx-ML commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto main (b6e9283), so the diff shows only this commit. The one
conflict was in macsmc-test.c: main added the WKTP tests at the same place as
macsmc_atomic_after_fault_test, and both are kept. macsmc-reboot.c is still the only caller
of apple_smc_enter_atomic(), so the change in what it allows still affects only power-off and
restart.

The KUnit link in the description is from the old base. My fork's Actions could not run this
time, so the PR's own CI is the check at this head. It still needs the power-off run listed in
the description.

Assisted-by: LLM (Claude:Opus 5.5)

@Alyx-ML
Alyx-ML force-pushed the aurora/macsmc-fault-poweroff branch from 5f71ecd to b6e9283 Compare November 27, 2026 01:14

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