[PATCH v25 00/16] ALSA: virtio: serialize PCM recovery and preserve capture and playback progress

From: Joonho Lee

Date: Tue Nov 10 2026 - 21:57:23 EST


This series updates ALSA PCM recovery and virtio-snd request ownership.
Capture receives into request-owned buffers so valid short completions
can be appended to the ALSA ring without leaving a gap.

This replaces v24 in full. Apply all sixteen patches to the base commit
below. The previous version is at:

https://lore.kernel.org/linux-sound/20261111000543.28550-1-mynameisjune111@xxxxxxxxx/T/

Changes since v24:

Capture DRAINING keeps a full buffer readable and reports progress
beyond capacity as XRUN. The read loop refreshes availability after an
unlocked copy so a tail published during that copy is included before
EOF. Playback drain completion is unchanged.

ACK checks the core buffer-access gate before entering the transfer
path. The existing PCM lock barriers in prepare, RESET, hw_params and
hw_free wait for ACKs already admitted before the gate closes. Internal
RESET pointer observation retains its separate bypass.

Playback period work checks for new progress or a latched error under
the PCM stream lock. This prevents work queued before a paused RESET
from publishing a duplicate period after resume. Prepare and RESET clear
both the cached device latency and runtime delay.

The capture allocation and copy description now lives in the ALSA
configuration guide. On MMU systems, per-period page rounding can make
additional memory exceed the ALSA ring size; the request buffers remain
allocated from hw_params until hw_free. Pause documentation now
describes STOP/RELEASE followed by PREPARE/START. The ACK
error-propagation and teardown wait patches carry Fixes tags. Patch
descriptions state their changes against the pinned base.

Validation:

The pinned v24 baseline was rebuilt with the saved KASAN and lockdep
configuration and the same builder. Fresh cumulative W=1 builds cover
stages 2, 12 and 16. Each passed with no new warning lines in the
changed audio builds. The full baseline build retains 517 warnings in
unchanged ARM64 files; other intermediate stages were not rebuilt.

Matched synthetic ALSA PCM tests compared baseline and integrated
candidate. The candidate preserved and read all 8192 frames in a full
capture buffer, returned EOF on the next read, reported 8193 unread
frames as XRUN, and returned both a 1024-frame prefix and the 512-frame
tail published during an unlocked read before reaching EOF. Playback
drain still completes. These fixtures exercise PCM core behavior, not
virtio transport or physical device DMA.

ACK probes on baseline, isolated candidate and integrated candidate
verified the baseline admitted a gated ACK and queued TX; both
candidates rejected ACK with -EBADFD and queued no TX. All three also
verified completion of a pre-gate ACK before linked prepare crossed its
lock barrier, and the internal RESET bypass. The integrated playback
probes verified stale work across PAUSED RESET/resume and clearing of a
synthetic 256-frame device delay after RESET and PREPARE. Clean
integrated RW and MMAP capture runs each lasted 70 seconds; all seven
segments totaling 7,104,000 frames matched the unchanged independent
oracle. These QEMU runs reported no KASAN or lockdep diagnostics. KCSAN
was not run.

The default RX path adds request-owned memory and an IRQ-path copy.
Packed status and RELEASE/reprepare pause are opt-in and disabled by
default. CPU and worst-case IRQ lock-hold time remain unqualified. The
playback queue cap reduces buffering tolerance, especially with two
periods. This revision has no new physical VZ or KCSAN qualification.
Uncertain control timeouts can still require device reset or reprobe.
The deterministic review fixtures are local and have not been published.

base-commit: a4311e9447bbb219044db38897f95be112f46a8a