Commit 4de00436 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Ingo Molnar

x86: nmi_watchdog - introduce nmi_watchdog_active() helper

Signed-off-by: default avatarCyrill Gorcunov <gorcunov@gmail.com>
Cc: macro@linux-mips.org
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent c376d454
...@@ -119,10 +119,7 @@ int __init check_nmi_watchdog(void) ...@@ -119,10 +119,7 @@ int __init check_nmi_watchdog(void)
unsigned int *prev_nmi_count; unsigned int *prev_nmi_count;
int cpu; int cpu;
if (nmi_watchdog == NMI_NONE) if (!nmi_watchdog_active() || !atomic_read(&nmi_active))
return 0;
if (!atomic_read(&nmi_active))
return 0; return 0;
prev_nmi_count = kmalloc(nr_cpu_ids * sizeof(int), GFP_KERNEL); prev_nmi_count = kmalloc(nr_cpu_ids * sizeof(int), GFP_KERNEL);
...@@ -317,8 +314,7 @@ void setup_apic_nmi_watchdog(void *unused) ...@@ -317,8 +314,7 @@ void setup_apic_nmi_watchdog(void *unused)
void stop_apic_nmi_watchdog(void *unused) void stop_apic_nmi_watchdog(void *unused)
{ {
/* only support LOCAL and IO APICs for now */ /* only support LOCAL and IO APICs for now */
if (nmi_watchdog != NMI_LOCAL_APIC && if (!nmi_watchdog_active())
nmi_watchdog != NMI_IO_APIC)
return; return;
if (__get_cpu_var(wd_enabled) == 0) if (__get_cpu_var(wd_enabled) == 0)
return; return;
...@@ -348,8 +344,7 @@ static DEFINE_PER_CPU(int, nmi_touch); ...@@ -348,8 +344,7 @@ static DEFINE_PER_CPU(int, nmi_touch);
void touch_nmi_watchdog(void) void touch_nmi_watchdog(void)
{ {
if (nmi_watchdog == NMI_LOCAL_APIC || if (nmi_watchdog_active()) {
nmi_watchdog == NMI_IO_APIC) {
unsigned cpu; unsigned cpu;
/* /*
...@@ -474,7 +469,7 @@ int proc_nmi_enabled(struct ctl_table *table, int write, struct file *file, ...@@ -474,7 +469,7 @@ int proc_nmi_enabled(struct ctl_table *table, int write, struct file *file,
if (!!old_state == !!nmi_watchdog_enabled) if (!!old_state == !!nmi_watchdog_enabled)
return 0; return 0;
if (atomic_read(&nmi_active) < 0 || nmi_watchdog == NMI_NONE) { if (atomic_read(&nmi_active) < 0 || !nmi_watchdog_active()) {
printk(KERN_WARNING printk(KERN_WARNING
"NMI watchdog is permanently disabled\n"); "NMI watchdog is permanently disabled\n");
return -EIO; return -EIO;
......
...@@ -56,6 +56,19 @@ static inline void localise_nmi_watchdog(void) ...@@ -56,6 +56,19 @@ static inline void localise_nmi_watchdog(void)
if (nmi_watchdog == NMI_IO_APIC) if (nmi_watchdog == NMI_IO_APIC)
nmi_watchdog = NMI_LOCAL_APIC; nmi_watchdog = NMI_LOCAL_APIC;
} }
/* check if nmi_watchdog is active (ie was specified at boot) */
static inline int nmi_watchdog_active(void)
{
/*
* actually it should be:
* return (nmi_watchdog == NMI_LOCAL_APIC ||
* nmi_watchdog == NMI_IO_APIC)
* but since they are power of two we could use a
* cheaper way --cvg
*/
return nmi_watchdog & 0x3;
}
#endif #endif
void lapic_watchdog_stop(void); void lapic_watchdog_stop(void);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment