Repository navigation
ASoC: apple: t8140-aop-audio: count the holders of the lpai run state - #239
Merged
Merged
Conversation
The low-power microphone's runn state is requested by its own PCM and, around every back-end and microphone-array startup, by with_fabric_raised(), which runs the stream to bring a gated audio fabric back. Each request reads the state back from the firmware and fails on a mismatch, but nothing orders the requests. When two services start at the same time, one raise returns lpai to idle between the other's run request and its readback, and that open fails with EIO: audio.3.auto: lpai power state 0x69646c65 after requesting 0x72756e6e A raise that finishes while the PCM starts likewise idles the capture the PCM just started, and a raise that skips the run request because the PCM holds it powers the leaves while the PCM's close idles the stream under it. Count the holders of runn under a mutex: the first holder requests runn, the last one requests idle, and every lpai power request is made by one caller at a time. Fixes: 656867b ("ASoC: apple: t8140-aop-audio: raise a gated audio fabric before the leaves") Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
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.
ASoC: apple: t8140-aop-audio: count the holders of the lpai run state
On the MacBook Neo (J700), opening two AOP audio streams at the same time could fail one of them with EIO:
(
idleread back after requestingrunn.) It showed up as an occasional failed jack or microphone open when anotherAOP stream was starting.
Cause
The firmware power-gates the audio fabric when no service needs it. Since 656867b, every back-end startup (jack,
speaker, speaker sense tap) and the microphone array raise the fabric first:
with_fabric_raised()puts thelow-power microphone (
lpai) inrunnuntil its first report arrives, powers the leaves, and returnslpaitoidle. The low-power microphone's own PCM also requestsrunnat prepare andidleat close. Every request reads thestate back and fails on a mismatch.
Nothing ordered these requests or counted their holders:
lpaitoidlebetween the other'srunnrequest and itsreadback. That open fails with EIO, as above.
runn, powers its leaves while the PCM's closecan idle the stream under it.
Fix
The
runnstate is now reference-counted under a mutex. The PCM, while prepared, and each fabric raise hold areference. The first holder requests
runn, the last one requestsidle, and only one caller at a time makes anlpaipower request. If the finalidlerequest fails, the state stays marked running, so the next holder does notrequest it again. Teardown retries that request.
Testing (MacBook Neo J700)
Written for aurora-wip
c679c8a75a89; measured on the MacBook Neo (J700). The stress test opens, starts, brieflycaptures from and closes the three AOP-backed capture PCMs in parallel loops for 31 minutes: the microphone array
(
hpai), the low-power microphone (lpai) and the jack's headset microphone, with jittered holds of 1-40 ms and 5 msgaps. Alongside it, the speaker PCM was opened and closed once a second, without hw_params, prepare or start, so
nothing is played; that exercises the speaker front-end and back-end fabric raises.
lpai power state ... after requesting ...lpai: no report while raising the fabricThe higher cycle rate follows from the fix: every "no report" used to cost a 500 ms wait.
Checks
checkpatch.pl --strict: clean except theAssisted-byformat warning.W=1andCLIPPY=1builds ofsound/soc/apple/, then Image and modules. Nowarnings from W=1 or the full build, and the same clippy output before and after (none in this driver).
Provenance
Written for this tree; measured on the MacBook Neo (J700).
🤖 Generated with Claude Code