x86: fix section mismatch warning - apic_x2apic_uv_x
[safe/jmp/linux-2.6] / arch / x86 / kernel / nmi.c
index 32acda2..2c97f07 100644 (file)
@@ -114,15 +114,29 @@ static __init void nmi_cpu_busy(void *data)
 }
 #endif
 
+static void report_broken_nmi(int cpu, int *prev_nmi_count)
+{
+       printk(KERN_CONT "\n");
+
+       printk(KERN_WARNING
+               "WARNING: CPU#%d: NMI appears to be stuck (%d->%d)!\n",
+                       cpu, prev_nmi_count[cpu], get_nmi_count(cpu));
+
+       printk(KERN_WARNING
+               "Please report this to bugzilla.kernel.org,\n");
+       printk(KERN_WARNING
+               "and attach the output of the 'dmesg' command.\n");
+
+       per_cpu(wd_enabled, cpu) = 0;
+       atomic_dec(&nmi_active);
+}
+
 int __init check_nmi_watchdog(void)
 {
        unsigned int *prev_nmi_count;
        int cpu;
 
-       if (nmi_watchdog == NMI_NONE)
-               return 0;
-
-       if (!atomic_read(&nmi_active))
+       if (!nmi_watchdog_active() || !atomic_read(&nmi_active))
                return 0;
 
        prev_nmi_count = kmalloc(nr_cpu_ids * sizeof(int), GFP_KERNEL);
@@ -133,7 +147,7 @@ int __init check_nmi_watchdog(void)
 
 #ifdef CONFIG_SMP
        if (nmi_watchdog == NMI_LOCAL_APIC)
-               smp_call_function(nmi_cpu_busy, (void *)&endflag, 0, 0);
+               smp_call_function(nmi_cpu_busy, (void *)&endflag, 0);
 #endif
 
        for_each_possible_cpu(cpu)
@@ -144,15 +158,8 @@ int __init check_nmi_watchdog(void)
        for_each_online_cpu(cpu) {
                if (!per_cpu(wd_enabled, cpu))
                        continue;
-               if (get_nmi_count(cpu) - prev_nmi_count[cpu] <= 5) {
-                       printk(KERN_WARNING "WARNING: CPU#%d: NMI "
-                               "appears to be stuck (%d->%d)!\n",
-                               cpu,
-                               prev_nmi_count[cpu],
-                               get_nmi_count(cpu));
-                       per_cpu(wd_enabled, cpu) = 0;
-                       atomic_dec(&nmi_active);
-               }
+               if (get_nmi_count(cpu) - prev_nmi_count[cpu] <= 5)
+                       report_broken_nmi(cpu, prev_nmi_count);
        }
        endflag = 1;
        if (!atomic_read(&nmi_active)) {
@@ -174,6 +181,9 @@ int __init check_nmi_watchdog(void)
 error:
        if (nmi_watchdog == NMI_IO_APIC && !timer_through_8259)
                disable_8259A_irq(0);
+#ifdef CONFIG_X86_32
+       timer_ack = 0;
+#endif
        return -1;
 }
 
@@ -263,7 +273,7 @@ late_initcall(init_lapic_nmi_sysfs);
 
 static void __acpi_nmi_enable(void *__unused)
 {
-       apic_write_around(APIC_LVT0, APIC_DM_NMI);
+       apic_write(APIC_LVT0, APIC_DM_NMI);
 }
 
 /*
@@ -272,12 +282,12 @@ static void __acpi_nmi_enable(void *__unused)
 void acpi_nmi_enable(void)
 {
        if (atomic_read(&nmi_active) && nmi_watchdog == NMI_IO_APIC)
-               on_each_cpu(__acpi_nmi_enable, NULL, 0, 1);
+               on_each_cpu(__acpi_nmi_enable, NULL, 1);
 }
 
 static void __acpi_nmi_disable(void *__unused)
 {
-       apic_write_around(APIC_LVT0, APIC_DM_NMI | APIC_LVT_MASKED);
+       apic_write(APIC_LVT0, APIC_DM_NMI | APIC_LVT_MASKED);
 }
 
 /*
@@ -286,7 +296,16 @@ static void __acpi_nmi_disable(void *__unused)
 void acpi_nmi_disable(void)
 {
        if (atomic_read(&nmi_active) && nmi_watchdog == NMI_IO_APIC)
-               on_each_cpu(__acpi_nmi_disable, NULL, 0, 1);
+               on_each_cpu(__acpi_nmi_disable, NULL, 1);
+}
+
+/*
+ * This function is called as soon the LAPIC NMI watchdog driver has everything
+ * in place and it's ready to check if the NMIs belong to the NMI watchdog
+ */
+void cpu_nmi_set_wd_enabled(void)
+{
+       __get_cpu_var(wd_enabled) = 1;
 }
 
 void setup_apic_nmi_watchdog(void *unused)
@@ -301,8 +320,6 @@ void setup_apic_nmi_watchdog(void *unused)
 
        switch (nmi_watchdog) {
        case NMI_LOCAL_APIC:
-                /* enable it before to avoid race with handler */
-               __get_cpu_var(wd_enabled) = 1;
                if (lapic_watchdog_init(nmi_hz) < 0) {
                        __get_cpu_var(wd_enabled) = 0;
                        return;
@@ -317,8 +334,7 @@ void setup_apic_nmi_watchdog(void *unused)
 void stop_apic_nmi_watchdog(void *unused)
 {
        /* only support LOCAL and IO APICs for now */
-       if (nmi_watchdog != NMI_LOCAL_APIC &&
-           nmi_watchdog != NMI_IO_APIC)
+       if (!nmi_watchdog_active())
                return;
        if (__get_cpu_var(wd_enabled) == 0)
                return;
@@ -348,8 +364,7 @@ static DEFINE_PER_CPU(int, nmi_touch);
 
 void touch_nmi_watchdog(void)
 {
-       if (nmi_watchdog == NMI_LOCAL_APIC ||
-               nmi_watchdog == NMI_IO_APIC) {
+       if (nmi_watchdog_active()) {
                unsigned cpu;
 
                /*
@@ -450,6 +465,13 @@ nmi_watchdog_tick(struct pt_regs *regs, unsigned reason)
 
 #ifdef CONFIG_SYSCTL
 
+static int __init setup_unknown_nmi_panic(char *str)
+{
+       unknown_nmi_panic = 1;
+       return 1;
+}
+__setup("unknown_nmi_panic", setup_unknown_nmi_panic);
+
 static int unknown_nmi_panic_callback(struct pt_regs *regs, int cpu)
 {
        unsigned char reason = get_nmi_reason();
@@ -474,7 +496,7 @@ int proc_nmi_enabled(struct ctl_table *table, int write, struct file *file,
        if (!!old_state == !!nmi_watchdog_enabled)
                return 0;
 
-       if (atomic_read(&nmi_active) < 0 || nmi_watchdog == NMI_NONE) {
+       if (atomic_read(&nmi_active) < 0 || !nmi_watchdog_active()) {
                printk(KERN_WARNING
                        "NMI watchdog is permanently disabled\n");
                return -EIO;