mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] ALSA: 6fire: avoid resubmitting an active URB
@ 2026-11-23  8:48 YuanZhe Liu
  2026-11-23  8:48 ` [PATCH 1/2] ALSA: 6fire: Don't resubmit an active MIDI URB YuanZhe Liu
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: YuanZhe Liu @ 2026-11-23  8:48 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: Jaroslav Kysela, linux-sound, linux-kernel, Bin Yu, Cheng Wen

The 6fire driver submits URBs from callbacks that do not own them, and the
USB core complains when the URB is still queued:

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

There are two independent paths.  The MIDI output resubmits rt->out_urb
after the stream was stopped while the previous transfer was still in
flight, and the PCM capture handler unconditionally resubmits the
playback URB paired with the capture URB that has just completed.

Both patches make the driver check whether the URB is still queued, as
sound/usb/midi.c does with active_urbs, and leave the data to the
completion handler instead of submitting an active URB.


YuanZhe Liu (2):
  ALSA: 6fire: Don't resubmit an active MIDI URB
  ALSA: 6fire: Don't resubmit an active PCM out URB

 sound/usb/6fire/midi.c | 21 +++++++++++++++++----
 sound/usb/6fire/midi.h |  1 +
 sound/usb/6fire/pcm.c  | 16 +++++++++++++++-
 sound/usb/6fire/pcm.h  |  2 ++
 4 files changed, 35 insertions(+), 5 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/2] ALSA: 6fire: Don't resubmit an active MIDI URB
  2026-11-23  8:48 [PATCH 0/2] ALSA: 6fire: avoid resubmitting an active URB YuanZhe Liu
@ 2026-11-23  8:48 ` YuanZhe Liu
  2026-11-23  8:48 ` [PATCH 2/2] ALSA: 6fire: Don't resubmit an active PCM out URB YuanZhe Liu
  2026-12-01 10:23 ` [PATCH 0/2] ALSA: 6fire: avoid resubmitting an active URB Takashi Iwai
  2 siblings, 0 replies; 7+ messages in thread
From: YuanZhe Liu @ 2026-11-23  8:48 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: Jaroslav Kysela, linux-sound, linux-kernel, Bin Yu, Cheng Wen

The MIDI output keeps the transmission state in rt->out and submits
rt->out_urb from the rawmidi trigger callback.  Stopping the stream,
for example through the SNDRV_RAWMIDI_IOCTL_DROP ioctl, only clears
rt->out; the URB itself stays queued until the device has accepted the
pending data, which can take a while when the device delays the
transfer.

If the stream is started again before that happens, the trigger callback
passes the still-active URB to usb_submit_urb() a second time.  The USB
core rejects it and the new data is not sent:

  URB 00000000c6cd6557 submitted while active
  WARNING: drivers/usb/core/urb.c:379 at usb_submit_urb
  ...
  usb6fire_midi_out_trigger
  snd_rawmidi_kernel_write1
  ...
  usb 1-1: midi out urb submit failed: -16

Track whether the URB is queued separately from the substream that owns
it, and let the completion handler send the data queued by a restart
while the URB is still in flight.

Fixes: c6d43ba816d1 ("ALSA: usb/6fire - Driver for TerraTec DMX 6Fire USB")
Co-developed-by: Bin Yu <byu@xidian.edu.cn>
Signed-off-by: Bin Yu <byu@xidian.edu.cn>
Co-developed-by: Cheng Wen <wencheng@xidian.edu.cn>
Signed-off-by: Cheng Wen <wencheng@xidian.edu.cn>
Signed-off-by: YuanZhe Liu <25031212351@stu.xidian.edu.cn>
---
 sound/usb/6fire/midi.c | 21 +++++++++++++++++----
 sound/usb/6fire/midi.h |  1 +
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/sound/usb/6fire/midi.c b/sound/usb/6fire/midi.c
index 279b449936e7..ae8a0d48eb41 100644
--- a/sound/usb/6fire/midi.c
+++ b/sound/usb/6fire/midi.c
@@ -25,6 +25,7 @@ static void usb6fire_midi_out_handler(struct urb *urb)
 	int ret;
 
 	guard(spinlock_irqsave)(&rt->out_lock);
+	rt->out_urb_active = false;
 
 	if (rt->out) {
 		ret = snd_rawmidi_transmit(rt->out, rt->out_buffer + 4,
@@ -39,6 +40,8 @@ static void usb6fire_midi_out_handler(struct urb *urb)
 				dev_err(&urb->dev->dev,
 					"midi out urb submit failed: %d\n",
 					ret);
+			else
+				rt->out_urb_active = true;
 		} else /* no more data to transmit */
 			rt->out = NULL;
 	}
