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 BFAE1C43217 for ; Mon, 28 Nov 2022 13:52:15 +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 3B54116CE; Mon, 28 Nov 2022 14:51:23 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 3B54116CE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1669643533; bh=v3YZpEf7jpmXFCxNmwP3HAh9E9Aa984s0XhNT5/lda8=; h=Date:From:To:Subject:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=NDgHYdmplrJ6fvslXk3t31k/GSQkBI0DJvKOVg1xanO4rK6YZyEeCVqKqwQFgrtNQ IqPUzcgEqucI3twKIlUE9K89OQTY64rOR7l444pJfkPEc0mkYDkbFyasILVKIBxWWJ b/1NFJbqBUeg1VT6pTDz6TEskkjh88Md02SNmIF8= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id EAEAFF801D8; Mon, 28 Nov 2022 14:51:22 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 57BABF8020D; Mon, 28 Nov 2022 14:51:22 +0100 (CET) Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) (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 44FE0F800B6 for ; Mon, 28 Nov 2022 14:51:16 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 44FE0F800B6 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="tb4dXBk9"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="9n45SyRa" 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-out1.suse.de (Postfix) with ESMTPS id 9DB4721B8A; Mon, 28 Nov 2022 13:51:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1669643475; 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=bOLaMPxOUG7+4vSlzBdUMwRrj0JlFA0stWHUkYrEcl0=; b=tb4dXBk9E7uOnfLm/jK09MAtSuGeVbvX6bCRzTOUyE+Me+WcmVUbJrEUt6ZzUzTNsyxs8N 5aFhdfa/4Mrmbt1ih0yhNPrA7a9K9WNqZhwm2ozWl/xNtoF1rjiPstMJS505SiHkNGs6ne 4LeQy9fB6JEU9HNFyfd5KOuQZyK40sE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1669643475; 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=bOLaMPxOUG7+4vSlzBdUMwRrj0JlFA0stWHUkYrEcl0=; b=9n45SyRa82AFe61XqCIG9WmD1Zciit8L0w9BUBrIdwvZ0drp0HlLjsFxRo88uQdEdZ4IMZ pNEDcwZyT9/8iGDw== 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 7CCFE1326E; Mon, 28 Nov 2022 13:51:15 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id A/2xHdO8hGP/EgAAMHmgww (envelope-from ); Mon, 28 Nov 2022 13:51:15 +0000 Date: Mon, 28 Nov 2022 14:51:15 +0100 Message-ID: <87lenvyyp8.wl-tiwai@suse.de> From: Takashi Iwai To: John Keeping Subject: Re: [PATCH] ALSA: usb-audio: Add quirk for Tascam Model 12 In-Reply-To: <20221128122353.763696-1-john@metanate.com> References: <20221128122353.763696-1-john@metanate.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: linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, Takashi Iwai 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 Mon, 28 Nov 2022 13:23:52 +0100, John Keeping wrote: > > Tascam's Model 12 is a mixer which can also operate as a USB audio > interface. The audio interface uses explicit feedback but it seems that > it does not correctly handle missing isochronous frames. > > When injecting an xrun (or doing anything else that pauses the playback > stream) the feedback rate climbs (for example, at 44,100Hz nominal, I > see a stable rate around 44,099 but xrun injection sees this peak at > around 44,135 in most cases) and glitches are heard in the audio stream > for several seconds - this is significantly worse than the single glitch > expected for an underrun. > > While the stream does normally recover and the feedback rate returns to > a stable value, I have seen some occurrences where this does not happen > and the rate continues to increase while no audio is heard from the > output. I have not found a solid reproduction for this. > > This misbehaviour can be avoided by totally resetting the stream state > by switching the interface to alt 0 and back before restarting the > playback stream. > > Add a new quirk flag which forces the endpoint and interface to be > reconfigured whenever the stream is stopped, and use this for the Tascam > Model 12. > > Signed-off-by: John Keeping Thanks for the patch, it's an interesting case. About the code change: > --- a/sound/usb/endpoint.c > +++ b/sound/usb/endpoint.c > @@ -1673,6 +1673,13 @@ void snd_usb_endpoint_stop(struct snd_usb_endpoint *ep, bool keep_pending) > stop_urbs(ep, false, keep_pending); > if (ep->clock_ref) > atomic_dec(&ep->clock_ref->locked); > + > + if (ep->chip->quirk_flags & QUIRK_FLAG_FORCE_IFACE_RESET && > + usb_pipeout(ep->pipe)) { > + ep->need_setup = true; > + if (ep->iface_ref) > + ep->iface_ref->need_setup = true; > + } Is this the forced reset always safe? Imagine that you have individual playback and capture streams, and what if only one of them gets stopped and restarted while another keeps running? thanks, Takashi 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 D9113C433FE for ; Mon, 28 Nov 2022 13:51:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232146AbiK1NvW (ORCPT ); Mon, 28 Nov 2022 08:51:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231445AbiK1NvR (ORCPT ); Mon, 28 Nov 2022 08:51:17 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F16EC1EC50 for ; Mon, 28 Nov 2022 05:51:16 -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-out1.suse.de (Postfix) with ESMTPS id 9DB4721B8A; Mon, 28 Nov 2022 13:51:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1669643475; 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=bOLaMPxOUG7+4vSlzBdUMwRrj0JlFA0stWHUkYrEcl0=; b=tb4dXBk9E7uOnfLm/jK09MAtSuGeVbvX6bCRzTOUyE+Me+WcmVUbJrEUt6ZzUzTNsyxs8N 5aFhdfa/4Mrmbt1ih0yhNPrA7a9K9WNqZhwm2ozWl/xNtoF1rjiPstMJS505SiHkNGs6ne 4LeQy9fB6JEU9HNFyfd5KOuQZyK40sE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1669643475; 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=bOLaMPxOUG7+4vSlzBdUMwRrj0JlFA0stWHUkYrEcl0=; b=9n45SyRa82AFe61XqCIG9WmD1Zciit8L0w9BUBrIdwvZ0drp0HlLjsFxRo88uQdEdZ4IMZ pNEDcwZyT9/8iGDw== 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 7CCFE1326E; Mon, 28 Nov 2022 13:51:15 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id A/2xHdO8hGP/EgAAMHmgww (envelope-from ); Mon, 28 Nov 2022 13:51:15 +0000 Date: Mon, 28 Nov 2022 14:51:15 +0100 Message-ID: <87lenvyyp8.wl-tiwai@suse.de> From: Takashi Iwai To: John Keeping Cc: alsa-devel@alsa-project.org, Jaroslav Kysela , Takashi Iwai , linux-kernel@vger.kernel.org Subject: Re: [PATCH] ALSA: usb-audio: Add quirk for Tascam Model 12 In-Reply-To: <20221128122353.763696-1-john@metanate.com> References: <20221128122353.763696-1-john@metanate.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 Mon, 28 Nov 2022 13:23:52 +0100, John Keeping wrote: > > Tascam's Model 12 is a mixer which can also operate as a USB audio > interface. The audio interface uses explicit feedback but it seems that > it does not correctly handle missing isochronous frames. > > When injecting an xrun (or doing anything else that pauses the playback > stream) the feedback rate climbs (for example, at 44,100Hz nominal, I > see a stable rate around 44,099 but xrun injection sees this peak at > around 44,135 in most cases) and glitches are heard in the audio stream > for several seconds - this is significantly worse than the single glitch > expected for an underrun. > > While the stream does normally recover and the feedback rate returns to > a stable value, I have seen some occurrences where this does not happen > and the rate continues to increase while no audio is heard from the > output. I have not found a solid reproduction for this. > > This misbehaviour can be avoided by totally resetting the stream state > by switching the interface to alt 0 and back before restarting the > playback stream. > > Add a new quirk flag which forces the endpoint and interface to be > reconfigured whenever the stream is stopped, and use this for the Tascam > Model 12. > > Signed-off-by: John Keeping Thanks for the patch, it's an interesting case. About the code change: > --- a/sound/usb/endpoint.c > +++ b/sound/usb/endpoint.c > @@ -1673,6 +1673,13 @@ void snd_usb_endpoint_stop(struct snd_usb_endpoint *ep, bool keep_pending) > stop_urbs(ep, false, keep_pending); > if (ep->clock_ref) > atomic_dec(&ep->clock_ref->locked); > + > + if (ep->chip->quirk_flags & QUIRK_FLAG_FORCE_IFACE_RESET && > + usb_pipeout(ep->pipe)) { > + ep->need_setup = true; > + if (ep->iface_ref) > + ep->iface_ref->need_setup = true; > + } Is this the forced reset always safe? Imagine that you have individual playback and capture streams, and what if only one of them gets stopped and restarted while another keeps running? thanks, Takashi