Merge branch 'for-rmk' of git://linux-arm.org/linux-2.6 into devel
[sfrench/cifs-2.6.git] / arch / arm / kernel / smp.c
index ece658e773a6ff71075c63f40ec082439c0b4bf4..de885fd256c519b220e6d48d86996e1f7027cd5d 100644 (file)
 #include <linux/smp.h>
 #include <linux/seq_file.h>
 #include <linux/irq.h>
+#include <linux/percpu.h>
+#include <linux/clockchips.h>
 
 #include <asm/atomic.h>
 #include <asm/cacheflush.h>
 #include <asm/cpu.h>
+#include <asm/cputype.h>
 #include <asm/mmu_context.h>
 #include <asm/pgtable.h>
 #include <asm/pgalloc.h>
 #include <asm/processor.h>
 #include <asm/tlbflush.h>
 #include <asm/ptrace.h>
-#include <asm/cputype.h>
+#include <asm/localtimer.h>
 
 /*
  * as from 2.5, kernels no longer have an init_tasks structure
@@ -164,7 +167,7 @@ int __cpuexit __cpu_disable(void)
         * Take this CPU offline.  Once we clear this, we can't return,
         * and we must not schedule until we're ready to give up the cpu.
         */
-       cpu_clear(cpu, cpu_online_map);
+       set_cpu_online(cpu, false);
 
        /*
         * OK - migrate IRQs away from this CPU
@@ -275,9 +278,9 @@ asmlinkage void __cpuinit secondary_start_kernel(void)
        local_fiq_enable();
 
        /*
-        * Setup local timer for this CPU.
+        * Setup the percpu timer for this CPU.
         */
-       local_timer_setup();
+       percpu_timer_setup();
 
        calibrate_delay();
 
@@ -286,7 +289,7 @@ asmlinkage void __cpuinit secondary_start_kernel(void)
        /*
         * OK, now it's safe to let the boot CPU continue
         */
-       cpu_set(cpu, cpu_online_map);
+       set_cpu_online(cpu, true);
 
        /*
         * OK, it's off to the idle thread for us
@@ -384,10 +387,16 @@ void show_local_irqs(struct seq_file *p)
        seq_putc(p, '\n');
 }
 
+/*
+ * Timer (local or broadcast) support
+ */
+static DEFINE_PER_CPU(struct clock_event_device, percpu_clockevent);
+
 static void ipi_timer(void)
 {
+       struct clock_event_device *evt = &__get_cpu_var(percpu_clockevent);
        irq_enter();
-       local_timer_interrupt();
+       evt->event_handler(evt);
        irq_exit();
 }
 
@@ -406,6 +415,42 @@ asmlinkage void __exception do_local_timer(struct pt_regs *regs)
 }
 #endif
 
+#ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
+static void smp_timer_broadcast(const struct cpumask *mask)
+{
+       send_ipi_message(mask, IPI_TIMER);
+}
+
+static void broadcast_timer_set_mode(enum clock_event_mode mode,
+       struct clock_event_device *evt)
+{
+}
+
+static void local_timer_setup(struct clock_event_device *evt)
+{
+       evt->name       = "dummy_timer";
+       evt->features   = CLOCK_EVT_FEAT_ONESHOT |
+                         CLOCK_EVT_FEAT_PERIODIC |
+                         CLOCK_EVT_FEAT_DUMMY;
+       evt->rating     = 400;
+       evt->mult       = 1;
+       evt->set_mode   = broadcast_timer_set_mode;
+       evt->broadcast  = smp_timer_broadcast;
+
+       clockevents_register_device(evt);
+}
+#endif
+
+void __cpuinit percpu_timer_setup(void)
+{
+       unsigned int cpu = smp_processor_id();
+       struct clock_event_device *evt = &per_cpu(percpu_clockevent, cpu);
+
+       evt->cpumask = cpumask_of(cpu);
+
+       local_timer_setup(evt);
+}
+
 static DEFINE_SPINLOCK(stop_lock);
 
 /*
@@ -418,7 +463,7 @@ static void ipi_cpu_stop(unsigned int cpu)
        dump_stack();
        spin_unlock(&stop_lock);
 
-       cpu_clear(cpu, cpu_online_map);
+       set_cpu_online(cpu, false);
 
        local_fiq_disable();
        local_irq_disable();
@@ -502,11 +547,6 @@ void smp_send_reschedule(int cpu)
        send_ipi_message(cpumask_of(cpu), IPI_RESCHEDULE);
 }
 
-void smp_timer_broadcast(const struct cpumask *mask)
-{
-       send_ipi_message(mask, IPI_TIMER);
-}
-
 void smp_send_stop(void)
 {
        cpumask_t mask = cpu_online_map;