Message ID | 20221122082040.48591-1-michael@allwinnertech.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2076165wrr; Tue, 22 Nov 2022 00:28:55 -0800 (PST) X-Google-Smtp-Source: AA0mqf4Yi4GKHt3QM4NzMZEyf4Wmtzgz79vPz7LHOhRotR6EueWuKEeBWtFU/YKy3Rc4RM82F5hR X-Received: by 2002:a05:6402:1f85:b0:462:2410:9720 with SMTP id c5-20020a0564021f8500b0046224109720mr20029493edc.84.1669105735022; Tue, 22 Nov 2022 00:28:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669105735; cv=none; d=google.com; s=arc-20160816; b=dArjp1gBwoGL21r4LkFWEcOHsESIl9aJrlPz8yU8llROYKM0K3KaQ4kjoLbdZhDR5e YSo85zHgDJT4jlhLvCCS91xlxJir0U0S+iivENBZ5MyTpyVqMGCHR1+2k2mQklh+nKk/ ZICsLpOPNmluLf8wLlNpMta8fnANJq1A47BPnT6RWy2EvupdA6cZOopsM8IL2X4kGDNL O36ydO3Y0hrRw1W1P9Hdx11+n5wls4PdpkpcLwNarWxKH97n9lYHrZNybDm65xPruqvI jY3FxhTSvHjL+Vs6HSpsDhCR25+AFHtJ7ii+68EGq3uT6vq7eE3HU3dd819Z3OubB6xz WHkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=6C5ycclEwhv8DTYPNeROZoIK+tr/HDUqMAQdxBS7I6w=; b=n5TRWydy2wuA6OMcWaGFIvE0mBnnZ113ixSU/gs0OAkbMbi0tyIvhOiYCNs75RXlcD mzSiUqJKINcqTdQrwEs15Xv1N34W8ZN7smHXlccTdqSakW08zdRyC5QAuu2d2PlMdpHV jO8RF5qx27dT2496G0eCni6u871PFRlrU+b4j1zz9lwvheoaMKkxu+ZhA8zqWcNsjHLi gz4J6nQ4/e64SVy1zB7Eam/iF0CFhZdjlOMhaaPF7dbQlpe3d8i3wacYkyxKWigbcEyS Ou9mGkWdng7nOpx35Sg4OfV1AtbaYxlnTpqWaoQjeVcM7ouCLdXokK6lUJU/5imhGjGo prug== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j11-20020a05640211cb00b0046627848e32si12511739edw.634.2022.11.22.00.28.30; Tue, 22 Nov 2022 00:28:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232695AbiKVIVP (ORCPT <rfc822;cjcooper78@gmail.com> + 99 others); Tue, 22 Nov 2022 03:21:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232605AbiKVIVL (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 22 Nov 2022 03:21:11 -0500 Received: from out29-121.mail.aliyun.com (out29-121.mail.aliyun.com [115.124.29.121]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDD5C40443 for <linux-kernel@vger.kernel.org>; Tue, 22 Nov 2022 00:21:08 -0800 (PST) X-Alimail-AntiSpam: AC=CONTINUE;BC=0.08002614|-1;BR=01201311R161S84rulernew998_84748_2000303;CH=blue;DM=|CONTINUE|false|;DS=CONTINUE|ham_system_inform|0.00516761-0.000814287-0.994018;FP=0|0|0|0|0|-1|-1|-1;HT=ay29a033018047201;MF=michael@allwinnertech.com;NM=1;PH=DS;RN=8;RT=8;SR=0;TI=SMTPD_---.QE3zAv6_1669105264; Received: from SunxiBot.allwinnertech.com(mailfrom:michael@allwinnertech.com fp:SMTPD_---.QE3zAv6_1669105264) by smtp.aliyun-inc.com; Tue, 22 Nov 2022 16:21:05 +0800 From: Michael Wu <michael@allwinnertech.com> To: perex@perex.cz, tiwai@suse.com, aichao@kylinos.cn, wanjiabing@vivo.com, ubizjak@gmail.com Cc: tiwai@suse.de, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH] ALSA: usb-audio: fix urb timeout with URB_ISO_ASAP flag Date: Tue, 22 Nov 2022 16:20:40 +0800 Message-Id: <20221122082040.48591-1-michael@allwinnertech.com> X-Mailer: git-send-email 2.29.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750184215290720051?= X-GMAIL-MSGID: =?utf-8?q?1750184215290720051?= |
Series |
ALSA: usb-audio: fix urb timeout with URB_ISO_ASAP flag
|
|
Commit Message
Michael Wu
Nov. 22, 2022, 8:20 a.m. UTC
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(-)
Comments
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 >
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...
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;