ALSA: pcm: preserve capture tail during drain
Status from this message: Applied both to for-next branch now. Thanks.
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v5 Latest2 patches 1 replyApplied
- v4 RFC2 patches 1 replySuperseded
- v3 RFC2 patches 0 repliesSuperseded
Earlier versions · 2
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v2 RFC | 2 patches | 0 replies | Superseded | |
| v1 RFC | 2 patches | 6 replies | Superseded |
Changes in v5 from the cover letter
- Submit as a non-RFC series following Takashi's response.
- No changes to either patch body, including the commit message, diff, and existing trailers. This cover and the mail headers are updated.
Patches in v5 Applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | ALSA: pcm: allow capture reads while drainingsound/ sound/ | +11 | 0 replies | |
| 2/2 | ALSA: pcm: refresh linked pointers before drainingsound/ | +25 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v5 yet.
Cover letter [PATCH v5 0/2] ALSA: pcm: preserve capture tail during drain
Capture drain can leave final frames buffered after the device stops. This series lets userspace read those frames and refreshes the linked streams' hardware pointers before drain-init.
Patch 1 allows capture reads in DRAINING, preserves the unread count when waking a blocked reader, and finishes capture with snd_pcm_drain_done() so linked playback can continue draining. DELAY and SYNC_PTR(HWSYNC) use the cached final capture pointer after capture stops.
Patch 2 refreshes each running member under its stream lock while holding snd_pcm_link_rwsem for reading. It updates both playback and capture, after the existing pause-resume step. The pause and drain-init actions remain outside the link rwsem. Pointer errors follow the normal XRUN path and return -EPIPE before drain-init.
Changes since RFC v4:
- Submit as a non-RFC series following Takashi's response.
- No changes to either patch body, including the commit message, diff, and existing trailers. This cover and the mail headers are updated.
Takashi said both patches look OK and that he can try merging a non-RFC series:
https://lore.kernel.org/all/[email protected]/
Previous RFC v4:
https://lore.kernel.org/all/[email protected]/
Implementation and test discussion:
https://lore.kernel.org/all/[email protected]/
The five-patch virtio-snd lifetime v3 series is unchanged:
https://lore.kernel.org/all/[email protected]/
The base and prerequisite IDs below preserve the tested integration:
apply the five lifetime patches, then these two core patches. Replace both earlier core patches when testing this revision. Core has no dependency on the generic control-wait or VZ compatibility RFC. This submission does not revise either companion series.
The following validation is from RFC v4's unchanged source; no new runtime tests were run for this mail-only revision.
Validation used ARM64 QEMU with KASAN and lockdep:
- 26 linked-stream checks passed across atomic and nonatomic modes, including paused drain, first/later member pointer errors, normal XRUN handling, tail reads, and unlink/prepare/reopen recovery.
- The three patch-1 failures were reproduced with the helper and the old first patch in both locking modes. All six corresponding fixed cases
passed: a blocked reader received all 64 final frames, capture EOF left linked playback in DRAINING, and both position queries succeeded without another pointer callback.
- Four additional blocked-reader runs compared baseline and fixed modules in both modes with a stronger gate: thread sleep and a pointer callback after START. They confirmed the baseline loss and fixed 64-frame read.
- The 10 existing lifecycle and timeout/reset scenarios passed, including held STOP/RELEASE, SIGKILL, reset, and subsequent I/O recovery.
- No KASAN, lockdep, or panic diagnostics appeared in the 54 selected logs, which include the baseline behavioral-failure comparisons.
The full Image and modules were first built with the new helper and the old first patch. After fixing the three tail issues, sound/core was rebuilt with W=1 against that same configuration and symbol versions, and the corrected PCM module was used for the runs above. The module build had no warnings or errors. The full build had 517 existing -Woverride-init warnings in arch/arm64 outside sound/. The exported v5 core source matches the tested source byte for byte.
These tests use synthetic drivers and modified fault/reset backends.
LLM assistance was used for implementation, reproducer development, analysis, and documentation. I reviewed the changes and test evidence.
Joonho Lee (2):
ALSA: pcm: allow capture reads while draining
ALSA: pcm: refresh linked pointers before draining
sound/core/pcm_lib.c | 16 ++++++++++------ sound/core/pcm_native.c | 27 ++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 7 deletions(-)
base-commit: 8d70e364e866bdfca81eee24d0688fac9472cfb9
prerequisite-patch-id: 39fb327a004c966ab90f66a34a64bbdbb3ffb475
prerequisite-patch-id: 7c6bc344656fd839ae0d697ba18d66ac0b47827a
prerequisite-patch-id: 9dd290ac3147fa7b49a475d7df8a6172778f2860
prerequisite-patch-id: f4c24a5e441343a690f4ac2437f181c815bc23d0
prerequisite-patch-id: ab4a5b770247a65272ab7af18a75a147daf81287