Re: [PATCH] ASoC: Intel: avs: Reset the stream unless it is already prepared
From: Cezary Rojewski
Date: Mon Oct 12 2026 - 11:06:11 EST
On 10/10/2026 12:37 PM, Sergey Tiraspolsky wrote:
> Commit cfca1637bc2b ("ASoC: Intel: avs: Unprepare a stream when XRUN
> occurs") resets the HDA stream when ->prepare() is called in the XRUN
> state. User space does not always recover that way. PipeWire's ALSA
> backend recovers from an underrun with snd_pcm_drop(), snd_pcm_prepare()
> and a new start, so ->prepare() runs in the SETUP state,
> hdac_stream->prepared is still set and the reset is skipped. Every
> recovery attempt then fails the same way:
>
> spa.alsa: hw:avsmax98927,1p: snd_pcm_avail after recover: Broken pipe
>
> On a Google Pixelbook (Kaby Lake, max98927 speakers) this happens after
> an occasional underrun during normal playback and silences the speakers
> for one to four minutes, until the PCM is closed. It can be provoked by
> stopping PipeWire with SIGSTOP for 0.5 s during playback: in one run
> that single underrun led to 1297 failed recoveries over two minutes,
> until the sink was suspended. A plain alsa-lib program that recovers
> with snd_pcm_drop() and snd_pcm_prepare() hits the same loop, while
> snd_pcm_prepare() straight from XRUN recovers at once.
The patch looks outstanding! Thank you not only for the fix, but for the
thorough explanation and the reproduction technique too.
Acked-by: Cezary Rojewski <cezary.rojewski@xxxxxxxxx>
> Fixes: cfca1637bc2b ("ASoC: Intel: avs: Unprepare a stream when XRUN occurs")
While I prefer to leave Fixes: tag here so it may get populated
downstream, this is in fact a complementing fix, not a fix for a fix.
IIRC recovery on alsa-lib side is handled with either:
1) snd_pcm_prepare(state=XRUN)
2) snd_pcm_drop/drain() -> snd_pcm_prepare(state=SETUP)
Without the commit mentioned here, 1) and 2) are both unaccounted for.
With the commit, 1) gets accounted for. By adding the change of yours to
the mix, 1) and 2) should be accounted for.
I'll prepare an equivalent change for the HDAudio BackEnd side as well
as re-check whether ->prepared and ->link_prepared flags are actually
needed once the fixes are applied.
> Assisted-by: Claude:claude-opus-5-5
> Signed-off-by: Sergey Tiraspolsky <stiraspo@xxxxxxxxx>
Kind regards,
Czarek