Repository navigation
power: supply: macsmc-power: optionally wake from s2idle on charger plug/unplug (opt-in) - #456
Open
WilliamJohnDavisIII wants to merge 1 commit into
Conversation
macOS wakes briefly when a charger is connected while the system is asleep, so it can play the power chime. On Linux the AC state change is only noticed once something else wakes the system, so userspace that reacts to it (a sound, a notification) fires late. The SMC keeps delivering notifications while the AP is in s2idle; the lid open event already wakes the system this way via macsmc-input. Track when the device is between PM prepare and complete, and treat connector insert/remove events (0x7113xxxx) received in that window as a wakeup event. The device is only marked wakeup-capable, so this is opt-in through power/wakeup and the default behaviour is unchanged. Events seen while suspended are logged at debug level. Tested on a MacBook Air (M1, 2020, j313): with wakeup enabled, plugging in or removing the charger with the lid closed wakes the system, and logind suspends it again after its holdoff timeout. Signed-off-by: William John Davis III <58375683+WilliamJohnDavisIII@users.noreply.github.com>
WilliamJohnDavisIII
requested review from
maralcbr and
scottjones
as code owners
November 11, 2026 20:12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
macOS wakes briefly when a charger is connected while the lid is closed and the Mac is asleep, so it can play the power chime. On Aurora the charger change is only noticed when the lid is next opened, so anything in userspace that reacts to AC changes (a sound, a notification) fires late.
The SMC keeps delivering notifications while the AP is in s2idle (the lid open event
0x72030001already wakes the system this way through macsmc-input). This patch has macsmc-power treat connector insert/remove events (0x7113xxxx) received while suspended as a wakeup event.It is opt-in: the driver marks the device wakeup-capable but leaves wakeup disabled, so nothing changes unless userspace enables it:
or with a udev rule:
Events seen while suspended are logged with
dev_dbg.Event codes seen while suspended (j313)
70200000 71130103 71060100 71060000 71010101 71060100 71060000 71130104 71130103 71130103 7106010071020000 71010100 71060000 71060100 71130102 70200000 71130103 7113ff0472030001(plus sometimes71020000)Only
0x7113xxxxtriggers the wake.71010101/71010100look like "charger attached/detached" and could be used to wake on plug-in only, but waking on both matches what userspace sees while awake.Testing
apple,j313/apple,t8103linux-aurora 7.2.11.aurora14-1, OS firmware 13.5onlinechange reaches userspace;checkpatch.pl --strict: no errors or warnings.Battery charging during s2idle was already working before this patch; the SMC handles it on its own. This only affects when the AP finds out.
Disclosure
This patch was written with the help of an AI coding assistant, and tested on my own hardware as described above.