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 2D251C54EE9 for ; Wed, 7 Sep 2022 09:42:35 +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 476ED1E8; Wed, 7 Sep 2022 11:41:43 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 476ED1E8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1662543753; bh=mdnbTjysnb+CsmA3fsADc9q6d17xIUOv8MbSo9YAqFo=; h=Date:From:To:Subject:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=IX5u3sgya33fY1v28IXsDZKYTXiEQqeDGiZEYTM+U8TFVk3YYA5eZQBTTvsj/SqLu 9+BFxziQa6NetSd586PhYlymrtaKkbzsbhFd1nh/EoD2qF8qsSmmqfHfmRwLA3hAdW No4PTSkK5LSV2EsKrIM3faeb95i6bf1rLzh9LtCM= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id D3F51F80249; Wed, 7 Sep 2022 11:41:42 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 51980F8023B; Wed, 7 Sep 2022 11:41:41 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) (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 35947F8023B for ; Wed, 7 Sep 2022 11:41:34 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 35947F8023B Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="pdv/adkq"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="tfRWsEJs" 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 5E3CA20244; Wed, 7 Sep 2022 09:41:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1662543694; 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=ze00JS9YGRsmAOsgdNY0pIe743MLOM0ULC1uIhk+gSI=; b=pdv/adkqMdjWaF2y66ATUsR60vbM0O7UPXb51iHgb0pEVrf2UvXNh2FnzLyBfipQ/7kGYo 4+nN5w1A8fFBp5LhtY2fDYqTFJPASxc7vdDUIuDH9ZOcJLBO/yrlNdKmXgqDz6vy5c8b06 DYke03vLgwuchnkpTR9hkqh0pmQJrxg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1662543694; 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=ze00JS9YGRsmAOsgdNY0pIe743MLOM0ULC1uIhk+gSI=; b=tfRWsEJswRREbJ4G7TnFuakduyK92hysTRuQg0+KaImRZDoFb9k3Qum09HGJppbgLLictf Hh1c6TT5AnnyJwCA== 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 4A08813486; Wed, 7 Sep 2022 09:41:34 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 1TesEU5nGGMwNQAAMHmgww (envelope-from ); Wed, 07 Sep 2022 09:41:34 +0000 Date: Wed, 07 Sep 2022 11:41:33 +0200 Message-ID: <878rmvmshe.wl-tiwai@suse.de> From: Takashi Iwai To: "Jason A. Donenfeld" Subject: Re: [PATCH] ALSA: usb-audio: Don't refcount multiple accesses on the single clock In-Reply-To: References: <20220905101403.1435037-1-Jason@zx2c4.com> <87sfl6jbb3.wl-tiwai@suse.de> <87czc7ehqp.wl-tiwai@suse.de> 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, Wim Taymans , =?ISO-8859-4?Q?Nikl=E0vs_Ko=B6es=F1ikovs?= <89q1r14hd@relay.firefox.com>, LKML , stable 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 Wed, 07 Sep 2022 11:28:54 +0200, Jason A. Donenfeld wrote: > > On Wed, Sep 07, 2022 at 10:00:46AM +0200, Takashi Iwai wrote: > > On Mon, 05 Sep 2022 14:16:39 +0200, > > Jason A. Donenfeld wrote: > > > > > > On Mon, Sep 5, 2022 at 1:44 PM Takashi Iwai wrote: > > > > When you load snd-usb-audio with dyndbg=+p option, does it show the > > > > new error message "Mismatched sample rate xxx"? > > > > > > No. > > > > What about the patch below? > > > > > > Takashi > > > > -- 8< -- > > --- a/sound/usb/endpoint.c > > +++ b/sound/usb/endpoint.c > > @@ -925,6 +925,8 @@ void snd_usb_endpoint_close(struct snd_usb_audio *chip, > > endpoint_set_interface(chip, ep, false); > > > > if (!--ep->opened) { > > + if (ep->clock_ref && !atomic_read(&ep->clock_ref->locked)) > > + ep->clock_ref->rate = 0; > > ep->iface = 0; > > ep->altsetting = 0; > > ep->cur_audiofmt = NULL; > > I think this works. OK, thanks. If this patch fixes, the problem is that the behavior of the applications that do only PCM prepare without actually starting, then closes. This left the last set rate unexpectedly. I'm going to write up the proper patch. 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 BEB35ECAAD3 for ; Wed, 7 Sep 2022 09:41:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229793AbiIGJlk (ORCPT ); Wed, 7 Sep 2022 05:41:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229889AbiIGJlk (ORCPT ); Wed, 7 Sep 2022 05:41:40 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB3A6816AC; Wed, 7 Sep 2022 02:41:35 -0700 (PDT) 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 5E3CA20244; Wed, 7 Sep 2022 09:41:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1662543694; 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=ze00JS9YGRsmAOsgdNY0pIe743MLOM0ULC1uIhk+gSI=; b=pdv/adkqMdjWaF2y66ATUsR60vbM0O7UPXb51iHgb0pEVrf2UvXNh2FnzLyBfipQ/7kGYo 4+nN5w1A8fFBp5LhtY2fDYqTFJPASxc7vdDUIuDH9ZOcJLBO/yrlNdKmXgqDz6vy5c8b06 DYke03vLgwuchnkpTR9hkqh0pmQJrxg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1662543694; 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=ze00JS9YGRsmAOsgdNY0pIe743MLOM0ULC1uIhk+gSI=; b=tfRWsEJswRREbJ4G7TnFuakduyK92hysTRuQg0+KaImRZDoFb9k3Qum09HGJppbgLLictf Hh1c6TT5AnnyJwCA== 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 4A08813486; Wed, 7 Sep 2022 09:41:34 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 1TesEU5nGGMwNQAAMHmgww (envelope-from ); Wed, 07 Sep 2022 09:41:34 +0000 Date: Wed, 07 Sep 2022 11:41:33 +0200 Message-ID: <878rmvmshe.wl-tiwai@suse.de> From: Takashi Iwai To: "Jason A. Donenfeld" Cc: alsa-devel@alsa-project.org, LKML , stable , =?ISO-8859-4?Q?Nikl=E0vs_Ko=B6es=F1ikovs?= <89q1r14hd@relay.firefox.com>, Wim Taymans Subject: Re: [PATCH] ALSA: usb-audio: Don't refcount multiple accesses on the single clock In-Reply-To: References: <20220905101403.1435037-1-Jason@zx2c4.com> <87sfl6jbb3.wl-tiwai@suse.de> <87czc7ehqp.wl-tiwai@suse.de> 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: stable@vger.kernel.org On Wed, 07 Sep 2022 11:28:54 +0200, Jason A. Donenfeld wrote: > > On Wed, Sep 07, 2022 at 10:00:46AM +0200, Takashi Iwai wrote: > > On Mon, 05 Sep 2022 14:16:39 +0200, > > Jason A. Donenfeld wrote: > > > > > > On Mon, Sep 5, 2022 at 1:44 PM Takashi Iwai wrote: > > > > When you load snd-usb-audio with dyndbg=+p option, does it show the > > > > new error message "Mismatched sample rate xxx"? > > > > > > No. > > > > What about the patch below? > > > > > > Takashi > > > > -- 8< -- > > --- a/sound/usb/endpoint.c > > +++ b/sound/usb/endpoint.c > > @@ -925,6 +925,8 @@ void snd_usb_endpoint_close(struct snd_usb_audio *chip, > > endpoint_set_interface(chip, ep, false); > > > > if (!--ep->opened) { > > + if (ep->clock_ref && !atomic_read(&ep->clock_ref->locked)) > > + ep->clock_ref->rate = 0; > > ep->iface = 0; > > ep->altsetting = 0; > > ep->cur_audiofmt = NULL; > > I think this works. OK, thanks. If this patch fixes, the problem is that the behavior of the applications that do only PCM prepare without actually starting, then closes. This left the last set rate unexpectedly. I'm going to write up the proper patch. Takashi