Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp8142995ybl; Tue, 24 Dec 2019 16:10:26 -0800 (PST) X-Google-Smtp-Source: APXvYqwzLajQyL7reGJnKMCBB95mx4TloVui/oGJZLD9BrSeXg3ef4q/KQZC554cgr1w/KRG15tG X-Received: by 2002:aca:52cd:: with SMTP id g196mr1346782oib.18.1577232626239; Tue, 24 Dec 2019 16:10:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577232626; cv=none; d=google.com; s=arc-20160816; b=ySP7bmsrik0e95AS1Vqs3U4t4/b2BJqhDUMBgvo263k5PghhV97YWUr8xaQNTHvSEE mlf/7b1tYrB8WakQ2IczrDzdNJxlzMMQALZkw4g6ifipaMyul3m2htgV5zQTyxoJTbB3 7OnOqrsF2AfqxlSKXN2VsaAJBl5wlZIVRtLyVQTiTuGLyE+iGbv4ZstLsxnh3icplixe L9Q7LGXcUx2DaxnJHX/hpm9dJIgTqZz2tDCJFV8LcMczBYAp/VXwI9VK4KMqm5SM1JYe dbhbz2CiT8ZrgIgm9TsEg8+ZBdPF3yTge6ZxznqJvwPbB89V5nm40YjsjdI9/sOWFUE6 e/5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:message-id:in-reply-to:subject:cc:to :from:dkim-signature; bh=2GeG6xR/J7VM2a/ObwQ0fm8SxgMna4I+z6ph1YDl5Rs=; b=kAsD6zpgLYOY43O4rRgv+p1x5KsUFFLQoGIEsAYKIWhjsRa1IDpvy/u1JISBEaWIu0 +uZFFwI8u2+j3Mw5reXx6b+cNo8vLBc549fursDsHYeOcCjKQ7meIKeKHbTQoRz3wj6H VR1pVY+GzI0FRGl6XWxFU4MvcjoRhahhQfs6JmHaCewEpYWgIT3jksRbalCQAk6k0E8P E1uaVmjyutogLPV0Vsx/oG9l60apBPKsWhVcqjogn8HtiALdUFVsaVHUkDFdn6GDMGwO mKntS9cG+Cxga+jKSMi7MMb5GdSdgPYqPExfS6PDWRBksnprX3Hg0ztrjLbdg6e7iE9/ plUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=LfGTMjJE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l19si11401707oii.54.2019.12.24.16.10.14; Tue, 24 Dec 2019 16:10:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=LfGTMjJE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727056AbfLYAJ0 (ORCPT + 99 others); Tue, 24 Dec 2019 19:09:26 -0500 Received: from heliosphere.sirena.org.uk ([172.104.155.198]:33446 "EHLO heliosphere.sirena.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726375AbfLYAJP (ORCPT ); Tue, 24 Dec 2019 19:09:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sirena.org.uk; s=20170815-heliosphere; h=Date:Message-Id:In-Reply-To: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner: List-Archive; bh=2GeG6xR/J7VM2a/ObwQ0fm8SxgMna4I+z6ph1YDl5Rs=; b=LfGTMjJEKuyE ea2zyxLVkyi/yF1/sjsO/UviCdqxEIx6SmUAf7MFxvGMd6I8DPh1SDStqKKqQXjLH489wNc3RxTX3 XIJvnfZFcRRD6MmFMjE8SqAl826vjxoKHWJbEacnMcrwy4WqFPWWimrMW2kz7gYxPh4hzAfikFEGO oNTC4=; Received: from cpc102320-sgyl38-2-0-cust46.18-2.cable.virginm.net ([82.37.168.47] helo=fitzroy.sirena.org.uk) by heliosphere.sirena.org.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ijuEd-0007M2-Vr; Wed, 25 Dec 2019 00:09:08 +0000 Received: by fitzroy.sirena.org.uk (Postfix, from userid 1000) id 7D617D01957; Wed, 25 Dec 2019 00:09:07 +0000 (GMT) From: Mark Brown To: Olivier Moysan Cc: alexandre.torgue@st.com, alsa-devel@alsa-project.org, broonie@kernel.org, lgirdwood@gmail.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, Mark Brown , mcoquelin.stm32@gmail.com, olivier.moysan@st.com, perex@perex.cz, tiwai@suse.com Subject: Applied "ASoC: stm32: spdifrx: fix inconsistent lock state" to the asoc tree In-Reply-To: <20191204154333.7152-2-olivier.moysan@st.com> Message-Id: X-Patchwork-Hint: ignore Date: Wed, 25 Dec 2019 00:09:07 +0000 (GMT) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The patch ASoC: stm32: spdifrx: fix inconsistent lock state has been applied to the asoc tree at https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark From 2859b1784031b5709446af8f6039c467f136e67d Mon Sep 17 00:00:00 2001 From: Olivier Moysan Date: Wed, 4 Dec 2019 16:43:31 +0100 Subject: [PATCH] ASoC: stm32: spdifrx: fix inconsistent lock state In current spdifrx driver locks may be requested as follows: - request lock on iec capture control, when starting synchronization. - request lock in interrupt context, when spdifrx stop is called from IRQ handler. Take lock with IRQs disabled, to avoid the possible deadlock. Lockdep report: [ 74.278059] ================================ [ 74.282306] WARNING: inconsistent lock state [ 74.290120] -------------------------------- ... [ 74.314373] CPU0 [ 74.314377] ---- [ 74.314381] lock(&(&spdifrx->lock)->rlock); [ 74.314396] [ 74.314400] lock(&(&spdifrx->lock)->rlock); Fixes: 03e4d5d56fa5 ("ASoC: stm32: Add SPDIFRX support") Signed-off-by: Olivier Moysan Link: https://lore.kernel.org/r/20191204154333.7152-2-olivier.moysan@st.com Signed-off-by: Mark Brown --- sound/soc/stm/stm32_spdifrx.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sound/soc/stm/stm32_spdifrx.c b/sound/soc/stm/stm32_spdifrx.c index 3fd28ee01675..9c6beb610c17 100644 --- a/sound/soc/stm/stm32_spdifrx.c +++ b/sound/soc/stm/stm32_spdifrx.c @@ -320,6 +320,7 @@ static void stm32_spdifrx_dma_ctrl_stop(struct stm32_spdifrx_data *spdifrx) static int stm32_spdifrx_start_sync(struct stm32_spdifrx_data *spdifrx) { int cr, cr_mask, imr, ret; + unsigned long flags; /* Enable IRQs */ imr = SPDIFRX_IMR_IFEIE | SPDIFRX_IMR_SYNCDIE | SPDIFRX_IMR_PERRIE; @@ -327,7 +328,7 @@ static int stm32_spdifrx_start_sync(struct stm32_spdifrx_data *spdifrx) if (ret) return ret; - spin_lock(&spdifrx->lock); + spin_lock_irqsave(&spdifrx->lock, flags); spdifrx->refcount++; @@ -362,7 +363,7 @@ static int stm32_spdifrx_start_sync(struct stm32_spdifrx_data *spdifrx) "Failed to start synchronization\n"); } - spin_unlock(&spdifrx->lock); + spin_unlock_irqrestore(&spdifrx->lock, flags); return ret; } @@ -370,11 +371,12 @@ static int stm32_spdifrx_start_sync(struct stm32_spdifrx_data *spdifrx) static void stm32_spdifrx_stop(struct stm32_spdifrx_data *spdifrx) { int cr, cr_mask, reg; + unsigned long flags; - spin_lock(&spdifrx->lock); + spin_lock_irqsave(&spdifrx->lock, flags); if (--spdifrx->refcount) { - spin_unlock(&spdifrx->lock); + spin_unlock_irqrestore(&spdifrx->lock, flags); return; } @@ -393,7 +395,7 @@ static void stm32_spdifrx_stop(struct stm32_spdifrx_data *spdifrx) regmap_read(spdifrx->regmap, STM32_SPDIFRX_DR, ®); regmap_read(spdifrx->regmap, STM32_SPDIFRX_CSR, ®); - spin_unlock(&spdifrx->lock); + spin_unlock_irqrestore(&spdifrx->lock, flags); } static int stm32_spdifrx_dma_ctrl_register(struct device *dev, -- 2.20.1