Merge branch 'for-linus' of master.kernel.org:/home/rmk/linux-2.6-arm
[cascardo/linux.git] / arch / arm / kernel / smp.c
index 421329f..e9dfbab 100644 (file)
@@ -7,6 +7,7 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
+#include <linux/module.h>
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/spinlock.h>
 #include <linux/profile.h>
 #include <linux/errno.h>
 #include <linux/mm.h>
+#include <linux/err.h>
 #include <linux/cpu.h>
 #include <linux/smp.h>
 #include <linux/seq_file.h>
+#include <linux/irq.h>
 
 #include <asm/atomic.h>
 #include <asm/cacheflush.h>
@@ -287,6 +290,11 @@ asmlinkage void __cpuinit secondary_start_kernel(void)
        local_irq_enable();
        local_fiq_enable();
 
+       /*
+        * Setup local timer for this CPU.
+        */
+       local_timer_setup(cpu);
+
        calibrate_delay();
 
        smp_store_cpu_info(cpu);
@@ -296,11 +304,6 @@ asmlinkage void __cpuinit secondary_start_kernel(void)
         */
        cpu_set(cpu, cpu_online_map);
 
-       /*
-        * Setup local timer for this CPU.
-        */
-       local_timer_setup(cpu);
-
        /*
         * OK, it's off to the idle thread for us
         */
@@ -449,6 +452,28 @@ int smp_call_function(void (*func)(void *info), void *info, int retry,
        return smp_call_function_on_cpu(func, info, retry, wait,
                                        cpu_online_map);
 }
+EXPORT_SYMBOL_GPL(smp_call_function);
+
+int smp_call_function_single(int cpu, void (*func)(void *info), void *info,
+                            int retry, int wait)
+{
+       /* prevent preemption and reschedule on another processor */
+       int current_cpu = get_cpu();
+       int ret = 0;
+
+       if (cpu == current_cpu) {
+               local_irq_disable();
+               func(info);
+               local_irq_enable();
+       } else
+               ret = smp_call_function_on_cpu(func, info, retry, wait,
+                                              cpumask_of_cpu(cpu));
+
+       put_cpu();
+
+       return ret;
+}
+EXPORT_SYMBOL_GPL(smp_call_function_single);
 
 void show_ipi_list(struct seq_file *p)
 {
@@ -474,25 +499,25 @@ void show_local_irqs(struct seq_file *p)
        seq_putc(p, '\n');
 }
 
-static void ipi_timer(struct pt_regs *regs)
+static void ipi_timer(void)
 {
-       int user = user_mode(regs);
-
        irq_enter();
-       profile_tick(CPU_PROFILING, regs);
-       update_process_times(user);
+       local_timer_interrupt();
        irq_exit();
 }
 
 #ifdef CONFIG_LOCAL_TIMERS
-asmlinkage void do_local_timer(struct pt_regs *regs)
+asmlinkage void __exception do_local_timer(struct pt_regs *regs)
 {
+       struct pt_regs *old_regs = set_irq_regs(regs);
        int cpu = smp_processor_id();
 
        if (local_timer_ack()) {
                irq_stat[cpu].local_timer_irqs++;
-               ipi_timer(regs);
+               ipi_timer();
        }
+
+       set_irq_regs(old_regs);
 }
 #endif
 
@@ -547,10 +572,11 @@ static void ipi_cpu_stop(unsigned int cpu)
  *
  *  Bit 0 - Inter-processor function call
  */
-asmlinkage void do_IPI(struct pt_regs *regs)
+asmlinkage void __exception do_IPI(struct pt_regs *regs)
 {
        unsigned int cpu = smp_processor_id();
        struct ipi_data *ipi = &per_cpu(ipi_data, cpu);
+       struct pt_regs *old_regs = set_irq_regs(regs);
 
        ipi->ipi_count++;
 
@@ -574,7 +600,7 @@ asmlinkage void do_IPI(struct pt_regs *regs)
 
                        switch (nextmsg) {
                        case IPI_TIMER:
-                               ipi_timer(regs);
+                               ipi_timer();
                                break;
 
                        case IPI_RESCHEDULE:
@@ -599,6 +625,8 @@ asmlinkage void do_IPI(struct pt_regs *regs)
                        }
                } while (msgs);
        }
+
+       set_irq_regs(old_regs);
 }
 
 void smp_send_reschedule(int cpu)
@@ -613,6 +641,11 @@ void smp_send_timer(void)
        send_ipi_message(mask, IPI_TIMER);
 }
 
+void smp_timer_broadcast(cpumask_t mask)
+{
+       send_ipi_message(mask, IPI_TIMER);
+}
+
 void smp_send_stop(void)
 {
        cpumask_t mask = cpu_online_map;
@@ -623,7 +656,7 @@ void smp_send_stop(void)
 /*
  * not supported here
  */
-int __init setup_profiling_timer(unsigned int multiplier)
+int setup_profiling_timer(unsigned int multiplier)
 {
        return -EINVAL;
 }