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 781D9C77B71 for ; Fri, 21 Apr 2023 15:39:15 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id B4E90E94; Fri, 21 Apr 2023 17:38:22 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz B4E90E94 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1682091552; bh=n8nuWUFqDyci38iXLDh7y9WLCUFNrTKBXtqXcF3b1p8=; h=Date:From:To:Subject:In-Reply-To:References:CC:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=UDkPG6i6Q7knrgEHIUOMbU9EPbXIoirxjyGTFQxbG2mV6dS5bxhujLQAK4SsO/FRH yA2lyzkA+2FBMp9+pd6KqVimK0eel3AxXG5TfIQIP50bdoPA2sk9OBc2TZE/h3rBm6 uZHbXdgu6zk51k2GyDrQVyH7eKgGVZ0A4VJVdNV8= Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 8023EF80155; Fri, 21 Apr 2023 17:37:57 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 71693F80155; Fri, 21 Apr 2023 17:37:54 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 02656F800F8 for ; Fri, 21 Apr 2023 17:37:49 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 02656F800F8 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=mm7BQ/nm; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=kd/1dBUY 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 81A16218D5; Fri, 21 Apr 2023 15:37:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1682091469; 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=gIQMf4SltSejANF4Gl5TJd9QHAPLK+5OGd/Ed4gc4+E=; b=mm7BQ/nmqSghYxASMnnMXk+jOM4yIdtEYUg6yS1lbjvkDYxvdJoA5Zf6DuBY4EBGJGVchU NxcbTYJHoZVkwEBzudXUMo7MNqkZJslTDaG2lCnP9x6ggU6XoMHZjKKQOglxbLafFUx51Z x8Jf3TWyyahf13pD5B9g0ofsP+dEtBM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1682091469; 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=gIQMf4SltSejANF4Gl5TJd9QHAPLK+5OGd/Ed4gc4+E=; b=kd/1dBUYfltRJdnIhWVr+hiOkPu8MY5wVAFS3AVoYP8+QjebPLMt981NX49NeV9VOwKHQ9 Hzx3ajnHEUDZ7tCw== 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 443331390E; Fri, 21 Apr 2023 15:37:49 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id OZLED82tQmQiIwAAMHmgww (envelope-from ); Fri, 21 Apr 2023 15:37:49 +0000 Date: Fri, 21 Apr 2023 17:37:48 +0200 Message-ID: <87cz3xqm9f.wl-tiwai@suse.de> From: Takashi Iwai To: Chris Down Subject: Re: [PATCH] usb-audio: Rate limit usb_set_interface error reporting In-Reply-To: References: <87wn25qosu.wl-tiwai@suse.de> <87mt31qngg.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 Message-ID-Hash: 4EHMCDRQHO74KOFBQN2RQPO4L65M5Y4K X-Message-ID-Hash: 4EHMCDRQHO74KOFBQN2RQPO4L65M5Y4K X-MailFrom: tiwai@suse.de X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, Takashi Iwai X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Fri, 21 Apr 2023 17:16:59 +0200, Chris Down wrote: > > Takashi Iwai writes: > > Hrm, is "usb 3-7.1.4" really the USB audio device? The previous > > errors like "Unable to submit urb #2..." are certainly for USB audio, > > and those are with "usb 3-7.4". > > There are two USB audio devices -- 3-7.1.4 is input, 3-7.4 is output. > > % dmesg --notime | grep -e 'usb 3-7.4' -e 'usb 3-7.1.4' | grep Product: | sort | uniq > usb 3-7.1.4: Product: USB2.0 Microphone > usb 3-7.4: Product: USB Audio Device Ah I see. Then those are two different sound cards? The repeated call of usb_set_interface() might be avoided by the additional check like below. But it's still puzzling how it happens, because the only caller of endpoint_set_interface() you modified is snd_usb_endpoint_prepare(), and it's called only from snd_usb_pcm_prepare(). And, snd_usb_pcm_preapre() has the snd_usb_lock_shutdown() call, which does the check of the card->shutdown flag that should be set by the USB disconnection callback... thanks, Takashi -- 8< -- --- a/sound/usb/endpoint.c +++ b/sound/usb/endpoint.c @@ -911,6 +911,9 @@ static int endpoint_set_interface(struct snd_usb_audio *chip, if (ep->iface_ref->altset == altset) return 0; + /* already disconnected? */ + if (unlikely(atomic_read(&chip->shutdown))) + return -ENODEV; usb_audio_dbg(chip, "Setting usb interface %d:%d for EP 0x%x\n", ep->iface, altset, ep->ep_num); 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 7BF2DC77B76 for ; Fri, 21 Apr 2023 15:37:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232849AbjDUPhx (ORCPT ); Fri, 21 Apr 2023 11:37:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231955AbjDUPhv (ORCPT ); Fri, 21 Apr 2023 11:37:51 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9361E5C for ; Fri, 21 Apr 2023 08:37:50 -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-out1.suse.de (Postfix) with ESMTPS id 81A16218D5; Fri, 21 Apr 2023 15:37:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1682091469; 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=gIQMf4SltSejANF4Gl5TJd9QHAPLK+5OGd/Ed4gc4+E=; b=mm7BQ/nmqSghYxASMnnMXk+jOM4yIdtEYUg6yS1lbjvkDYxvdJoA5Zf6DuBY4EBGJGVchU NxcbTYJHoZVkwEBzudXUMo7MNqkZJslTDaG2lCnP9x6ggU6XoMHZjKKQOglxbLafFUx51Z x8Jf3TWyyahf13pD5B9g0ofsP+dEtBM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1682091469; 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=gIQMf4SltSejANF4Gl5TJd9QHAPLK+5OGd/Ed4gc4+E=; b=kd/1dBUYfltRJdnIhWVr+hiOkPu8MY5wVAFS3AVoYP8+QjebPLMt981NX49NeV9VOwKHQ9 Hzx3ajnHEUDZ7tCw== 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 443331390E; Fri, 21 Apr 2023 15:37:49 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id OZLED82tQmQiIwAAMHmgww (envelope-from ); Fri, 21 Apr 2023 15:37:49 +0000 Date: Fri, 21 Apr 2023 17:37:48 +0200 Message-ID: <87cz3xqm9f.wl-tiwai@suse.de> From: Takashi Iwai To: Chris Down Cc: linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, Jaroslav Kysela , Takashi Iwai Subject: Re: [PATCH] usb-audio: Rate limit usb_set_interface error reporting In-Reply-To: References: <87wn25qosu.wl-tiwai@suse.de> <87mt31qngg.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: linux-kernel@vger.kernel.org On Fri, 21 Apr 2023 17:16:59 +0200, Chris Down wrote: > > Takashi Iwai writes: > > Hrm, is "usb 3-7.1.4" really the USB audio device? The previous > > errors like "Unable to submit urb #2..." are certainly for USB audio, > > and those are with "usb 3-7.4". > > There are two USB audio devices -- 3-7.1.4 is input, 3-7.4 is output. > > % dmesg --notime | grep -e 'usb 3-7.4' -e 'usb 3-7.1.4' | grep Product: | sort | uniq > usb 3-7.1.4: Product: USB2.0 Microphone > usb 3-7.4: Product: USB Audio Device Ah I see. Then those are two different sound cards? The repeated call of usb_set_interface() might be avoided by the additional check like below. But it's still puzzling how it happens, because the only caller of endpoint_set_interface() you modified is snd_usb_endpoint_prepare(), and it's called only from snd_usb_pcm_prepare(). And, snd_usb_pcm_preapre() has the snd_usb_lock_shutdown() call, which does the check of the card->shutdown flag that should be set by the USB disconnection callback... thanks, Takashi -- 8< -- --- a/sound/usb/endpoint.c +++ b/sound/usb/endpoint.c @@ -911,6 +911,9 @@ static int endpoint_set_interface(struct snd_usb_audio *chip, if (ep->iface_ref->altset == altset) return 0; + /* already disconnected? */ + if (unlikely(atomic_read(&chip->shutdown))) + return -ENODEV; usb_audio_dbg(chip, "Setting usb interface %d:%d for EP 0x%x\n", ep->iface, altset, ep->ep_num);