mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: linux-kernel@vger.kernel.org
Subject: [PATCH 06/25] clocksource: sh_mtu2: Replace global spinlock with a per-device spinlock
Date: Wed, 23 Jul 2014 12:53:48 +0200	[thread overview]
Message-ID: <1406112847-26275-6-git-send-email-daniel.lezcano@linaro.org> (raw)
In-Reply-To: <1406112847-26275-1-git-send-email-daniel.lezcano@linaro.org>

From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

The global spinlock is used to protect the shared start/stop register.
Now that all MTU2 channels are handled by a single device instance, use
a per-device spinlock.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Tested-by: Wolfram Sang <wsa@sang-engineering.com>
---
 drivers/clocksource/sh_mtu2.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c
index 0342e4a..b0c229f 100644
--- a/drivers/clocksource/sh_mtu2.c
+++ b/drivers/clocksource/sh_mtu2.c
@@ -47,14 +47,14 @@ struct sh_mtu2_device {
 	void __iomem *mapbase;
 	struct clk *clk;
 
+	raw_spinlock_t lock; /* Protect the shared registers */
+
 	struct sh_mtu2_channel *channels;
 	unsigned int num_channels;
 
 	bool has_clockevent;
 };
 
-static DEFINE_RAW_SPINLOCK(sh_mtu2_lock);
-
 #define TSTR -1 /* shared register */
 #define TCR  0 /* channel register */
 #define TMDR 1 /* channel register */
@@ -192,7 +192,7 @@ static void sh_mtu2_start_stop_ch(struct sh_mtu2_channel *ch, int start)
 	unsigned long flags, value;
 
 	/* start stop register shared by multiple timer channels */
-	raw_spin_lock_irqsave(&sh_mtu2_lock, flags);
+	raw_spin_lock_irqsave(&ch->mtu->lock, flags);
 	value = sh_mtu2_read(ch, TSTR);
 
 	if (start)
@@ -201,7 +201,7 @@ static void sh_mtu2_start_stop_ch(struct sh_mtu2_channel *ch, int start)
 		value &= ~(1 << ch->index);
 
 	sh_mtu2_write(ch, TSTR, value);
-	raw_spin_unlock_irqrestore(&sh_mtu2_lock, flags);
+	raw_spin_unlock_irqrestore(&ch->mtu->lock, flags);
 }
 
 static int sh_mtu2_enable(struct sh_mtu2_channel *ch)
@@ -402,6 +402,8 @@ static int sh_mtu2_setup(struct sh_mtu2_device *mtu,
 
 	mtu->pdev = pdev;
 
+	raw_spin_lock_init(&mtu->lock);
+
 	/* Get hold of clock. */
 	mtu->clk = clk_get(&mtu->pdev->dev, "fck");
 	if (IS_ERR(mtu->clk)) {
-- 
1.7.9.5


  parent reply	other threads:[~2014-07-23 11:00 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-23 10:51 [PULL] clockevents changes for 3.17 Daniel Lezcano
2014-07-23 10:53 ` [PATCH 01/25] clocksource: sh_cmt: Drop support for legacy platform data Daniel Lezcano
2014-07-23 10:53   ` [PATCH 02/25] clocksource: sh_cmt: Replace global spinlock with a per-device spinlock Daniel Lezcano
2014-07-23 10:53   ` [PATCH 03/25] clocksource: sh_tmu: Drop support for legacy platform data Daniel Lezcano
2014-07-23 10:53   ` [PATCH 04/25] clocksource: sh_tmu: Replace global spinlock with a per-device spinlock Daniel Lezcano
2014-07-23 10:53   ` [PATCH 05/25] clocksource: sh_mtu2: Drop support for legacy platform data Daniel Lezcano
2014-07-23 10:53   ` Daniel Lezcano [this message]
2014-07-23 10:53   ` [PATCH 07/25] clocksource: shmobile: Remove unused sh_timer_config members Daniel Lezcano
2014-07-23 10:53   ` [PATCH 08/25] clocksource: sh_cmt: Add DT support Daniel Lezcano
2014-07-23 10:53   ` [PATCH 09/25] clocksource: sh_tmu: " Daniel Lezcano
2014-07-23 10:53   ` [PATCH 10/25] clocksource: sh_mtu2: " Daniel Lezcano
2014-07-23 10:53   ` [PATCH 11/25] clocksource: sh_mtu2: Tidy up Kconfig typo for MTU2 Daniel Lezcano
2014-07-23 10:53   ` [PATCH 12/25] of: Provide a function to request and map memory Daniel Lezcano
2014-07-23 10:53   ` [PATCH 13/25] clocksource: Add support for the Mediatek SoCs Daniel Lezcano
2014-07-23 10:53   ` [PATCH 14/25] dt-bindings: Add mtk-timer bindings Daniel Lezcano
2014-07-23 10:53   ` [PATCH 15/25] vendor-prefixes: Add prefix for Mediatek Inc Daniel Lezcano
2014-07-23 10:53   ` [PATCH 16/25] clocksource: Kconfig: Let EM_TIMER_STI depend on HAS_IOMEM Daniel Lezcano
2014-07-23 10:53   ` [PATCH 17/25] clocksource: sirf: Fix incorrect clock enable counter for timer Daniel Lezcano
2014-07-23 10:54   ` [PATCH 18/25] clocksource: clps711x: Add CLPS711X clocksource driver Daniel Lezcano
2014-07-23 10:54   ` [PATCH 19/25] clocksource: clps711x: Add DT bindings documentation Daniel Lezcano
2014-07-23 10:54   ` [PATCH 20/25] clocksource: pxa: Move PXA timer to clocksource framework Daniel Lezcano
2014-07-23 10:54   ` [PATCH 21/25] clocksource: pxa: Add device-tree support for PXA timer Daniel Lezcano
2014-07-23 10:54   ` [PATCH 22/25] ARM: pxa: Add CLKSRC_OF dependency Daniel Lezcano
2014-07-23 10:54   ` [PATCH 23/25] ARM: pxa: Add non device-tree timer link to clocksource Daniel Lezcano
2014-07-23 10:54   ` [PATCH 24/25] clocksource: exynos_mct: Use readl_relaxed/writel_relaxed Daniel Lezcano
2014-07-23 10:54   ` [PATCH 25/25] clocksource: exynos_mct: Only use 32-bits where possible Daniel Lezcano

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=1406112847-26275-6-git-send-email-daniel.lezcano@linaro.org \
    --to=daniel.lezcano@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®