@@ -74,6 +77,14 @@ static void usb6fire_midi_out_trigger(
 		if (rt->out) /* we are already transmitting so just return */
 			return;
 
+		rt->out = alsa_sub;
+		/*
+		 * The urb is still in flight from the previous transmission;
+		 * the completion handler sends the queued data instead.
+		 */
+		if (rt->out_urb_active)
+			return;
+
 		ret = snd_rawmidi_transmit(alsa_sub, rt->out_buffer + 4,
 				MIDI_BUFSIZE - 4);
 		if (ret > 0) {
@@ -82,13 +93,15 @@ static void usb6fire_midi_out_trigger(
 			urb->transfer_buffer_length = ret + 4;
 
 			ret = usb_submit_urb(urb, GFP_ATOMIC);
-			if (ret < 0)
+			if (ret < 0) {
+				rt->out = NULL;
 				dev_err(&urb->dev->dev,
 					"midi out urb submit failed: %d\n",
 					ret);
-			else
-				rt->out = alsa_sub;
-		}
+			} else
+				rt->out_urb_active = true;
+		} else
+			rt->out = NULL;
 	} else if (rt->out == alsa_sub)
 		rt->out = NULL;
 }
diff --git a/sound/usb/6fire/midi.h b/sound/usb/6fire/midi.h
index 8716ab8a863a..221361442435 100644
--- a/sound/usb/6fire/midi.h
+++ b/sound/usb/6fire/midi.h
@@ -23,6 +23,7 @@ struct midi_runtime {
 	spinlock_t out_lock;
 	struct snd_rawmidi_substream *out;
 	struct urb *out_urb;
+	bool out_urb_active; /* out urb is still queued in the HCD */
 	u8 out_serial; /* serial number of out packet */
 	u8 *out_buffer;
 	int buffer_offset;
-- 
2.34.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 2/2] ALSA: 6fire: Don't resubmit an active PCM out URB
  2026-11-23  8:48 [PATCH 0/2] ALSA: 6fire: avoid resubmitting an active URB YuanZhe Liu
  2026-11-23  8:48 ` [PATCH 1/2] ALSA: 6fire: Don't resubmit an active MIDI URB YuanZhe Liu
@ 2026-11-23  8:48 ` YuanZhe Liu
  2026-12-01 10:23 ` [PATCH 0/2] ALSA: 6fire: avoid resubmitting an active URB Takashi Iwai
  2 siblings, 0 replies; 7+ messages in thread
From: YuanZhe Liu @ 2026-11-23  8:48 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: Jaroslav Kysela, linux-sound, linux-kernel, Bin Yu, Cheng Wen

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@xidian.edu.cn>
Signed-off-by: Bin Yu <byu@xidian.edu.cn>
Co-developed-by: Cheng Wen <wencheng@xidian.edu.cn>
Signed-off-by: Cheng Wen <wencheng@xidian.edu.cn>
Signed-off-by: YuanZhe Liu <25031212351@stu.xidian.edu.cn>
---
 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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/2] ALSA: 6fire: avoid resubmitting an active URB
  2026-11-23  8:48 [PATCH 0/2] ALSA: 6fire: avoid resubmitting an active URB YuanZhe Liu
  2026-11-23  8:48 ` [PATCH 1/2] ALSA: 6fire: Don't resubmit an active MIDI URB YuanZhe Liu
  2026-11-23  8:48 ` [PATCH 2/2] ALSA: 6fire: Don't resubmit an active PCM out URB YuanZhe Liu
@ 2026-12-01 10:23 ` Takashi Iwai
  2026-12-01 11:35   ` [PATCH v2 " YuanZhe Liu
  2 siblings, 1 reply; 7+ messages in thread
From: Takashi Iwai @ 2026-12-01 10:23 UTC (permalink / raw)
  To: YuanZhe Liu
  Cc: Takashi Iwai, Jaroslav Kysela, linux-sound, linux-kernel, Bin Yu,
	Cheng Wen

On Mon, 23 Nov 2026 09:48:44 +0100,
YuanZhe Liu wrote:
> 
> The 6fire driver submits URBs from callbacks that do not own them, and the
> USB core complains when the URB is still queued:
> 
>   URB 000000003ec29e65 submitted while active
>   WARNING: drivers/usb/core/urb.c:379 at usb_submit_urb
> 
> There are two independent paths.  The MIDI output resubmits rt->out_urb
> after the stream was stopped while the previous transfer was still in
> flight, and the PCM capture handler unconditionally resubmits the
> playback URB paired with the capture URB that has just completed.
> 
> Both patches make the driver check whether the URB is still queued, as
> sound/usb/midi.c does with active_urbs, and leave the data to the
> completion handler instead of submitting an active URB.
> 
> 
> YuanZhe Liu (2):
>   ALSA: 6fire: Don't resubmit an active MIDI URB
>   ALSA: 6fire: Don't resubmit an active PCM out URB

There was some suggestion from Sashiko.  Could you verify?


thanks,

Takashi

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 0/2] ALSA: 6fire: avoid resubmitting an active URB
  2026-12-01 10:23 ` [PATCH 0/2] ALSA: 6fire: avoid resubmitting an active URB Takashi Iwai
