Repository navigation
Conversation
After a firmware sleep, the codec comes out of reset and the resume writes its cached registers back with regcache_sync(), in address order, with the interrupt still off. Turning tip and ring sensing on latches plug events at once, as do some later writes (MSM_BLOCK_EN3 among them), and the remote button sources come up latched (0x60 in REMOTE_BUTTON_STATUS1). Nothing reads them, and the codec stops answering the bus a write or two later: the write times out (-ETIME), the resume fails, and the jack stays dead until the driver is bound again. On the MacBook Air (M4, J713) this happened on every deep sleep. Write plug detection back first, in the order the probe sets it up, then every other register the cache holds, once each, in address order, and read the plug interrupt status after each write to clear what it latched, as the interrupt thread does. The remote button status is read once, after plug detection. A KUnit suite checks that order, that the plug detection list matches what the probe writes, and that a codec that stops answering ends the write-back with the error. Fixes: b912083 ("ASoC: cs42l84: Bring the codec back after a firmware sleep") Assisted-by: LLM Signed-off-by: Bartosz Nitka <niteria@gmail.com>
A headset unplugged during a firmware sleep leaves its bias on. The resume writes the cache back, the 2.7 V mic bias included, finds the jack empty and reports it, but unlike the interrupt thread's unplug path it does not call cs42l84_revert_hs(). The bias stays powered, disconnected from the jack, until the next plug. Revert the headset setup when the jack is empty after the wake, as the unplug path does. Fixes: b912083 ("ASoC: cs42l84: Bring the codec back after a firmware sleep") Assisted-by: LLM Signed-off-by: Bartosz Nitka <niteria@gmail.com>
niteria
force-pushed
the
j713/cs42l84-sleep
branch
from
November 18, 2026 19:17
984b7c8 to
00f350b
Compare
niteria
marked this pull request as ready for review
November 18, 2026 19:26
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.
After a deep sleep, the cs42l84 headphone codec stops answering the bus while its registers are written back, so the jack stays dead until the driver is bound again. On the MacBook Air (M4, J713) this happened on every deep sleep:
Cause
The resume (b912083) releases the reset, checks the device ID, and writes the cache back with
regcache_sync(), in address order, with the interrupt still off. Turning tip and ring sensing on latches plug events at once (TSRS_PLUG_INT_STATUSreads 0xd right afterTIP_SENSE_CTL2), some later writes latch more (MSM_BLOCK_EN3), and the remote button sources come up latched (REMOTE_BUTTON_STATUS1= 0x60, as #1895 found on the J604). Nothing reads them, and a write or two later the codec stops answering. Which register fails moves with the order; the latched events are what it follows. A rebind (probe's sequence, with the interrupt live) works at any time after the wake.Change
Two fixes to the resume from b912083.
Write the registers back without leaving events latched. Plug detection is written back first, in the order
cs42l84_setup_plug_detect()sets it up, andREMOTE_BUTTON_STATUS1is read once after it. Then every other register the cache holds is written once, in address order.TSRS_PLUG_INT_STATUSis read after every write to clear what it latched, as the interrupt thread does.A KUnit suite,
snd-soc-cs42l84-sleep-test, runs the write-back on a regmap with the driver's cache and volatile registers. It checks that order, that the plug detection list matches what the probe writes, and that a codec that stops answering ends the write-back with the error.Power the headset bias down after an unplug in a sleep. When a headset was unplugged during the sleep, the resume reported the empty jack but, unlike the interrupt thread's unplug path, did not call
cs42l84_revert_hs(). The headset's 2.7 V mic bias (MISC_DET_CTL0x1f) stayed on, disconnected from the jack, until the next plug. The resume now reverts the headset setup as the unplug path does.Tested
J713 (MacBook Air M4), integration/aurora a7dd26e with this as an out-of-tree snd-soc-cs42l84.ko (the cs42l84 files are unchanged on integration since), the built-in 3.5 mm jack and a headset whose mic the codec detects, so the cache holds the mic bias on across a sleep with it plugged in. Woken by the RTC (rtc1) or the power key.
Before: every deep sleep failed to restore the codec (-62), and the jack stayed dead until a rebind.
Playback was checked by ear after five of them: the headset after the music, idle and plug-in sleeps, and the speakers after both unplugs. After an unplug in a sleep
MISC_DET_CTLreads 0x03 (bias off), where it read 0x1f without the bias fix. The headset-in sleeps, three of the empty ones and one unplug ran without the bias fix, which only changes what the resume does when it finds the jack empty.KUnit on UML:
snd-soc-cs42l84-test17/17 andsnd-soc-cs42l84-sleep-test2/2. The new suite fails on the oldregcache_sync()write-back and on five other mutations: plug detection written a second time, no status read, the list out of step with the probe, no button read, errors ignored.Host tests (tools/asahi/run-host-tests.py, full run): 427/427 on each commit and on the base. It merges cleanly with #2112 (jack reporting at attach and after a sleep that keeps the codec powered), which covers a different case, and with #1895.
🤖 Generated with Claude Code