summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Frid <afrid@nvidia.com>2010-05-15 17:49:46 -0700
committerGary King <gking@nvidia.com>2010-05-20 10:53:31 -0700
commitb344cce5024b2742219db782aeeb38772a05325a (patch)
tree9285078fe841fe401cb0d8628126b4c01da41ff6
parent4bc4768e06afa53392678197d59b6394cdab5e1c (diff)
tegra timers: Added safety net for SMP tick handover.
Made sure that jiffies update duty is not stuck with off-line CPU: if this situation is detected, re-assign the tick ownership respectively (should fix bug 683277). Replaced spin-locks in timer access code with local interrupt control: local timers are "local", and do not need interprocessor protection. Change-Id: Ib0d690d8558724f7da384aba8b5cdf3d5ea8fdbb Reviewed-on: http://git-master/r/1415 Tested-by: Aleksandr Frid <afrid@nvidia.com> Reviewed-by: Gary King <gking@nvidia.com>
-rw-r--r--arch/arm/kernel/smp_twd.c22
-rw-r--r--kernel/time/tick-sched.c8
2 files changed, 18 insertions, 12 deletions
diff --git a/arch/arm/kernel/smp_twd.c b/arch/arm/kernel/smp_twd.c
index e7177d921b32..b170fe6bc82c 100644
--- a/arch/arm/kernel/smp_twd.c
+++ b/arch/arm/kernel/smp_twd.c
@@ -49,9 +49,6 @@ void __iomem *twd_base;
#ifdef CONFIG_USE_ARM_TWD_PRESCALER
/* dynamically updated by the platform code */
unsigned long timer_prescaler = 0;
-
-static spinlock_t timer_control_lock = SPIN_LOCK_UNLOCKED;
-static unsigned long flags;
#endif
static unsigned long twd_timer_rate;
@@ -60,6 +57,9 @@ static void twd_set_mode(enum clock_event_mode mode,
struct clock_event_device *clk)
{
unsigned long ctrl;
+#ifdef CONFIG_USE_ARM_TWD_PRESCALER
+ unsigned long flags;
+#endif
switch(mode) {
case CLOCK_EVT_MODE_PERIODIC:
@@ -77,12 +77,12 @@ static void twd_set_mode(enum clock_event_mode mode,
ctrl = 0;
}
#ifdef CONFIG_USE_ARM_TWD_PRESCALER
- spin_lock_irqsave(&timer_control_lock, flags);
+ local_irq_save(flags);
ctrl |= (timer_prescaler << TWD_TIMER_CONTROL_PRESCALER_LSB);
__raw_writel(ctrl, twd_base + TWD_TIMER_CONTROL);
- spin_unlock_irqrestore(&timer_control_lock, flags);
+ local_irq_restore(flags);
#else
__raw_writel(ctrl, twd_base + TWD_TIMER_CONTROL);
#endif
@@ -92,9 +92,9 @@ static int twd_set_next_event(unsigned long evt,
struct clock_event_device *unused)
{
#ifdef CONFIG_USE_ARM_TWD_PRESCALER
- unsigned long ctrl;
+ unsigned long ctrl, flags;
- spin_lock_irqsave(&timer_control_lock, flags);
+ local_irq_save(flags);
ctrl = __raw_readl(twd_base + TWD_TIMER_CONTROL);
ctrl &= (~TWD_TIMER_CONTROL_PRESCALER_FIELD);
@@ -104,7 +104,7 @@ static int twd_set_next_event(unsigned long evt,
__raw_writel(evt, twd_base + TWD_TIMER_COUNTER);
__raw_writel(ctrl, twd_base + TWD_TIMER_CONTROL);
- spin_unlock_irqrestore(&timer_control_lock, flags);
+ local_irq_restore(flags);
#else
unsigned long ctrl = __raw_readl(twd_base + TWD_TIMER_CONTROL);
@@ -121,16 +121,16 @@ static int twd_set_next_event(unsigned long evt,
*/
void twd_set_prescaler(void* unused)
{
- unsigned long ctrl;
+ unsigned long ctrl, flags;
- spin_lock_irqsave(&timer_control_lock, flags);
+ local_irq_save(flags);
ctrl = __raw_readl(twd_base + TWD_TIMER_CONTROL);
ctrl &= (~TWD_TIMER_CONTROL_PRESCALER_FIELD);
ctrl |= (timer_prescaler << TWD_TIMER_CONTROL_PRESCALER_LSB);
__raw_writel(ctrl, twd_base + TWD_TIMER_CONTROL);
- spin_unlock_irqrestore(&timer_control_lock, flags);
+ local_irq_restore(flags);
}
#endif
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 4012da672821..6737d68fdb8d 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -639,9 +639,15 @@ static enum hrtimer_restart tick_sched_timer(struct hrtimer *timer)
* into a long sleep. If two cpus happen to assign themself to
* this duty, then the jiffies update is still serialized by
* xtime_lock.
+ *
+ * Also check if the do_timer duty is stuck with off-line cpu.
+ * Then, use the same remedy as for dropped duty: re-assign it
+ * to the cpu servicing this tick.
*/
- if (unlikely(tick_do_timer_cpu == TICK_DO_TIMER_NONE))
+ if ((unlikely(tick_do_timer_cpu == TICK_DO_TIMER_NONE)) ||
+ (!cpu_online(tick_do_timer_cpu))) {
tick_do_timer_cpu = cpu;
+ }
#endif
/* Check, if the jiffies need an update */