mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joonho Lee <mynameisjune111@gmail.com>
To: linux-sound@vger.kernel.org
Cc: tiwai@suse.de, perex@perex.cz, anton.yakovlev@opensynergy.com,
	mst@redhat.com, virtualization@lists.linux.dev,
	linux-kernel@vger.kernel.org, corbet@lwn.net,
	skhan@linuxfoundation.org, rdunlap@infradead.org,
	linux-doc@vger.kernel.org
Subject: [PATCH v12 00/12] ALSA: virtio: staged capture recovery and PCM RESET synchronization
Date: Tue,  3 Nov 2026 09:03:51 +0900	[thread overview]
Message-ID: <20261103000403.67106-1-mynameisjune111@gmail.com> (raw)

Hi Takashi,

This revision replaces v11 and carries the unmerged prerequisites.
Apply patches 1-12 to sound.git for-next at
a4311e9447bbb219044db38897f95be112f46a8a.
Targeting 7.5 or later still works for me.

Previous revision:
https://lore.kernel.org/linux-sound/20261031020855.2402-1-mynameisjune111@gmail.com/T/

The series adds staged capture for shared clients such as dsnoop,
lifecycle recovery and synchronized PCM RESET accounting. Capture
compatibility options remain opt-in and disabled by default.

Changes since v11

The ACK path tried buffer_mutex while holding the PCM lock. That mutex
can already be held during normal RESET, refinement and linked prepare.
ACK then returned -EBADFD despite a valid stream. Private accounting can
also change before the indirect helper sees the ACK error.

Patch 10 uses the PCM lock for ACK and prepare accounting, with a
preparing gate lasting until the RESET callback completes. The core
keeps that same lock through its public pointer rebase. Playback RESET
rebases private accounting while preserving queued TX ownership. Both
capture modes synchronize their private pointers with the common reset,
including RESET from PREPARED. Queue-to-substream lock order is retained.

Paused native capture accepts RX completions from the live prepared
epoch even when transfers are disabled. Refill remains gated by transfer
state. Resume preserves the notification floor, so real missed periods
retain their PCM timer ticks and synthetic progress adds none. Device
events and failed STOP latch XRUN and wake readers. ACK rejects invalid
or stopped streams. Failed PREPARE preserves the previous accounting.

Ordinary RX validates status and payload before advancing counters.
Empty STOP responses contribute zero frames. Full-ring XRUN detection
remains enabled: sample checks showed a real overwritten ring after a
220 ms observation delay. A candidate that suppressed the error returned
frame 31680 where frame 24000 was expected. That candidate was discarded.
The final code reports -EPIPE and recovers through prepare. Normal drain
returns the expected 64-frame tail. The full-ring check in v11 remains
valid; the corrected issue is frame accounting for empty STOP responses.

Byte alignment uses gcd(frame_bits, 8), preserving byte-aligned queue
boundaries for packed 4-bit formats. Broader format runtime coverage is
still pending.

Several findings reproduce before v11, including ACK mutex contention
in the earlier lifecycle implementation and playback RESET accounting.
The ACK mutex findings share one synchronization cause. The staged
pause-tail and missed-period failures reproduce in both v10 and v11.
The local comparison retains original, earlier and final results.

Patch layout and dependencies

  1-6: ACK errors, START/RELEASE recovery and request/DMA lifetime.
  7:   Core stop-threshold accesses used by capture policy sampling.
  8:   Partial-progress notification under the PCM stream lock.
  9:   Optional PCM reset operation under the stream lock.
  10:  Staged capture, lifecycle serialization and driver RESET users.
  11:  Staged capture work priority.
  12:  Capture compatibility option documentation.

Patches 1-8 are unchanged from v11. The previous core patch 12 moves to
patch 9 without a code change. Previous driver patches 9, 13 and 14 are
combined in patch 10 with the corrections above. ACK's preparing gate
and its RESET completion must arrive together; separating them would
leave an intermediate driver with no matching completion path.
Previous patches 10 and 11 become patches 11 and 12.

The core API stays separate from its driver users. Drivers without a
reset callback retain the ioctl path. Linked RESET and prepare stop at
the first error and can leave earlier members completed. Applications
must recover the group after partial failure. A zero callback result
allows the core rebase; later I/O can report XRUN. The internal
snd_pcm_ops change requires out-of-tree users to be rebuilt.