@ 2026-12-01 11:35   ` YuanZhe Liu
  2026-12-01 11:35     ` [PATCH v2 1/2] ALSA: 6fire: Don't resubmit an active MIDI URB YuanZhe Liu
  2026-12-01 11:35     ` [PATCH v2 2/2] ALSA: 6fire: Don't resubmit an active PCM out URB YuanZhe Liu
  0 siblings, 2 replies; 7+ messages in thread
From: YuanZhe Liu @ 2026-12-01 11:35 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: Jaroslav Kysela, linux-sound, linux-kernel, Bin Yu, Cheng Wen

The 6fire driver submits URBs from callbacks that do not own them, and the
USB core complains when the URB is still queued:

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

There are two independent paths.  The MIDI output resubmits rt->out_urb
after the stream was stopped while the previous transfer was still in
flight, and the PCM capture handler unconditionally resubmits the
playback URB paired with the capture URB that has just completed.

Both patches make the driver check whether the URB is still queued, as
sound/usb/midi.c does with active_urbs, and leave the data to the
completion handler instead of submitting an active URB.

v1 -> v2:
- Clear rt->out also when the resubmission fails in the MIDI completion
  handler; otherwise a later trigger(1) returns early at the rt->out
  check and the stream stays stalled.  Pointed out by the Sashiko
  review.


YuanZhe Liu (2):
  ALSA: 6fire: Don't resubmit an active MIDI URB
  ALSA: 6fire: Don't resubmit an active PCM out URB

 sound/usb/6fire/midi.c | 24 +++++++++++++++++++-----
 sound/usb/6fire/midi.h |  1 +
 sound/usb/6fire/pcm.c  | 16 +++++++++++++++-
 sound/usb/6fire/pcm.h  |  2 ++
 4 files changed, 37 insertions(+), 6 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 1/2] ALSA: 6fire: Don't resubmit an active MIDI URB
  2026-12-01 11:35   ` [PATCH v2 " YuanZhe Liu
@ 2026-12-01 11:35     ` YuanZhe Liu
  2026-12-01 11:35     ` [PATCH v2 2/2] ALSA: 6fire: Don't resubmit an active PCM out URB YuanZhe Liu
  1 sibling, 0 replies; 7+ messages in thread
From: YuanZhe Liu @ 2026-12-01 11:35 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: Jaroslav Kysela, linux-sound, linux-kernel, Bin Yu, Cheng Wen

The MIDI output keeps the transmission state in rt->out and submits
rt->out_urb from the rawmidi trigger callback.  Stopping the stream,
for example through the SNDRV_RAWMIDI_IOCTL_DROP ioctl, only clears
rt->out; the URB itself stays queued until the device has accepted the
pending data, which can take a while when the device delays the
transfer.

If the stream is started again before that happens, the trigger callback
passes the still-active URB to usb_submit_urb() a second time.  The USB
core rejects it and the new data is not sent:

  URB 00000000c6cd6557 submitted while active
  WARNING: drivers/usb/core/urb.c:379 at usb_submit_urb
  ...
  usb6fire_midi_out_trigger
  snd_rawmidi_kernel_write1
  ...
  usb 1-1: midi out urb submit failed: -16

Track whether the URB is queued separately from the substream that owns
it, and let the completion handler send the data queued by a restart
while the URB is still in flight.  Clear rt->out when the resubmission
fails there as well, like the trigger callback already does, so that a
later write restarts the transfer instead of returning early forever.

Fixes: c6d43ba816d1 ("ALSA: usb/6fire - Driver for TerraTec DMX 6Fire USB")
Co-developed-by: Bin Yu <byu@xidian.edu.cn>
Signed-off-by: Bin Yu <byu@xidian.edu.cn>
Co-developed-by: Cheng Wen <wencheng@xidian.edu.cn>
Signed-off-by: Cheng Wen <wencheng@xidian.edu.cn>
Signed-off-by: YuanZhe Liu <25031212351@stu.xidian.edu.cn>
---
 sound/usb/6fire/midi.c | 24 +++++++++++++++++++-----
 sound/usb/6fire/midi.h |  1 +
 2 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/sound/usb/6fire/midi.c b/sound/usb/6fire/midi.c
index 279b449936e7..407f5d73b07d 100644
--- a/sound/usb/6fire/midi.c
+++ b/sound/usb/6fire/midi.c
@@ -25,6 +25,7 @@ static void usb6fire_midi_out_handler(struct urb *urb)
 	int ret;
 
 	guard(spinlock_irqsave)(&rt->out_lock);
+	rt->out_urb_active = false;
 
 	if (rt->out) {
 		ret = snd_rawmidi_transmit(rt->out, rt->out_buffer + 4,
@@ -35,10 +36,13 @@ static void usb6fire_midi_out_handler(struct urb *urb)
 			urb->transfer_buffer_length = ret + 4;
 
 			ret = usb_submit_urb(urb, GFP_ATOMIC);
-			if (ret < 0)
+			if (ret < 0) {
+				rt->out = NULL;
 				dev_err(&urb->dev->dev,
 					"midi out urb submit failed: %d\n",
 					ret);
+			} else
+				rt->out_urb_active = true;
 		} else /* no more data to transmit */
 			rt->out = NULL;
 	}
@@ -74,6 +78,14 @@ static void usb6fire_midi_out_trigger(
 		if (rt->out) /* we are already transmitting so just return */
 			return;
 
+		rt->out = alsa_sub;
+		/*
+		 * The urb is still in flight from the previous transmission;
+		 * the completion handler sends the queued data instead.
+		 */
+		if (rt->out_urb_active)
+			return;
+
 		ret = snd_rawmidi_transmit(alsa_sub, rt->out_buffer + 4,
 				MIDI_BUFSIZE - 4);
 		if (ret > 0) {
@@ -82,13 +94,15 @@ static void usb6fire_midi_out_trigger(
 			urb->transfer_buffer_length = ret + 4;
 
 			ret = usb_submit_urb(urb, GFP_ATOMIC);
-			if (ret < 0)
+			if (ret < 0) {
+				rt->out = NULL;
 				dev_err(&urb->dev->dev,
 					"midi out urb submit failed: %d\n",
 					ret);
-			else
-				rt->out = alsa_sub;
-		}
+			} else
+				rt->out_urb_active = true;
+		} else
+			rt->out = NULL;
 	} else if (rt->out == alsa_sub)
 		rt->out = NULL;
 }
