Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 04AE0C43381 for ; Wed, 23 Dec 2020 02:25:45 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 86517229CA for ; Wed, 23 Dec 2020 02:25:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 86517229CA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org 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 1DA781802; Wed, 23 Dec 2020 03:24:53 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 1DA781802 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1608690343; bh=ZVKz6YYdYlSmUSkdGxVvR4U/1tFvgjIlZOECnL+jpz8=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=n/VnnYhsq6xEIcOezmlv9BbnV0/N+UwXnkn3fVz1/JqEU0+AK2JonDx55bS42G2ii WFqtuGRFKz+GdT111ca9xvkWWA64Skck9ng+r4J/kQU21oVvZdZ+kXFQOkVGmrCmL4 Mapef4SV8jy20GUbz9uHZ55rm1N2P14RVdEWFOwg= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 9DCE3F800BC; Wed, 23 Dec 2020 03:24:52 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id D84D5F8028D; Wed, 23 Dec 2020 03:24:50 +0100 (CET) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 0EF99F800BC for ; Wed, 23 Dec 2020 03:24:45 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 0EF99F800BC Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="eYsrdNEz" Received: by mail.kernel.org (Postfix) with ESMTPSA id C25792222D; Wed, 23 Dec 2020 02:24:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1608690283; bh=ZVKz6YYdYlSmUSkdGxVvR4U/1tFvgjIlZOECnL+jpz8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eYsrdNEziAqp79Vaxv/Ix9pogI5rFzcY0JyBbG71T8GZtdqcoF/o+6vmUM2B833dw cqiVR3dFtBHD21HVTJc4wP83w2tBGv7yhqTP+p+FB/+Apz4eVKlQLiRPI53TN0P178 01fpb6xJohFMABXFY8oAALWiR2Wgwh4XOIsxGrtUJ/XXhNPjzsX7kKWp3uIyQGoQEe ViTxSBYpvBhiiF/2LT4I7kn6h6XTrGDAQ63aFQvHI6zAePt/R1rfN63D6sdAQ8ichy wM3844fxzSGw92xHT5qQ7WN1qlPokiG5DcvJYGn810DHPLrU03Y3XwycKEj5+Ts/Ra rqZvykV2cVgAw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH AUTOSEL 4.9 22/48] ALSA: usb-audio: Don't call usb_set_interface() at trigger callback Date: Tue, 22 Dec 2020 21:23:50 -0500 Message-Id: <20201223022417.2794032-22-sashal@kernel.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201223022417.2794032-1-sashal@kernel.org> References: <20201223022417.2794032-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Cc: Takashi Iwai , Sasha Levin , alsa-devel@alsa-project.org, Dylan Robinson , Keith Milner 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" From: Takashi Iwai [ Upstream commit 4974b7950929e4a28d4eaee48e4ad07f168ac132 ] The PCM trigger callback is atomic, hence we must not call a function like usb_set_interface() there. Calling it from there would lead to a kernel Oops. Fix it by moving the usb_set_interface() call to set_sync_endpoint(). Also, apply the snd_usb_set_interface_quirk() for consistency, too. Tested-by: Keith Milner Tested-by: Dylan Robinson Link: https://lore.kernel.org/r/20201123085347.19667-3-tiwai@suse.de Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin --- sound/usb/pcm.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c index 95d02e25a3133..77c704847e4ac 100644 --- a/sound/usb/pcm.c +++ b/sound/usb/pcm.c @@ -242,21 +242,6 @@ static int start_endpoints(struct snd_usb_substream *subs) !test_and_set_bit(SUBSTREAM_FLAG_SYNC_EP_STARTED, &subs->flags)) { struct snd_usb_endpoint *ep = subs->sync_endpoint; - if (subs->data_endpoint->iface != subs->sync_endpoint->iface || - subs->data_endpoint->altsetting != subs->sync_endpoint->altsetting) { - err = usb_set_interface(subs->dev, - subs->sync_endpoint->iface, - subs->sync_endpoint->altsetting); - if (err < 0) { - clear_bit(SUBSTREAM_FLAG_SYNC_EP_STARTED, &subs->flags); - dev_err(&subs->dev->dev, - "%d:%d: cannot set interface (%d)\n", - subs->sync_endpoint->iface, - subs->sync_endpoint->altsetting, err); - return -EIO; - } - } - dev_dbg(&subs->dev->dev, "Starting sync EP @%p\n", ep); ep->sync_slave = subs->data_endpoint; @@ -499,6 +484,19 @@ static int set_sync_endpoint(struct snd_usb_substream *subs, subs->data_endpoint->sync_master = subs->sync_endpoint; + if (subs->data_endpoint->iface != subs->sync_endpoint->iface || + subs->data_endpoint->altsetting != subs->sync_endpoint->altsetting) { + err = usb_set_interface(subs->dev, + subs->sync_endpoint->iface, + subs->sync_endpoint->altsetting); + if (err < 0) + return err; + dev_dbg(&dev->dev, "setting usb interface %d:%d\n", + subs->sync_endpoint->iface, + subs->sync_endpoint->altsetting); + snd_usb_set_interface_quirk(dev); + } + return 0; } -- 2.27.0