Hi Takashi, This revision follows v6 and addresses nine Sashiko findings in the staged capture and recovery paths. The follow-up diff is relative to the submitted v6 series, which applies to sound.git for-next at bcb4494239f57c98a8ef576566b03f2935b3000f. Targeting 7.5 or later still works for me.
The existing request-lifetime, ACK-accounting, high-priority period-work and dsnoop changes remain prerequisites. The capture compatibility options remain opt-in and false by default. This revision adds no performance tuning to the period worker. Patches 1-14 preserve the v6 changes and commit messages. Patch 15 adds the ALSA core paused-stop synchronization change. Patch 16 carries the virtio-snd review corrections and depends on patch 15. All prerequisites are included in this series. Changes since v6 Successful START and PAUSE_RELEASE schedule pending period notifications. RESET rebases the staged capture counters and callback snapshot along with the ALSA position. A per-stream lifecycle mutex serializes prepare, sync_stop, hw_params and hw_free. The trigger path does not acquire this mutex. RELEASE_SENT retries wait for pending RX without cancelling the period worker while holding the PCM lock. Failed resume wakes an active runtime through the XRUN path even when transfers have already been disabled. Successful paused ACKs no longer predict a stop from an intermediate availability value. The ALSA core change marks stop_operating when snd_pcm_do_stop() leaves PAUSED, so subsequent sync_stop can clean up outstanding requests. This affects PCM drivers beyond virtio-snd and needs separate core review. Playback pause/drop/prepare/write and reopen tests passed with the change. Reset generations reject stale control completions with -ECANCELED. Prepare revokes the previous prepared state before its early error paths, and completed RELEASE revokes device PREPARE permission. Cached capture tails remain readable in DRAINING and the supported released- pause state without refilling RX. Buffer allocation moves from automatic managed allocation into the driver callbacks. hw_params drains old RX under the lifecycle mutex before replacing the runtime buffer. hw_free revokes transfer and copy access and performs synchronous cleanup before releasing the mapping. Existing request-owned page and bounce-buffer lifetime protection remains in place. Validation The corrected ARM64 kernel was built with KASAN and lockdep. Targeted tests covered pending period wakeup, RUNNING and PAUSED RESET, paused forward and wrapped reads, concurrent release/prepare, RELEASE_SENT retry, failed resume, late control completion across virtio bus freeze/restore, early prepare failure and non-staged paused XRUN recovery. The original RELEASE retry produced a lockdep cycle and timed out. The corrected test completed and recovered through prepare. RESET and non- staged recovery tests received 48000 frames after recovery. Native-pause and pause-restart mode/lifecycle suites each passed 13 cases. A separate two-vCPU test completed 70 seconds at 16, 44.1, 48 and 96 kHz, followed by a five-second reopen. The fault-injection hooks are confined to test builds. The normal candidate kernel contains none of those hooks. Successful runs checked loaded module hashes and immutable inputs; the corrected regression runs reported no KASAN or lockdep errors. One-vCPU XRUN follow-up I compared v6 and the corrected kernel with the same kernel configuration, QEMU binary, rootfs and fixture. The guest had one vCPU, 512 MiB RAM and two CPU busy loops. Four dsnoop clients requested 16, 44.1, 48 and 96 kHz from a 48 kHz mono slave with 960-frame periods and a 7680-frame buffer (160 ms). In 70-second TCG runs ordered original/corrected/corrected/original, the original passed one of two runs and the corrected kernel passed neither. Errors occurred at alsa-lib's client_threshold check while the hardware slave remained RUNNING. In one corrected run, two readers completed all 70 seconds after the other two had failed. With HVF, both kernels passed two 70-second runs and their five-second reopens under the same guest CPU load. With TCG, lowering only the two busy loops to nice 19 also let both kernels complete 70 seconds and reopen. Delaying just the 96 kHz reader by 240 ms under HVF caused that client to XRUN on both kernels while the other three readers completed their requested frames. These controls support delayed client consumption under CPU contention as the immediate failure mechanism. They do not establish identical performance. In separate 20-second TCG probe runs, mean period-worker wall time was 343/359 us for v6 and 391/456 us for the corrected kernel. The corresponding HVF measurements were about 22.9 and 18.6 us. Both kernels made about 1000 worker calls per 20 seconds, with no probe misses. The probe measures elapsed time including waits and preemption, rather than exclusive kernel CPU time. Host workloads were left running. TCG and HVF also use different CPU models, so their absolute timings are not a regression ratio. The longer TCG worker times remain an observation requiring further isolation; the hardware-accelerated comparison did not reproduce that increase. RX completion and period-worker function bodies are unchanged between the two sources, although structure layout and control paths differ. All 20 follow-up runs were collected and checked, including three ordinary TCG failures and two intentionally delayed-reader failures. No KASAN or lockdep diagnostics appeared. Overflow checks and buffer sizes were unchanged. Scope These results use synthetic QEMU capture. Physical VZ/MOTU, KCSAN, 32-bit and NOMMU runtime tests were not rerun for this candidate. The buffer-lifetime changes were exercised on an MMU guest; NOMMU bounce-copy execution still needs separate coverage. The tests check frame counts and recovery without a new bit-exact sample-continuity claim. Virtio bus freeze/restore testing does not cover physical host suspend, and the core change has not been tested across all PCM drivers. AI assistance was used to examine the review, prepare corrections and diagnostic fixtures, analyse the results and draft this text. The new patches carry Assisted-by attribution. Previous v6: https://lore.kernel.org/linux-sound/[email protected]/ Sashiko review of v6: https://sashiko.dev/#/patchset/20261028025317.92450-1-mynameisjune111%40gmail.com Thanks, Joonho --- base-commit: bcb4494239f57c98a8ef576566b03f2935b3000f