Validation

The final source matches the corrected candidate byte for byte across
all 15 touched files. The comparison includes 43 ARM64 QEMU runs, with
56 transition checks across ordinary/staged capture and KASAN/KCSAN,
and four linked prepare/ACK checks. Faults include ACK contention,
failed PREPARE/STOP, paused RX, status-only RX and invalid ACK states.
KASAN, lockdep and KCSAN_STRICT reported no diagnostics in those runs.

Uninstrumented RW and MMAP captures ran for 70 seconds per mode and
capture policy, with pause, RESET and reopen. All 14 segments,
14,208,000 mono S16 frames at 48 kHz, matched independent sequence
hashes. Native-pause tail checks and PCM timer tests compared v11 with
the correction. Core compatibility tests include 72 callback/legacy,
atomic/nonatomic and linked-failure checks, plus snd-dummy playback and
capture. Test hooks are excluded from the submitted source.

Each of the 12 reconstructed intermediate sources is checked by applying
its mail patch to the pinned baseline and comparing the postimage.
ARM64 W=1 Image/modules builds and additional intermediate-stage runtime
checks are recorded in the local submission package. Fifteen additional
VM runs passed, including 28 injected transition checks at patch 10.

These are ARM64 QEMU TCG tests with two vCPUs and 512 MiB. Physical
VZ/MOTU acceptance for this revision and broader format, multichannel
and architecture runtime coverage remain pending. Earlier high-load
TCG XRUN results limit performance conclusions; this revision does not
claim a general CPU or scheduling improvement. The optional core APIs
and linked RESET partial-failure policy still need maintainer review.

Coding assistance was used for analysis, implementation, fixtures and
this explanation. The patches carry Assisted-by: LLM.

Thanks,
Joonho

base-commit: a4311e9447bbb219044db38897f95be112f46a8a

             reply	other threads:[~2026-11-03  0:04 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-03  0:03 Joonho Lee [this message]
2026-11-03  0:03 ` [PATCH v12 01/12] ALSA: virtio: Propagate PCM send failures through ACK Joonho Lee
2026-11-03  0:03 ` [PATCH v12 02/12] ALSA: virtio: Recover PCM state after a failed start Joonho Lee
2026-11-03  0:03 ` [PATCH v12 03/12] ALSA: virtio: Retain queued messages through device reset Joonho Lee
2026-11-03  0:03 ` [PATCH v12 04/12] ALSA: virtio: Keep PCM DMA buffers alive through device ownership Joonho Lee
2026-11-03  0:03 ` [PATCH v12 05/12] ALSA: virtio: Keep control payloads alive through DMA completion Joonho Lee
2026-11-03  0:03 ` [PATCH v12 06/12] ALSA: virtio: wait through signals for PCM teardown Joonho Lee
2026-11-03  0:03 ` [PATCH v12 07/12] ALSA: pcm: mark stop-threshold accesses for capture policy sampling Joonho Lee
2026-11-03  0:03 ` [PATCH v12 08/12] ALSA: pcm: report partial progress under the stream lock Joonho Lee
2026-11-03  0:04 ` [PATCH v12 09/12] ALSA: pcm: add an optional reset operation " Joonho Lee
2026-11-03  0:04 ` [PATCH v12 10/12] ALSA: virtio: add staged capture and serialize PCM lifecycle accounting Joonho Lee
2026-11-03  0:04 ` [PATCH v12 11/12] ALSA: virtio: prioritize staged capture period work Joonho Lee
2026-11-03  0:04 ` [PATCH v12 12/12] docs: describe virtio-sound capture options Joonho Lee
2026-11-03  0:55   ` Randy Dunlap

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=20261103000403.67106-1-mynameisjune111@gmail.com \
    --to=mynameisjune111@gmail.com \
    --cc=anton.yakovlev@opensynergy.com \
    --cc=corbet@lwn.net \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=perex@perex.cz \
    --cc=rdunlap@infradead.org \
    --cc=skhan@linuxfoundation.org \
    --cc=tiwai@suse.de \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®