* [PATCH] ASoC: Intel: avs: Reset the stream unless it is already prepared
@ 2026-10-10 10:37 Sergey Tiraspolsky
2026-10-12 14:58 ` Cezary Rojewski
2026-10-12 18:01 ` Mark Brown
0 siblings, 2 replies; 3+ messages in thread
From: Sergey Tiraspolsky @ 2026-10-10 10:37 UTC (permalink / raw)
To: Cezary Rojewski
Cc: Liam Girdwood, Peter Ujfalusi, Bard Liao, Kai Vehmanen,
Pierre-Louis Bossart, Mark Brown, Jaroslav Kysela, Takashi Iwai,
linux-sound, linux-kernel, Sergey Tiraspolsky
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.
Skip the reset only when the stream is already PREPARED, the repeated
->prepare() case the check exists for, and reset it otherwise. With
this change both kinds of recovery succeed with a single restart.
Fixes: cfca1637bc2b ("ASoC: Intel: avs: Unprepare a stream when XRUN occurs")
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Sergey Tiraspolsky <stiraspo@gmail.com>
---
How this was tested, and what was not:
- Built out of tree against a 7.2.5 distribution kernel (Omarchy
linux-omarchy 7.2.5-3, whose sound backports do not touch
avs_dai_fe_prepare()). The rebuilt stock module's .text matched the
shipped one byte for byte; the patched one differs only in this
comparison. It was installed in place of the stock module and tested
from a clean boot. It was not built or run on this branch.
- alsa-lib reproducer, no PipeWire: on hw:avsmax98927,1 write four
periods, stall 0.5 s so the stream underruns, recover, then keep
writing for 1 s, recovering every further -EPIPE the same way.
Recovering with snd_pcm_drop() + snd_pcm_prepare(): stock 958, 228
and 526 further xruns in that second; patched none (3 runs each).
Recovering with snd_pcm_prepare() from XRUN: none on either.
- PipeWire, SIGSTOP for 0.5 s during playback: stock got stuck in XRUN
3 out of 3 times until the sink was suspended; patched recovered with
a single restart 3 out of 3 times.
- Patched, also checked: HDMI 1-3, headphone playback, headset and DMIC
capture (repeated prepare and both recovery styles, no further
xruns), audible speaker playback, headphone hot-plug, and
suspend/resume during playback. After resume PipeWire logs one
"after recover: Broken pipe" and plays on, on stock and patched alike.
- Only one machine (Google Pixelbook, Kaby Lake) was tested.
sound/soc/intel/avs/pcm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/intel/avs/pcm.c b/sound/soc/intel/avs/pcm.c
index ad25bd355..880cd7a9f 100644
--- a/sound/soc/intel/avs/pcm.c
+++ b/sound/soc/intel/avs/pcm.c
@@ -756,7 +756,7 @@ static int avs_dai_fe_prepare(struct snd_pcm_substream *substream, struct snd_so
data = snd_soc_dai_get_dma_data(dai, substream);
host_stream = data->host_stream;
- if (runtime->state == SNDRV_PCM_STATE_XRUN)
+ if (runtime->state != SNDRV_PCM_STATE_PREPARED)
hdac_stream(host_stream)->prepared = false;
if (hdac_stream(host_stream)->prepared)
return 0;
base-commit: f90f8afb61beb268ca8092e7f3a826b520d3e8da
--
2.55.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ASoC: Intel: avs: Reset the stream unless it is already prepared
2026-10-10 10:37 [PATCH] ASoC: Intel: avs: Reset the stream unless it is already prepared Sergey Tiraspolsky
@ 2026-10-12 14:58 ` Cezary Rojewski
2026-10-12 18:01 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Cezary Rojewski @ 2026-10-12 14:58 UTC (permalink / raw)
To: Sergey Tiraspolsky
Cc: Liam Girdwood, Peter Ujfalusi, Bard Liao, Kai Vehmanen,
Pierre-Louis Bossart, Mark Brown, Jaroslav Kysela, Takashi Iwai,
linux-sound, linux-kernel
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@intel.com>
> 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@gmail.com>
Kind regards,
Czarek
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ASoC: Intel: avs: Reset the stream unless it is already prepared
2026-10-10 10:37 [PATCH] ASoC: Intel: avs: Reset the stream unless it is already prepared Sergey Tiraspolsky
2026-10-12 14:58 ` Cezary Rojewski
@ 2026-10-12 18:01 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2026-10-12 18:01 UTC (permalink / raw)
To: Cezary Rojewski, Sergey Tiraspolsky
Cc: Liam Girdwood, Peter Ujfalusi, Bard Liao, Kai Vehmanen,
Pierre-Louis Bossart, Jaroslav Kysela, Takashi Iwai, linux-sound,
linux-kernel
On Sat, 10 Oct 2026 03:37:53 -0700, Sergey Tiraspolsky wrote:
> ASoC: Intel: avs: Reset the stream unless it is already prepared
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.3
Thanks!
[1/1] ASoC: Intel: avs: Reset the stream unless it is already prepared
https://git.kernel.org/broonie/misc/c/f6be9f558a83
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-12 19:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-10 10:37 [PATCH] ASoC: Intel: avs: Reset the stream unless it is already prepared Sergey Tiraspolsky
2026-10-12 14:58 ` Cezary Rojewski
2026-10-12 18:01 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®