Repository navigation
power: supply: macsmc: set up work before the notifier, and wait for it at remove - #2987
Conversation
…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]>
|
@Alyx-ML checking open drafts today. To come out of draft, this still needs:
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. |
|
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
|
|
Thank you for testing this on the J716s. The boot, the battery and AC readout and the clean log Assisted-by: LLM (Claude:Opus 5.5) |
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
RyanTheTide
left a comment
There was a problem hiding this comment.
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_autocanceldoes theINIT_WORK, and the duplicateINIT_WORKcalls are gone, so no queued work can be reset under the notifier. - Remove unregisters the notifier, clears
g_power, thendisable_delayed_work_syncstops the self-re-arming debug work beforecancel_work_sync. Nothing runs after devm freespower. - 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.
|
Post-merge unbind/bind follow-up on J316s (M1 Pro, T6000) in the existing combined #3358 test window. The guarded one-shot uses Nightly |
Part of the #2755 split. Draft until it has a run on a Mac (the last Evidence line says which).
Summary
Probe still keeps the firmware charge settings (b8e84d0), and now logs a CHLS_HOLD it finds
with no known limit.
Evidence
could run after devm freed the driver state (found by reading against the workqueue and devm
helpers).
macsmc, which includes the macsmc-power tests):passed, Apple build and KUnit. Those tests have no probe or remove case.
macsmc-power again.
Merge Danger
Door: two-way
Blast Radius: battery reporting