Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp5457956pxu; Tue, 22 Dec 2020 18:39:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJzFO74KjNvYzQA3KA4O7fEosCJMOpNHR2Qj5NqUubv5eEVbo2CRviXVOMFsw59KtcLPyvKx X-Received: by 2002:a17:906:c1c6:: with SMTP id bw6mr22901919ejb.199.1608691193443; Tue, 22 Dec 2020 18:39:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608691193; cv=none; d=google.com; s=arc-20160816; b=TjHC84qqCSh7lifZBrWsXLiscfli933iiBzMU6Fuj0NUSqxSZwuwcSuEAajpWqBv+S O8ktgKKo9B+4pIu5RlGZ9c8zneTBiY/9bgrTD0pkm9JFKcx3Yex42MiyaDibVYKN1brX Qgicj2/HvL275HFbpiWPt/7qibf6oXpDeBKviZVrevd+k1ZhVxmYfOo4jCx/ycknr1yX lKgxC0Ra27xbWZVZeN/rM8nTZImjseeQMcO05OCmZyPL6azoYDbP/FVlZrxwS4ybk7iI 2UpWVzO0f43oj4sOl4+MMUJdyb/hz4RKckzfjcFuxvVzgZLN5N22fOm0+drpDLhscDt6 yPgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=a2arXbhiXx9O5D+zGX2lImEwMZ2yCIDRDjE4N2Z/qcY=; b=GrPEoKHleg/JE6HzUlYyZiBJTxJz0Ui72OoSRdvghnKS0MIPHh5dBED78Gb0L1dDC5 IGSD5SMWXnqXDEQEi0On2la6I0043+wGxansUPzWuXhCQiJMuUx0v/tNFibbc5wd6bz2 KBh1hdcedabkI7mbI1Ywp1MP31JibXVu464wzGSklAgL4d77OFygovyY+WAK0zdxW9Nx x63Ue7MYkcnumcuJHJ/2m6OaWMG5b47+iSy9YaVyL7tbxP3h9XK3DNZvjE+eDHrleBc+ WGFMLF5K2U5v8axUHsd4dFzDWVh371TFxqsyX7jMJ4/eQWOufTLM174FMcrVZWEFL9nO 85Kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gq56vUSD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t12si16330676edc.228.2020.12.22.18.39.31; Tue, 22 Dec 2020 18:39:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gq56vUSD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730184AbgLWCYV (ORCPT + 99 others); Tue, 22 Dec 2020 21:24:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:54080 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728523AbgLWCYM (ORCPT ); Tue, 22 Dec 2020 21:24:12 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4B01622273; Wed, 23 Dec 2020 02:23:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1608690212; bh=8/9mTcfvkzgNMCWVtLKeifjY/iJKLM5eRp/Y9Ydkqtw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gq56vUSDYk8v65Q0GCi70H4MXF7n9C9LPmZN4e1/CHQW/CGbeh0GvfSAjOwAHi9n8 j4we64PbPxpov9aqL7O+kF12f/LVn0+iyvh0GbLO5sEM6UxcINK1Z/GrFI6poYmCKg 5j8nUE3lxeQkmrRDu8yX3t5lg988QzAc+V7412509xbKxG3i8ai9iB2cEIjGoAYH6Q htqs7a2zbFGVeVHyYsSJYzwpgo6/pjTokH3BlTLLRnYNd5S1P19Omfmb1OFO20CmOY bgIM4dljobpxp+OHG74ltPWVF/jVeiIhsA6Tw4j7Q2IuvGQNIzGbvuG7eX0JwlMNkF s63weQF808EpQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Takashi Iwai , Keith Milner , Dylan Robinson , Sasha Levin , alsa-devel@alsa-project.org Subject: [PATCH AUTOSEL 4.14 31/66] ALSA: usb-audio: Don't call usb_set_interface() at trigger callback Date: Tue, 22 Dec 2020 21:22:17 -0500 Message-Id: <20201223022253.2793452-31-sashal@kernel.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201223022253.2793452-1-sashal@kernel.org> References: <20201223022253.2793452-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 6caf94581a0e8..1ed4a7c094c48 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