linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ALSA: usb-audio: fix urb timeout with URB_ISO_ASAP flag
@ 2022-11-22  8:20 Michael Wu
  2022-11-22  8:46 ` Takashi Iwai
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Wu @ 2022-11-22  8:20 UTC (permalink / raw)
  To: perex, tiwai, aichao, wanjiabing, ubizjak; +Cc: tiwai, alsa-devel, linux-kernel

When the loglevel is greater than 4, with a long messages printed on the
console while playing or recording audios, the usb controller may become
abnormal.
`usb 1-2: timeout: still 1 active urbs on EP #1`

Fix it by configuring the transfer_flags URB_ISO_ASAP flag.

Signed-off-by: Michael Wu <michael@allwinnertech.com>
---
 sound/usb/endpoint.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c
index 310cd6fb0038..df9a91c2fc7d 100644
--- a/sound/usb/endpoint.c
+++ b/sound/usb/endpoint.c
@@ -1245,7 +1245,7 @@ static int data_ep_set_params(struct snd_usb_endpoint *ep)
 		if (!u->urb->transfer_buffer)
 			goto out_of_memory;
 		u->urb->pipe = ep->pipe;
-		u->urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP;
+		u->urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP;
 		u->urb->interval = 1 << ep->datainterval;
 		u->urb->context = u;
 		u->urb->complete = snd_complete_urb;
@@ -1288,7 +1288,7 @@ static int sync_ep_set_params(struct snd_usb_endpoint *ep)
 		u->urb->transfer_dma = ep->sync_dma + i * 4;
 		u->urb->transfer_buffer_length = 4;
 		u->urb->pipe = ep->pipe;
-		u->urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP;
+		u->urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP;
 		u->urb->number_of_packets = 1;
 		u->urb->interval = 1 << ep->syncinterval;
 		u->urb->context = u;
-- 
2.29.0


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

* Re: [PATCH] ALSA: usb-audio: fix urb timeout with URB_ISO_ASAP flag
  2022-11-22  8:20 [PATCH] ALSA: usb-audio: fix urb timeout with URB_ISO_ASAP flag Michael Wu
@ 2022-11-22  8:46 ` Takashi Iwai
  2022-11-22  8:54   ` Michael Wu
  0 siblings, 1 reply; 3+ messages in thread
From: Takashi Iwai @ 2022-11-22  8:46 UTC (permalink / raw)
  To: Michael Wu
  Cc: perex, tiwai, aichao, wanjiabing, ubizjak, alsa-devel, linux-kernel

On Tue, 22 Nov 2022 09:20:40 +0100,
Michael Wu wrote:
> 
> When the loglevel is greater than 4, with a long messages printed on the
> console while playing or recording audios, the usb controller may become
> abnormal.
> `usb 1-2: timeout: still 1 active urbs on EP #1`
> 
> Fix it by configuring the transfer_flags URB_ISO_ASAP flag.
> 
> Signed-off-by: Michael Wu <michael@allwinnertech.com>

Hrm, that's somewhat backward action to the change we've done years
ago, commit c75c5ab575af7db707689cdbb5a5c458e9a034bb:

    ALSA: USB: adjust for changed 3.8 USB API
    
    The recent changes in the USB API ("implement new semantics for
    URB_ISO_ASAP") made the former meaning of the URB_ISO_ASAP flag the
    default, and changed this flag to mean that URBs can be delayed.
    This is not the behaviour wanted by any of the audio drivers because
    it leads to discontinuous playback with very small period sizes.
    Therefore, our URBs need to be submitted without this flag.

I rather suspect that your problem is in the USB controller side.


thanks,

Takashi

> ---
>  sound/usb/endpoint.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c
> index 310cd6fb0038..df9a91c2fc7d 100644
> --- a/sound/usb/endpoint.c
> +++ b/sound/usb/endpoint.c
> @@ -1245,7 +1245,7 @@ static int data_ep_set_params(struct snd_usb_endpoint *ep)
>  		if (!u->urb->transfer_buffer)
>  			goto out_of_memory;
>  		u->urb->pipe = ep->pipe;
> -		u->urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP;
> +		u->urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP;
>  		u->urb->interval = 1 << ep->datainterval;
>  		u->urb->context = u;
>  		u->urb->complete = snd_complete_urb;
> @@ -1288,7 +1288,7 @@ static int sync_ep_set_params(struct snd_usb_endpoint *ep)
>  		u->urb->transfer_dma = ep->sync_dma + i * 4;
>  		u->urb->transfer_buffer_length = 4;
>  		u->urb->pipe = ep->pipe;
> -		u->urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP;
> +		u->urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP;
>  		u->urb->number_of_packets = 1;
>  		u->urb->interval = 1 << ep->syncinterval;
>  		u->urb->context = u;
> -- 
> 2.29.0
> 

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

* Re: [PATCH] ALSA: usb-audio: fix urb timeout with URB_ISO_ASAP flag
  2022-11-22  8:46 ` Takashi Iwai
@ 2022-11-22  8:54   ` Michael Wu
  0 siblings, 0 replies; 3+ messages in thread
From: Michael Wu @ 2022-11-22  8:54 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: perex, tiwai, aichao, wanjiabing, ubizjak, alsa-devel, linux-kernel

On 11/22/2022 4:46 PM, Takashi Iwai wrote:
> On Tue, 22 Nov 2022 09:20:40 +0100,
> Michael Wu wrote:
>>
>> When the loglevel is greater than 4, with a long messages printed on the
>> console while playing or recording audios, the usb controller may become
>> abnormal.
>> `usb 1-2: timeout: still 1 active urbs on EP #1`
>>
>> Fix it by configuring the transfer_flags URB_ISO_ASAP flag.
>>
>> Signed-off-by: Michael Wu <michael@allwinnertech.com>
> 
> Hrm, that's somewhat backward action to the change we've done years
> ago, commit c75c5ab575af7db707689cdbb5a5c458e9a034bb:
> 
>      ALSA: USB: adjust for changed 3.8 USB API
>      
>      The recent changes in the USB API ("implement new semantics for
>      URB_ISO_ASAP") made the former meaning of the URB_ISO_ASAP flag the
>      default, and changed this flag to mean that URBs can be delayed.
>      This is not the behaviour wanted by any of the audio drivers because
>      it leads to discontinuous playback with very small period sizes.
>      Therefore, our URBs need to be submitted without this flag.
> 
> I rather suspect that your problem is in the USB controller side.
> 
> 
> thanks,
> 
> Takashi
> 
Dear Takashi, thanks for the reminding. Let me check...

-- 
Regards,
Michael Wu

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

end of thread, other threads:[~2022-11-22  8:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-22  8:20 [PATCH] ALSA: usb-audio: fix urb timeout with URB_ISO_ASAP flag Michael Wu
2022-11-22  8:46 ` Takashi Iwai
2022-11-22  8:54   ` Michael Wu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).