Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp15457074rwb; Mon, 28 Nov 2022 11:48:33 -0800 (PST) X-Google-Smtp-Source: AA0mqf4N3Yc2CqAkvLimlCfGsCGni3G17XhQkRHKgAOjF1o6sVTSwRihen21Lm3doVBOtFtOTaeM X-Received: by 2002:a17:902:7686:b0:177:faf5:58c5 with SMTP id m6-20020a170902768600b00177faf558c5mr35458700pll.166.1669664913230; Mon, 28 Nov 2022 11:48:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669664913; cv=none; d=google.com; s=arc-20160816; b=vR/QyRecOz8pp0QjVnGUxkupg9S0ROoh9rPKn6PXi1j7glOTL0K1arRdpHwgZkM6Kn jJLOzHNjNQpGRlL4H1kiQNqUPy36SsSVVYpTcXv/qigsWv39ioilDKsfB4QnIt/yxfEB QWRLsdgZQD2jzrWJTz5TzhvqHBc1j1o5gsISkUxmob5hlj4smYLMFIuSPCRgR+ASB1/j uDziCGeXs02EB0ySxFPzFA7vwpOvr1x9qGH2rOQ5nTYzhkvMKtZhrn++yirk+fbBKAg9 oMAsSiBV4tbWrOj8/YfLvApr9w5zJjEvLjul/oLLMTl90/grE63UP2Ja4VWqal6pE8Xh CS+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=r137AssrJXVYmY3OjLXheXtN7yuxhyQR1OJqI3kZFPs=; b=ZbauBsVrgx++p95EJ792R97aJSflqS1RhgTe2TpvmRracWjXmsjG0GhMc25eeymrUs 2U4wkvglsMSqrDfR6mQKkjFdCdla95r+Ax8JwN+o2SbVcbgHx+JW45n5mnZiVhsbQiRB Wj/JGOaQBGl3vjiLnjlNYOuqvqiADE7IBdodtA6MpWw9vyPuDmlMWRyrnpMupKDbbV/x LusbLpzmLJSFHHBhI4Oe3FBkyXZpR7cLIqnCSHsVj4OYhOY/82gRApwayBclx83Lth7H H5OKVdBMUsF8u11rfRoi8uNt6mDg2UM0XN1J4itZz33VuFGH7qyfGByyJYKUB7X+zLRK NP9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@metanate.com header.s=stronger header.b=PNmxFpSK; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=metanate.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id om7-20020a17090b3a8700b002194ca43255si228272pjb.50.2022.11.28.11.48.21; Mon, 28 Nov 2022 11:48:33 -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; dkim=pass (test mode) header.i=@metanate.com header.s=stronger header.b=PNmxFpSK; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=metanate.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232648AbiK1TUV (ORCPT + 85 others); Mon, 28 Nov 2022 14:20:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233471AbiK1TUQ (ORCPT ); Mon, 28 Nov 2022 14:20:16 -0500 Received: from metanate.com (unknown [IPv6:2001:8b0:1628:5005::111]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5DB86245 for ; Mon, 28 Nov 2022 11:20:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=metanate.com; s=stronger; h=In-Reply-To:Content-Type:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description; bh=r137AssrJXVYmY3OjLXheXtN7yuxhyQR1OJqI3kZFPs=; b=PNmxF pSKb6RMRGqzzuajMCDJpv4MhkotfpWGbHMtdu9kol4N9HnrlbDQkgygbJlwCCX2tJHzPdoh5/Wjhe B77atnoQ9p58XZGXkaKb+Saz93tJmdVMPlk66jibn5maA+Ek7mEp6P6NEW7LVmLUWQFnJNB5K/lBL L7xCqufNay6viLEjQkf4ZqMoYDjPMEpB5TC0JgjvGRuYfXEvNCfyCLF8C6BKyAC7TqAZUY/qmNKb3 uMmWdyoqPsnxGR/plKnDaLQauLniyXOdLFd0CmNkz+CAlkbc5nCuoSvh1aUnvigfmq+mF6/9G1zTw p8AiY0rq3oZGo7tPcRslpM/iWaXiQ==; Received: from [81.174.171.191] (helo=donbot) by email.metanate.com with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1ozjfi-0006Ll-Ip; Mon, 28 Nov 2022 19:20:07 +0000 Date: Mon, 28 Nov 2022 19:20:05 +0000 From: John Keeping To: Takashi Iwai 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 Message-ID: References: <20221128122353.763696-1-john@metanate.com> <87lenvyyp8.wl-tiwai@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87lenvyyp8.wl-tiwai@suse.de> X-Authenticated: YES X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RDNS_NONE,SPF_HELO_PASS, SPF_PASS autolearn=no 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: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 28, 2022 at 02:51:15PM +0100, Takashi Iwai wrote: > 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; It seems I missed this when forward porting the patch from 5.15 - this should be setting ep->need_prepare and will change in v2. > > + 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? I /think/ this is okay because the interfaces for capture & playback are separate (although the clock is shared). There are two endpoints on the playback interface - the playback data and explicit feedback endpoints - but these are always stopped and started at the same time so I can't see any problem here. (Only the data endpoint will trigger the reset request here due to the usb_pipeout() check.)