]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/x86/kernel/smpboot.c
x86: kexec/i386: fix sparse warnings: Using plain integer as NULL pointer
[linux-2.6-omap-h63xx.git] / arch / x86 / kernel / smpboot.c
index def770b57b5a0309af4c8dff32dfe34555013bd3..9ce666387f37c7a12b00eca4a0ccb3c7617d7f8a 100644 (file)
@@ -2,7 +2,7 @@
  *     x86 SMP booting functions
  *
  *     (c) 1995 Alan Cox, Building #3 <alan@lxorguk.ukuu.org.uk>
- *     (c) 1998, 1999, 2000 Ingo Molnar <mingo@redhat.com>
+ *     (c) 1998, 1999, 2000, 2009 Ingo Molnar <mingo@redhat.com>
  *     Copyright 2001 Andi Kleen, SuSE Labs.
  *
  *     Much of the core SMP work is based on previous work by Thomas Radke, to
 #include <asm/tlbflush.h>
 #include <asm/mtrr.h>
 #include <asm/vmi.h>
-#include <asm/genapic.h>
+#include <asm/apic.h>
 #include <asm/setup.h>
 #include <asm/uv/uv.h>
 #include <linux/mc146818rtc.h>
 
-#include <mach_apic.h>
-#include <mach_wakecpu.h>
-#include <smpboot_hooks.h>
+#include <asm/smpboot_hooks.h>
 
 #ifdef CONFIG_X86_32
 u8 apicid_2_node[MAX_APICID];
@@ -163,7 +161,7 @@ static void map_cpu_to_logical_apicid(void)
 {
        int cpu = smp_processor_id();
        int apicid = logical_smp_processor_id();
-       int node = apicid_to_node(apicid);
+       int node = apic->apicid_to_node(apicid);
 
        if (!node_online(node))
                node = first_online_node;
@@ -196,7 +194,8 @@ static void __cpuinit smp_callin(void)
         * our local APIC.  We have to wait for the IPI or we'll
         * lock up on an APIC access.
         */
-       wait_for_init_deassert(&init_deasserted);
+       if (apic->wait_for_init_deassert)
+               apic->wait_for_init_deassert(&init_deasserted);
 
        /*
         * (This works even if the APIC is not enabled.)
@@ -243,7 +242,8 @@ static void __cpuinit smp_callin(void)
         */
 
        pr_debug("CALLIN, before setup_local_APIC().\n");
-       smp_callin_clear_local_apic();
+       if (apic->smp_callin_clear_local_apic)
+               apic->smp_callin_clear_local_apic();
        setup_local_APIC();
        end_local_APIC_setup();
        map_cpu_to_logical_apicid();
@@ -583,7 +583,7 @@ wakeup_secondary_cpu_via_nmi(int logical_apicid, unsigned long start_eip)
        /* Target chip */
        /* Boot on the stack */
        /* Kick the second */
-       apic_icr_write(APIC_DM_NMI | APIC_DEST_LOGICAL, logical_apicid);
+       apic_icr_write(APIC_DM_NMI | apic->dest_logical, logical_apicid);
 
        pr_debug("Waiting for send to finish...\n");
        send_status = safe_apic_wait_icr_idle();
@@ -745,21 +745,21 @@ static void __cpuinit do_fork_idle(struct work_struct *work)
        complete(&c_idle->done);
 }
 
-static int __cpuinit do_boot_cpu(int apicid, int cpu)
 /*
  * NOTE - on most systems this is a PHYSICAL apic ID, but on multiquad
  * (ie clustered apic addressing mode), this is a LOGICAL apic ID.
- * Returns zero if CPU booted OK, else error code from wakeup_secondary_cpu.
+ * Returns zero if CPU booted OK, else error code from ->wakeup_cpu.
  */
+static int __cpuinit do_boot_cpu(int apicid, int cpu)
 {
        unsigned long boot_error = 0;
-       int timeout;
        unsigned long start_ip;
-       unsigned short nmi_high = 0, nmi_low = 0;
+       int timeout;
        struct create_idle c_idle = {
-               .cpu = cpu,
-               .done = COMPLETION_INITIALIZER_ONSTACK(c_idle.done),
+               .cpu    = cpu,
+               .done   = COMPLETION_INITIALIZER_ONSTACK(c_idle.done),
        };
+
        INIT_WORK(&c_idle.work, do_fork_idle);
 
        alternatives_smp_switch(1);
@@ -793,7 +793,6 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu)
 do_rest:
        per_cpu(current_task, cpu) = c_idle.idle;
 #ifdef CONFIG_X86_32
