Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3104502ybt; Mon, 29 Jun 2020 15:30:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz1MSDkg9HqZGE0thrVfPd0kA0QA5WUE8rUju5MhQUgivHdTKCdqgsnDZW24oqJ3SNmlVeo X-Received: by 2002:a17:906:d286:: with SMTP id ay6mr7018552ejb.400.1593469856356; Mon, 29 Jun 2020 15:30:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593469856; cv=none; d=google.com; s=arc-20160816; b=s05yivPkoWdSlE+9dbCbM63vL7GRlLX7ucI9hpvnyx55Zez5z7qU8Nhc5yY9ONU7zy XhR5EB6z5A4/kiRmkHw5GjmUguFrl9DtbMckPcnopHQeilPunsqeVNagdUQPxpG6hzdJ LtxVeg8Jh+gl0aIM8Q1bNuQoQ/dFmQNeXJWKxH2dy05sJmdmo2bNX3ZOyE3HLrtY+mL7 uwm9Mz176CJAJodCeu5lMsGHXGEaA2QO/2GYU1DRGTa5uh+I/V7EwsdOiKBck52QVxkX +W6U2K/A0tYI7HZnOGpzR4PdT3nPf68GzDzI5eE/aM7o4rjznYuWzi44jeKVWf4heXcQ QLBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=PM5wIT7DWyHbHeFIq+mfaNX5VGla+JE/KaYzZrkEIp8=; b=xktfcUNke37cScx0ndw6RaTsAEA3crxh2pMSs/5aBeUGhLiAYRNCVc0z6flTR6jKdu BLyFRKtlQTIzsKXOSKjfn3GP4ZaJqSYtzySlCFs7monx+SD11l32YnEb1AWlN0JaINla xAet/DLBz6JIjxIJqyhOP0QNbr5oXpqLKgQfURa+8cUQBHEPjPE8m2TSoqQuHrP6DuV5 SDGRGzc3lQAcP60YD7WXPZ+KbculsniP2H4/Bd1bzd/0Ddf/4phmoTa4ibalV1sayDNk J83DilGmsejLxOsSNnjSVrl2ptjfSHyVRxkbrMsb/mU/E5RLLOM6QuEbchmowC+nERg+ 5Xng== ARC-Authentication-Results: i=1; mx.google.com; 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 b9si509184edq.23.2020.06.29.15.30.33; Mon, 29 Jun 2020 15:30:56 -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; 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 S1727836AbgF2WaJ (ORCPT + 99 others); Mon, 29 Jun 2020 18:30:09 -0400 Received: from relay7-d.mail.gandi.net ([217.70.183.200]:40965 "EHLO relay7-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726951AbgF2WaI (ORCPT ); Mon, 29 Jun 2020 18:30:08 -0400 X-Originating-IP: 86.202.110.81 Received: from localhost (lfbn-lyo-1-15-81.w86-202.abo.wanadoo.fr [86.202.110.81]) (Authenticated sender: alexandre.belloni@bootlin.com) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id AAEDB20009; Mon, 29 Jun 2020 22:30:04 +0000 (UTC) Date: Tue, 30 Jun 2020 00:30:04 +0200 From: Alexandre Belloni To: =?utf-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= Cc: Nicolas Ferre , Arnd Bergmann , Greg Kroah-Hartman , Ludovic Desroches , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] misc: atmel-ssc: lock with mutex instead of spinlock Message-ID: <20200629223004.GC3800@piout.net> References: <50f0d7fa107f318296afb49477c3571e4d6978c5.1592998403.git.mirq-linux@rere.qmqm.pl> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <50f0d7fa107f318296afb49477c3571e4d6978c5.1592998403.git.mirq-linux@rere.qmqm.pl> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 24/06/2020 13:35:41+0200, Michał Mirosław wrote: > 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; > } > -- > 2.20.1 > -- Alexandre Belloni, Bootlin Embedded Linux and Kernel engineering https://bootlin.com