From patchwork Wed Jun 24 11:35:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= X-Patchwork-Id: 11622959 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C4184913 for ; Wed, 24 Jun 2020 11:38:01 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 9CA0D2084D for ; Wed, 24 Jun 2020 11:38:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="0dTpqBb+"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="W2S5XRf6"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=rere.qmqm.pl header.i=@rere.qmqm.pl header.b="hXopi1yH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9CA0D2084D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=rere.qmqm.pl Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:MIME-Version:Subject:From:Message-Id:Date: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=xAFzO6okDuvCfP2gDP7XISioAgnIWGLcTZGrWjlm90o=; b=0dTpqBb+x01dZjhZSJ1m0GV2wU NLrEsKaSsoURIcVaYIz95TJ9CWkUZzsSOFxmuN6Ukfjbpd1OV5nkmpEl75sT9mDbKTrr2sqMxo+sX e60/8Id3vh7tBFahQ8bMs3lCwlBzU/4Fahh+70pPasAxSjbA+P6Bhff9tmKDkQqzluDTcHJ0dsA20 VWXCkmWknW1Fh0TZ9mIGXyBV7swu9OZXDYiUUrRtSYjCppcD9vPyOtZOpYC7bPvMmmD/hsK/3P58A BCkeWgkpBvMslmdD2atcdzGD//83qp52aim7Zo+lY9NGSw1jvHTwwXSi2ciO/psyPeujBtBhFc6MC h6FQ44LQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jo3h9-0004ij-AE; Wed, 24 Jun 2020 11:35:59 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jo3h6-0004hy-UN for linux-arm-kernel@merlin.infradead.org; Wed, 24 Jun 2020 11:35:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Cc:To:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:From:Message-Id:Date:Sender:Reply-To: Content-ID:Content-Description:In-Reply-To:References; bh=e868Sb9kZpxjHH1z3YX0lz5qRjRYWSv5SW+29HqBZyo=; b=W2S5XRf6tve0gZ6hhfoZYK4MCw LzqO5CvusPTYP5/De6dejvWUIFD71ejtw0a955BJTYAA4OLMKgtiHMKyZ2KAu4CH+Wdqx/0Gmg3nn EHfJ0BM/ZyX9UhixdnbsRkBEoLiAwj2ZhH7lBFBEpUfPqDRPCW83r2zlI6QAsI3Oh0MzkMvNHOpnU BXItCNLlTQ8axKqLvTH+6QJqMrByoWAoIxve4tjJUEtqFUEq9JvV4Y75o1Dxo92HY7/SmRgtBCARx QmFy/bJy4naaG0bstxj/hdg3dsSIaU02iut7v/8bjlwjVr7HRkoS1aun92xu6wWJMaIthYtUGcxHX fh6KoLjw==; Received: from rere.qmqm.pl ([91.227.64.183]) by casper.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jo3h3-0000rT-0r for linux-arm-kernel@lists.infradead.org; Wed, 24 Jun 2020 11:35:56 +0000 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 49sLgL05fdz78; Wed, 24 Jun 2020 13:35:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1592998543; bh=wjpWIWEP1hkY8svUlhleFLTk7ObRZTWAWpqhbdFBczc=; h=Date:From:Subject:To:Cc:From; b=hXopi1yH9bPrHFT2dyLe9HH7FVO6vzTRw2ya/Qizr5b8TonRsWBiLeosVkYkJfBwR x1rd4DJ+MsejoEUpPyRoMKheaaSf8nHJZKkwhPj3e+Bxwnmez82RxBu2dUeSor8ZY5 yZZTgrPfCNxKyvDprOUFHQsRxMbBZbhK16aKmBhefHwTWpwg3NFsB2EmdYMZ2DDtTp 4QxxG/myoy2A4IwtizKLU2iGHVIuLVcBCkRdOXwhJBqjIl28dCVwAMvTpxIWNmQWcU IEHTDlz5SXnRHCXIJxmXbkhImJIUSQNJSxkAusgv16xQWccYTOJMYYnnt7gTXmZBpX L2FxOFgF8LiZg== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.102.3 at mail Date: Wed, 24 Jun 2020 13:35:41 +0200 Message-Id: <50f0d7fa107f318296afb49477c3571e4d6978c5.1592998403.git.mirq-linux@rere.qmqm.pl> From: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH v2] misc: atmel-ssc: lock with mutex instead of spinlock MIME-Version: 1.0 To: Nicolas Ferre , Arnd Bergmann , Greg Kroah-Hartman , Alexandre Belloni , Ludovic Desroches X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200624_123553_480951_C777D4A0 X-CRM114-Status: GOOD ( 12.07 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.4.4 on casper.infradead.org summary: Content analysis details: (-2.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Uninterruptible context is not needed in the driver and causes lockdep warning because of mutex taken in of_alias_get_id(). Convert the lock to mutex to avoid the issue. Cc: stable@vger.kernel.org Fixes: 099343c64e16 ("ARM: at91: atmel-ssc: add device tree support") Signed-off-by: Michał Mirosław Acked-by: Alexandre Belloni --- v2: rebased onto v5.7.5, added Fixes tag --- drivers/misc/atmel-ssc.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/misc/atmel-ssc.c b/drivers/misc/atmel-ssc.c index ab4144ea1f11..d6cd5537126c 100644 --- a/drivers/misc/atmel-ssc.c +++ b/drivers/misc/atmel-ssc.c @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include #include @@ -20,7 +20,7 @@ #include "../../sound/soc/atmel/atmel_ssc_dai.h" /* Serialize access to ssc_list and user count */ -static DEFINE_SPINLOCK(user_lock); +static DEFINE_MUTEX(user_lock); static LIST_HEAD(ssc_list); struct ssc_device *ssc_request(unsigned int ssc_num) @@ -28,7 +28,7 @@ struct ssc_device *ssc_request(unsigned int ssc_num) int ssc_valid = 0; struct ssc_device *ssc; - spin_lock(&user_lock); + mutex_lock(&user_lock); list_for_each_entry(ssc, &ssc_list, list) { if (ssc->pdev->dev.of_node) { if (of_alias_get_id(ssc->pdev->dev.of_node, "ssc") @@ -44,18 +44,18 @@ struct ssc_device *ssc_request(unsigned int ssc_num) } if (!ssc_valid) { - spin_unlock(&user_lock); + mutex_unlock(&user_lock); pr_err("ssc: ssc%d platform device is missing\n", ssc_num); return ERR_PTR(-ENODEV); } if (ssc->user) { - spin_unlock(&user_lock); + mutex_unlock(&user_lock); dev_dbg(&ssc->pdev->dev, "module busy\n"); return ERR_PTR(-EBUSY); } ssc->user++; - spin_unlock(&user_lock); + mutex_unlock(&user_lock); clk_prepare(ssc->clk); @@ -67,14 +67,14 @@ void ssc_free(struct ssc_device *ssc) { bool disable_clk = true; - spin_lock(&user_lock); + mutex_lock(&user_lock); if (ssc->user) ssc->user--; else { disable_clk = false; dev_dbg(&ssc->pdev->dev, "device already free\n"); } - spin_unlock(&user_lock); + mutex_unlock(&user_lock); if (disable_clk) clk_unprepare(ssc->clk); @@ -237,9 +237,9 @@ static int ssc_probe(struct platform_device *pdev) return -ENXIO; } - spin_lock(&user_lock); + mutex_lock(&user_lock); list_add_tail(&ssc->list, &ssc_list); - spin_unlock(&user_lock); + mutex_unlock(&user_lock); platform_set_drvdata(pdev, ssc); @@ -258,9 +258,9 @@ static int ssc_remove(struct platform_device *pdev) ssc_sound_dai_remove(ssc); - spin_lock(&user_lock); + mutex_lock(&user_lock); list_del(&ssc->list); - spin_unlock(&user_lock); + mutex_unlock(&user_lock); return 0; }