From: Joonho Lee <mynameisjune111@gmail.com>
To: Takashi Iwai <tiwai@suse.com>
Cc: "Michael S . Tsirkin" <mst@redhat.com>,
Jaroslav Kysela <perex@perex.cz>,
virtualization@lists.linux.dev, linux-sound@vger.kernel.org,
linux-kernel@vger.kernel.org,
Matias Ezequiel Vara Larsen <mvaralar@redhat.com>,
Eugenio Perez <eperezma@redhat.com>
Subject: [PATCH v3 0/5] ALSA: virtio: Fix request lifetime and error recovery
Date: Tue, 13 Oct 2026 17:57:47 +0900 [thread overview]
Message-ID: <cover.1791881787.git.mynameisjune111@gmail.com> (raw)
A failed PCM start or a timed-out request can leave virtio-snd messages
owned by the device after the caller returns. Retrying can then reuse
pending messages, and freeing ALSA or control buffers can leave their
addresses in a virtqueue.
This series fixes enqueue-error recovery and keeps the memory referenced
by outstanding requests alive until completion or device reset. Reset
also detaches unused descriptors before deleting the queues, releasing
their DMA mappings and cancelling PCM messages without reporting them
as completed audio.
Changes since v2, following the Sashiko AI review:
- Patch 2 protects all stopped-state accesses with vss->lock, including
hw_params, prepare, open, STOP and sync_stop completion. The RELEASE
decision and stopped=true transition now share a critical section.
Sleeping operations remain outside the spinlock.
- Patch 5 aligns every DMA region for both cache maintenance and typed
CPU accesses, and removes the initial +1 offset. This handles coherent
systems where dma_get_cache_alignment() returns 1, as well as odd
region lengths that could otherwise misalign later payloads.
- Patches 1, 3 and 4 are unchanged.
Validation of the final v3 source:
- ARM64 W=1 module build and ARM32 CONFIG_MMU=n driver object build.
- Source-extracted ASan/UBSan PCM, control, reset, ACK and DMA lifetime
regressions on macOS arm64. The v2 control allocator produces UBSan
misalignment diagnostics; the v3 allocator passes typed header and
request/response integer64 accesses with DMA alignments 1, 2, 4, 8,
32, 64 and 128.
- Deterministic stopped-state lock instrumentation catches unlocked v2
accesses and passes 73 lifecycle assertions for v3. It covers ACK
failure, RELEASE failure/retry and ACK during RELEASE, and checks that
blocking operations do not run with the spinlock held.
The stopped-state test instruments extracted source; it is not KCSAN or
an actual threaded kernel race test. NOMMU was compiled, not booted.
Physical non-coherent DMA hardware and host microphone behavior were
not tested by these regressions. The QEMU ARM64 KASAN fault/recovery runs
reported in v2 have not been rerun for these v3 changes.
Reproducer source and instructions:
https://github.com/whatisyourname0/virtio-snd-reproducer/tree/3ee5c7c1e864dae50a127b0a25cd122532daa6de
Based on sound.git for-next commit
8d70e364e866bdfca81eee24d0688fac9472cfb9.
AI assistance was used for code changes, tests, review and patch text.
Assisted-by trailers are included. Sashiko's findings were checked against
the driver and covered by regressions before incorporating the fixes.
Previous series Message-ID:
<cover.1791877396.git.mynameisjune111@gmail.com>
Joonho Lee (5):
ALSA: virtio: Propagate PCM send failures through ACK
ALSA: virtio: Recover PCM state after a failed start
ALSA: virtio: Retain queued messages through device reset
ALSA: virtio: Keep PCM DMA buffers alive through device ownership
ALSA: virtio: Keep control payloads alive through DMA completion
sound/virtio/virtio_card.c | 44 ++++-
sound/virtio/virtio_card.h | 2 +
sound/virtio/virtio_ctl_msg.c | 307 +++++++++++++++++++++++++++-------
sound/virtio/virtio_ctl_msg.h | 28 +++-
sound/virtio/virtio_kctl.c | 104 ++++++------
sound/virtio/virtio_pcm.h | 17 +-
sound/virtio/virtio_pcm_msg.c | 295 +++++++++++++++++++++++++++++---
sound/virtio/virtio_pcm_ops.c | 165 +++++++++++++++---
8 files changed, 798 insertions(+), 164 deletions(-)
base-commit: 8d70e364e866bdfca81eee24d0688fac9472cfb9
--
2.54.0 (Apple Git-157)
next reply other threads:[~2026-10-13 8:57 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-13 8:57 Joonho Lee [this message]
2026-10-13 8:57 ` [PATCH v3 1/5] ALSA: virtio: Propagate PCM send failures through ACK Joonho Lee
2026-10-13 9:07 ` sashiko-bot
2026-10-13 8:57 ` [PATCH v3 2/5] ALSA: virtio: Recover PCM state after a failed start Joonho Lee
2026-10-13 9:25 ` sashiko-bot
2026-10-13 8:57 ` [PATCH v3 3/5] ALSA: virtio: Retain queued messages through device reset Joonho Lee
2026-10-13 9:38 ` sashiko-bot
2026-10-13 8:57 ` [PATCH v3 4/5] ALSA: virtio: Keep PCM DMA buffers alive through device ownership Joonho Lee
2026-10-13 9:53 ` sashiko-bot
2026-10-13 8:57 ` [PATCH v3 5/5] ALSA: virtio: Keep control payloads alive through DMA completion Joonho Lee
2026-10-13 10:01 ` 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=cover.1791881787.git.mynameisjune111@gmail.com \
--to=mynameisjune111@gmail.com \
--cc=eperezma@redhat.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=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.