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);