Repository navigation
ASoC: apple: AOP LPAI: xrun on lost samples, wait for the first report on a completion - #2350
RyanTheTide wants to merge 3 commits into
Conversation
…pletion Before a leaf power request, the low-power microphone is run to raise the audio fabric, and its first report proves the fabric is up. The driver waited for that report by polling a flag every 5 ms, 100 times. The report is a firmware message the driver handles. Complete a completion from the report path on the first report after a run request, and wait on it for the same 500 ms. A raise that finds the report already in returns at once; one that gets the completion hands it on to a raise waiting beside it, and the next run request drops any left over. Fixes: 07084c3 ("ASoC: apple: t8140-aop-audio: raise the fabric before every leaf request") Signed-off-by: Ryan Murray <[email protected]>
…lost samples
When the low-power microphone's producer could not be followed, the
capture went on as if nothing happened: a T6041 ring producer that
lapped the consumer or stepped back was taken as the new position
("lpai ring position lost, continuing at the producer"), an inline
T8112/T6000 report that started after the last copied byte was copied
on as if contiguous ("lpai stream gap, continuing at the new
position"), and a report larger than the ALSA buffer was dropped. The
application got a stream with a hole in it, the PCM status showed
nothing, and the one-time warning was all that remained.
Lost capture samples are an overrun. Stop the stream with
snd_pcm_stop_xrun() in each of these cases, so the application sees
-EPIPE and restarts it with prepare, which already resets the consumer
to start at the next producer position. The first report after a start
still only sets the position. A whole stale inline report is still
skipped: nothing is lost there.
The xrun is raised under the stream state lock, which the trigger
callback never takes, the same order snd_pcm_period_elapsed() already
uses on this path. The consumer steps now name the loss (RingStep::Lost,
Continuity::Gap) and the KUnit cases follow.
Fixes: fbec62e ("ASoC: apple: aop_audio: capture the low-power microphone on T8112 and T6000 (#1493)")
Fixes: 6f17cbf ("ASoC: apple: aop_audio: capture the low-power microphone on T6041 (#1505)")
Signed-off-by: Ryan Murray <[email protected]>
|
Blockers: 1.
The rest is correct:
HW row: the combined-kernel row (0 overrun lines, byte counts unchanged on M1 Pro, M2 and J616s) proves no regression on clean captures, so it covers the normal path. After the fix, add the KUnit run (all cases pass, including the new full-buffer ring case). Also rerun the J616s 3 x 10 s low-power capture with a 20 ms ALSA buffer ( Assisted-by: LLM (Claude:Opus 5.5) |
RyanTheTide
left a comment
There was a problem hiding this comment.
Review at 0f7dc0d. Reporting an xrun rather than treating a gap as contiguous fixes the capture boundary. Please verify prepare/start after that xrun clears the missed-sample state, with both late inline T8112 reports and the separate DMA format. The ordinary 10-second capture remains the positive control. No playback is needed.
…rst lpai report on a completion Folds #2404 into this PR unchanged. Signed-off-by: Ryan Murray <[email protected]>
|
Row: Neo (J700, T8140 AOP audio), silent capture. Combined one-shot kernel 7.3.0-aurora-dsw2 (main 2a173ca + this PR's head c225627 + 14 other drafts; none of the others touches |
What: ASoC: apple: AOP LPAI: xrun on lost samples, wait for the first report on a completion. This PR now carries these drafts as one feature (merge commits, the commits themselves unchanged):
Tested: each part as tested on its own PR (folded bodies below; no hardware row on this head yet). Combined with current main (ba29027) together with the other folds of 11-25: full arm64 build (Image, modules, dtbs; fleet89 config, clang 22, rustc 1.97.1) clean.
Risk: two-way · Neo (T8140 AOP audio) and AOP mic Macs
Not yet: a silent low-power mic capture row on the Neo on this head.
#2350 original description
Problem
The low-power microphone (
lpai, capture PCM 1 of the AOP card) kept capturing when its producer could not be followed (sound/soc/apple/aop_lpai.rs at 0abc2f3):lpai ring position lost, continuing at the producer, :835).lpai stream gap, continuing at the new position, :907).In all three cases the application got a stream with a hole in it while the PCM state stayed RUNNING. The only trace was a one-time warning per driver instance.
Change
Lost capture samples are an overrun. Each of these cases now calls
snd_pcm_stop_xrun(). The application sees-EPIPE(arecord printsoverrun!!!) and recovers with prepare, which already resets the consumer so it restarts at the next producer position. These cases are unchanged:Locking: the xrun is raised under the stream-state spinlock. The trigger callback, which runs under the ALSA stream lock, never takes that spinlock.
snd_pcm_period_elapsed()already uses the same order on this path, andsync_stoptakes the state lock without the stream lock, so the change adds no new lock dependency.The consumer steps now name the loss (
RingStep::Start/Lost,Continuity::Gap), and the KUnit cases follow.The T8140 low-power microphone is in aop_t8140.rs and is not affected.
Testing
make O=... sound/soc/apple/aop_audio.o(arm64, LLVM, release config) withCONFIG_KUNIT=y, so thesnd_soc_apple_aop_lpaiKUnit suite is compiled: no warnings. The suite was not run: it needs an Apple arm64 kernel booted under KUnit, which is not cheap on the build host.Still to run
Capture only, nothing kept:
arecord -D hw:AppleJ316HPAI,1 -f S16_LE -r 16000 -c 3 -d 10 -t raw | wc -creturns 960000, with nooverrun!!!.hw:AppleJ413HPAI,1, which returns 960000.arecord -D hw:AppleJ616HPAI,1 -f S32_LE -r 16000 -c 3 -d 10 -t raw | wc -creturns 1920000.dmesg | grep -i 'lpai.*overrun'is empty. A/B: before and after are both 3/3 clean runs of 10 s. Anyoverrunline now matches an xrun that arecord reports, where it used to be a silent hole.Hardware rows (combined test kernel, 2026-11-20)
This change was booted in a combined test kernel: integration/aurora 0abc2f3 plus the open gate-sweep drafts plus this and the related drafts (7.3.0-aurora-hk2/pwr1/hk3). It ran once on each lab Mac (M1 Pro J316s, M2 J413, J616s, Neo J700) and was compared against the production kernel on the same Mac, using the same silent row script:
M1 Pro, M2 and J616s matched production on every row, apart from the new counters and lines the drafts add. The Neo row found the old-DTB display regression that #2358's follow-up commit fixes.
This PR: lpai lost-sample and overrun lines: 0 on all four Macs, before and after. Low-power mic capture byte counts identical.
#2404 original description
Problem
sound/soc/apple/aop_t8140.rs:867(07084c3): before a leaf power request, the driver runs the low-power microphone to raise the audio fabric. It then polls a flag every 5 ms, up to 100 times, until the first report shows the fabric is up. That report is a firmware message the driver already handles.Change
The report path signals a
Completionon the first report after a run request, and the raise waits on it with the same 500 ms timeout. If the report has already arrived, the raise returns at once. A raise that receives the completion hands it on to any raise waiting beside it, and the next run request drops any token left over. This is T8140 only, because the file is the T8140 backend.Testing
make sound/soc/apple/aop_audio.o(Rust, release config): builds, no warnings.Still to run
lpai: no report while raising the fabricand no PMGR leaf timeout. The audio must start no later than before.rtcwake -d rtc0 -m freeze -s 20).