x86: call check_nmi_watchdog explicitly in native_smp_cpus_done
[sfrench/cifs-2.6.git] / arch / x86 / kernel / smpboot_32.c
index 0e86ccc90d821ec23cc81edfe3711b77d408bafd..1f3aff4caaf7baa60d571b218f439ee8b59128a8 100644 (file)
@@ -59,8 +59,6 @@
 #include <asm/vmi.h>
 #include <asm/mtrr.h>
 
-extern int smp_b_stepping;
-
 static cpumask_t smp_commenced_mask;
 
 /* which logical CPU number maps to which CPU (physical APIC ID) */
@@ -70,6 +68,12 @@ void *x86_cpu_to_apicid_early_ptr;
 DEFINE_PER_CPU(u16, x86_cpu_to_apicid) = BAD_APICID;
 EXPORT_PER_CPU_SYMBOL(x86_cpu_to_apicid);
 
+u16 x86_bios_cpu_apicid_init[NR_CPUS] __initdata
+                               = { [0 ... NR_CPUS-1] = BAD_APICID };
+void *x86_bios_cpu_apicid_early_ptr;
+DEFINE_PER_CPU(u16, x86_bios_cpu_apicid) = BAD_APICID;
+EXPORT_PER_CPU_SYMBOL(x86_bios_cpu_apicid);
+
 u8 apicid_2_node[MAX_APICID];
 
 static void map_cpu_to_logical_apicid(void);
@@ -160,8 +164,6 @@ static void __cpuinit smp_callin(void)
        cpu_set(cpuid, cpu_callin_map);
 }
 
-static int cpucount;
-
 /*
  * Activate a secondary processor.
  */
@@ -519,16 +521,6 @@ wakeup_secondary_cpu(int phys_apicid, unsigned long start_eip)
 #endif /* WAKE_SECONDARY_VIA_INIT */
 
 extern cpumask_t cpu_initialized;
-static inline int alloc_cpu_id(void)
-{
-       cpumask_t       tmp_map;
-       int cpu;
-       cpus_complement(tmp_map, cpu_present_map);
-       cpu = first_cpu(tmp_map);
-       if (cpu >= NR_CPUS)
-               return -ENODEV;
-       return cpu;
-}
 
 #ifdef CONFIG_HOTPLUG_CPU
 static struct task_struct * __cpuinitdata cpu_idle_tasks[NR_CPUS];
@@ -589,7 +581,6 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu)
        /* start_eip had better be page-aligned! */
        start_eip = setup_trampoline();
 
-       ++cpucount;
        alternatives_smp_switch(1);
 
        /* So we see what's up   */
@@ -599,7 +590,6 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu)
 
        irq_ctx_init(cpu);
 
-       per_cpu(x86_cpu_to_apicid, cpu) = apicid;
        /*
         * This grunge runs the startup process for
         * the targeted processor.
@@ -659,10 +649,8 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu)
                unmap_cpu_to_logical_apicid(cpu);
                cpu_clear(cpu, cpu_callout_map); /* was set here (do_boot_cpu()) */
                cpu_clear(cpu, cpu_initialized); /* was set by cpu_init() */
-               cpucount--;
-       } else {
-               per_cpu(x86_cpu_to_apicid, cpu) = apicid;
-               cpu_set(cpu, cpu_present_map);
+               cpu_clear(cpu, cpu_possible_map);
+               per_cpu(x86_cpu_to_apicid, cpu) = BAD_APICID;
        }
 
        /* mark "stuck" area as not stuck */
@@ -678,7 +666,6 @@ void cpu_exit_clear(void)
 
        idle_task_exit();
 
-       cpucount --;
        cpu_uninit();
        irq_ctx_exit(cpu);
 
@@ -737,6 +724,8 @@ EXPORT_SYMBOL(xquad_portio);
 
 static void __init disable_smp(void)
 {
+       cpu_possible_map = cpumask_of_cpu(0);
+       cpu_present_map = cpumask_of_cpu(0);
        smpboot_clear_io_apic_irqs();
        phys_cpu_present_map = physid_mask_of_physid(0);
        map_cpu_to_logical_apicid();
@@ -799,14 +788,12 @@ static int __init smp_sanity_check(unsigned max_cpus)
        return 0;
 }
 
