linux-sh.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] clocksource: sh_cmt: Remove nested spinlock fix
@ 2010-12-17  7:25 Magnus Damm
  2010-12-17 10:42 ` Paul Mundt
  0 siblings, 1 reply; 2+ messages in thread
From: Magnus Damm @ 2010-12-17  7:25 UTC (permalink / raw)
  To: linux-sh

From: Takashi YOSHII <takashi.yoshii.zj@renesas.com>

There are control flow that sh_cmt_set_next() does double
spin-lock. The callers sh_cmt_{start,stop}() already have
lock. But another callers sh_cmt_clock_event_{start,next}()
does not.
    
Now sh_cmt_set_next() does not lock by itself. All the
callers should hold spin-lock before calling it.

[damm@opensource.se: use __sh_cmt_set_next() to simplify code]
[damm@opensource.se: added stable, suitable for v2.6.35 + v2.6.36]
Cc: stable@kernel.org
Signed-off-by: Takashi YOSHII <takashi.yoshii.zj@renesas.com>
Signed-off-by: Magnus Damm <damm@opensource.se>
---

 drivers/clocksource/sh_cmt.c |   17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

--- 0001/drivers/clocksource/sh_cmt.c
+++ work/drivers/clocksource/sh_cmt.c	2010-12-17 15:42:31.000000000 +0900
@@ -283,16 +283,21 @@ static void sh_cmt_clock_event_program_v
 	} while (delay);
 }
 
-static void sh_cmt_set_next(struct sh_cmt_priv *p, unsigned long delta)
+static void __sh_cmt_set_next(struct sh_cmt_priv *p, unsigned long delta)
 {
-	unsigned long flags;
-
 	if (delta > p->max_match_value)
 		dev_warn(&p->pdev->dev, "delta out of range\n");
 
-	spin_lock_irqsave(&p->lock, flags);
 	p->next_match_value = delta;
 	sh_cmt_clock_event_program_verify(p, 0);
+}
+
+static void sh_cmt_set_next(struct sh_cmt_priv *p, unsigned long delta)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(&p->lock, flags);
+	__sh_cmt_set_next(p, delta);
 	spin_unlock_irqrestore(&p->lock, flags);
 }
 
@@ -359,7 +364,7 @@ static int sh_cmt_start(struct sh_cmt_pr
 
 	/* setup timeout if no clockevent */
 	if ((flag = FLAG_CLOCKSOURCE) && (!(p->flags & FLAG_CLOCKEVENT)))
-		sh_cmt_set_next(p, p->max_match_value);
+		__sh_cmt_set_next(p, p->max_match_value);
  out:
 	spin_unlock_irqrestore(&p->lock, flags);
 
@@ -381,7 +386,7 @@ static void sh_cmt_stop(struct sh_cmt_pr
 
 	/* adjust the timeout to maximum if only clocksource left */
 	if ((flag = FLAG_CLOCKEVENT) && (p->flags & FLAG_CLOCKSOURCE))
-		sh_cmt_set_next(p, p->max_match_value);
+		__sh_cmt_set_next(p, p->max_match_value);
 
 	spin_unlock_irqrestore(&p->lock, flags);
 }

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] clocksource: sh_cmt: Remove nested spinlock fix
  2010-12-17  7:25 [PATCH] clocksource: sh_cmt: Remove nested spinlock fix Magnus Damm
@ 2010-12-17 10:42 ` Paul Mundt
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Mundt @ 2010-12-17 10:42 UTC (permalink / raw)
  To: linux-sh

On Fri, Dec 17, 2010 at 04:25:09PM +0900, Magnus Damm wrote:
> From: Takashi YOSHII <takashi.yoshii.zj@renesas.com>
> 
> There are control flow that sh_cmt_set_next() does double
> spin-lock. The callers sh_cmt_{start,stop}() already have
> lock. But another callers sh_cmt_clock_event_{start,next}()
> does not.
>     
> Now sh_cmt_set_next() does not lock by itself. All the
> callers should hold spin-lock before calling it.
> 
> [damm@opensource.se: use __sh_cmt_set_next() to simplify code]
> [damm@opensource.se: added stable, suitable for v2.6.35 + v2.6.36]
> Cc: stable@kernel.org
> Signed-off-by: Takashi YOSHII <takashi.yoshii.zj@renesas.com>
> Signed-off-by: Magnus Damm <damm@opensource.se>

Applied to sh/urgent, thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-12-17 10:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-17  7:25 [PATCH] clocksource: sh_cmt: Remove nested spinlock fix Magnus Damm
2010-12-17 10:42 ` Paul Mundt

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).