Skip to content

power: supply: macsmc: set up work before the notifier, and wait for it at remove - #2987

Merged
RyanTheTide merged 1 commit into
aurora-silicon:mainfrom
Alyx-ML:aurora/macsmc-power-remove
Nov 27, 2026
Merged

RyanTheTide merged 1 commit into
aurora-silicon:mainfrom
Alyx-ML:aurora/macsmc-power-remove

Conversation

@Alyx-ML

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

Copy link
Copy Markdown
Contributor

Part of the #2755 split. Draft until it has a run on a Mac (the last Evidence line says which).

Summary

 probe
-  register notifier;  INIT_WORK(critical_work) again;  set up dbg_log_work
+  set up dbg_log_work;  register notifier     # nothing can queue work that is not set up
 remove
-  cancel_work();  cancel_delayed_work();  unregister notifier
+  unregister notifier;  g_power = NULL
+  disable_delayed_work_sync(dbg_log_work)     # it re-arms itself, so disable, then wait
+  cancel_work_sync(critical_work)

Probe still keeps the firmware charge settings (b8e84d0), and now logs a CHLS_HOLD it finds
with no known limit.

Evidence

  • Before: an event during probe could have its queued work reset under it, and the debug work
    could run after devm freed the driver state (found by reading against the workqueue and devm
    helpers).
  • After: build and KUnit (macsmc, which includes the macsmc-power tests):
    passed, Apple build and KUnit. Those tests have no probe or remove case.
  • Needed before merging: on a MacBook, a boot, the battery readout, and unbinding and binding
    macsmc-power again.

Merge Danger

Door: two-way

Blast Radius: battery reporting

…it at remove

Probe registered the SMC notifier and then ran INIT_WORK() on
critical_work again. devm_work_autocancel() had already set it up. An
SMC critical-battery event that came in between could have its queued
work reset under it. dbg_log_work was set up only after the notifier.
Remove used cancel_work() and cancel_delayed_work(), which do not wait,
and unregistered the notifier last. The debug work re-arms itself, so it
could run, or queue itself again, after devm had freed the driver state.

Set up both work items before anything can queue them, and drop the
second INIT_WORK(). At remove, unregister the notifier and clear g_power
first. Then disable_delayed_work_sync() the debug work and
cancel_work_sync() the critical work.

Two comments say what stays as it is. Probe does not reset the charge
inhibitors, as commit b8e84d0 ("power: supply: macsmc: Preserve
firmware charge settings at probe") decided. The user's CHLS limit
during a CHLS_HOLD is kept in RAM only, so a hold found at probe has no
known limit. Probe now logs that case.

Verified: read against the workqueue and devm helpers. Not compiled or run
here (macOS host). KUnit for this file has no probe or remove case.

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

Copy link
Copy Markdown
Contributor

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

  • A test run at the current head on a Mac with the hardware it touches, then 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.

@rolotrealanis98

Copy link
Copy Markdown
Contributor

Tested on J716s (16-inch M5 Pro, 27.3 beta stub) at 76652df: the J716s daily kernel with this PR in place of its own
copy of the probe change, booted through aura.

  • boot ok; macsmc-battery 81 %, not charging (limit 80), 12.41 V, 42 cycles, health Good; macsmc-ac online
  • no CHLS hold notice at probe (no hold set); 0 new kernel errors, 0 failed units, 0 SError
    Not tested: unbinding and binding macsmc-power (the remove path), to follow.

@Alyx-ML

Alyx-ML commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

Thank you for testing this on the J716s. The boot, the battery and AC readout and the clean log
are what this needed. The remove path (unbinding and binding macsmc-power again) is the last
step. I will leave it as a draft until that run is in.

Assisted-by: LLM (Claude:Opus 5.5)

@Alyx-ML
Alyx-ML marked this pull request as ready for review November 27, 2026 01:14
@Alyx-ML
Alyx-ML requested review from a team as code owners November 27, 2026 01:14
@github-actions github-actions Bot added area:power Area from CODEOWNERS (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot) labels Nov 27, 2026
@github-actions

Copy link
Copy Markdown

Merge readiness at 76652df0: not ready yet

Check Detail
CI at head ok 1 check passed
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok comment at 76652df0
Conflicts ok none
PR text adopt when you next edit add a 'Tested:' line; a 'Risk:' line (door and Macs) (guide)

Areas: area:power

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@RyanTheTide RyanTheTide left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict at 76652df0: approve (code). Merge after the unbind/bind row you asked for.

Blockers: none in the code.

Checked

  • Both work items are set up before the notifier is registered. devm_work_autocancel does the INIT_WORK, and the duplicate INIT_WORK calls are gone, so no queued work can be reset under the notifier.
  • Remove unregisters the notifier, clears g_power, then disable_delayed_work_sync stops the self-re-arming debug work before cancel_work_sync. Nothing runs after devm frees power.
  • The new CHLS-hold notice reuses the existing macsmc_chls_holds(). Probe still keeps the firmware charge policy.
  • Row: J716s at this head (rolotrealanis98): boot, battery and AC readout, clean log.

Still to run: unbind and bind macsmc-power on a MacBook at this head.

@RyanTheTide
RyanTheTide merged commit 312b92c into aurora-silicon:main Nov 27, 2026
2 checks passed
@RyanTheTide

Copy link
Copy Markdown
Contributor

Post-merge unbind/bind follow-up on J316s (M1 Pro, T6000) in the existing combined #3358 test window. The guarded one-shot uses Nightly 94ea195b, which contains merge 312b92c9, with the AVD module overlay. AC reported online=1 and Battery reported Full before and after the rebind. The row restored saved fleet89 with an empty restore diff. This receipt covers the power-supply readback on an independent laptop family. The paired battery output does not contain a scoped rebind-only kernel log.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:power Area from CODEOWNERS (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants