aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/kernel/nmi.c13
-rw-r--r--include/asm-x86/nmi.h13
2 files changed, 17 insertions, 9 deletions
diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
index 32acda25e3cb..8dfe9db87a9e 100644
--- a/arch/x86/kernel/nmi.c
+++ b/arch/x86/kernel/nmi.c
@@ -119,10 +119,7 @@ int __init check_nmi_watchdog(void)
119 unsigned int *prev_nmi_count; 119 unsigned int *prev_nmi_count;
120 int cpu; 120 int cpu;
121 121
122 if (nmi_watchdog == NMI_NONE) 122 if (!nmi_watchdog_active() || !atomic_read(&nmi_active))
123 return 0;
124
125 if (!atomic_read(&nmi_active))
126 return 0; 123 return 0;
127 124
128 prev_nmi_count = kmalloc(nr_cpu_ids * sizeof(int), GFP_KERNEL); 125 prev_nmi_count = kmalloc(nr_cpu_ids * sizeof(int), GFP_KERNEL);
@@ -317,8 +314,7 @@ void setup_apic_nmi_watchdog(void *unused)
317void stop_apic_nmi_watchdog(void *unused) 314void stop_apic_nmi_watchdog(void *unused)
318{ 315{
319 /* only support LOCAL and IO APICs for now */ 316 /* only support LOCAL and IO APICs for now */
320 if (nmi_watchdog != NMI_LOCAL_APIC && 317 if (!nmi_watchdog_active())
321 nmi_watchdog != NMI_IO_APIC)
322 return; 318 return;
323 if (__get_cpu_var(wd_enabled) == 0) 319 if (__get_cpu_var(wd_enabled) == 0)
324 return; 320 return;
@@ -348,8 +344,7 @@ static DEFINE_PER_CPU(int, nmi_touch);
348 344
349void touch_nmi_watchdog(void) 345void touch_nmi_watchdog(void)
350{ 346{
351 if (nmi_watchdog == NMI_LOCAL_APIC || 347 if (nmi_watchdog_active()) {
352 nmi_watchdog == NMI_IO_APIC) {
353 unsigned cpu; 348 unsigned cpu;
354 349
355 /* 350 /*
@@ -474,7 +469,7 @@ int proc_nmi_enabled(struct ctl_table *table, int write, struct file *file,
474 if (!!old_state == !!nmi_watchdog_enabled) 469 if (!!old_state == !!nmi_watchdog_enabled)
475 return 0; 470 return 0;
476 471
477 if (atomic_read(&nmi_active) < 0 || nmi_watchdog == NMI_NONE) { 472 if (atomic_read(&nmi_active) < 0 || !nmi_watchdog_active()) {
478 printk(KERN_WARNING 473 printk(KERN_WARNING
479 "NMI watchdog is permanently disabled\n"); 474 "NMI watchdog is permanently disabled\n");
480 return -EIO; 475 return -EIO;
diff --git a/include/asm-x86/nmi.h b/include/asm-x86/nmi.h
index 1348e542360f..21f8d0202a82 100644
--- a/include/asm-x86/nmi.h
+++ b/include/asm-x86/nmi.h
@@ -56,6 +56,19 @@ static inline void localise_nmi_watchdog(void)
56 if (nmi_watchdog == NMI_IO_APIC) 56 if (nmi_watchdog == NMI_IO_APIC)
57 nmi_watchdog = NMI_LOCAL_APIC; 57 nmi_watchdog = NMI_LOCAL_APIC;
58} 58}
59
60/* check if nmi_watchdog is active (ie was specified at boot) */
61static inline int nmi_watchdog_active(void)
62{
63 /*
64 * actually it should be:
65 * return (nmi_watchdog == NMI_LOCAL_APIC ||
66 * nmi_watchdog == NMI_IO_APIC)
67 * but since they are power of two we could use a
68 * cheaper way --cvg
69 */
70 return nmi_watchdog & 0x3;
71}
59#endif 72#endif
60 73
61void lapic_watchdog_stop(void); 74void lapic_watchdog_stop(void);