-
 /*
  * Cycle through the processors sending APIC IPIs to boot each.
  */
 static void __init smp_boot_cpus(unsigned int max_cpus)
 {
        int apicid, cpu, bit, kicked;
-       unsigned long bogosum = 0;
 
        /*
         * Setup boot CPU information
@@ -817,7 +804,6 @@ static void __init smp_boot_cpus(unsigned int max_cpus)
 
        boot_cpu_physical_apicid = GET_APIC_ID(apic_read(APIC_ID));
        boot_cpu_logical_apicid = logical_smp_processor_id();
-       per_cpu(x86_cpu_to_apicid, 0) = boot_cpu_physical_apicid;
 
        current_thread_info()->cpu = 0;
 
@@ -856,52 +842,19 @@ static void __init smp_boot_cpus(unsigned int max_cpus)
 
                if (!check_apicid_present(bit))
                        continue;
-               if (max_cpus <= cpucount+1)
+               if (max_cpus <= cpus_weight(cpu_present_map))
                        continue;
-
-               if (((cpu = alloc_cpu_id()) <= 0) || do_boot_cpu(apicid, cpu))
+               /* Utterly temporary */
+               for (cpu = 0; cpu < NR_CPUS; cpu++)
+                       if (per_cpu(x86_cpu_to_apicid, cpu) == apicid)
+                               break;
+               if (do_boot_cpu(apicid, cpu))
                        printk("CPU #%d not responding - cannot use it.\n",
                                                                apicid);
                else
                        ++kicked;
        }
 
-       /*
-        * Cleanup possible dangling ends...
-        */
-       smpboot_restore_warm_reset_vector();
-
-       /*
-        * Allow the user to impress friends.
-        */
-       Dprintk("Before bogomips.\n");
-       for_each_possible_cpu(cpu)
-               if (cpu_isset(cpu, cpu_callout_map))
-                       bogosum += cpu_data(cpu).loops_per_jiffy;
-       printk(KERN_INFO
-               "Total of %d processors activated (%lu.%02lu BogoMIPS).\n",
-               cpucount+1,
-               bogosum/(500000/HZ),
-               (bogosum/(5000/HZ))%100);
-       
-       Dprintk("Before bogocount - setting activated=1.\n");
-
-       if (smp_b_stepping)
-               printk(KERN_WARNING "WARNING: SMP operation may be unreliable with B stepping processors.\n");
-
-       /*
-        * Don't taint if we are running SMP kernel on a single non-MP
-        * approved Athlon
-        */
-       if (tainted & TAINT_UNSAFE_SMP) {
-               if (cpucount)
-                       printk (KERN_INFO "WARNING: This combination of AMD processors is not suitable for SMP.\n");
-               else
-                       tainted &= ~TAINT_UNSAFE_SMP;
-       }
-
-       Dprintk("Boot done.\n");
-
        /*
         * construct cpu_sibling_map, so that we can tell sibling CPUs
         * efficiently.
@@ -936,10 +889,7 @@ void __init native_smp_prepare_boot_cpu(void)
        init_gdt(cpu);
        switch_to_new_gdt();
 
-       cpu_set(cpu, cpu_online_map);
        cpu_set(cpu, cpu_callout_map);
-       cpu_set(cpu, cpu_present_map);
-       cpu_set(cpu, cpu_possible_map);
        __get_cpu_var(cpu_state) = CPU_ONLINE;
 }
 
@@ -996,31 +946,23 @@ int __cpuinit native_cpu_up(unsigned int cpu)
        return 0;
 }
 
-void __init native_smp_cpus_done(unsigned int max_cpus)
-{
-#ifdef CONFIG_X86_IO_APIC
-       setup_ioapic_dest();
-#endif
-       zap_low_mappings();
-}
+extern void impress_friends(void);
+extern void smp_checks(void);
 
-void __init smp_intr_init(void)
+void __init native_smp_cpus_done(unsigned int max_cpus)
 {
        /*
-        * IRQ0 must be given a fixed assignment and initialized,
-        * because it's used before the IO-APIC is set up.
-        */
-       set_intr_gate(FIRST_DEVICE_VECTOR, interrupt[0]);
-
-       /*
-        * The reschedule interrupt is a CPU-to-CPU reschedule-helper
-        * IPI, driven by wakeup.
+        * Cleanup possible dangling ends...
         */
-       set_intr_gate(RESCHEDULE_VECTOR, reschedule_interrupt);
+       smpboot_restore_warm_reset_vector();
 
-       /* IPI for invalidation */
-       set_intr_gate(INVALIDATE_TLB_VECTOR, invalidate_interrupt);
+       Dprintk("Boot done.\n");
 
-       /* IPI for generic function call */
-       set_intr_gate(CALL_FUNCTION_VECTOR, call_function_interrupt);
+       impress_friends();
+       smp_checks();
+#ifdef CONFIG_X86_IO_APIC
+       setup_ioapic_dest();
+#endif
+       check_nmi_watchdog();
+       zap_low_mappings();
 }