-       init_gdt(cpu);
        /* Stack for startup_32 can be just as for start_secondary onwards */
        irq_ctx_init(cpu);
 #else
@@ -825,8 +824,6 @@ do_rest:
 
                pr_debug("Setting warm reset code and vector.\n");
 
-               store_NMI_vector(&nmi_high, &nmi_low);
-
                smpboot_setup_warm_reset_vector(start_ip);
                /*
                 * Be paranoid about clearing APIC errors.
@@ -840,7 +837,7 @@ do_rest:
        /*
         * Starting actual IPI sequence...
         */
-       boot_error = wakeup_secondary_cpu(apicid, start_ip);
+       boot_error = apic->wakeup_cpu(apicid, start_ip);
 
        if (!boot_error) {
                /*
@@ -874,8 +871,8 @@ do_rest:
                        else
                                /* trampoline code not run */
                                printk(KERN_ERR "Not responding.\n");
-                       if (get_uv_system_type() != UV_NON_UNIQUE_APIC)
-                               inquire_remote_apic(apicid);
+                       if (apic->inquire_remote_apic)
+                               apic->inquire_remote_apic(apicid);
                }
        }
 
@@ -906,7 +903,7 @@ do_rest:
 
 int __cpuinit native_cpu_up(unsigned int cpu)
 {
-       int apicid = cpu_present_to_apicid(cpu);
+       int apicid = apic->cpu_present_to_apicid(cpu);
        unsigned long flags;
        int err;
 
@@ -999,14 +996,14 @@ static int __init smp_sanity_check(unsigned max_cpus)
 {
        preempt_disable();
 
-#if defined(CONFIG_X86_PC) && defined(CONFIG_X86_32)
+#if !defined(CONFIG_X86_BIGSMP) && defined(CONFIG_X86_32)
        if (def_to_bigsmp && nr_cpu_ids > 8) {
                unsigned int cpu;
                unsigned nr;
 
                printk(KERN_WARNING
                       "More than 8 CPUs detected - skipping them.\n"
-                      "Use CONFIG_X86_GENERICARCH and CONFIG_X86_BIGSMP.\n");
+                      "Use CONFIG_X86_BIGSMP.\n");
 
                nr = 0;
                for_each_present_cpu(cpu) {
@@ -1052,7 +1049,7 @@ static int __init smp_sanity_check(unsigned max_cpus)
         * Should not be necessary because the MP table should list the boot
         * CPU too, but we do it for the sake of robustness anyway.
         */
-       if (!check_phys_apicid_present(boot_cpu_physical_apicid)) {
+       if (!apic->check_phys_apicid_present(boot_cpu_physical_apicid)) {
                printk(KERN_NOTICE
                        "weird, boot CPU (#%d) not listed by the BIOS.\n",
                        boot_cpu_physical_apicid);
@@ -1070,7 +1067,7 @@ static int __init smp_sanity_check(unsigned max_cpus)
                printk(KERN_ERR "... forcing use of dummy APIC emulation."
                                "(tell your hw vendor)\n");
                smpboot_clear_io_apic();
-               disable_ioapic_setup();
+               arch_disable_smp_support();
                return -1;
        }
 
@@ -1127,9 +1124,9 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus)
        current_thread_info()->cpu = 0;  /* needed? */
        set_cpu_sibling_map(0);
 
-#ifdef CONFIG_X86_64
        enable_IR_x2apic();
-       setup_apic_routing();
+#ifdef CONFIG_X86_64
+       default_setup_apic_routing();
 #endif
 
        if (smp_sanity_check(max_cpus) < 0) {
@@ -1153,18 +1150,18 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus)
         */
        setup_local_APIC();
 
-#ifdef CONFIG_X86_64
        /*
         * Enable IO APIC before setting up error vector
         */
        if (!skip_ioapic_setup && nr_ioapics)
                enable_IO_APIC();
-#endif
+
        end_local_APIC_setup();
 
        map_cpu_to_logical_apicid();
 
-       setup_portio_remap();
+       if (apic->setup_portio_remap)
+               apic->setup_portio_remap();
 
        smpboot_setup_io_apic();
        /*
@@ -1186,10 +1183,7 @@ out:
 void __init native_smp_prepare_boot_cpu(void)
 {
        int me = smp_processor_id();
-#ifdef CONFIG_X86_32
-       init_gdt(me);
-#endif
-       switch_to_new_gdt();
+       switch_to_new_gdt(me);
        /* already set me in cpu_online_mask in boot_cpu_init() */
        cpumask_set_cpu(me, cpu_callout_mask);
        per_cpu(cpu_state, me) = CPU_ONLINE;