parisc/CPU hotplug: Add missing call to notify_cpu_starting()
[linux-flexiantxendom0-3.2.10.git] / arch / parisc / kernel / smp.c
index 80bc000..4dc7b79 100644 (file)
@@ -18,7 +18,6 @@
 */
 #include <linux/types.h>
 #include <linux/spinlock.h>
-#include <linux/slab.h>
 
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/err.h>
 #include <linux/delay.h>
 #include <linux/bitops.h>
+#include <linux/ftrace.h>
+#include <linux/cpu.h>
 
-#include <asm/system.h>
-#include <asm/atomic.h>
+#include <linux/atomic.h>
 #include <asm/current.h>
 #include <asm/delay.h>
 #include <asm/tlbflush.h>
@@ -56,18 +56,17 @@ static int smp_debug_lvl = 0;
                if (lvl >= smp_debug_lvl)       \
                        printk(printargs);
 #else
-#define smp_debug(lvl, ...)
+#define smp_debug(lvl, ...)    do { } while(0)
 #endif /* DEBUG_SMP */
 
-DEFINE_SPINLOCK(smp_lock);
-
 volatile struct task_struct *smp_init_current_idle_task;
 
-static volatile int cpu_now_booting __read_mostly = 0; /* track which CPU is booting */
+/* track which CPU is booting */
+static volatile int cpu_now_booting __cpuinitdata;
 
-static int parisc_max_cpus __read_mostly = 1;
+static int parisc_max_cpus __cpuinitdata = 1;
 
