ALSA: virtio: staged capture recovery and PCM RESET synchronization
Subsystems (4)
v12 cover ALSA: virtio: staged capture recovery and PCM RESET synchronization
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/[email protected]/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
PATCH v12 1/12 ALSA: virtio: Propagate PCM send failures through ACK
virtsnd_pcm_msg_send() can fail while queueing a transfer. Restore the failed message's length and notify the device about earlier messages queued by the same call, so they do not remain stranded.
Propagate that failure through the indirect PCM transfer callback instead of discarding it. Commit the updated indirect state only after successful submission and stop further transfers when a send fails. Return an XRUN error to ALSA so the stream can recover.
Keep the polling feature path unchanged.
---
sound/virtio/virtio_pcm_msg.c +12 -0
@@ -260,6 +260,18 @@dev_err (&vdev->dev,"SID %u: failed to send I/O message\n" , vss->sid); + msg->length -= n; + +/* +* Do not leave earlier messages queued without notifying +* the device when a later message could not be added. +*/ +if (msg_count != vss->msg_count && + !(vss->features & + (1U <<VIRTIO_SND_PCM_F_MSG_POLLING )) && +virtqueue_kick_prepare (vqueue)) +virtqueue_notify (vqueue); +return rc; }
sound/virtio/virtio_pcm_ops.c +78 -14
114 lines not on this page · raw message
[email protected]
AI reviewRe: [PATCH v12 01/12] ALSA: virtio: Propagate PCM send failures through ACK
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] ALSA: virtio: race on stopped and stop_operating in virtsnd_pcm_pb_ack() --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] ALSA: virtio: race on stopped and stop_operating in virtsnd_pcm_pb_ack() --
commit adfc01993325cef03121710f81f719a0dc208b01
Author: Joonho Lee <[email protected]>
ALSA: virtio: Propagate PCM send failures through ACK
This commit updates virtsnd_pcm_msg_send() to roll back the message length and notify the virtqueue for previously queued messages when adding a message fails. It also propagates transfer errors through virtsnd_pcm_pb_ack() and virtsnd_pcm_cp_ack() so ALSA can handle them as XRUNs.
Quoted 51 lines
sound/virtio/virtio_pcm_ops.c +28
-3@@ -466,36 +466,100 @@ virtsnd_pcm_cp_pointer(struct snd_pcm_substream *substream) vss->hw_ptr); } +struct virtsnd_pcm_transfer { +struct snd_pcm_indirect indirect; +int error; +}; +static void virtsnd_pcm_trans_copy (struct snd_pcm_substream *substream,struct snd_pcm_indirect *rec,size_t bytes) {struct virtio_pcm_substream *vss =snd_pcm_substream_chip (substream); +struct virtsnd_pcm_transfer *transfer = + container_of(rec, struct virtsnd_pcm_transfer, indirect); + +if (transfer->error) +return ; -virtsnd_pcm_msg_send (vss, rec->sw_data, bytes); + transfer->error =virtsnd_pcm_msg_send (vss, rec->sw_data, bytes); +} + +/* Caller holds vss->lock. */ +static void virtsnd_pcm_transfer_failed (struct virtio_pcm_substream *vss) +{ + vss->xfer_enabled = false; + vss->stopped = true; + vss->substream->runtime->stop_operating = true; }static int virtsnd_pcm_pb_ack (struct snd_pcm_substream *substream) {struct virtio_pcm_substream *vss =snd_pcm_substream_chip (substream);struct virtio_snd_queue *queue =virtsnd_pcm_queue (vss); +struct virtsnd_pcm_transfer transfer = {}; +int rc; -guard (spinlock_irqsave)(&queue->lock); -guard (spinlock)(&vss->lock); + scoped_guard(spinlock_irqsave, &queue->lock) { +guard (spinlock)(&vss->lock); + transfer.indirect = vss->pcm_indirect; +if (vss->stopped) { + rc = -EPIPE ; + }else { + rc = snd_pcm_indirect_playback_transfer(substream,
sound/virtio/virtio_pcm_ops.c virtsnd_pcm_cp_pointer(struct snd_pcm_substream *substream) · line 518
Quoted 10 lines
sound/virtio/virtio_pcm_ops.c +10
-0+ &transfer.indirect, + virtsnd_pcm_trans_copy); + } +if (!rc) + rc = transfer.error; +if (rc) +virtsnd_pcm_transfer_failed (vss); +else + vss->pcm_indirect = transfer.indirect; + }
[Severity: Medium]
Can virtsnd_pcm_pb_ack() and virtsnd_pcm_cp_ack() race with snd_pcm_sync_stop() and virtsnd_pcm_sync_stop() on vss->stopped and substream->runtime->stop_operating?
Because virtio-snd PCM devices are nonatomic (vpcm->pcm->nonatomic = true), snd_pcm_sync_stop() is invoked without holding the PCM stream lock (substream->self_group.mutex), such as from snd_pcm_drop() after dropping pcm_stream_lock_irq() or from snd_pcm_do_prepare() under runtime->buffer_mutex. Meanwhile, a concurrent SNDRV_PCM_IOCTL_SYNC_PTR ioctl in snd_pcm_sync_ptr() acquires only pcm_stream_lock_irq() and calls:
snd_pcm_sync_ptr()
pcm_lib_apply_appl_ptr()
virtsnd_pcm_pb_ack() / virtsnd_pcm_cp_ack()
In sound/virtio/virtio_pcm_ops.c, virtsnd_pcm_sync_stop() reads and clears vss->stopped without holding vss->lock or the PCM stream lock, after snd_pcm_sync_stop() clears substream->runtime->stop_operating:
static int virtsnd_pcm_sync_stop(struct snd_pcm_substream *substream)
{
...
cancel_work_sync(&vss->elapsed_period);
if (!vss->stopped)
return 0;
...
vss->stopped = false;
return 0;
}If a concurrent ACK runs while vss->stopped is true, virtsnd_pcm_pb_ack() or virtsnd_pcm_cp_ack() sets rc = -EPIPE and calls virtsnd_pcm_transfer_failed(), which writes vss->stopped = true and substream->runtime->stop_operating = true. That races with virtsnd_pcm_sync_stop() and re-arms stop_operating after snd_pcm_sync_stop() cleared it, while returning -EPIPE so pcm_lib_apply_appl_ptr() invokes __snd_pcm_xrun() even when snd_pcm_drop() had placed the stream in SNDRV_PCM_STATE_SETUP.
Conversely, virtsnd_pcm_pb_ack() and virtsnd_pcm_cp_ack() only check vss->stopped before transferring data. Once virtsnd_pcm_sync_stop() clears vss->stopped = false after releasing the stream in SNDRV_PCM_STATE_SETUP, a subsequent SNDRV_PCM_IOCTL_SYNC_PTR ioctl sees vss->stopped == false and enqueues virtio I/O messages on a released stream.
Later commits in this series ("ALSA: virtio: Recover PCM state after a failed start" and "ALSA: virtio: add staged capture and serialize PCM lifecycle accounting") partially address this by guarding vss->stopped with vss->lock and gating ACK on vss->prepared and vss->preparing, but do not completely resolve the race. In virtsnd_pcm_sync_stop_locked() (and virtsnd_pcm_pause_restart_sync_stop()) as well as virtsnd_pcm_prepare_locked(), vss->prepared remains true while vss->stopped is true across sleeping teardown calls (cancel_work_sync(), virtsnd_pcm_stop_device(), and virtsnd_pcm_send_sync() for VIRTIO_SND_R_PCM_RELEASE), and virtsnd_pcm_pb_ack() does not check runtime->state. A concurrent SNDRV_PCM_IOCTL_SYNC_PTR during that window still sees vss->prepared == true and vss->stopped == true, calls virtsnd_pcm_transfer_failed() to set runtime->stop_operating = true after snd_pcm_sync_stop() cleared it, and returns -EPIPE to trigger __snd_pcm_xrun().
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
PATCH v12 2/12 ALSA: virtio: Recover PCM state after a failed start
In reply to Joonho LeeCapture trigger queues I/O messages before PCM_START. If the START message cannot be allocated or sent, transfers may remain queued, and ALSA does not invoke the action undo callback for the failed trigger.
Mark the stream stopped and disable transfers for every failed START path. Arm runtime->stop_operating so sync_stop releases pending I/O and prevents prepare, hw_params, or START retries until release succeeds.
The stopped flag is shared with ACK callbacks that can run without the ALSA stream lock. Protect every stopped access with vss->lock. Read the pending message count under the same lock in open and hw_params. In sync_stop, decide whether RELEASE is needed and mark the stream stopped in one locked transition; leave it stopped when release or draining fails.
Always cancel elapsed-period work in sync_stop, even when no RELEASE is needed.
Record the RELEASE obligation after successful PREPARE and clear it as soon as RELEASE succeeds. If the subsequent RX wait fails, retry that wait without submitting RELEASE again.
---
sound/virtio/virtio_pcm.h +4 -2
@@ -26,13 +26,13 @@* @hw: Kernel ALSA substream hardware descriptor. * @elapsed_period: Kernel work to handle the elapsed period state. * @lock: Spinlock that protects fields shared by interrupt handlers and -* substream operators. +* substream operators, including @stopped. * @buffer_bytes: Current buffer size in bytes. * @hw_ptr: Substream hardware pointer value in bytes [0 ... buffer_bytes). * @xfer_enabled: Data transfer state (0 - off, 1 - on). * @xfer_xrun: Data underflow/overflow state (0 - no xrun, 1 - xrun). * @stopped: True if the substream is stopped and must be released on the device -* side. +* side; protected by @lock. * @suspended: True if the substream is suspended and must be reconfigured on * the device side at resume. * @msgs: Allocated I/O messages.
@@ -56,6 +56,8 @@bool xfer_enabled;bool xfer_xrun;bool stopped; +/* Successful PREPARE still needs RELEASE; protected by lock. */ +bool release_required;bool suspended;struct virtio_pcm_msg **msgs;unsigned int nmsgs;
sound/virtio/virtio_pcm_ops.c +84 -22
184 lines not on this page · raw message
[email protected]
AI reviewRe: [PATCH v12 02/12] ALSA: virtio: Recover PCM state after a failed start
Sashiko has reviewed this patch and found no issues.
Quoted 17 lines
Capture trigger queues I/O messages before
PCM_START. If the START message cannot be allocated or sent, transfers may remain queued, and ALSA does not invoke the action undo callback for the failed trigger.Mark the stream stopped and disable transfers for every failed START path. Arm
runtime->stop_operatingsosync_stopreleases pending I/O and prevents prepare,hw_params, or START retries until release succeeds.The stopped flag is shared with ACK callbacks that can run without the ALSA stream lock. Protect every stopped access with
vss->lock. Read the pending message count under the same lock in open andhw_params. Insync_stop, decide whether RELEASE is needed and mark the stream stopped in one locked transition; leave it stopped when release or draining fails.Always cancel elapsed-period work in
sync_stop, even when no RELEASE is needed.
Quoted 7 lines
Record the RELEASE obligation after successful PREPARE and clear it as soon as RELEASE succeeds. If the subsequent RX wait fails, retry that wait without submitting RELEASE again.
Fixes da76e9f3e43a ("ALSA: virtio: PCM substream operators")Assisted-by LLMSigned-off-by Joonho Lee <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
PATCH v12 3/12 ALSA: virtio: Retain queued messages through device reset
In reply to Joonho LeeKeep the control queue available through snd_card_free() so close-time STOP and RELEASE commands can still be submitted. Block new control requests and mark pending messages canceled before reset, then release their queue references only after reset and queue deletion.
For PCM queues, detach each remaining virtqueue buffer after the device has stopped DMA and retire its message without reporting a normal completion. Detach all queues before deleting them so outstanding DMA mappings are unmapped and no token remains for a late device completion.
Clear each queue wrapper inside the same critical section that detaches its buffers. Check the callback's queue identity under the wrapper lock for PCM, control and event queues. This makes queue retirement explicit through teardown and restore. A forced callback test passed on both versions; the proposed detached-ring IRQ failure was not reproduced on the tested PCI transport.
---
sound/virtio/virtio_card.c +41 -5
@@ -87,6 +87,8 @@u32 length;guard (spinlock_irqsave)(&queue->lock); +if (queue->vqueue != vqueue) +return ; do { virtqueue_disable_cb(vqueue); while ((event = virtqueue_get_buf(vqueue, &length))) {
@@ -338,6 +340,38 @@ }/** +* virtsnd_reset_vqs() - Stop device access and unmap outstanding buffers. +* @snd: VirtIO sound device. +* +* Context: Any context that permits to sleep. +*/ +static void virtsnd_reset_vqs (struct virtio_snd *snd) +{ +struct virtio_device *vdev = snd->vdev; +unsigned int i; + +virtio_reset_device (vdev); + +/* Deleting a virtqueue does not unmap its outstanding descriptors. */ +for (i =0 ; i <VIRTIO_SND_VQ_MAX ; ++i) { +struct virtio_snd_queue *queue = &snd->queues[i]; +unsigned long flags; +void *msg; + +spin_lock_irqsave (&queue->lock, flags); +if (queue->vqueue) +while ((msg =virtqueue_detach_unused_buf (queue->vqueue))) +if (i ==VIRTIO_SND_VQ_TX || i ==VIRTIO_SND_VQ_RX ) +virtsnd_pcm_msg_cancel (msg); +/* IRQ callbacks must never see a detached ring as live. */ + queue->vqueue =NULL ; +spin_unlock_irqrestore (&queue->lock, flags); + } + + vdev->config->del_vqs (vdev); +} + +/** * virtsnd_remove() - Remove VirtIO and ALSA devices. * @vdev: VirtIO parent device. *
@@ -349,13 +383,14 @@unsigned int i;virtsnd_disable_event_vq (snd); -virtsnd_ctl_msg_cancel_all (snd);if (snd->card)snd_card_free (snd->card); -virtio_reset_device (vdev); - vdev->config->del_vqs (vdev); +virtsnd_ctl_msg_cancel_all (snd); + +virtsnd_reset_vqs (snd); +virtsnd_ctl_msg_cleanup (snd);for (i =0 ; snd->substreams && i < snd->nsubstreams; ++i) {struct virtio_pcm_substream *vss = &snd->substreams[i];
@@ -383,8 +418,8 @@virtsnd_disable_event_vq (snd);virtsnd_ctl_msg_cancel_all (snd); -virtio_reset_device (vdev); - vdev->config->del_vqs (vdev); +virtsnd_reset_vqs (snd); +virtsnd_ctl_msg_cleanup (snd);for (i =0 ; i < snd->nsubstreams; ++i)cancel_work_sync (&snd->substreams[i].elapsed_period);
@@ -412,6 +447,7 @@return rc;virtio_device_ready (vdev); +virtsnd_ctl_msg_enable (snd);virtsnd_enable_event_vq (snd);
sound/virtio/virtio_card.h +2 -0
@@ -47,6 +47,7 @@* @queues: Virtqueue wrappers. * @card: ALSA sound card. * @ctl_msgs: Pending control request list. +* @ctl_msgs_blocked: Control requests are blocked during teardown or suspend. * @event_msgs: Device events. * @pcm_list: VirtIO PCM device list. * @jacks: VirtIO jacks.
@@ -64,6 +65,7 @@struct virtio_snd_queue queues[VIRTIO_SND_VQ_MAX ];struct snd_card *card;struct list_head ctl_msgs; +bool ctl_msgs_blocked;struct virtio_snd_event *event_msgs;struct list_head pcm_list;struct virtio_jack *jacks;
sound/virtio/virtio_ctl_msg.c +57 -7
130 lines not on this page · raw message
sound/virtio/virtio_ctl_msg.h +4 -0
@@ -68,6 +68,10 @@void virtsnd_ctl_msg_cancel_all (struct virtio_snd *snd); +void virtsnd_ctl_msg_cleanup (struct virtio_snd *snd); + +void virtsnd_ctl_msg_enable (struct virtio_snd *snd); +void virtsnd_ctl_msg_complete (struct virtio_snd_msg *msg); int virtsnd_ctl_query_info(struct virtio_snd *snd, int command, int start_id,
sound/virtio/virtio_pcm.h +2 -0
@@ -122,6 +122,8 @@void virtsnd_pcm_msg_reset (struct virtio_pcm_substream *vss); +void virtsnd_pcm_msg_cancel (struct virtio_pcm_msg *msg); +int virtsnd_pcm_msg_send (struct virtio_pcm_substream *vss,unsigned long offset,unsigned long bytes);
sound/virtio/virtio_pcm_msg.c +38 -4
74 lines not on this page · raw message
[email protected]
AI reviewRe: [PATCH v12 03/12] ALSA: virtio: Retain queued messages through device reset
Sashiko has reviewed this patch and found no issues.
Quoted 17 lines
Keep the control queue available through
snd_card_free()so close-time STOP and RELEASE commands can still be submitted. Block new control requests and mark pending messages canceled before reset, then release their queue references only after reset and queue deletion.For PCM queues, detach each remaining virtqueue buffer after the device has stopped DMA and retire its message without reporting a normal completion. Detach all queues before deleting them so outstanding DMA mappings are unmapped and no token remains for a late device completion.
Clear each queue wrapper inside the same critical section that detaches its buffers. Check the callback's queue identity under the wrapper lock for PCM, control and event queues. This makes queue retirement explicit through teardown and restore. A forced callback test passed on both versions; the proposed detached-ring IRQ failure was not reproduced on the tested PCI transport.
Quoted 3 lines
Fixes 9d45e514da88 ("ALSA: virtio: handling control messages")Assisted-by LLMSigned-off-by Joonho Lee <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
PATCH v12 4/12 ALSA: virtio: Keep PCM DMA buffers alive through device ownership
In reply to Joonho LeeRetain references to the pages backing ALSA's vmalloc buffer until its queued I/O messages are freed. On NOMMU systems, use driver-owned memory for DMA and copy playback data before submission and capture data after completion, so ALSA buffer release cannot invalidate an active request.
Validate the PCM buffer and each period before building scatterlists. Clamp device-reported capture lengths to the message capacity before advancing the hardware pointer, preventing an oversized completion from accounting bytes beyond the buffer actually submitted.
Require whole-byte periods whose total matches the negotiated buffer. Check offset, length and the final message index before indexing the message array, including empty transfers and arithmetic wraparound.
Seed the ordinary capture ring once per prepare. Native STOP preserves queued requests and unread samples, so PAUSE_RELEASE must retain their ownership. Re-enqueuing the entire ring adds another period to pending message lengths and exposes unread DMA slots to the device. Return consumed space through the existing indirect ACK path.
---
sound/virtio/virtio_pcm.h +13 -0
@@ -13,6 +13,7 @@struct virtio_pcm ;struct virtio_pcm_msg ; +struct page ;/** * struct virtio_pcm_substream - VirtIO PCM substream.
@@ -29,6 +30,7 @@* substream operators, including @stopped. * @buffer_bytes: Current buffer size in bytes. * @hw_ptr: Substream hardware pointer value in bytes [0 ... buffer_bytes). +* @capture_rx_seeded: Ordinary capture ring was queued since prepare. * @xfer_enabled: Data transfer state (0 - off, 1 - on). * @xfer_xrun: Data underflow/overflow state (0 - no xrun, 1 - xrun). * @stopped: True if the substream is stopped and must be released on the device
@@ -38,6 +40,10 @@* @msgs: Allocated I/O messages. * @nmsgs: Number of allocated I/O messages. * @msg_count: Number of pending I/O messages in the virtqueue. +* @dma_pages: Pages backing DMA messages, retained until messages are freed. +* @ndma_pages: Number of retained pages. +* @owned_dma_area: Driver-owned PCM buffer backing asynchronous messages. +* @owned_dma_bytes: Size of @owned_dma_area. * @msg_empty: Notify when msg_count is zero. */ struct virtio_pcm_substream {
@@ -53,6 +59,7 @@spinlock_t lock;size_t buffer_bytes;size_t hw_ptr; +bool capture_rx_seeded;bool xfer_enabled;bool xfer_xrun;bool stopped;
@@ -62,6 +69,12 @@struct virtio_pcm_msg **msgs;unsigned int nmsgs;unsigned int msg_count; +struct page **dma_pages; +unsigned int ndma_pages; +#ifndef CONFIG_MMU +u8 *owned_dma_area; +size_t owned_dma_bytes; +#endif wait_queue_head_t msg_empty; };
sound/virtio/virtio_pcm_msg.c +239 -23
375 lines not on this page · raw message
sound/virtio/virtio_pcm_ops.c +18 -1
@@ -25,6 +25,8 @@* signal or due to a timeout. In this case, the device can still access * messages even after calling ops->hw_free(). It can also issue an interrupt, * and the interrupt handler will also try to access message structures. +* The messages retain references to the PCM buffer pages until they are +* freed, so late DMA does not target pages released by ALSA. * * Therefore, freeing of already allocated messages occurs: *
@@ -228,8 +230,19 @@struct virtio_pcm_substream *vss =snd_pcm_substream_chip (substream);struct virtio_device *vdev = vss->snd->vdev;unsigned int msg_count; +size_t period_buffer_bytes;bool stopped;int rc; + +/* Fixed descriptors require whole-byte periods covering the buffer. */ +if (check_mul_overflow ((size_t )params_periods (hw_params), + (size_t )params_period_bytes (hw_params), + &period_buffer_bytes) || + period_buffer_bytes !=params_buffer_bytes (hw_params) || + (params_period_size (hw_params) * + (u64 )snd_pcm_format_physical_width (params_format (hw_params)) * +params_channels (hw_params)) %8 ) +return -EINVAL ; scoped_guard(spinlock_irqsave, &vss->lock) { msg_count = vss->msg_count;
@@ -380,8 +393,12 @@ substream->runtime->stop_operating = true;return -EBADFD ; } -if (vss->direction ==SNDRV_PCM_STREAM_CAPTURE ) +if (vss->direction ==SNDRV_PCM_STREAM_CAPTURE && + !vss->capture_rx_seeded) { rc =virtsnd_pcm_msg_send (vss,0 , vss->buffer_bytes); +if (!rc) + vss->capture_rx_seeded = true; + }if (rc) { vss->stopped = true; substream->runtime->stop_operating = true;
[email protected]
AI reviewRe: [PATCH v12 04/12] ALSA: virtio: Keep PCM DMA buffers alive through device ownership
Sashiko has reviewed this patch and found no issues.
Quoted 20 lines
Retain references to the pages backing ALSA's vmalloc buffer until its queued I/O messages are freed. On NOMMU systems, use driver-owned memory for DMA and copy playback data before submission and capture data after completion, so ALSA buffer release cannot invalidate an active request.
Validate the PCM buffer and each period before building scatterlists. Clamp device-reported capture lengths to the message capacity before advancing the hardware pointer, preventing an oversized completion from accounting bytes beyond the buffer actually submitted.
Require whole-byte periods whose total matches the negotiated buffer. Check offset, length and the final message index before indexing the message array, including empty transfers and arithmetic wraparound.
Seed the ordinary capture ring once per prepare. Native STOP preserves queued requests and unread samples, so
PAUSE_RELEASEmust retain their ownership. Re-enqueuing the entire ring adds another period to pending message lengths and exposes unread DMA slots to the device. Return consumed space through the existing indirect ACK path.
Quoted 3 lines
Fixes f40a28679e0b ("ALSA: virtio: handling control and I/O messages for the PCM device")Assisted-by LLMSigned-off-by Joonho Lee <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
PATCH v12 5/12 ALSA: virtio: Keep control payloads alive through DMA completion
In reply to Joonho LeeControl requests can expose caller-owned payloads to the device after a synchronous send times out. Keep request and response headers and payloads in the reference-counted message so caller cleanup cannot invalidate DMA.
Keep the queue reference until device completion or post-reset cleanup, even when the caller times out or is interrupted. Consume the caller's reference on every send path, and let response readers retain an extra reference through copyout. Check payload sizes and allocation arithmetic before building the scatterlists.
A control value payload is also read by the CPU as a typed structure. DMA cacheline alignment alone does not guarantee the structure's CPU alignment. Align regions to the greater of the DMA cacheline and control-value type alignment, and reserve prefix slack from the buffer base so typed accesses remain aligned while scatterlist regions stay on cacheline boundaries.
Keep response values in a separately allocated aligned response buffer so INTEGER64 control accesses are aligned from this patch onward.
---
sound/virtio/virtio_ctl_msg.c +218 -71
@@ -3,7 +3,10 @@* virtio-snd: Virtio sound device * Copyright (C) 2021 OpenSynergy GmbH */ +#include <linux/dma-mapping.h> +#include <linux/limits.h> #include <linux/moduleparam.h> +#include <linux/overflow.h> #include <linux/virtio_config.h> #include "virtio_card.h"
@@ -11,7 +14,12 @@/** * struct virtio_snd_msg - Control message. * @sg_request: Scattergather list containing a device request (header). +* @sg_request_data: Scattergather list containing request data. * @sg_response: Scattergather list containing a device response (status). +* @sg_response_data: Scattergather list containing response data. +* @dma_buffer: Message-owned storage for all DMA-visible SG regions. +* @request_data_size: Size of the request data buffer. +* @response_data_size: Size of the response data buffer. * @list: Pending message list entry. * @notify: Request completed notification. * @ref_count: Reference count used to manage a message lifetime.
@@ -19,7 +27,12 @@*/ struct virtio_snd_msg {struct scatterlist sg_request; +struct scatterlist sg_request_data;struct scatterlist sg_response; +struct scatterlist sg_response_data; +void *dma_buffer; +size_t request_data_size; +size_t response_data_size;struct list_head list;struct completion notify;refcount_t ref_count;
@@ -47,8 +60,10 @@*/ void virtsnd_ctl_msg_unref (struct virtio_snd_msg *msg) { -if (refcount_dec_and_test (&msg->ref_count)) +if (refcount_dec_and_test (&msg->ref_count)) { +kfree (msg->dma_buffer);kfree (msg); + } }/**
@@ -71,12 +86,73 @@void *virtsnd_ctl_msg_response (struct virtio_snd_msg *msg) {return sg_virt (&msg->sg_response); +} + +/** +* virtsnd_ctl_msg_request_data() - Get the request data buffer. +* @msg: Control message. +* +* Context: Any context. +*/ +void *virtsnd_ctl_msg_request_data (struct virtio_snd_msg *msg) +{ +return msg->request_data_size ?sg_virt (&msg->sg_request_data) :NULL ; +} + +/** +* virtsnd_ctl_msg_response_data() - Get the response data buffer. +* @msg: Control message. +* +* Context: Any context. +*/ +void *virtsnd_ctl_msg_response_data (struct virtio_snd_msg *msg) +{ +return msg->response_data_size ?sg_virt (&msg->sg_response_data) :NULL ; +} + +/** +* virtsnd_ctl_msg_sg_init() - Place one DMA region on cacheline boundaries. +* @sg: Scattergather entry for the region. +* @cursor: Current location in the message-owned DMA buffer. +* @size: Region length. +* @alignment: Alignment for DMA cachelines and typed CPU accesses. +* +* Context: Any context during message allocation. +* Return: 0 on success, -EOVERFLOW if the address cannot be represented. +*/ +static int virtsnd_ctl_msg_sg_init (struct scatterlist *sg,u8 **cursor, +size_t size,size_t alignment) +{ +uintptr_t address = (uintptr_t )*cursor; +uintptr_t end; +size_t padding; + + padding = address % alignment; +if (padding && +check_add_overflow (address, (uintptr_t )(alignment - padding), + &address)) +return -EOVERFLOW ; + +if (check_add_overflow (address, (uintptr_t )size, &end)) +return -EOVERFLOW ; + + padding = end % alignment; +if (padding && +check_add_overflow (end, (uintptr_t )(alignment - padding), &end)) +return -EOVERFLOW ; + +sg_init_one (sg, (void *)address, (unsigned int )size); + *cursor = (u8 *)end; + +return 0 ; }/** * virtsnd_ctl_msg_alloc() - Allocate and initialize a control message. * @request_size: Size of request header. * @response_size: Size of response header. +* @request_data_size: Size of request data buffer. +* @response_data_size: Size of response data buffer. * @gfp: Kernel flags for memory allocation. * * The message will be automatically freed when the ref_count value is 0.
@@ -85,20 +161,85 @@* Return: Allocated message on success, NULL on failure. */ struct virtio_snd_msg *virtsnd_ctl_msg_alloc (size_t request_size, -size_t response_size,gfp_t gfp) +size_t response_size, +size_t request_data_size, +size_t response_data_size, +gfp_t gfp) {struct virtio_snd_msg *msg; - -if (!request_size || !response_size) +struct scatterlist *sgs[4 ]; +size_t sizes[4 ] = { + request_size, + response_size, + request_data_size, + response_data_size, + }; +size_t alignment; +size_t dma_buffer_size; +size_t aligned_size; +size_t padding; +u8 *data; +unsigned int i; +int cache_alignment; +int rc; + +if (!request_size || !response_size || request_size >UINT_MAX || + response_size >UINT_MAX || request_data_size >UINT_MAX || + response_data_size >UINT_MAX )return NULL ; - - msg =kzalloc (sizeof (*msg) + request_size + response_size, gfp); + cache_alignment =dma_get_cache_alignment (); +if (cache_alignment <=0 ) +return NULL ; +/* DMA coherence does not remove the CPU's type alignment requirement. */ + alignment =max_t (size_t, cache_alignment, + __alignof__(struct virtio_snd_ctl_value )); + +/* Reserve prefix alignment slack before the first DMA region. */ + dma_buffer_size = alignment -1 ; +for (i =0 ; i <ARRAY_SIZE (sizes); ++i) { +if (!sizes[i]) +continue ; + + padding = sizes[i] % alignment; + aligned_size = sizes[i]; +if (padding && +check_add_overflow (aligned_size, alignment - padding, + &aligned_size)) +return NULL ; + +if (check_add_overflow (dma_buffer_size, aligned_size, + &dma_buffer_size)) +return NULL ; + } + + msg =kzalloc (sizeof (*msg), gfp);if (!msg)return NULL ; -sg_init_one (&msg->sg_request, (u8 *)msg +sizeof (*msg), request_size); -sg_init_one (&msg->sg_response, (u8 *)msg +sizeof (*msg) + request_size, - response_size); + msg->dma_buffer =kzalloc (dma_buffer_size, gfp); +if (!msg->dma_buffer) { +kfree (msg); +return NULL ; + } + data = msg->dma_buffer; + sgs[0 ] = &msg->sg_request; + sgs[1 ] = &msg->sg_response; + sgs[2 ] = &msg->sg_request_data; + sgs[3 ] = &msg->sg_response_data; +for (i =0 ; i <ARRAY_SIZE (sizes); ++i) { +if (!sizes[i]) +continue ; + + rc =virtsnd_ctl_msg_sg_init (sgs[i], &data, sizes[i], alignment); +if (rc) { +kfree (msg->dma_buffer); +kfree (msg); +return NULL ; + } + } + + msg->request_data_size = request_data_size; + msg->response_data_size = response_data_size;INIT_LIST_HEAD (&msg->list);init_completion (&msg->notify);
@@ -112,17 +253,15 @@* virtsnd_ctl_msg_send() - Send a control message. * @snd: VirtIO sound device. * @msg: Control message. -* @out_sgs: Additional sg-list to attach to the request header (may be NULL). -* @in_sgs: Additional sg-list to attach to the response header (may be NULL). * @nowait: Flag indicating whether to wait for completion. * * Context: Any context. Takes and releases the control queue spinlock. * May sleep if @nowait is false. +* Consumes the caller's reference on every return path. * Return: 0 on success, -errno on failure. */ int virtsnd_ctl_msg_send (struct virtio_snd *snd,struct virtio_snd_msg *msg, -struct scatterlist *out_sgs, -struct scatterlist *in_sgs,bool nowait) +bool nowait) {struct virtio_device *vdev = snd->vdev;struct virtio_snd_queue *queue =virtsnd_control_queue (snd);
@@ -133,6 +272,7 @@unsigned int nins =0 ;struct scatterlist *psgs[4 ];bool notify = false; +unsigned long flags;int rc;virtsnd_ctl_msg_ref (msg);
@@ -142,27 +282,27 @@ response->code =cpu_to_le32 (VIRTIO_SND_S_IO_ERR ); psgs[nouts++] = &msg->sg_request; -if (out_sgs) - psgs[nouts++] = out_sgs; +if (msg->request_data_size) + psgs[nouts++] = &msg->sg_request_data; psgs[nouts + nins++] = &msg->sg_response; -if (in_sgs) - psgs[nouts + nins++] = in_sgs; - - scoped_guard(spinlock_irqsave, &queue->lock) { -if (snd->ctl_msgs_blocked) - rc = -ENODEV ; -else - rc =virtqueue_add_sgs (queue->vqueue, psgs, nouts, nins, - msg,GFP_ATOMIC ); -if (!rc) { - notify =virtqueue_kick_prepare (queue->vqueue); - -list_add_tail (&msg->list, &snd->ctl_msgs); -if (notify) -virtqueue_notify (queue->vqueue); - } - } +if (msg->response_data_size) + psgs[nouts + nins++] = &msg->sg_response_data; + +spin_lock_irqsave (&queue->lock, flags); +if (snd->ctl_msgs_blocked) + rc = -ENODEV ; +else + rc =virtqueue_add_sgs (queue->vqueue, psgs, nouts, nins, msg, +GFP_ATOMIC ); +if (!rc) { + notify =virtqueue_kick_prepare (queue->vqueue); + +list_add_tail (&msg->list, &snd->ctl_msgs); +if (notify) +virtqueue_notify (queue->vqueue); + } +spin_unlock_irqrestore (&queue->lock, flags);if (rc) { dev_err(&vdev->dev, "failed to send control message (0x%08x)\n",
@@ -173,46 +313,36 @@* called, it is necessary to decrement the reference count. */ virtsnd_ctl_msg_unref (msg); - - goto on_exit; - } - -if (nowait) - goto on_exit; - - rc =wait_for_completion_interruptible_timeout (&msg->notify, js); -if (rc <=0 ) { + }else if (!nowait) { + rc =wait_for_completion_interruptible_timeout (&msg->notify, js);if (!rc) {dev_err (&vdev->dev,"control message (0x%08x) timeout\n" ,le32_to_cpu (request->code)); rc = -ETIMEDOUT ; + }else if (rc >0 ) { +if (READ_ONCE (msg->cancelled)) { + rc = -ENODEV ; + }else { +switch (le32_to_cpu (response->code)) { +case VIRTIO_SND_S_OK : + rc =0 ; +break ; +case VIRTIO_SND_S_NOT_SUPP : + rc = -EOPNOTSUPP ; +break ; +case VIRTIO_SND_S_IO_ERR : + rc = -EIO ; +break ; +default : + rc = -EINVAL ; +break ; + } + } } - - goto on_exit; - } - -if (READ_ONCE (msg->cancelled)) { - rc = -ENODEV ; - goto on_exit; - } - -switch (le32_to_cpu (response->code)) { -case VIRTIO_SND_S_OK : - rc =0 ; -break ; -case VIRTIO_SND_S_NOT_SUPP : - rc = -EOPNOTSUPP ; -break ; -case VIRTIO_SND_S_IO_ERR : - rc = -EIO ; -break ; -default : - rc = -EINVAL ; -break ; - } - -on_exit: + } + +/* Drop the reference consumed by this send attempt. */ virtsnd_ctl_msg_unref (msg);return rc;
@@ -308,10 +438,23 @@ {struct virtio_snd_msg *msg;struct virtio_snd_query_info *query; -struct scatterlist sg; +size_t info_size; +int rc; + +if (count <0 ) +return -EINVAL ; + +if (size >UINT_MAX || +check_mul_overflow ((size_t )count, size, &info_size) || + info_size >UINT_MAX ) +return -EOVERFLOW ; + +if (info_size && !info) +return -EINVAL ; msg =virtsnd_ctl_msg_alloc (sizeof (*query), -sizeof (struct virtio_snd_hdr ),GFP_KERNEL ); +sizeof (struct virtio_snd_hdr ),0 , info_size, +GFP_KERNEL );if (!msg)return -ENOMEM ;
@@ -321,9 +464,13 @@ query->count =cpu_to_le32 (count); query->size =cpu_to_le32 (size); -sg_init_one (&sg, info, count * size); - -return virtsnd_ctl_msg_send (snd, msg,NULL , &sg, false); +virtsnd_ctl_msg_ref (msg); + rc =virtsnd_ctl_msg_send (snd, msg, false); +if (!rc && info_size) +memcpy (info,virtsnd_ctl_msg_response_data (msg), info_size); +virtsnd_ctl_msg_unref (msg); + +return rc; }/**
sound/virtio/virtio_ctl_msg.h +16 -8
@@ -21,20 +21,28 @@void *virtsnd_ctl_msg_response (struct virtio_snd_msg *msg);struct virtio_snd_msg *virtsnd_ctl_msg_alloc (size_t request_size, -size_t response_size,gfp_t gfp); +size_t response_size, +size_t request_data_size, +size_t response_data_size, +gfp_t gfp); + +void *virtsnd_ctl_msg_request_data (struct virtio_snd_msg *msg); + +void *virtsnd_ctl_msg_response_data (struct virtio_snd_msg *msg);int virtsnd_ctl_msg_send (struct virtio_snd *snd,struct virtio_snd_msg *msg, -struct scatterlist *out_sgs, -struct scatterlist *in_sgs,bool nowait); +bool nowait);/** * virtsnd_ctl_msg_send_sync() - Simplified sending of synchronous message. * @snd: VirtIO sound device. * @msg: Control message. * -* After returning from this function, the message will be deleted. If message -* content is still needed, the caller must additionally to -* virtsnd_ctl_msg_ref/unref() it. +* This function consumes the caller's message reference on return. A message +* accepted by the control queue keeps its queue reference until completion or +* post-reset cleanup, including when this function returns on timeout or +* interruption. Callers that read the response after success must retain an +* additional reference through that access. * * The msg_timeout_ms module parameter defines the message completion timeout. * If the message is not completed within this time, the function will return an
@@ -49,7 +57,7 @@static inline int virtsnd_ctl_msg_send_sync (struct virtio_snd *snd,struct virtio_snd_msg *msg) { -return virtsnd_ctl_msg_send (snd, msg,NULL ,NULL , false); +return virtsnd_ctl_msg_send (snd, msg, false); }/**
@@ -63,7 +71,7 @@static inline int virtsnd_ctl_msg_send_async (struct virtio_snd *snd,struct virtio_snd_msg *msg) { -return virtsnd_ctl_msg_send (snd, msg,NULL ,NULL , true); +return virtsnd_ctl_msg_send (snd, msg, true); }void virtsnd_ctl_msg_cancel_all (struct virtio_snd *snd);
sound/virtio/virtio_kctl.c +65 -56
192 lines not on this page · raw message
sound/virtio/virtio_pcm_msg.c +1 -1
@@ -684,7 +684,7 @@break ; } - msg =virtsnd_ctl_msg_alloc (request_size, response_size, gfp); + msg =virtsnd_ctl_msg_alloc (request_size, response_size,0 ,0 , gfp);if (msg) {struct virtio_snd_pcm_hdr *hdr =virtsnd_ctl_msg_request (msg);
[email protected]
AI reviewRe: [PATCH v12 05/12] ALSA: virtio: Keep control payloads alive through DMA completion
Sashiko has reviewed this patch and found no issues.
Quoted 16 lines
Control requests can expose caller-owned payloads to the device after a synchronous send times out. Keep request and response headers and payloads in the reference-counted message so caller cleanup cannot invalidate DMA.
Keep the queue reference until device completion or post-reset cleanup, even when the caller times out or is interrupted. Consume the caller's reference on every send path, and let response readers retain an extra reference through copyout. Check payload sizes and allocation arithmetic before building the scatterlists.
A control value payload is also read by the CPU as a typed structure. DMA cacheline alignment alone does not guarantee the structure's CPU alignment. Align regions to the greater of the DMA cacheline and control-value type alignment, and reserve prefix slack from the buffer base so typed accesses remain aligned while scatterlist regions stay on cacheline boundaries.
Quoted 6 lines
Keep response values in a separately allocated aligned response buffer so INTEGER64 control accesses are aligned from this patch onward.
Fixes 9d45e514da88 ("ALSA: virtio: handling control messages")Assisted-by LLMSigned-off-by Joonho Lee <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
PATCH v12 6/12 ALSA: virtio: wait through signals for PCM teardown
In reply to Joonho LeeA signal can end the interruptible wait while a STOP or RELEASE request is still pending. A later teardown may then submit another RELEASE before the first request completes.
Keep both waits non-interruptible and use the existing message timeout. Other control requests remain interruptible. Device reset still cancels the pending request and wakes the waiter.
---
sound/virtio/virtio_ctl_msg.c +14 -1
@@ -314,7 +314,20 @@*/ virtsnd_ctl_msg_unref (msg); }else if (!nowait) { - rc =wait_for_completion_interruptible_timeout (&msg->notify, js); +/* +* Teardown must observe completion even with a pending signal. +* Otherwise a subsequent open can retry RELEASE while the device +* is still processing the previous teardown request. +*/ +switch (le32_to_cpu (request->code)) { +case VIRTIO_SND_R_PCM_STOP : +case VIRTIO_SND_R_PCM_RELEASE : + rc =wait_for_completion_timeout (&msg->notify, js); +break ; +default : + rc =wait_for_completion_interruptible_timeout (&msg->notify, js); +break ; + }if (!rc) { dev_err(&vdev->dev, "control message (0x%08x) timeout\n",
sound/virtio/virtio_ctl_msg.h +3 -0
@@ -47,6 +47,9 @@* The msg_timeout_ms module parameter defines the message completion timeout. * If the message is not completed within this time, the function will return an * error. +* PCM STOP and RELEASE wait through pending signals within this timeout. +* Other requests remain interruptible. Device reset cancels and wakes either +* kind of waiter. * * Context: Any context that permits to sleep. * Return: 0 on success, -errno on failure.
[email protected]
AI reviewRe: [PATCH v12 06/12] ALSA: virtio: wait through signals for PCM teardown
Sashiko has reviewed this patch and found no issues.
Quoted 10 lines
A signal can end the interruptible wait while a STOP or RELEASE request is still pending. A later teardown may then submit another RELEASE before the first request completes.
Keep both waits non-interruptible and use the existing message timeout. Other control requests remain interruptible. Device reset still cancels the pending request and wakes the waiter.
Assisted-by LLMSigned-off-by Joonho Lee <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6
PATCH v12 7/12 ALSA: pcm: mark stop-threshold accesses for capture policy sampling
In reply to Joonho LeeThe staged virtio-snd capture path needs to sample stop_threshold from completion context to distinguish free-running capture from bounded capture. Software parameters can update this field while capture runs.
Mark the runtime stop-threshold assignments with WRITE_ONCE and the proc status read with READ_ONCE. This pairs the assignments with the driver's READ_ONCE policy sampling in patch 9.
These annotations do not provide a transaction for the entire sw_params update. The driver serializes its cached policy and accounting with its own substream lock.
---
sound/core/oss/pcm_oss.c +1 -1
@@ -2958,7 +2958,7 @@ runtime->oss.mmap_bytes);#endif /* In mmap mode we never stop */ - runtime->stop_threshold = runtime->boundary; +WRITE_ONCE (runtime->stop_threshold, runtime->boundary);return 0 ; }
sound/core/pcm.c +2 -1
@@ -422,7 +422,8 @@snd_iprintf (buffer,"period_step: %u\n" , runtime->period_step);snd_iprintf (buffer,"avail_min: %lu\n" , runtime->control->avail_min);snd_iprintf (buffer,"start_threshold: %lu\n" , runtime->start_threshold); -snd_iprintf (buffer,"stop_threshold: %lu\n" , runtime->stop_threshold); +snd_iprintf (buffer,"stop_threshold: %lu\n" , +READ_ONCE (runtime->stop_threshold));snd_iprintf (buffer,"silence_threshold: %lu\n" , runtime->silence_threshold);snd_iprintf (buffer,"silence_size: %lu\n" , runtime->silence_size);snd_iprintf (buffer,"boundary: %lu\n" , runtime->boundary);
sound/core/pcm_native.c +3 -2
@@ -871,7 +871,7 @@ runtime->period_step =1 ; runtime->control->avail_min = runtime->period_size; runtime->start_threshold =1 ; - runtime->stop_threshold = runtime->buffer_size; +WRITE_ONCE (runtime->stop_threshold, runtime->buffer_size); runtime->silence_threshold =0 ; runtime->silence_size =0 ; runtime->boundary = runtime->buffer_size;
@@ -1062,7 +1062,8 @@ runtime->period_step = params->period_step; runtime->control->avail_min = params->avail_min; runtime->start_threshold = params->start_threshold; - runtime->stop_threshold = params->stop_threshold; +/* Drivers may sample the stop policy from completion context. */ +WRITE_ONCE (runtime->stop_threshold, params->stop_threshold); runtime->silence_threshold = params->silence_threshold; runtime->silence_size = params->silence_size; params->boundary = runtime->boundary;
[email protected]
AI reviewRe: [PATCH v12 07/12] ALSA: pcm: mark stop-threshold accesses for capture policy sampling
Sashiko has reviewed this patch and found no issues.
Quoted 8 lines
The staged virtio-snd capture path needs to sample
stop_thresholdfrom completion context to distinguish free-running capture from bounded capture. Software parameters can update this field while capture runs.Mark the runtime stop-threshold assignments with
WRITE_ONCEand the proc status read withREAD_ONCE. This pairs the assignments with the driver'sREAD_ONCEpolicy sampling in patch 9.
Quoted 6 lines
These annotations do not provide a transaction for the entire
sw_paramsupdate. The driver serializes its cached policy and accounting with its own substream lock.Assisted-by LLMSigned-off-by Joonho Lee <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=7
PATCH v12 8/12 ALSA: pcm: report partial progress under the stream lock
In reply to Joonho LeeStaged capture can make readable data available before a complete period has elapsed. Skipping notification leaves a blocked reader asleep, while using the period-interrupt path for this event can infer a false ring wrap when the notification is delayed.
Add snd_pcm_progress_under_stream_lock() to update the hardware pointer through the non-interrupt path and notify readers and fasync listeners. It runs under the caller's PCM stream lock and does not tick the PCM timer. The driver must release its pointer and trigger locks before calling it. Existing period notification callers keep their current behavior.
Atomic and nonatomic synthetic PCM tests reproduced the missing wakeup and false-wrap alternatives. The new helper delivered 64 final frames and reported four available frames after delayed partial progress without XRUN.
---
include/sound/pcm.h +1 -0
@@ -1182,6 +1182,7 @@int snd_pcm_lib_ioctl (struct snd_pcm_substream *substream,unsigned int cmd,void *arg);void snd_pcm_period_elapsed_under_stream_lock (struct snd_pcm_substream *substream); +void snd_pcm_progress_under_stream_lock (struct snd_pcm_substream *substream);void snd_pcm_period_elapsed (struct snd_pcm_substream *substream); snd_pcm_sframes_t __snd_pcm_lib_xfer(struct snd_pcm_substream *substream, void *buf, bool interleaved,
sound/core/pcm_lib.c +19 -0
@@ -1919,6 +1919,25 @@EXPORT_SYMBOL (snd_pcm_period_elapsed_under_stream_lock);/** +* snd_pcm_progress_under_stream_lock - Report progress without a period IRQ +* @substream: PCM substream +* +* Context: PCM stream lock held, with no driver pointer or trigger locks held. +* Updates the pointer and wakes readers for partial-period transfers. Unlike +* a period notification, this does not imply an elapsed period or tick the PCM +* timer. The same pointer, trigger and timestamp callbacks may be invoked. +*/ +void snd_pcm_progress_under_stream_lock (struct snd_pcm_substream *substream) +{ +if (PCM_RUNTIME_CHECK (substream) || !snd_pcm_running (substream)) +return ; +snd_pcm_update_hw_ptr (substream); +snd_kill_fasync (substream->runtime->fasync,SIGIO ,POLL_IN ); +} +EXPORT_SYMBOL_GPL (snd_pcm_progress_under_stream_lock); + + +/** * snd_pcm_period_elapsed() - update the status of runtime for the next period by acquiring lock of * PCM substream. * @substream: the instance of PCM substream.
[email protected]
AI reviewRe: [PATCH v12 08/12] ALSA: pcm: report partial progress under the stream lock
Sashiko has reviewed this patch and found no issues.
Quoted 11 lines
Staged capture can make readable data available before a complete period has elapsed. Skipping notification leaves a blocked reader asleep, while using the period-interrupt path for this event can infer a false ring wrap when the notification is delayed.
Add
snd_pcm_progress_under_stream_lock()to update the hardware pointer through the non-interrupt path and notify readers and fasync listeners. It runs under the caller's PCM stream lock and does not tick the PCM timer. The driver must release its pointer and trigger locks before calling it. Existing period notification callers keep their current behavior.
Quoted 6 lines
Atomic and nonatomic synthetic PCM tests reproduced the missing wakeup and false-wrap alternatives. The new helper delivered 64 final frames and reported four available frames after delayed partial progress without XRUN.
Assisted-by LLMSigned-off-by Joonho Lee <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=8
PATCH v12 9/12 ALSA: pcm: add an optional reset operation under the stream lock
In reply to Joonho LeeA driver may need to synchronize private capture accounting with the common RESET pointer observation and the core's position rebase.
Add an optional reset operation called under the member's stream lock. Expose snd_pcm_lib_reset() so the callback can retain common pointer and time handling. On zero return the core completes that member's rebase before unlocking it. Drivers without the callback retain the ioctl path. The operation is also used after a successful prepare.
Zero permits the position rebase; it does not promise XRUN recovery. A negative return skips the core rebase, so a callback returning an error must leave coherent pointer state even after partial work.
Linked RESET and prepare stop at the first error without rollback. Earlier callback members may already have completed. Legacy members keep the existing post_action policy. Applications must recover the group after partial failure before relying on shared positions.
This adds an internal kernel operation and no userspace ioctl or layout. Out-of-tree modules using snd_pcm_ops need to be rebuilt.
Complete appl_ptr rebasing once in the callback path. A later linked member can sleep in prepare while the earlier member accepts SYNC_PTR; a subsequent unlocked post_prepare assignment would overwrite that acknowledgment. Keep explicit RESET playback silence processing and leave prepare-time filling to the normal START path, preserving samples written and rewound after prepare.
Atomic and nonatomic synthetic-driver tests exercised both callback and legacy members, mixed linked groups and later-member failures. The callback retained an acknowledged appl_ptr of 64, and finite-silence playback kept the written prefix while clearing the rewound tail.
---
include/sound/pcm.h +21 -0
@@ -77,6 +77,26 @@ unsigned long offset);int (*mmap)(struct snd_pcm_substream *substream,struct vm_area_struct *vma);int (*ack)(struct snd_pcm_substream *substream); +/* +* Optional RESET operation, also used after a successful prepare. +* Called with this substream's PCM lock held; atomic streams must not +* sleep. Do not reacquire the PCM lock through snd_pcm_lib_ioctl(). +* snd_pcm_lib_reset() provides the common pointer update under this +* lock. The core completes the position and appl_ptr rebase before +* unlocking a successful member. +* +* Return zero to let the core complete the position rebase. As with +* the legacy RESET ioctl, zero does not guarantee recovery from XRUN; +* callers must still handle the stream state and subsequent I/O errors. +* On a negative return the core does not finish the rebase, so the +* callback must leave coherent pointer state even after partial work. +* +* Linked RESET/prepare +* stops at the first error without rollback. Earlier callback members +* retain their completed reset; legacy members retain the existing +* post_action policy. An error does not guarantee unchanged state. +*/ +int (*reset)(struct snd_pcm_substream *substream); };/*
@@ -1179,6 +1199,7 @@ { substream->runtime->std_sync_id = true; } +int snd_pcm_lib_reset (struct snd_pcm_substream *substream);int snd_pcm_lib_ioctl (struct snd_pcm_substream *substream,unsigned int cmd,void *arg);void snd_pcm_period_elapsed_under_stream_lock (struct snd_pcm_substream *substream);
sound/core/pcm_lib.c +24 -5
@@ -1760,20 +1760,39 @@ }EXPORT_SYMBOL (snd_pcm_hw_params_bits); -static int snd_pcm_lib_ioctl_reset (struct snd_pcm_substream *substream, -void *arg) +/** +* snd_pcm_lib_reset - Reset the pointer while holding the PCM stream lock +* @substream: PCM substream +* +* Context: PCM stream lock held. The caller must not hold driver locks +* acquired by the pointer or XRUN callbacks. +* +* Update a running stream through the ordinary pointer path. Other states +* start at zero. Pointer errors keep the existing RESET return semantics; +* a zero return does not imply recovery from XRUN. +* This helper does not update appl_ptr or acquire the stream lock. +* +* Return: zero. +*/ +int snd_pcm_lib_reset (struct snd_pcm_substream *substream) {struct snd_pcm_runtime *runtime = substream->runtime; -guard (pcm_stream_lock_irqsave)(substream); -if (snd_pcm_running (substream) && -snd_pcm_update_hw_ptr (substream) >=0 ) +if (snd_pcm_running (substream) &&snd_pcm_update_hw_ptr (substream) >=0 ) runtime->status->hw_ptr %= runtime->buffer_size;else { runtime->status->hw_ptr =0 ; runtime->hw_ptr_wrap =0 ; }return 0 ; +} +EXPORT_SYMBOL (snd_pcm_lib_reset); + +static int snd_pcm_lib_ioctl_reset (struct snd_pcm_substream *substream, +void *arg) +{ +guard (pcm_stream_lock_irqsave)(substream); +return snd_pcm_lib_reset (substream); } static int snd_pcm_lib_ioctl_channel_info(struct snd_pcm_substream *substream,
sound/core/pcm_native.c +40 -5
75 lines not on this page · raw message
[email protected]
AI reviewRe: [PATCH v12 09/12] ALSA: pcm: add an optional reset operation under the stream lock
Sashiko has reviewed this patch and found no issues.
Quoted 13 lines
A driver may need to synchronize private capture accounting with the common RESET pointer observation and the core's position rebase.
Add an optional reset operation called under the member's stream lock. Expose
snd_pcm_lib_reset()so the callback can retain common pointer and time handling. On zero return the core completes that member's rebase before unlocking it. Drivers without the callback retain the ioctl path. The operation is also used after a successful prepare.Zero permits the position rebase; it does not promise XRUN recovery. A negative return skips the core rebase, so a callback returning an error must leave coherent pointer state even after partial work.
Quoted 8 lines
Linked RESET and prepare stop at the first error without rollback. Earlier callback members may already have completed. Legacy members keep [ ... ]
callback retained an acknowledgedappl_ptrof 64, and finite-silence playback kept the written prefix while clearing the rewound tail.Assisted-by LLMSigned-off-by Joonho Lee <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=9
PATCH v12 10/12 ALSA: virtio: add staged capture and serialize PCM lifecycle accounting
In reply to Joonho LeeStaged capture needs request-owned DMA storage and separate produced, observed and consumed positions when shared clients use a boundary stop threshold. Synchronize policy, RX completion and acknowledgment under the queue and substream locks, with lifecycle_lock covering control work.
The v11 ACK path tried buffer_mutex while holding the PCM stream lock. Core RESET, parameter refinement and linked prepare can already hold that mutex, so normal ACK returned -EBADFD. Serialize ACK and prepare accounting through the PCM lock instead. Set a preparing gate before dropping that lock for PREPARE; clear it in the RESET callback while the core keeps the same lock through the public appl_ptr rebase. A later linked member can sleep in prepare without exposing half-rebased private accounting.
Use the preceding optional RESET operation for playback and both capture modes. Retain common pointer/time handling and rebase private appl_ptr with the public pointer. Preserve queued TX ownership on playback RESET. Reset staged accounting and ordinary capture sw_ready after a successful prepare, including repeated RESET from PREPARED.
Native pause can return RX buffers while transfers are disabled. Accept those completions for a live prepared capture epoch, and refill only when transfers are enabled. Keep the period notification floor across resume; report recovery progress without inventing PCM timer ticks. Latch XRUN on device events and failed STOP, reject ACK from invalid or stopped states, and keep successful prepared accounting until PREPARE succeeds. Compatibility pause retains its released-epoch handling.
Validate ordinary RX status and payload before advancing counters. Empty STOP completions carry no frames. Preserve full-ring XRUN protection:
a delayed observation can mean real DMA overwrite. Recovering that case by exposing the modulo pointer returned an old ring of samples in tests.
Use gcd(frame_bits, 8) for byte alignment so packed 4-bit frames retain byte-aligned queue boundaries. Keep the queue-to-substream lock order. The compatibility options remain disabled by default.
ARM64 QEMU tests reproduced ACK contention, failed prepare and STOP, paused RX, status-only RX and reset recovery. The corrected source passed 56 KASAN/KCSAN transition checks and four linked prepare/ACK checks. RW and MMAP capture, RESET, pause/resume and reopen produced 14,208,000 oracle-matched samples. Physical VZ capture remains untested for this revision. Sample tests cover mono S16 at 48 kHz.
---
sound/virtio/virtio_card.c +32 -1
@@ -350,6 +350,22 @@struct virtio_device *vdev = snd->vdev;unsigned int i; +for (i =0 ; snd->substreams && i < snd->nsubstreams; ++i) { +struct virtio_pcm_substream *vss = &snd->substreams[i]; +struct virtio_snd_queue *queue =virtsnd_pcm_queue (vss); + +guard (spinlock_irqsave)(&queue->lock); +guard (spinlock)(&vss->lock); + vss->reset_epoch++; + vss->resetting = true; + vss->prepared = false; + vss->device_running = false; + vss->release_required = false; + vss->control_uncertain = false; + vss->capture_reset_observing = false; + vss->xfer_enabled = false; + vss->suspended = true; + }virtio_reset_device (vdev);/* Deleting a virtqueue does not unmap its outstanding descriptors. */
@@ -367,8 +383,16 @@ queue->vqueue =NULL ;spin_unlock_irqrestore (&queue->lock, flags); } - vdev->config->del_vqs (vdev); +for (i =0 ; snd->substreams && i < snd->nsubstreams; ++i) { +struct virtio_pcm_substream *vss = &snd->substreams[i]; + +cancel_work_sync (&vss->elapsed_period); +guard (spinlock_irqsave)(&vss->lock); + vss->stopped = false; + vss->xfer_xrun = false; + vss->pause_restart_state =VIRTSND_PCM_PAUSE_RESTART_NONE ; + } }/**
@@ -441,6 +465,7 @@ {struct virtio_snd *snd = vdev->priv;int rc; +unsigned int i; rc =virtsnd_find_vqs (snd);if (rc)
@@ -449,6 +474,12 @@virtio_device_ready (vdev);virtsnd_ctl_msg_enable (snd); +for (i =0 ; i < snd->nsubstreams; ++i) { +struct virtio_pcm_substream *vss = &snd->substreams[i]; + +guard (spinlock_irqsave)(&vss->lock); + vss->resetting = false; + }virtsnd_enable_event_vq (snd);return 0 ;
sound/virtio/virtio_ctl_msg.c +53 -5
86 lines not on this page · raw message
sound/virtio/virtio_ctl_msg.h +8 -1
@@ -11,6 +11,13 @@struct virtio_snd ;struct virtio_snd_msg ; +struct virtio_pcm_substream ; + +void virtsnd_ctl_msg_bind_pcm (struct virtio_snd_msg *msg, +struct virtio_pcm_substream *vss,u64 epoch); +u64 virtsnd_ctl_msg_pcm_epoch (struct virtio_snd_msg *msg); + +bool virtsnd_ctl_msg_uncertain (struct virtio_snd_msg *msg,int rc);void virtsnd_ctl_msg_ref (struct virtio_snd_msg *msg);
@@ -47,7 +54,7 @@* The msg_timeout_ms module parameter defines the message completion timeout. * If the message is not completed within this time, the function will return an * error. -* PCM STOP and RELEASE wait through pending signals within this timeout. +* PCM state-changing requests wait through pending signals within this timeout. * Other requests remain interruptible. Device reset cancels and wakes either * kind of waiter. *
sound/virtio/virtio_pcm.c +122 -4
153 lines not on this page · raw message
sound/virtio/virtio_pcm.h +139 -2
207 lines not on this page · raw message
sound/virtio/virtio_pcm_msg.c +426 -60
633 lines not on this page · raw message
sound/virtio/virtio_pcm_ops.c +1425 -98
1,810 lines not on this page · raw message
[email protected]
AI reviewRe: [PATCH v12 10/12] ALSA: virtio: add staged capture and serialize PCM lifecycle accounting
Thank you for your contribution! Sashiko AI review found 10 potential issue(s) to consider: - [High] ALSA: virtio: broken indirect ring state in virtsnd_pcm_playback_reset() - [High] ALSA: virtio…
Thank you for your contribution! Sashiko AI review found 10 potential issue(s) to consider:
- [High] ALSA: virtio: broken indirect ring state in virtsnd_pcm_playback_reset()
- [High] ALSA: virtio: post-stop capture RX not retired in virtsnd_pcm_msg_complete()
- [Medium] ALSA: virtio: missing prepared and preparing checks in virtsnd_pcm_cp_pointer()
- [Medium] ALSA: virtio: vss->preparing gate leaked on prepare failure and reset races
- [Medium] ALSA: virtio: stale vss->suspended flag across open and virtsnd_pcm_hw_params()
- [Medium] ALSA: virtio: sub-byte frame truncation in virtsnd_pcm_capture_staged_ack()
- [Medium] ALSA: virtio: missing state and xrun checks in virtsnd_pcm_pb_ack() and pointer
- [Medium] ALSA: virtio: stale vss->suspended across virtsnd_pcm_open() and hw_params()
- [Medium] ALSA: virtio: virtsnd_pcm_pause_restart_start() returns -EBADFD on xfer_xrun
- [Medium] ALSA: virtio: incomplete xrun and pointer rebase in virtsnd_pcm_reset() --
commit aed4d30e1eeffd3a8fd687d7393b3bfcaedf5c71
Author: Joonho Lee <[email protected]>
ALSA: virtio: add staged capture and serialize PCM lifecycle accounting
This commit adds opt-in staged PCM capture using request-owned DMA buffers and serializes PCM lifecycle, reset, and acknowledgment accounting under the queue and substream locks.
Quoted 4 lines
sound/virtio/virtio_pcm_msg.c +0
-0
[ ... ]
Quoted 20 lines
sound/virtio/virtio_pcm_msg.c +9
-5@@ -540,19 +880,52 @@ static void virtsnd_pcm_msg_complete(struct virtio_pcm_msg *msg, size_t written_bytes) {struct virtio_pcm_substream *vss = msg->substream; +size_t completed_bytes; +u32 latency_bytes; + +if (vss->direction ==SNDRV_PCM_STREAM_CAPTURE && + vss->capture_staging) { +virtsnd_pcm_capture_complete (msg, written_bytes); +return ; + } -/* -* hw_ptr always indicates the buffer position of the first I/O message -* in the virtqueue. Therefore, on each completion of an I/O message, -* the hw_ptr value is unconditionally advanced. -*/ +/* Only completed TX requests and valid RX audio advance the pointer. */ guard (spinlock)(&vss->lock);
sound/virtio/virtio_pcm_msg.c static void virtsnd_pcm_msg_complete(struct virtio_pcm_msg *msg, · line 903
Quoted 10 lines
sound/virtio/virtio_pcm_msg.c +10
-0+/* Empty STOP returns retire ownership without inventing captured data. */ +if (vss->direction ==SNDRV_PCM_STREAM_CAPTURE && + (!vss->prepared || + (vss->stopped && written_bytes <=sizeof (*msg->status)))) { + msg->length =0 ; + vss->msg_count--; +if (!vss->msg_count) +wake_up_all (&vss->msg_empty); +return ; + }
[Severity: High]
As reported by Sashiko on v11 [1], what happens in virtsnd_pcm_msg_complete() when an in-flight ordinary capture RX buffer completes with written_bytes > sizeof(*msg->status) after vss->stopped has been set?
On an ordinary capture substream, SNDRV_PCM_TRIGGER_STOP (called during capture drain in snd_pcm_do_drain_init(), snd_pcm_drop(), or virtsnd_pcm_sync_stop_locked()) sets vss->stopped = true while vss->prepared remains true until VIRTIO_SND_R_PCM_RELEASE completes. Unlike staged capture in virtsnd_pcm_capture_complete(), which ignores all completions when vss->stopped is true, virtsnd_pcm_msg_complete() only retires stopped capture completions early if written_bytes <= sizeof(*msg->status).
During SNDRV_PCM_STATE_DRAINING, ALSA stops calling ops->pointer(), so vss->capture_pointer_seen_total stops advancing while the application drains already-captured frames via virtsnd_pcm_cp_ack_locked(). If pending RX buffers complete with audio payloads after STOP, they advance vss->capture_copied_total untilvss->capture_copied_total - vss->capture_pointer_seen_total >= vss->buffer_bytes (or fail virtsnd_pcm_capture_status() if completed with a non-OK status), latching vss->xfer_xrun = true and causing virtsnd_pcm_cp_ack_locked() to abort capture drain with -EPIPE.
In addition, during virtsnd_pcm_sync_stop_locked(), cancel_work_sync() runs before VIRTIO_SND_R_PCM_STOP and VIRTIO_SND_R_PCM_RELEASE are sent:
virtsnd_pcm_sync_stop_locked()
cancel_work_sync(&vss->elapsed_period);
rc = virtsnd_pcm_stop_device(vss, epoch);
...
rc = virtsnd_pcm_send_sync(vss, msg); /* VIRTIO_SND_R_PCM_RELEASE */
scoped_guard(spinlock_irqsave, &vss->lock) {
...
vss->prepared = false;
}If a non-empty RX completion arrives while STOP or RELEASE is in flight and vss->xfer_xrun is set, virtsnd_pcm_msg_complete() will call virtsnd_pcm_schedule_period_elapsed(vss) after cancel_work_sync() has already returned, and will also skip the else-if wake_up_all(&vss->msg_empty) when vss->msg_count reaches zero. Should virtsnd_pcm_msg_complete() retire all capture completions whenever !vss->prepared || vss->stopped?
Quoted 4 lines
sound/virtio/virtio_pcm_ops.c +0
-0
[ ... ]
Quoted 1 line
sound/virtio/virtio_pcm_ops.c +0
-0@@ -119,23 +381,42 @@ static int virtsnd_pcm_open(struct snd_pcm_substream *substream)
[ ... ]
sound/virtio/virtio_pcm_ops.c line 131
Quoted 6 lines
sound/virtio/virtio_pcm_ops.c +0
-1snd_pcm_hw_constraint_integer (substream->runtime,SNDRV_PCM_HW_PARAM_PERIODS );scoped_guard (spinlock_irqsave, &vss->lock) vss->stopped |= !!vss->msg_count; - vss->suspended = false;
[Severity: Medium]
If vss->suspended = false is removed from virtsnd_pcm_open() and is not cleared in virtsnd_pcm_hw_params() either, can vss->suspended remain stale until virtsnd_pcm_prepare_locked()?
When virtsnd_reset_vqs() runs during device reset or freeze/restore, it sets vss->suspended = true on all substreams (including closed ones), and closing a substream after SNDRV_PCM_TRIGGER_SUSPEND also leaves vss->suspended = true. When the substream is subsequently opened via virtsnd_pcm_open() and configured via virtsnd_pcm_hw_params(), virtsnd_pcm_hw_params() sends VIRTIO_SND_R_PCM_SET_PARAMS to the device, but vss->suspended remains true.
When virtsnd_pcm_prepare_locked() then runs, it sees suspended == true, which skips the !virtsnd_pcm_msg_pending_num(vss) queue sanity check and sends a redundant VIRTIO_SND_R_PCM_SET_PARAMS request to the device. Should vss->suspended be cleared in virtsnd_pcm_open() or when virtsnd_pcm_dev_set_params() succeeds in virtsnd_pcm_hw_params()?
[ ... ]
Quoted 11 lines
sound/virtio/virtio_pcm_ops.c +10
-0@@ -320,129 +717,615 @@ static int virtsnd_pcm_prepare(struct snd_pcm_substream *substream) + scoped_guard(pcm_stream_lock_irqsave, substream) { +guard (spinlock_irqsave)(&vss->lock); +if (vss->resetting || vss->reset_epoch != epoch) +return -ECANCELED ; + vss->prepared = false; + vss->preparing = true; + suspended = vss->suspended; + } + +if (pause_restart) {
sound/virtio/virtio_pcm_ops.c static int virtsnd_pcm_prepare(struct snd_pcm_substream *substream) · line 736
Quoted 10 lines
sound/virtio/virtio_pcm_ops.c +10
-0+enum virtio_pcm_pause_restart_state state; + +scoped_guard (spinlock_irqsave, &vss->lock) + state = vss->pause_restart_state; +if (state ==VIRTSND_PCM_PAUSE_RESTART_RESET_REQUIRED || +virtsnd_pcm_pause_restart_transitioning (state)) { +virtsnd_pcm_pause_restart_fail (vss, true, epoch); +return -EIO ; + } + }
[Severity: Medium]
If virtsnd_pcm_prepare_locked() fails after setting vss->preparing = true, what clears vss->preparing?
In snd_pcm_do_prepare(), the core only calls snd_pcm_reset_substream() (which invokes substream->ops->reset() and clears vss->preparing = false) if substream->ops->prepare() returns 0. If virtsnd_pcm_prepare_locked() returns an error on any of the subsequent failure paths (such as the pause_restart state check, the stopped check, pending messages, virtsnd_pcm_dev_set_params(), virtsnd_pcm_dev_prepare(), or virtsnd_pcm_capture_refresh_mode_locked()), vss->preparing remains stuck at true.
Similarly, in virtsnd_pcm_indirect_reset(), virtsnd_pcm_reset(), and virtsnd_reset_vqs(), if a device reset occurs (setting vss->resetting = true), virtsnd_pcm_indirect_reset() and virtsnd_pcm_reset() return early at if (vss->resetting) return 0; before clearing vss->preparing = false, and virtsnd_reset_vqs() does not clear vss->preparing either. While vss->preparing is stuck at true, pointer and ACK callbacks remain locked out and return SNDRV_PCM_POS_XRUN or -EBADFD instead of -EPIPE.
[ ... ]
Quoted 25 lines
sound/virtio/virtio_pcm_ops.c +25
-0+static int virtsnd_pcm_pause_restart_start(struct virtio_pcm_substream *vss, + bool resume) +{ + struct virtio_snd_queue *queue = virtsnd_pcm_queue(vss); + struct virtio_snd_msg *msg; + enum virtio_pcm_pause_restart_state state; + bool reset_required; + bool invalid_state; + int rc = 0; + u64 epoch; + + scoped_guard(spinlock_irqsave, &vss->lock) { + if (vss->resetting) + return -ECANCELED; + epoch = vss->reset_epoch; + state = vss->pause_restart_state; + reset_required = + state == VIRTSND_PCM_PAUSE_RESTART_RESET_REQUIRED || + virtsnd_pcm_pause_restart_transitioning(state); + invalid_state = + vss->xfer_xrun || + (resume &&\n+ (state != VIRTSND_PCM_PAUSE_RESTART_RELEASED || + !vss->stopped || vss->msg_count || + !vss->runtime_active)) || + (!resume &&\n+ (state != VIRTSND_PCM_PAUSE_RESTART_PREPARED ||
sound/virtio/virtio_pcm_ops.c line 830
Quoted 10 lines
sound/virtio/virtio_pcm_ops.c +10
-0+ vss->stopped)); + } +if (reset_required) { +virtsnd_pcm_pause_restart_fail (vss, true, epoch); +return -EIO ; + } +if (invalid_state) { +virtsnd_pcm_pause_restart_fail (vss, false, epoch); +return -EBADFD ; + }
[Severity: Medium]
In virtsnd_pcm_pause_restart_start(), if vss->xfer_xrun is already latched (for example via VIRTIO_SND_EVT_PCM_XRUN in virtsnd_pcm_event() while prepared or before queueing in the second check below), should this return -EPIPE instead of -EBADFD, matching virtsnd_pcm_start_queue()?
In snd_pcm_do_start(), the ALSA core only transitions the runtime state to SNDRV_PCM_STATE_XRUN when trigger(SNDRV_PCM_TRIGGER_START) returns -EPIPE. Returning -EBADFD leaves the substream in SNDRV_PCM_STATE_PREPARED with vss->stopped = true and vss->xfer_xrun = true, where virtsnd_pcm_period_elapsed() will not move it to XRUN either because snd_pcm_running() is false.
[ ... ]
Quoted 27 lines
sound/virtio/virtio_pcm_ops.c +12
-2@@ -521,10 +1426,16 @@ static snd_pcm_uframes_t virtsnd_pcm_pb_pointer(struct snd_pcm_substream *substream) {struct virtio_pcm_substream *vss =snd_pcm_substream_chip (substream); +size_t hw_ptr; + + scoped_guard(spinlock_irqsave, &vss->lock) { +if (!vss->prepared || vss->preparing) +return SNDRV_PCM_POS_XRUN ; + hw_ptr = vss->hw_ptr; + }return snd_pcm_indirect_playback_pointer (substream, - &vss->pcm_indirect, - vss->hw_ptr); + &vss->pcm_indirect, hw_ptr); }/** @@ -539,10 +1450,62 @@ static snd_pcm_uframes_t virtsnd_pcm_cp_pointer(struct snd_pcm_substream *substream) {struct virtio_pcm_substream *vss =snd_pcm_substream_chip (substream); +size_t hw_ptr =0 ; +u64 total; +bool free_running; +bool xrun;
sound/virtio/virtio_pcm_ops.c static snd_pcm_uframes_t · line 1466
Quoted 10 lines
sound/virtio/virtio_pcm_ops.c +10
-0+ +if (vss->capture_staging) { + scoped_guard(spinlock_irqsave, &vss->lock) { + xrun = vss->xfer_xrun; +if (!xrun && +virtsnd_pcm_capture_refresh_mode_locked (vss, + &free_running)) + xrun = true; +if (!xrun && !virtsnd_pcm_capture_counters_valid (vss)) + xrun = true;
[Severity: Medium]
Unlike virtsnd_pcm_pb_pointer(), the non-staged branch of virtsnd_pcm_cp_pointer(), and virtsnd_pcm_capture_staged_ack(), the staged capture branch of virtsnd_pcm_cp_pointer() does not check vss->prepared, vss->preparing, or vss->suspended.
When virtsnd_reset_vqs() runs during a device reset, it sets vss->prepared = false, vss->xfer_enabled = false, vss->suspended = true, and vss->xfer_xrun = false, while leaving vss->runtime_active, vss->buffer_bytes, vss->capture_boundary, and the staged capture counters intact. Likewise, virtsnd_pcm_prepare_locked() sets vss->prepared = false and vss->preparing = true before dropping the PCM stream lock. Because neither virtsnd_pcm_capture_refresh_mode_locked() nor virtsnd_pcm_capture_counters_valid() checks vss->prepared, vss->preparing, or vss->suspended, won't pointer queries on a reset or preparing staged capture substream return a stale ring offset instead of SNDRV_PCM_POS_XRUN?
[ ... ]
Quoted 22 lines
sound/virtio/virtio_pcm_ops.c +3
-1@@ -571,7 +1536,7 @@ static void virtsnd_pcm_transfer_failed(struct virtio_pcm_substream *vss) vss->substream->runtime->stop_operating = true; } -static int virtsnd_pcm_pb_ack (struct snd_pcm_substream *substream) +static int virtsnd_pcm_pb_ack_locked (struct snd_pcm_substream *substream) {struct virtio_pcm_substream *vss =snd_pcm_substream_chip (substream);struct virtio_snd_queue *queue =virtsnd_pcm_queue (vss);@@ -580,6 +1545,8 @@ static int virtsnd_pcm_pb_ack(struct snd_pcm_substream *substream) scoped_guard(spinlock_irqsave, &queue->lock) {guard (spinlock)(&vss->lock); +if (!vss->prepared || vss->preparing) +return -EBADFD ; transfer.indirect = vss->pcm_indirect;if (vss->stopped) { rc = -EPIPE ;@@ -606,17 +1573,136 @@ static int virtsnd_pcm_pb_ack(struct snd_pcm_substream *substream)return 0 ; }
sound/virtio/virtio_pcm_ops.c static int virtsnd_pcm_pb_ack(struct snd_pcm_substream *substream) · line 1584
Quoted 10 lines
sound/virtio/virtio_pcm_ops.c +7
-1-static int virtsnd_pcm_cp_ack (struct snd_pcm_substream *substream) +/* The PCM lock serializes ACK with prepare's accounting reset. */ +static int virtsnd_pcm_pb_ack (struct snd_pcm_substream *substream) {struct virtio_pcm_substream *vss =snd_pcm_substream_chip (substream); + +if (vss->indirect_reset_observing) +return 0 ; +return virtsnd_pcm_pb_ack_locked (substream); +}
[Severity: Medium]
In virtsnd_pcm_cp_ack(), the capture path validates runtime->state (returning -EPIPE for SNDRV_PCM_STATE_XRUN and -EBADFD for states other than PREPARED, RUNNING, PAUSED, and DRAINING), and virtsnd_pcm_cp_ack_locked() and virtsnd_pcm_cp_pointer() check vss->xfer_xrun.
In contrast, virtsnd_pcm_pb_ack() does not check runtime->state, and neither virtsnd_pcm_pb_ack_locked() nor virtsnd_pcm_pb_pointer() checks vss->xfer_xrun. If a prepared playback stream is dropped via SNDRV_PCM_IOCTL_DROP (where snd_pcm_drop() transitions runtime->state to SNDRV_PCM_STATE_SETUP without calling trigger(STOP) because snd_pcm_running() is false, leaving vss->prepared == true and vss->stopped == false), or if a later member in a linked prepare sleeps or fails after playback prepare completes, or if VIRTIO_SND_EVT_PCM_XRUN sets vss->xfer_xrun = true, won't SNDRV_PCM_IOCTL_SYNC_PTR still call virtsnd_pcm_pb_ack() and enqueue TX buffers in invalid or XRUN states?
Quoted 4 lines
sound/virtio/virtio_pcm_ops.c +4
-0+ +static int virtsnd_pcm_capture_staged_ack (struct virtio_pcm_substream *vss, +struct snd_pcm_runtime *runtime) +{
[ ... ]
Quoted 10 lines
sound/virtio/virtio_pcm_ops.c +10
-0+/* ACK includes any subperiod tail already copied to the ring. */ + bytes =frames_to_bytes (runtime, diff); + outstanding = vss->capture_copied_total - + vss->capture_acked_total; +if ((!free_running && bytes > vss->capture_ready) || + (free_running && + (bytes > vss->buffer_bytes || bytes > outstanding)) || +check_add_overflow (vss->capture_acked_total, (u64 )bytes, + &next_acked_total) || + next_acked_total > vss->capture_pointer_seen_total) {
sound/virtio/virtio_pcm_ops.c line 1658
Quoted 10 lines
sound/virtio/virtio_pcm_ops.c +10
-0+ vss->xfer_xrun = true; +virtsnd_pcm_schedule_period_elapsed (vss); +return -EPIPE ; + } + + vss->capture_acked_total = next_acked_total; +if (!free_running) + vss->capture_ready -= bytes; + vss->pcm_indirect.appl_ptr = appl_ptr; + }
[Severity: Medium]
Can frames_to_bytes(runtime, diff) truncate sub-byte frame deltas here when capturing 4-bit frames (mono SNDRV_PCM_FORMAT_IMA_ADPCM, where runtime->frame_bits == 4)?
When diff is odd, frames_to_bytes(runtime, diff) computes (diff * 4) / 8 and truncates the half-byte, while vss->pcm_indirect.appl_ptr = appl_ptr advances past the full frame delta. Across multiple odd-frame ACKs (for example via SNDRV_PCM_IOCTL_SYNC_PTR), the uncounted half-bytes are never added to vss->capture_acked_total or subtracted from vss->capture_ready, leaking vss->capture_ready in managed mode until virtsnd_pcm_capture_complete() rejects a completion with ring_full and triggers a false XRUN.
[ ... ]
Quoted 17 lines
sound/virtio/virtio_pcm_ops.c +17
-0+/* The core holds the stream lock through the matching appl_ptr reset. */ +static int virtsnd_pcm_reset (struct snd_pcm_substream *substream) +{ +struct virtio_pcm_substream *vss =snd_pcm_substream_chip (substream); +struct snd_pcm_runtime *runtime = substream->runtime; +struct virtio_snd_queue *queue =virtsnd_pcm_queue (vss); +size_t position; +size_t period; +int rc; + +/* Reclaim RX space atomically with the pointer observation. */ +scoped_guard (spinlock_irqsave, &vss->lock) + vss->capture_reset_observing = true; + rc =snd_pcm_lib_reset (substream); +scoped_guard (spinlock_irqsave, &vss->lock) + vss->capture_reset_observing = false; +if (rc || !vss->capture_staging)
sound/virtio/virtio_pcm_ops.c line 1893
Quoted 10 lines
sound/virtio/virtio_pcm_ops.c +10
-0+return rc; + +guard (spinlock_irqsave)(&queue->lock); +guard (spinlock)(&vss->lock); +if (vss->resetting) +return 0 ; + vss->preparing = false; +/* The common reset has already handled a pointer-reported XRUN. */ +if (vss->xfer_xrun) +return 0 ;
[Severity: Medium]
As reported by Sashiko on v8 [2], what happens in virtsnd_pcm_reset() (and virtsnd_pcm_indirect_reset()) when vss->xfer_xrun is true, either while the stream is in SNDRV_PCM_STATE_PAUSED / SNDRV_PCM_STATE_PREPARED or when vss->xfer_xrun becomes true between snd_pcm_lib_reset() and acquiring vss->lock?
In snd_pcm_lib_reset(), snd_pcm_update_hw_ptr() is only called when snd_pcm_running(substream) is true. When the substream is paused or prepared (or if vss->xfer_xrun raced in after snd_pcm_lib_reset()), snd_pcm_lib_reset() does not observe the XRUN and returns 0, and snd_pcm_reset_substream() then rebases runtime->control->appl_ptr = runtime->status->hw_ptr. Returning 0 early here leaves vss->pcm_indirect.appl_ptr and the staged capture counters out of sync with runtime->control->appl_ptr, and in virtsnd_pcm_reset() also skips scheduling vss->elapsed_period to stop a paused substream on XRUN.
Quoted 36 lines
sound/virtio/virtio_pcm_ops.c +36
-0+if (snd_pcm_running (substream)) { +/* Keep completions arriving after the core's pointer observation. */ + vss->capture_acked_total = vss->capture_pointer_seen_total; + vss->capture_ready = vss->capture_free_running ?0 : + vss->capture_copied_total - vss->capture_acked_total; + }else { + position =frames_to_bytes (runtime, runtime->status->hw_ptr); + vss->hw_ptr = position; + period =snd_pcm_lib_period_bytes (substream); + vss->capture_copied_total = position; + vss->capture_acked_total = position; + vss->capture_pointer_seen_total = position; + vss->capture_ready =0 ; + vss->capture_notified_periods = period ? position / period :0 ; + } + vss->capture_callback_snapshot =0 ; + vss->capture_callback_snapshot_active = false; + vss->pcm_indirect.appl_ptr = runtime->status->hw_ptr; +if (snd_pcm_running (substream) && vss->xfer_enabled && vss->prepared) { + rc =virtsnd_pcm_capture_send (vss); +if (rc) { + vss->xfer_xrun = true; +virtsnd_pcm_schedule_period_elapsed (vss); + } + } +/* Complete the matching core pointer rebase before reporting XRUN. */ +return 0 ; +} + +/* Keep queued TX ownership while rebasing the application's write cursor. */ +static int virtsnd_pcm_playback_reset (struct snd_pcm_substream *substream) +{ +struct virtio_pcm_substream *vss =snd_pcm_substream_chip (substream); +int rc; + + vss->indirect_reset_observing = true;
sound/virtio/virtio_pcm_ops.c
Quoted 10 lines
sound/virtio/virtio_pcm_ops.c +10
-0+ rc =snd_pcm_lib_reset (substream); + vss->indirect_reset_observing = false; +if (rc) +return rc; +guard (spinlock_irqsave)(&vss->lock); + vss->preparing = false; + vss->pcm_indirect.appl_ptr = substream->runtime->status->hw_ptr; + vss->pcm_indirect.sw_ready =0 ; +return 0 ; +}
[Severity: High]
Does virtsnd_pcm_playback_reset() leave vss->pcm_indirect and vss->msgs[i]->length in an inconsistent state when SNDRV_PCM_IOCTL_RESET is called after playback frames have already been acknowledged?
In virtsnd_pcm_pb_ack_locked(), snd_pcm_indirect_playback_transfer() drains sw_ready into virtsnd_pcm_msg_send(), which advances pcm_indirect.sw_data, pcm_indirect.hw_data, and pcm_indirect.hw_ready ahead of pcm_indirect.sw_io and accumulates bytes into vss->msgs[i]->length. When virtsnd_pcm_playback_reset() runs, snd_pcm_reset_substream() rebases runtime->control->appl_ptr back to runtime->status->hw_ptr (matching sw_io), and virtsnd_pcm_playback_reset() sets pcm_indirect.appl_ptr and clears sw_ready = 0, but leaves sw_data, hw_data, hw_ready, and vss->msgs[i]->length untouched:
1. On the next write after RESET, ALSA writes new samples into runtime->dma_area starting at runtime->control->appl_ptr (sw_io, overwriting in-flight TX period buffers), while snd_pcm_indirect_playback_transfer() calls virtsnd_pcm_msg_send() starting from the old sw_data offset, sending unwritten/stale DMA buffer regions.
2. If a sub-period write occurred before RESET (leaving
0 < msg->length < period_bytes) or when sw_data wraps into an already-queued period (msg->length == period_bytes), virtsnd_pcm_msg_send() adds n to the existing msg->length, causing msg->length to exceed period_bytes so the descriptor is never submitted.
3. Because runtime->control->appl_ptr is rebased back to runtime->status->hw_ptr while hw_ready bytes remain queued in the TX virtqueue, completion of an in-flight TX period advances runtime->status->hw_ptr past runtime->control->appl_ptr and triggers a false playback XRUN.
4. If SNDRV_PCM_IOCTL_RESET is called while playback is in SNDRV_PCM_STATE_PAUSED after completing at least one period (vss->hw_ptr > 0), snd_pcm_lib_reset() sees !snd_pcm_running(substream) and resets runtime->status->hw_ptr = 0, while vss->hw_ptr, pcm_indirect.hw_io, and pcm_indirect.sw_io remain at the non-zero paused offset, causing the next virtsnd_pcm_pb_pointer() call to report a large pointer jump and XRUN.
[1] https://lore.kernel.org/r/[email protected]
[2] https://lore.kernel.org/r/[email protected]
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=10
PATCH v12 11/12 ALSA: virtio: prioritize staged capture period work
In reply to Joonho LeeQueue staged capture period notifications on system_highpri_wq through the common scheduling helper. This allows capture notifications to make progress when ordinary workqueue workers are delayed by CPU contention. Playback and ordinary capture keep schedule_work().
This preserves the existing priority proposal without mixing RESET or lifecycle changes into it. It provides no hard real-time deadline and cannot prevent a userspace reader from overrunning its buffer.
---
sound/virtio/virtio_pcm.h +4 -0
@@ -167,6 +167,10 @@static inline bool virtsnd_pcm_schedule_period_elapsed (struct virtio_pcm_substream *vss) { +if (vss->direction ==SNDRV_PCM_STREAM_CAPTURE && + vss->capture_staging) +return queue_work (system_highpri_wq, &vss->elapsed_period); +return schedule_work (&vss->elapsed_period); }
[email protected]
AI reviewRe: [PATCH v12 11/12] ALSA: virtio: prioritize staged capture period work
Sashiko has reviewed this patch and found no issues.
Quoted 11 lines
Queue staged capture period notifications on
system_highpri_wqthrough the common scheduling helper. This allows capture notifications to make progress when ordinary workqueue workers are delayed by CPU contention. Playback and ordinary capture keepschedule_work().This preserves the existing priority proposal without mixing RESET or lifecycle changes into it. It provides no hard real-time deadline and cannot prevent a userspace reader from overrunning its buffer.
Assisted-by LLMSigned-off-by Joonho Lee <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=11
PATCH v12 12/12 docs: describe virtio-sound capture options
In reply to Joonho LeeDocument the five opt-in capture module parameters introduced by this series. All default to false. Describe the startup-empty, short-payload, packed-status and pause-restart compatibility behavior alongside staging, and require validation with the target device.
---
Documentation/admin-guide/kernel-parameters.txt +30 -0
@@ -8328,6 +8328,36 @@ brightness level. default: 1 + virtio_snd.capture_allow_empty= [HW,SOUND] + Retry a bounded number of empty startup capture replies. + Format: <bool> + Default: false. Compatibility option for devices that + require staged capture; validate with the target device. + + virtio_snd.capture_allow_short= [HW,SOUND] + Accept non-empty, frame-aligned short capture replies. + Format: <bool> + Default: false. Compatibility option for devices that + require staged capture; validate with the target device. + + virtio_snd.capture_packed_status= [HW,SOUND] + Read status immediately after the returned capture data. + Format: <bool> + Default: false. Compatibility option for devices that + require staged capture; validate with the target device. + + virtio_snd.capture_pause_restart= [HW,SOUND] + Release and reprepare capture streams across pause. + Format: <bool> + Default: false. Compatibility option for devices that + require staged capture; validate with the target device. + + virtio_snd.capture_staging= [HW,SOUND] + Use request-owned buffers for capture data. + Format: <bool> + Default: false. Compatibility option for devices that + require staged capture; validate with the target device. + virtio_mmio.device= [VMMIO] Memory mapped virtio (platform) device.
[email protected]
AI reviewRe: [PATCH v12 12/12] docs: describe virtio-sound capture options
Sashiko has reviewed this patch and found no issues.
Quoted 7 lines
Document the five opt-in capture module parameters introduced by this series. All default to false. Describe the startup-empty, short-payload, packed-status and pause-restart compatibility behavior alongside staging, and require validation with the target device.
Assisted-by LLMSigned-off-by Joonho Lee <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=12
Randy Dunlap
reviewerRe: [PATCH v12 12/12] docs: describe virtio-sound capture options
In reply to Joonho LeeHi,
Quoted 9 lines · Joonho Lee
Document the five opt-in capture module parameters introduced by this series. All default to false. Describe the startup-empty, short-payload, packed-status and pause-restart compatibility behavior alongside staging, and require validation with the target device.
Assisted-by LLMSigned-off-by Joonho Lee <[email protected]>---
Please include a diffstat for each patch (here, below the "---" line).
Quoted 27 lines
Documentation/admin-guide/kernel-parameters.txt +20
-0@@ -8328,6 +8328,36 @@ brightness level. default: 1 + virtio_snd.capture_allow_empty= [HW,SOUND] + Retry a bounded number of empty startup capture replies. + Format: <bool> + Default: false. Compatibility option for devices that + require staged capture; validate with the target device. + + virtio_snd.capture_allow_short= [HW,SOUND] + Accept non-empty, frame-aligned short capture replies. + Format: <bool> + Default: false. Compatibility option for devices that + require staged capture; validate with the target device. + + virtio_snd.capture_packed_status= [HW,SOUND] + Read status immediately after the returned capture data. + Format: <bool> + Default: false. Compatibility option for devices that + require staged capture; validate with the target device. + + virtio_snd.capture_pause_restart= [HW,SOUND] + Release and reprepare capture streams across pause.
Documentation/admin-guide/kernel-parameters.txt line 8360
Quoted 10 lines
Documentation/admin-guide/kernel-parameters.txt +10
-0+ Format: <bool> + Default: false. Compatibility option for devices that + require staged capture; validate with the target device. + + virtio_snd.capture_staging= [HW,SOUND] + Use request-owned buffers for capture data. + Format: <bool> + Default: false. Compatibility option for devices that + require staged capture; validate with the target device. +
All virtio_snd entries should be *after* virtio_mmio (alphabetical order).
Quoted 3 lines
Documentation/admin-guide/kernel-parameters.txt +0
-0virtio_mmio.device= [VMMIO] Memory mapped virtio (platform) device.
Signature · 1 line
~Randy