This series updates PCM error recovery, queue ownership and capture accounting in virtio-snd. It also provides opt-in staged capture for backends whose completion lengths need explicit compatibility handling. The capture compatibility parameters remain disabled by default.
The previous series is at https://lore.kernel.org/linux-sound/[email protected]/T/. The v23 changes address the v22 automated review and a separate existing linked-buffer locking problem. Linked prepare now commits member states and driver admission under the group and member PCM locks. Suspended or disconnected members keep their states, and a canceled successful driver prepare returns an error to its caller. Failed prepares notify only the attempted prefix and do not generate a stop-timer event. A separate core patch closes every linked member's buffer-access gate and takes buffer mutexes in the stable group order. The caller-first ordering and caller-only access gate are already present in the upstream base; this patch is distinct from the prepare-completion API change. The failed-start patch owns the direction-independent error latch. The later recovery code keeps native pause admission closed when a linked resume rollback fails in PAUSED. Paused ordinary capture preserves the accounting-error XRUN path. Staged capture rejects unaligned application pointer deltas before changing policy or counters. The DMA lifetime and staged-capture commit messages now describe their full source changes. The order separates the ALSA core APIs and existing linked-buffer fix, ACK propagation and failed-start recovery, message and control lifetime, teardown waits, opt-in capture compatibility, work priority, and option documentation. Each patch is represented by an independently checked cumulative source stage. Validation used ARM64 QEMU with KASAN and lockdep. The eleven changed cumulative stages, 04 through 14, built with W=1 without compiler warnings or errors. Applying all fourteen patches in order reproduces every cumulative source stage and the exact final candidate. A test PCM driver passed fourteen core scenarios, including linked success and partial failure, atomic and nonatomic locks, suspend and disconnect cancellation, overlapping DROP, an active sibling buffer access, parallel group actions, and old-generation ACK retirement. The stop-timer change was checked by source review; this run did not attach a timer client to count timer notifications. The instrumented virtio-snd tests passed definite START and STOP rejection, RUNNING pause restoration, failed linked resume rollback, deferred group XRUN, DROP, prepare, real playback and capture I/O, and reopen in RW and MMAP modes. Actual SYNC_PTR calls checked rejected ACK rollback and unaligned ACK policy preservation. The alignment and invalid-accounting inputs are synthetic test geometry. A separate stage-07 test verified four START failure/recovery cases and failed playback drain termination. The pure final driver passed ordinary and staged RW and MMAP recording. Each configuration included a seventy-second capture. RW checked three reopen cycles; MMAP checked RESET and a reopened stream. All fourteen captured segments matched SHA256 values generated independently on the host from recorded QEMU sequence epochs. No KASAN or lockdep diagnostics were reported by the passing runs. Additional tests used the same candidate with strict KCSAN and lockdep. The runtime selftest and an isolated positive-control race confirmed instrumentation. Fourteen core cases passed at both default and higher sampling rates. Twenty-four driver control and accounting assertions passed. Ordinary and staged RW/MMAP captures matched all fourteen independent signal segments, including RESET and reopen. The KCSAN campaign did report an ARM64 saved-PSTATE race outside ALSA: copy_thread() races with spectre_v4_enable_task_mitigation(). I built the pristine base with the identical config and ran the same fork workload with all sound modules unloaded. It reproduced the original pair; the ARM64 source and compiled objects are identical between the two kernels. The report remains recorded, so this is not a globally KCSAN-clean result. No ARM64 change is included in this series. Physical tests on macOS VZ used Scarlett 2i2 input 1 at 48 kHz. Direct ALSA RW and MMAP each recorded seventy seconds, with signal statistics checked against a simultaneous host capture. Pause/RESET, the first open after killing a running recorder, and capture after VM restart passed. These tests enabled all five compatibility options. They do not establish bit-exact physical sample continuity or Docker Desktop microphone support. Two test-tool problems were corrected before the final runs: asynchronous ACK snapshots could evict a control-error record, and truncating an old capture file after START stalled the test client beyond its PCM ring. The final MMAP test prepares RAM before START and writes output after closing PCM. Source, config and data-oracle acceptance stayed unchanged. Synthetic alignment checks do not represent an actual sub-byte capture device. The stop-timer change remains source-reviewed without an attached timer client. One-shot command rejection exercises a definite error path; uncertain control timeouts can still require device reset or reprobe. Heavy-load TCG scheduling limits remain outside this qualification. The staged path and its backend compatibility options need maintainer review before they can be recommended for a production deployment.
