[PATCH 2/2] ALSA: 6fire: Don't resubmit an active PCM out URB

From: YuanZhe Liu

Date: Mon Nov 23 2026 - 03:49:08 EST


usb6fire_pcm_in_urb_handler() refills the playback URB paired with the
capture URB that has just completed and submits it unconditionally,
although the comment right above expects "a free out urb was found".
Both URBs carry the same number of isochronous packets and are rearmed
at the same time, so the playback URB can still be queued when the next
capture completion arrives. The handler then rewrites a transfer buffer
that is still owned by the host controller and submits the active URB
again:

URB 000000003ec29e65 submitted while active
WARNING: drivers/usb/core/urb.c:379 at usb_submit_urb
...
usb6fire_pcm_in_urb_handler
__usb_hcd_giveback_urb
...

The resubmission fails and the playback data of that period is lost.
This is observed when the completion of the playback URB is delayed, for
example by missed isochronous services on the host controller.

Check whether the out URB has completed and skip it for the period
otherwise; the next capture completion retries.

Fixes: c6d43ba816d1 ("ALSA: usb/6fire - Driver for TerraTec DMX 6Fire USB")
Co-developed-by: Bin Yu <byu@xxxxxxxxxxxxx>
Signed-off-by: Bin Yu <byu@xxxxxxxxxxxxx>
Co-developed-by: Cheng Wen <wencheng@xxxxxxxxxxxxx>
Signed-off-by: Cheng Wen <wencheng@xxxxxxxxxxxxx>
Signed-off-by: YuanZhe Liu <25031212351@xxxxxxxxxxxxxxxxx>
---
sound/usb/6fire/pcm.c | 16 +++++++++++++++-
sound/usb/6fire/pcm.h | 2 ++
2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/sound/usb/6fire/pcm.c b/sound/usb/6fire/pcm.c
index f5dfb8c3096a..d6ef8ffa97a9 100644
--- a/sound/usb/6fire/pcm.c
+++ b/sound/usb/6fire/pcm.c
@@ -460,6 +460,15 @@ static void usb6fire_pcm_in_urb_handler(struct urb *usb_urb)
if (period_elapsed)
snd_pcm_period_elapsed(sub->instance);

+ /*
+ * The out urb is submitted again from here, but the previous one may
+ * still be queued in the HCD. Its transfer buffer is owned by the
+ * HCD until it completes, so skip it for this period and retry at
+ * the next capture completion.
+ */
+ if (atomic_xchg(&out_urb->active, 1))
+ goto submit_in;
+
/* setup out urb structure */
for (i = 0; i < PCM_N_PACKETS_PER_URB; i++) {
unsigned int frames = 0;
@@ -525,8 +534,11 @@ static void usb6fire_pcm_in_urb_handler(struct urb *usb_urb)
* the frames of an out urb that was not submitted never reach the
* transmitter; the next urb continues the block at the same position
*/
- if (usb_submit_urb(out_urb->instance, GFP_ATOMIC) < 0)
+ if (usb_submit_urb(out_urb->instance, GFP_ATOMIC) < 0) {
rt->spdif_frame = spdif_frame;
+ atomic_set(&out_urb->active, 0);
+ }
+submit_in:
usb_submit_urb(in_urb->instance, GFP_ATOMIC);
}

@@ -535,6 +547,8 @@ static void usb6fire_pcm_out_urb_handler(struct urb *usb_urb)
struct pcm_urb *urb = usb_urb->context;
struct pcm_runtime *rt = urb->chip->pcm;

+ atomic_set(&urb->active, 0);
+
if (rt->stream_state == STREAM_STARTING) {
rt->stream_wait_cond = true;
wake_up(&rt->stream_wait_queue);
diff --git a/sound/usb/6fire/pcm.h b/sound/usb/6fire/pcm.h
index f1b867b9c468..b5d1f5106d2c 100644
--- a/sound/usb/6fire/pcm.h
+++ b/sound/usb/6fire/pcm.h
@@ -28,6 +28,8 @@ struct pcm_urb {
u8 *buffer;

struct pcm_urb *peer;
+
+ atomic_t active; /* urb is queued in the HCD */
};

struct pcm_substream {
--
2.34.1