[ARM] 3554/1: ARM: Fix dyntick locking
authorTony Lindgren <tony@atomide.com>
Sun, 18 Jun 2006 15:26:58 +0000 (16:26 +0100)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Sun, 18 Jun 2006 15:26:58 +0000 (16:26 +0100)
Patch from Tony Lindgren

This patch fixes some dyntick locking issues on ARM as pointed
out by Russell King.

Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
arch/arm/kernel/irq.c
arch/arm/kernel/time.c
include/asm-arm/mach/time.h

index 2d5896b36181fa8ceb9636240b8abd13a2a0992e..bcc19fbb32df41ecca339fa49a76a28f25782582 100644 (file)
@@ -342,10 +342,10 @@ __do_irq(unsigned int irq, struct irqaction *action, struct pt_regs *regs)
 
 #ifdef CONFIG_NO_IDLE_HZ
        if (!(action->flags & SA_TIMER) && system_timer->dyn_tick != NULL) {
-               write_seqlock(&xtime_lock);
+               spin_lock(&system_timer->dyn_tick->lock);
                if (system_timer->dyn_tick->state & DYN_TICK_ENABLED)
                        system_timer->dyn_tick->handler(irq, 0, regs);
-               write_sequnlock(&xtime_lock);
+               spin_unlock(&system_timer->dyn_tick->lock);
        }
 #endif
 
index d6bd435a685722c1c59a249fa9d89d260e36e3c4..9c12d4fefbd30c9aa969f1c189cbf9a3f4f1f8bd 100644 (file)
@@ -379,7 +379,7 @@ static int timer_dyn_tick_enable(void)
        int ret = -ENODEV;
 
        if (dyn_tick) {
-               write_seqlock_irqsave(&xtime_lock, flags);
+               spin_lock_irqsave(&dyn_tick->lock, flags);
                ret = 0;
                if (!(dyn_tick->state & DYN_TICK_ENABLED)) {
                        ret = dyn_tick->enable();
@@ -387,7 +387,7 @@ static int timer_dyn_tick_enable(void)
                        if (ret == 0)
                                dyn_tick->state |= DYN_TICK_ENABLED;
                }
-               write_sequnlock_irqrestore(&xtime_lock, flags);
+               spin_unlock_irqrestore(&dyn_tick->lock, flags);
        }
 
        return ret;
@@ -400,7 +400,7 @@ static int timer_dyn_tick_disable(void)
        int ret = -ENODEV;
 
        if (dyn_tick) {
-               write_seqlock_irqsave(&xtime_lock, flags);
+               spin_lock_irqsave(&dyn_tick->lock, flags);
                ret = 0;
                if (dyn_tick->state & DYN_TICK_ENABLED) {
                        ret = dyn_tick->disable();
@@ -408,7 +408,7 @@ static int timer_dyn_tick_disable(void)
                        if (ret == 0)
                                dyn_tick->state &= ~DYN_TICK_ENABLED;
                }
-               write_sequnlock_irqrestore(&xtime_lock, flags);
+               spin_unlock_irqrestore(&dyn_tick->lock, flags);
        }
 
        return ret;
@@ -422,15 +422,20 @@ static int timer_dyn_tick_disable(void)
 void timer_dyn_reprogram(void)
 {
        struct dyn_tick_timer *dyn_tick = system_timer->dyn_tick;
-       unsigned long next, seq;
+       unsigned long next, seq, flags;
 
-       if (dyn_tick && (dyn_tick->state & DYN_TICK_ENABLED)) {
+       if (!dyn_tick)
+               return;
+
+       spin_lock_irqsave(&dyn_tick->lock, flags);
+       if (dyn_tick->state & DYN_TICK_ENABLED) {
                next = next_timer_interrupt();
                do {
                        seq = read_seqbegin(&xtime_lock);
-                       dyn_tick->reprogram(next_timer_interrupt() - jiffies);
+                       dyn_tick->reprogram(next - jiffies);
                } while (read_seqretry(&xtime_lock, seq));
        }
+       spin_unlock_irqrestore(&dyn_tick->lock, flags);
 }
 
 static ssize_t timer_show_dyn_tick(struct sys_device *dev, char *buf)
@@ -499,5 +504,10 @@ void __init time_init(void)
        if (system_timer->offset == NULL)
                system_timer->offset = dummy_gettimeoffset;
        system_timer->init();
+
+#ifdef CONFIG_NO_IDLE_HZ
+       if (system_timer->dyn_tick)
+               system_timer->dyn_tick->lock = SPIN_LOCK_UNLOCKED;
+#endif
 }
 
index 96c6db7dd0e1928e25b96e9b0e87fb64c7f113ce..9f28073559e8f6140788546012acecdd16479330 100644 (file)
@@ -50,6 +50,7 @@ struct sys_timer {
 #define DYN_TICK_ENABLED       (1 << 1)
 
 struct dyn_tick_timer {
+       spinlock_t      lock;
        unsigned int    state;                  /* Current state */
        int             (*enable)(void);        /* Enables dynamic tick */
        int             (*disable)(void);       /* Disables dynamic tick */