Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2966636pxj; Mon, 17 May 2021 14:21:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzXn11kDYEdLBoQUuiA2ekWTDANwbvM2Uv81ux2MJmb3SpFc/5ZEwC4P6KYQ2KgW6p2Iv+y X-Received: by 2002:a02:b90b:: with SMTP id v11mr1982749jan.1.1621286462016; Mon, 17 May 2021 14:21:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621286462; cv=none; d=google.com; s=arc-20160816; b=Qr8E2hPI05v0413MdwUwFNU+9yUTCT0U7hCRoEapA/1eJZ/vV/68026eJcJa+5gBrb 4KeUxPi6iLrZ4bzfgL4jkowUzIqdQMK/qnDg8s2z8EgDEIag6IEW+8qBLKA04Dqd9kX0 qew6NV5A/c9+ZmdCBPVKn6jB1qUtMRLsaY8gFkp0mTzY151UtUl0t6a3uruOKaY3sDPc FnoCqvIoKUhcfoFiXrgFX7s5ABfUlzH51NjUmJjJKr30f+Y7gsRUCVWM9h82FpkJDRyS Ny0tBTwiHefN4LL42fAk3EhOj7IB6kqe3L8cv9RSFgoLMQq+FmlVtPzKMAdCWhRGLmru XCqQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=mvZK1eXmzitnMwvJ/rURpXSRKSbBNdPAsIWsgOV6og8=; b=X2qjuZ4TNvATEzhXr5HWzc2VxBDLkeX4zn7AmFk3X3zIJctwLQfE1rAQNVvLpQG38w MOpMvJLd4rjtIKZ3srMqrlOtINyHlE4eTCQox2Ah6IzSoscL+XnOOG1qdRT37ik8mdoU FSIKutk8tsUIxU6lLGezJtLUYf7hA4CXEex9Jcq08w+5qWX+UEMTlPx6zA/lGc8gh8MY W8ZPl0h1C1mXFpl7E9kW5yz9ehCj8OTLJxY7NIMWkrJreKzlaGPDhbsIQF4nJyBtXo87 sEQwIwLInyDuu6E0HHaODrk/H8BZLGAAitBrVhuf6alaCsICSucb7JyNVSsjlBUeHyV0 LluQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ac6Thoeq; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u9si20463225jat.83.2021.05.17.14.20.48; Mon, 17 May 2021 14:21:02 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=ac6Thoeq; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238484AbhEQOK4 (ORCPT + 99 others); Mon, 17 May 2021 10:10:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:60286 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236354AbhEQOIE (ORCPT ); Mon, 17 May 2021 10:08:04 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3F61761359; Mon, 17 May 2021 14:06:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621260389; bh=slT+Q2dWhK/Pdvc0JkBxSi4ZYL05dsOo7M1WRdImxtA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ac6ThoeqcusJqki2aHkRC0MLw3lvCCRneYOBN8jK8xJfR1/Vmzj78/L74TSW220ug xYyffpXSopYqIPgd4ujH2aS8pTcDMD6+8sWhZpWsU2Nsv2t9n/eET4Kqunq0vIEJQ9 mdDXhIDzClzf8BUnmzC9xJqx9FtN66grEL3MSvCk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Gyeongtaek Lee , Mark Brown , Sasha Levin Subject: [PATCH 5.12 058/363] ASoC: soc-compress: lock pcm_mutex to resolve lockdep error Date: Mon, 17 May 2021 15:58:44 +0200 Message-Id: <20210517140304.575982384@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140302.508966430@linuxfoundation.org> References: <20210517140302.508966430@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Gyeongtaek Lee [ Upstream commit 45475bf60cc1d42da229a0aa757180c88bab8d22 ] If panic_on_warn=1 is added in bootargs and compress offload playback with DPCM is started, kernel panic would be occurred because rtd->card->pcm_mutex isn't held in soc_compr_open_fe() and soc_compr_free_fe() and it generates lockdep warning in the following code. void snd_soc_runtime_action(struct snd_soc_pcm_runtime *rtd, int stream, int action) { struct snd_soc_dai *dai; int i; lockdep_assert_held(&rtd->card->pcm_mutex); To prevent lockdep warning but minimize side effect by adding mutex, pcm_mutex is held just before snd_soc_runtime_activate() and snd_soc_runtime_deactivate() and is released right after them. Signed-off-by: Gyeongtaek Lee Link: https://lore.kernel.org/r/1891546521.01617772502282.JavaMail.epsvc@epcpadp3 Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/soc-compress.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c index 246a5e32e22a..b4810266f5e5 100644 --- a/sound/soc/soc-compress.c +++ b/sound/soc/soc-compress.c @@ -153,7 +153,9 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream) fe->dpcm[stream].state = SND_SOC_DPCM_STATE_OPEN; fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO; + mutex_lock_nested(&fe->card->pcm_mutex, fe->card->pcm_subclass); snd_soc_runtime_activate(fe, stream); + mutex_unlock(&fe->card->pcm_mutex); mutex_unlock(&fe->card->mutex); @@ -181,7 +183,9 @@ static int soc_compr_free_fe(struct snd_compr_stream *cstream) mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME); + mutex_lock_nested(&fe->card->pcm_mutex, fe->card->pcm_subclass); snd_soc_runtime_deactivate(fe, stream); + mutex_unlock(&fe->card->pcm_mutex); fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE; -- 2.30.2