From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 24298C433FE for ; Tue, 22 Nov 2022 08:47:21 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 76FAE1614; Tue, 22 Nov 2022 09:46:29 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 76FAE1614 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1669106839; bh=4m5iGelGiyO17ITA9wzWjgZpqArhb3vr2tARRLjkmKw=; h=Date:From:To:Subject:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=h3v36Mh62/aiel+KIahxTRn8sIFUjEBRPQMSMy5JHz4WPfsRKHHUEzP1tkcHM5zhH cu/953xz2K0B5vY92Pau7cg6QnJRDPVy4v0r3piyocJzUdtroBaWDd3+ixiH0lnvlx A+dNttsce4HcKkYV4UgGWnY/rk2iDDLwEIDcwVjo= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 1922AF80115; Tue, 22 Nov 2022 09:46:29 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 06A3DF80272; Tue, 22 Nov 2022 09:46:28 +0100 (CET) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id BA3FFF80115 for ; Tue, 22 Nov 2022 09:46:21 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz BA3FFF80115 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="XeVfiBP9"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="hB/jCjDJ" Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id BF2331F86C; Tue, 22 Nov 2022 08:46:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1669106780; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=dXel8N1xdWLbkJWBa3cPHmwpPDZdmAoVd+uJGgsXh4A=; b=XeVfiBP9oK2YcOJON2fbP20TLQCkdS1CpOlcmLSDbN+w8OK3PvZSauF9KZTVYqxemH2xI+ n/Tl0WUAN1Sq1ifXz6rQjj2uWlhEEjiJo2H9v+QnEfUVafoV5EgosHU5GbC1LeJPjSyfEX aOomPsUzHypUqpuj0hpb2ucRAdFXF6k= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1669106780; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=dXel8N1xdWLbkJWBa3cPHmwpPDZdmAoVd+uJGgsXh4A=; b=hB/jCjDJEXLoJ1JadX6vM2lN/Kb+ltO0/n2a70XTNU1meIXRXp/n/LU7X6S5jAdebFtwUp IXr9wLlR/JN7yODw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 9929113B01; Tue, 22 Nov 2022 08:46:20 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id iefMJFyMfGNHJAAAMHmgww (envelope-from ); Tue, 22 Nov 2022 08:46:20 +0000 Date: Tue, 22 Nov 2022 09:46:20 +0100 Message-ID: <87tu2rv0kj.wl-tiwai@suse.de> From: Takashi Iwai To: Michael Wu Subject: Re: [PATCH] ALSA: usb-audio: fix urb timeout with URB_ISO_ASAP flag In-Reply-To: <20221122082040.48591-1-michael@allwinnertech.com> References: <20221122082040.48591-1-michael@allwinnertech.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) Emacs/27.2 Mule/6.0 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Cc: alsa-devel@alsa-project.org, wanjiabing@vivo.com, aichao@kylinos.cn, ubizjak@gmail.com, tiwai@suse.com, linux-kernel@vger.kernel.org X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" 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 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 > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 92726C4332F for ; Tue, 22 Nov 2022 08:46:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232459AbiKVIq1 (ORCPT ); Tue, 22 Nov 2022 03:46:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230284AbiKVIqX (ORCPT ); Tue, 22 Nov 2022 03:46:23 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CA6F28E37 for ; Tue, 22 Nov 2022 00:46:22 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id BF2331F86C; Tue, 22 Nov 2022 08:46:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1669106780; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=dXel8N1xdWLbkJWBa3cPHmwpPDZdmAoVd+uJGgsXh4A=; b=XeVfiBP9oK2YcOJON2fbP20TLQCkdS1CpOlcmLSDbN+w8OK3PvZSauF9KZTVYqxemH2xI+ n/Tl0WUAN1Sq1ifXz6rQjj2uWlhEEjiJo2H9v+QnEfUVafoV5EgosHU5GbC1LeJPjSyfEX aOomPsUzHypUqpuj0hpb2ucRAdFXF6k= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1669106780; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=dXel8N1xdWLbkJWBa3cPHmwpPDZdmAoVd+uJGgsXh4A=; b=hB/jCjDJEXLoJ1JadX6vM2lN/Kb+ltO0/n2a70XTNU1meIXRXp/n/LU7X6S5jAdebFtwUp IXr9wLlR/JN7yODw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 9929113B01; Tue, 22 Nov 2022 08:46:20 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id iefMJFyMfGNHJAAAMHmgww (envelope-from ); Tue, 22 Nov 2022 08:46:20 +0000 Date: Tue, 22 Nov 2022 09:46:20 +0100 Message-ID: <87tu2rv0kj.wl-tiwai@suse.de> From: Takashi Iwai To: Michael Wu Cc: perex@perex.cz, tiwai@suse.com, aichao@kylinos.cn, wanjiabing@vivo.com, ubizjak@gmail.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] ALSA: usb-audio: fix urb timeout with URB_ISO_ASAP flag In-Reply-To: <20221122082040.48591-1-michael@allwinnertech.com> References: <20221122082040.48591-1-michael@allwinnertech.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) Emacs/27.2 Mule/6.0 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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 >