Skip to content

ASoC: apple: t8140-aop-audio: count the holders of the lpai run state - #239

Merged
RyanTheTide merged 1 commit into
aurora-wipfrom
j700/aop-audio-fabric-lock
Oct 11, 2026
Merged

RyanTheTide merged 1 commit into
aurora-wipfrom
j700/aop-audio-fabric-lock

Conversation

@RyanTheTide

Copy link
Copy Markdown
Contributor

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:

snd_soc_t8140_aop_audio audio.3.auto: lpai power state 0x69646c65 after requesting 0x72756e6e

(idle read back after requesting runn.) It showed up as an occasional failed jack or microphone open when another
AOP 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 the
low-power microphone (lpai) in runn until its first report arrives, powers the leaves, and returns lpai to
idle. The low-power microphone's own PCM also requests runn at prepare and idle at close. Every request reads the
state back and fails on a mismatch.

Nothing ordered these requests or counted their holders:

  • When two services start together, one raise returns lpai to idle between the other's runn request and its
    readback. That open fails with EIO, as above.
  • A raise that ends while the low-power microphone PCM is starting idles the capture the PCM just started.
  • A raise that skipped its own request, because the PCM already held runn, powers its leaves while the PCM's close
    can idle the stream under it.

Fix

The runn state is now reference-counted under a mutex. The PCM, while prepared, and each fabric raise hold a
reference. The first holder requests runn, the last one requests idle, and only one caller at a time makes an
lpai power request. If the final idle request fails, the state stays marked running, so the next holder does not
request 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, briefly
captures 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 ms
gaps. 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.

aurora-wip (same AOP code, without this change) this change
capture cycles in 31 min 54,392 (29.2/s) 85,313 (45.9/s)
failed opens (EIO) 41 0
lpai power state ... after requesting ... 44 0
lpai: no report while raising the fabric 4,355 (21 % of array and jack opens) 0 (of 34,346)
speaker PCM open/close not run 1,716, 0 failures
IOMMU TLB timeouts, DART faults, WARN/Oops 0 0

The higher cycle rate follows from the fix: every "no report" used to cost a 500 ms wait.

Checks

  • checkpatch.pl --strict: clean except the Assisted-by format warning.
  • J700 config, base and this commit: W=1 and CLIPPY=1 builds of sound/soc/apple/, then Image and modules. No
    warnings 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

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]>
@RyanTheTide
RyanTheTide merged commit 259ee1d into aurora-wip Oct 11, 2026
@DjDeveloperr
DjDeveloperr deleted the j700/aop-audio-fabric-lock branch October 12, 2026 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant