macsmc-input: poll MSLD for lid state, fix spurious s2idle wake#509
Open
areofyl wants to merge 1 commit into
Open
macsmc-input: poll MSLD for lid state, fix spurious s2idle wake#509areofyl wants to merge 1 commit into
areofyl wants to merge 1 commit into
Conversation
SMC lid events (0x7203) show up in the SMC firmware syslog but never get delivered to Linux via RTKit notifications, so lid open/close is invisible to userspace. Switch to polling the MSLD key every second with a delayed_work and reporting SW_LID when it changes. 2-poll debounce because MSLD bounces during DP disconnect events. Also fixes spurious wake: the SMC fires a fake BTN_TOUCHID press+release within ~1ms of entering s2idle. Skip the first 2 button events after pm_prepare, real presses after that go through normally. Other fixes: - Add remove callback (old driver had none, leaked notifier + work) - pm_complete cancels and reschedules lid_work so polling survives suspend/resume cycles - Expose MSLD as sysfs attribute (msld_state) for debugging - Init pending_lid_state from MSLD at probe Tested on M1 MacBook Air (J313), fairydust 6.18.10. Signed-off-by: areofyl <areofyl@users.noreply.github.com>
b69f911 to
1affd03
Compare
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.
SMC lid events (0x7203) show up in the SMC firmware syslog but never actually get delivered to Linux via RTKit notifications. So lid open/close is completely invisible to userspace and logind never knows to suspend.
This switches to polling the MSLD key every second with a delayed_work and reporting SW_LID changes to the input subsystem. Added a 2-poll debounce because MSLD bounces during DP disconnect events.
Also fixes the spurious wake issue. The SMC fires a fake BTN_TOUCHID press+release within ~1ms of entering s2idle (this started happening after plugging in an external monitor, presumably changes some internal SMC state). The original upstream code passes that straight to pm_wakeup_dev_event which wakes the system instantly. Fixed by skipping the first 2 button events after pm_prepare, real presses after that go through normally.
Other stuff:
Tested on M1 MacBook Air (J313), fairydust 6.18.10. Lid close/open, suspend, power button wake all working.