diff --git a/sound/usb/6fire/midi.h b/sound/usb/6fire/midi.h
index 8716ab8a863a..221361442435 100644
--- a/sound/usb/6fire/midi.h
+++ b/sound/usb/6fire/midi.h
@@ -23,6 +23,7 @@ struct midi_runtime {
 	spinlock_t out_lock;
 	struct snd_rawmidi_substream *out;
 	struct urb *out_urb;
+	bool out_urb_active; /* out urb is still queued in the HCD */
 	u8 out_serial; /* serial number of out packet */
 	u8 *out_buffer;
 	int buffer_offset;
-- 
2.34.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 2/2] ALSA: 6fire: Don't resubmit an active PCM out URB
  2026-12-01 11:35   ` [PATCH v2 " YuanZhe Liu
  2026-12-01 11:35     ` [PATCH v2 1/2] ALSA: 6fire: Don't resubmit an active MIDI URB YuanZhe Liu
@ 2026-12-01 11:35     ` YuanZhe Liu
  1 sibling, 0 replies; 7+ messages in thread
From: YuanZhe Liu @ 2026-12-01 11:35 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: Jaroslav Kysela, linux-sound, linux-kernel, Bin Yu, Cheng Wen

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@xidian.edu.cn>
Signed-off-by: Bin Yu <byu@xidian.edu.cn>
Co-developed-by: Cheng Wen <wencheng@xidian.edu.cn>
Signed-off-by: Cheng Wen <wencheng@xidian.edu.cn>
Signed-off-by: YuanZhe Liu <25031212351@stu.xidian.edu.cn>
---
 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


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-12-01 11:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-23  8:48 [PATCH 0/2] ALSA: 6fire: avoid resubmitting an active URB YuanZhe Liu
2026-11-23  8:48 ` [PATCH 1/2] ALSA: 6fire: Don't resubmit an active MIDI URB YuanZhe Liu
2026-11-23  8:48 ` [PATCH 2/2] ALSA: 6fire: Don't resubmit an active PCM out URB YuanZhe Liu
2026-12-01 10:23 ` [PATCH 0/2] ALSA: 6fire: avoid resubmitting an active URB Takashi Iwai
2026-12-01 11:35   ` [PATCH v2 " YuanZhe Liu
2026-12-01 11:35     ` [PATCH v2 1/2] ALSA: 6fire: Don't resubmit an active MIDI URB YuanZhe Liu
2026-12-01 11:35     ` [PATCH v2 2/2] ALSA: 6fire: Don't resubmit an active PCM out URB YuanZhe Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®