Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp500910ybt; Wed, 24 Jun 2020 04:37:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrpYSKnsBFOsQJtcKVOhB0Qb9ScQIEnu9I166C/Jom7sPU6/siv6398W98Ty55fXNRHM1g X-Received: by 2002:a05:6402:144a:: with SMTP id d10mr5159538edx.35.1592998652158; Wed, 24 Jun 2020 04:37:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592998652; cv=none; d=google.com; s=arc-20160816; b=Im65NCBpZA7+cnwa9ZRaD+VbciTzWv5mlEf05d08TLCyZFsZDQT77ARynr5TWJYNiU wxHkYOxM/sl02K7KMkt1b40mbeg8HAOzB04y6fLpsHpHcJ58ezb5gbvSvXpGwYEXuWuC Wag+e4/bM2SRSjB6Cg/ny6Hx0XSzx073DdlrOFczYaN9g7W9L8xJw8sofr+dyxtlz3Pg w+M0wxOHrlVYNPUxbU9zsYev5dfXU0jhwRFrJBRcPWKEIonGOrud1pTfj9f0dz35xPbM B+l15GAXpFzdP5ZTkyOrAVNxU16USGJWzlXOsx8FSLpoA93TvDdJNbhzlrmJaP5FHW0L B7Hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:content-transfer-encoding :mime-version:subject:from:message-id:date:dkim-signature; bh=e868Sb9kZpxjHH1z3YX0lz5qRjRYWSv5SW+29HqBZyo=; b=09UT05vegFZYVztOe5KKt3JlQ+NpDCOWH4zWPJ40Pyxs/4bvSauaaMC/8dMV1t14cS wVZuhA/P5WprAKkk4dI4nCkL82c3VteMw9+NDDLHrUnYBtD6iLleugjIjQJiPwhblzsf PWvu1e79Zy4rFiW85gzKFP5Va3OTvvf8Y6w7EYBwPn4d+kJx/K9AeC6X48KSjUpOsTPg ZyLmRgVuSkZBY+8L7I+ZT9sRW0/VXBvAdV5Mb2ZUsc8kM7nVD/oYR1xDYmkm5ztszUxK ovY16y2V4kV28S+3UU5YM6j47ty5cXpInQAE1+s0IOxiuVigKCKAoHh0C46aZxuOiXH1 jNqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rere.qmqm.pl header.s=1 header.b=hXopi1yH; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w18si3089394ejk.216.2020.06.24.04.37.08; Wed, 24 Jun 2020 04:37:32 -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=@rere.qmqm.pl header.s=1 header.b=hXopi1yH; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390652AbgFXLfq (ORCPT + 99 others); Wed, 24 Jun 2020 07:35:46 -0400 Received: from rere.qmqm.pl ([91.227.64.183]:20004 "EHLO rere.qmqm.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388925AbgFXLfp (ORCPT ); Wed, 24 Jun 2020 07:35:45 -0400 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?q?Micha=C5=82=20Miros=C5=82aw?= Subject: [PATCH v2] misc: atmel-ssc: lock with mutex instead of spinlock MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To: Nicolas Ferre , Arnd Bergmann , Greg Kroah-Hartman , Alexandre Belloni , Ludovic Desroches Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 --- 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; } -- 2.20.1