-DEFINE_PER_CPU(spinlock_t, ipi_lock) = SPIN_LOCK_UNLOCKED;
+static DEFINE_PER_CPU(spinlock_t, ipi_lock);
 
 enum ipi_message_type {
        IPI_NOP=0,
@@ -112,18 +111,18 @@ halt_processor(void)
 {
        /* REVISIT : redirect I/O Interrupts to another CPU? */
        /* REVISIT : does PM *know* this CPU isn't available? */
-       cpu_clear(smp_processor_id(), cpu_online_map);
+       set_cpu_online(smp_processor_id(), false);
        local_irq_disable();
        for (;;)
                ;
 }
 
 
-irqreturn_t
+irqreturn_t __irq_entry
 ipi_interrupt(int irq, void *dev_id) 
 {
        int this_cpu = smp_processor_id();
-       struct cpuinfo_parisc *p = &cpu_data[this_cpu];
+       struct cpuinfo_parisc *p = &per_cpu(cpu_data, this_cpu);
        unsigned long ops;
        unsigned long flags;
 
@@ -156,10 +155,7 @@ ipi_interrupt(int irq, void *dev_id)
                                
                        case IPI_RESCHEDULE:
                                smp_debug(100, KERN_DEBUG "CPU%d IPI_RESCHEDULE\n", this_cpu);
-                               /*
-                                * Reschedule callback.  Everything to be
-                                * done is done by the interrupt return path.
-                                */
+                               scheduler_ipi();
                                break;
 
                        case IPI_CALL_FUNC:
@@ -202,32 +198,29 @@ ipi_interrupt(int irq, void *dev_id)
 static inline void
 ipi_send(int cpu, enum ipi_message_type op)
 {
-       struct cpuinfo_parisc *p = &cpu_data[cpu];
+       struct cpuinfo_parisc *p = &per_cpu(cpu_data, cpu);
        spinlock_t *lock = &per_cpu(ipi_lock, cpu);
        unsigned long flags;
 
        spin_lock_irqsave(lock, flags);
        p->pending_ipi |= 1 << op;
-       gsc_writel(IPI_IRQ - CPU_IRQ_BASE, cpu_data[cpu].hpa);
+       gsc_writel(IPI_IRQ - CPU_IRQ_BASE, p->hpa);
        spin_unlock_irqrestore(lock, flags);
 }
 
 static void
-send_IPI_mask(cpumask_t mask, enum ipi_message_type op)
+send_IPI_mask(const struct cpumask *mask, enum ipi_message_type op)
 {
        int cpu;
 
-       for_each_cpu_mask(cpu, mask)
+       for_each_cpu(cpu, mask)
                ipi_send(cpu, op);
 }
 
 static inline void
 send_IPI_single(int dest_cpu, enum ipi_message_type op)
 {
-       if (dest_cpu == NO_PROC_ID) {
-               BUG();
-               return;
-       }
+       BUG_ON(dest_cpu == NO_PROC_ID);
 
        ipi_send(dest_cpu, op);
 }
@@ -259,7 +252,7 @@ smp_send_all_nop(void)
        send_IPI_allbutself(IPI_NOP);
 }
 
-void arch_send_call_function_ipi(cpumask_t mask)
+void arch_send_call_function_ipi_mask(const struct cpumask *mask)
 {
        send_IPI_mask(mask, IPI_CALL_FUNC);
 }
@@ -298,19 +291,23 @@ smp_cpu_init(int cpunum)
        mb();
 
        /* Well, support 2.4 linux scheme as well. */
-       if (cpu_test_and_set(cpunum, cpu_online_map))
-       {
+       if (cpu_online(cpunum)) {
                extern void machine_halt(void); /* arch/parisc.../process.c */
 
                printk(KERN_CRIT "CPU#%d already initialized!\n", cpunum);
                machine_halt();
-       }  
+       }
+
+       notify_cpu_starting(cpunum);
+
+       ipi_call_lock();
+       set_cpu_online(cpunum, true);
+       ipi_call_unlock();
 
        /* Initialise the idle task for this CPU */
        atomic_inc(&init_mm.mm_count);
        current->active_mm = &init_mm;
-       if(current->mm)
-               BUG();
+       BUG_ON(current->mm);
        enter_lazy_tlb(&init_mm, current);
 
        init_IRQ();   /* make sure no IRQs are enabled or pending */
@@ -345,6 +342,7 @@ void __init smp_callin(void)
  */
 int __cpuinit smp_boot_one_cpu(int cpuid)
 {
+       const struct cpuinfo_parisc *p = &per_cpu(cpu_data, cpuid);
        struct task_struct *idle;
        long timeout;
 
@@ -376,7 +374,7 @@ int __cpuinit smp_boot_one_cpu(int cpuid)
        smp_init_current_idle_task = idle ;
        mb();
 
-       printk("Releasing cpu %d now, hpa=%lx\n", cpuid, cpu_data[cpuid].hpa);
+       printk(KERN_INFO "Releasing cpu %d now, hpa=%lx\n", cpuid, p->hpa);
 
        /*
        ** This gets PDC to release the CPU from a very tight loop.
@@ -387,7 +385,7 @@ int __cpuinit smp_boot_one_cpu(int cpuid)
        ** EIR{0}). MEM_RENDEZ is valid only when it is nonzero and the 
        ** contents of memory are valid."
        */
-       gsc_writel(TIMER_IRQ - CPU_IRQ_BASE, cpu_data[cpuid].hpa);
+       gsc_writel(TIMER_IRQ - CPU_IRQ_BASE, p->hpa);
        mb();
 
        /* 
@@ -419,15 +417,15 @@ alive:
        return 0;
 }
 
-void __devinit smp_prepare_boot_cpu(void)
+void __init smp_prepare_boot_cpu(void)
 {
-       int bootstrap_processor=cpu_data[0].cpuid;      /* CPU ID of BSP */
+       int bootstrap_processor = per_cpu(cpu_data, 0).cpuid;
 
        /* Setup BSP mappings */
-       printk("SMP: bootstrap CPU ID is %d\n",bootstrap_processor);
+       printk(KERN_INFO "SMP: bootstrap CPU ID is %d\n", bootstrap_processor);
 
-       cpu_set(bootstrap_processor, cpu_online_map);
-       cpu_set(bootstrap_processor, cpu_present_map);
+       set_cpu_online(bootstrap_processor, true);
+       set_cpu_present(bootstrap_processor, true);
 }
 
 
@@ -438,8 +436,12 @@ void __devinit smp_prepare_boot_cpu(void)
 */
 void __init smp_prepare_cpus(unsigned int max_cpus)
 {
-       cpus_clear(cpu_present_map);
-       cpu_set(0, cpu_present_map);
+       int cpu;
+
+       for_each_possible_cpu(cpu)
+               spin_lock_init(&per_cpu(ipi_lock, cpu));
+
+       init_cpu_present(cpumask_of(0));
 
        parisc_max_cpus = max_cpus;
        if (!max_cpus)