From: Takashi Iwai <tiwai@suse.de>
To: Ting-Han Hou <ue081723@gmail.com>
Cc: Anton Yakovlev <anton.yakovlev@opensynergy.com>,
"Michael S . Tsirkin" <mst@redhat.com>,
Takashi Iwai <tiwai@suse.com>, Jaroslav Kysela <perex@perex.cz>,
Matias Ezequiel Vara Larsen <mvaralar@redhat.com>,
virtualization@lists.linux.dev, linux-sound@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ALSA: virtio: reset I/O message fill level on prepare
Date: Mon, 12 Oct 2026 09:28:55 +0200 [thread overview]
Message-ID: <87zewjgyx4.wl-tiwai@suse.de> (raw)
In-Reply-To: <20261011125426.35745-1-ue081723@gmail.com>
On Sun, 11 Oct 2026 14:54:26 +0200,
Ting-Han Hou wrote:
>
> Since commit fe981e67568c ("ALSA: virtio: use ack callback"), an I/O
> message is only queued to the device once the application has filled
> the whole period: virtsnd_pcm_msg_send() accumulates the transferred
> bytes in msg->length and queues the message when it reaches
> period_bytes. msg->length is reset to 0 only when the device completes
> the message.
>
> If the substream is stopped (e.g. snd_pcm_drop()) while a period is
> only partially filled, the corresponding message is never queued and
> keeps its partial length. virtsnd_pcm_prepare() resets msg_count,
> hw_ptr and the indirect PCM state, but not msg->length. After the
> next start, the stale length is added to the new data, the sum never
> equals period_bytes, and the message is never sent again. Playback
> then stalls once hw_ptr reaches that period: writes fail with -EIO
> ("DMA or IRQ trouble") and drain fails with -EIO. Capture is affected the
> same way after a partial read.
>
> Clear the fill level of all messages in prepare. Outside of the resume
> path, virtsnd_pcm_prepare() already refuses to run while I/O messages
> are pending, so no message is owned by the device at this point and the
> reset does not race with message completion.
>
> Reproduced in QEMU (virtio-sound-pci, wav audiodev): prepare, write 1.5
> periods, drop, prepare, write 16 full periods, drain. Without this
> patch WRITEI returns -EIO after 14 periods and DRAIN fails; with it all
> 16 periods are played and DRAIN succeeds. Period-aligned prefill works
> in both cases. The same sequence on capture (read 1.5 periods, drop,
> prepare, read 16 periods) fails with -EIO after 10 periods without this
> patch and reads all 16 with it.
>
> Found by code inspection, confirmed with the reproducer above.
>
> Fixes: fe981e67568c ("ALSA: virtio: use ack callback")
> Assisted-by: LLM
> Signed-off-by: Ting-Han Hou <ue081723@gmail.com>
> ---
Applied to for-next branch now. Thanks.
Takashi
prev parent reply other threads:[~2026-10-12 7:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-11 12:54 [PATCH] ALSA: virtio: reset I/O message fill level on prepare Ting-Han Hou
2026-10-11 13:02 ` sashiko-bot
2026-10-12 7:28 ` Takashi Iwai [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87zewjgyx4.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=anton.yakovlev@opensynergy.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=mst@redhat.com \
--cc=mvaralar@redhat.com \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
--cc=ue081723@gmail.com \
--cc=virtualization@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.