All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Joonho Lee" <mynameisjune111@gmail.com>, linux-sound@vger.kernel.org
Cc: virtualization@lists.linux.dev,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Eugenio Perez" <eperezma@redhat.com>
Subject: Re: [PATCH v24 12/16] ALSA: virtio: use request-owned capture and serialize recovery
Date: Wed, 11 Nov 2026 00:38:38 +0000	[thread overview]
Message-ID: <sashiko-outbox-208028@kernel.org> (raw)
In-Reply-To: <20261111000543.28550-13-mynameisjune111@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] ALSA: virtio: virtsnd_pcm_ack_state() drops buffer_accessing
  gate check
- [Low] ALSA: virtio: commit message describes removal of non-existent
  module params
--

commit 3a8c0c09be55edc0cc56835782c41eed627f4c8b
Author: Joonho Lee <mynameisjune111@gmail.com>

ALSA: virtio: use request-owned capture and serialize recovery

This commit switches capture substreams to request-owned buffers with
in-order completion commits and serializes PCM control state transitions,
recovery, and reset handling across epochs.

> Replace the direct/staged split with a common request-owned capture
> path. Remove capture_staging, capture_allow_short and
> capture_allow_empty. Packed status decoding and RELEASE/reprepare pause
> are still explicit, default-off compatibility options. This changes the
> default RX memory and copy cost.

[Severity: Low]
Is this paragraph left over from an earlier development branch?  Neither
the baseline nor earlier commits in the series define capture_staging,
capture_allow_short, capture_allow_empty, or a direct/staged split, while
capture_packed_status and capture_pause_restart are newly added by this
patch rather than retained.

> diff --git a/sound/virtio/virtio_pcm_ops.c b/sound/virtio/virtio_pcm_ops.c
> index a5a682534acf7..da4e98836721d 100644
> --- a/sound/virtio/virtio_pcm_ops.c
> +++ b/sound/virtio/virtio_pcm_ops.c

[ ... ]

> @@ -733,116 +1840,397 @@ static void virtsnd_pcm_transfer_failed(struct virtio_pcm_substream *vss)
>  	vss->substream->runtime->stop_operating = true;
>  }
>  
> -/* The caller holds the PCM lock, also used by DROP and state transitions. */
> -static int virtsnd_pcm_ack_state(struct snd_pcm_substream *substream)
> +/* Caller holds vss->lock; a paused ACK must not trigger linked XRUN. */

[ ... ]

> +/* The caller holds the PCM lock, also used by DROP and state transitions. */
> +static int virtsnd_pcm_ack_state(struct snd_pcm_substream *substream)
> +{
> +	switch (substream->runtime->state) {
> +	case SNDRV_PCM_STATE_XRUN:
> +		/*
> +		 * pcm_lib_apply_appl_ptr() interprets -EPIPE as a new XRUN
> +		 * and calls __snd_pcm_xrun(), which stops the whole linked
> +		 * group. The stream is already XRUN; do not repeat that action.
> +		 */
> +		return -EBADFD;
> +	case SNDRV_PCM_STATE_PREPARED:
> +	case SNDRV_PCM_STATE_RUNNING:
> +	case SNDRV_PCM_STATE_PAUSED:
> +	case SNDRV_PCM_STATE_DRAINING:
> +		return 0;
> +	default:
> +		return -EBADFD;
> +	}
> +}

[Severity: Medium]
Can dropping the atomic_read(&substream->runtime->buffer_accessing) < 0
check here let a concurrent SNDRV_PCM_IOCTL_SYNC_PTR admit an ACK while a
non-atomic operation holds the buffer access lock?

snd_pcm_sync_ptr() does not check runtime->buffer_accessing before calling
pcm_lib_apply_appl_ptr() -> substream->ops->ack().  Relying only on
vss->preparing and vss->indirect_reset_observing leaves unguarded windows
where buffer_accessing is negative but those flags are not set on the
substream yet:

