From: Roland Stigge <stigge@antcom.de>
To: w.sang@pengutronix.de, bangaragiri.g@nxp.com,
srinivas.bakki@nxp.com, sundarapandian.andithevar@nxp.com,
linus.walleij@linaro.org, linux-kernel@vger.kernel.org,
kevin.wells@nxp.com, grant.likely@secretlab.ca,
linux-arm-kernel@lists.infradead.org
Cc: Roland Stigge <stigge@antcom.de>
Subject: [PATCH v2 7/7] LPC32xx: clock.c: Fix mutex lock issues
Date: Mon, 30 Jan 2012 17:02:06 +0100 [thread overview]
Message-ID: <1327939327-7799-7-git-send-email-stigge@antcom.de> (raw)
In-Reply-To: <1327939327-7799-1-git-send-email-stigge@antcom.de>
This patch fixes the mutex issue in clock.c, as done in Kevin Wells' original
driver update:
In some cases, the clock drivers could grab a mutex twice in an improper
context. This patch changes the mutex mechanism to a simple irq lock/unlock
mechanism and removes un-needed locks from some functions.
(See also git.lpclinux.com)
Signed-off-by: Roland Stigge <stigge@antcom.de>
diff --git a/arch/arm/mach-lpc32xx/clock.c b/arch/arm/mach-lpc32xx/clock.c
index f49638a..aceb88a 100644
--- a/arch/arm/mach-lpc32xx/clock.c
+++ b/arch/arm/mach-lpc32xx/clock.c
@@ -99,11 +99,12 @@
#include "clock.h"
#include "common.h"
+static DEFINE_SPINLOCK(global_clkregs_lock);
+
static int usb_pll_enable, usb_pll_valid;
static struct clk clk_armpll;
static struct clk clk_usbpll;
-static DEFINE_MUTEX(clkm_lock);
/*
* Post divider values for PLLs based on selected register value
@@ -934,16 +935,6 @@ static struct clk clk_lcd = {
.enable_mask = LPC32XX_CLKPWR_LCDCTRL_CLK_EN,
};
-static inline void clk_lock(void)
-{
- mutex_lock(&clkm_lock);
-}
-
-static inline void clk_unlock(void)
-{
- mutex_unlock(&clkm_lock);
-}
-
static void local_clk_disable(struct clk *clk)
{
/* Don't attempt to disable clock if it has no users */
@@ -988,10 +979,11 @@ static int local_clk_enable(struct clk *clk)
int clk_enable(struct clk *clk)
{
int ret;
+ unsigned long flags;
- clk_lock();
+ spin_lock_irqsave(&global_clkregs_lock, flags);
ret = local_clk_enable(clk);
- clk_unlock();
+ spin_unlock_irqrestore(&global_clkregs_lock, flags);
return ret;
}
@@ -1002,9 +994,11 @@ EXPORT_SYMBOL(clk_enable);
*/
void clk_disable(struct clk *clk)
{
- clk_lock();
+ unsigned long flags;
+
+ spin_lock_irqsave(&global_clkregs_lock, flags);
local_clk_disable(clk);
- clk_unlock();
+ spin_unlock_irqrestore(&global_clkregs_lock, flags);
}
EXPORT_SYMBOL(clk_disable);
@@ -1013,13 +1007,7 @@ EXPORT_SYMBOL(clk_disable);
*/
unsigned long clk_get_rate(struct clk *clk)
{
- unsigned long rate;
-
- clk_lock();
- rate = clk->get_rate(clk);
- clk_unlock();
-
- return rate;
+ return clk->get_rate(clk);
}
EXPORT_SYMBOL(clk_get_rate);
@@ -1035,11 +1023,8 @@ int clk_set_rate(struct clk *clk, unsigned long rate)
* the actual rate set as part of the peripheral dividers
* instead of high level clock control
*/
- if (clk->set_rate) {
- clk_lock();
+ if (clk->set_rate)
ret = clk->set_rate(clk, rate);
- clk_unlock();
- }
return ret;
}
@@ -1050,15 +1035,11 @@ EXPORT_SYMBOL(clk_set_rate);
*/
long clk_round_rate(struct clk *clk, unsigned long rate)
{
- clk_lock();
-
if (clk->round_rate)
rate = clk->round_rate(clk, rate);
else
rate = clk->get_rate(clk);
- clk_unlock();
-
return rate;
}
EXPORT_SYMBOL(clk_round_rate);
next prev parent reply other threads:[~2012-01-30 16:03 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-30 16:02 [PATCH v2 1/7] LPC32xx: clock.c: Missing header file Roland Stigge
2012-01-30 16:02 ` [PATCH v2 2/7] LPC32xx: clock.c: jiffies wrapping Roland Stigge
2012-01-31 10:24 ` Wolfram Sang
2012-01-30 16:02 ` [PATCH v2 3/7] LPC32xx: clock.c: Clock registration fixes Roland Stigge
2012-01-30 16:02 ` [PATCH v2 4/7] LPC32xx: clock.c: MMC update Roland Stigge
2012-01-30 16:02 ` [PATCH v2 5/7] LPC32xx: clock.c: warning fix Roland Stigge
2012-01-31 10:26 ` Wolfram Sang
2012-01-30 16:02 ` [PATCH v2 6/7] LPC32xx: clock.c: USB PLL fix Roland Stigge
2012-01-31 10:34 ` Wolfram Sang
2012-02-01 13:27 ` Roland Stigge
2012-02-02 16:49 ` Wolfram Sang
2012-02-02 19:20 ` Roland Stigge
2012-02-02 23:01 ` Wolfram Sang
2012-01-30 16:02 ` Roland Stigge [this message]
2012-01-31 10:27 ` [PATCH v2 7/7] LPC32xx: clock.c: Fix mutex lock issues Wolfram Sang
2012-01-30 17:56 ` [PATCH v2 1/7] LPC32xx: clock.c: Missing header file Sergei Shtylyov
2012-01-31 10:22 ` Wolfram Sang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1327939327-7799-7-git-send-email-stigge@antcom.de \
--to=stigge@antcom.de \
--cc=bangaragiri.g@nxp.com \
--cc=grant.likely@secretlab.ca \
--cc=kevin.wells@nxp.com \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=srinivas.bakki@nxp.com \
--cc=sundarapandian.andithevar@nxp.com \
--cc=w.sang@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).