CPU0                                  CPU1
snd_pcm_prepare(s0) [linked s0, s1]
  snd_pcm_group_buffer_access_lock()
    s1->runtime->buffer_accessing = -1
  snd_pcm_do_prepare(s0)
    virtsnd_pcm_prepare(s0) [sleeps]
                                      snd_pcm_sync_ptr(s1)
                                        pcm_lib_apply_appl_ptr(s1)
                                          virtsnd_pcm_pb_ack(s1)
                                            /* s1->preparing is false */
                                            virtsnd_pcm_msg_send(vss1)
  snd_pcm_do_prepare(s1)
    virtsnd_pcm_prepare(s1)

Here s1 is already in SNDRV_PCM_STATE_PREPARED when the linked prepare
starts, so CPU1 queues new TX descriptors on s1 after the group buffer
access gate was closed.  Similar windows exist across linked
snd_pcm_reset() before or after a member's snd_pcm_lib_reset() call, and
in snd_pcm_hw_params() or snd_pcm_hw_free() on a PREPARED substream before
virtsnd_pcm_sync_stop_locked() sets vss->preparing.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261111000543.28550-1-mynameisjune111@gmail.com?part=12

  reply	other threads:[~2026-11-11  0:38 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-11  0:05 [PATCH v24 00/16] ALSA: virtio: serialize PCM recovery and preserve capture and playback progress Joonho Lee
2026-11-11  0:05 ` [PATCH v24 01/16] ALSA: pcm: mark stop-threshold accesses for capture policy sampling Joonho Lee
2026-11-11  0:13   ` sashiko-bot
2026-11-11  0:05 ` [PATCH v24 02/16] ALSA: pcm: report partial progress under the stream lock Joonho Lee
2026-11-11  0:25   ` sashiko-bot
2026-11-11  0:05 ` [PATCH v24 03/16] ALSA: pcm: add an optional reset operation " Joonho Lee
2026-11-11  0:16   ` sashiko-bot
2026-11-11  0:05 ` [PATCH v24 04/16] ALSA: pcm: notify drivers after linked prepare completes Joonho Lee
2026-11-11  0:17   ` sashiko-bot
2026-11-11  0:05 ` [PATCH v24 05/16] ALSA: pcm: serialize linked buffer actions Joonho Lee
2026-11-11  0:13   ` sashiko-bot
2026-11-11  0:05 ` [PATCH v24 06/16] ALSA: virtio: propagate playback send failures through ACK Joonho Lee
2026-11-11  0:34   ` sashiko-bot
2026-11-11  0:05 ` [PATCH v24 07/16] ALSA: virtio: Recover PCM state after a failed start Joonho Lee
2026-11-11  0:33   ` sashiko-bot
2026-11-11  0:05 ` [PATCH v24 08/16] ALSA: virtio: Retain queued messages through device reset Joonho Lee
2026-11-11  0:25   ` sashiko-bot
2026-11-11  0:05 ` [PATCH v24 09/16] ALSA: virtio: bound PCM transfers and retain DMA buffers Joonho Lee
2026-11-11  0:27   ` sashiko-bot
2026-11-11  0:05 ` [PATCH v24 10/16] ALSA: virtio: Keep control payloads alive through DMA completion Joonho Lee
2026-11-11  0:16   ` sashiko-bot
2026-11-11  0:05 ` [PATCH v24 11/16] ALSA: virtio: wait through signals for PCM teardown Joonho Lee
2026-11-11  0:28   ` sashiko-bot
2026-11-11  0:05 ` [PATCH v24 12/16] ALSA: virtio: use request-owned capture and serialize recovery Joonho Lee
2026-11-11  0:38   ` sashiko-bot [this message]
2026-11-11  0:05 ` [PATCH v24 13/16] ALSA: virtio: prioritize capture period work Joonho Lee
2026-11-11  0:19   ` sashiko-bot
2026-11-11  0:05 ` [PATCH v24 14/16] docs: describe virtio-sound capture options Joonho Lee
2026-11-11  0:24   ` sashiko-bot
2026-11-11  0:05 ` [PATCH v24 15/16] ALSA: virtio: reject invalid playback completions Joonho Lee
2026-11-11  0:26   ` sashiko-bot
2026-11-11  0:05 ` [PATCH v24 16/16] ALSA: virtio: preserve playback progress across pause Joonho Lee
2026-11-11  0:49   ` sashiko-bot

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=sashiko-outbox-208028@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=eperezma@redhat.com \
    --cc=linux-sound@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=mynameisjune111@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --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.