1 /* 2 * HW NMI watchdog support 3 * 4 * started by Don Zickus, Copyright (C) 2010 Red Hat, Inc. 5 * 6 * Arch specific calls to support NMI watchdog 7 * 8 * Bits copied from original nmi.c file 9 * 10 */ 11 #include <asm/apic.h> 12 #include <asm/nmi.h> 13 14 #include <linux/cpumask.h> 15 #include <linux/kdebug.h> 16 #include <linux/notifier.h> 17 #include <linux/kprobes.h> 18 #include <linux/nmi.h> 19 #include <linux/module.h> 20 #include <linux/delay.h> 21 #include <linux/seq_buf.h> 22 23 #ifdef CONFIG_HARDLOCKUP_DETECTOR 24 u64 hw_nmi_get_sample_period(int watchdog_thresh) 25 { 26 return (u64)(cpu_khz) * 1000 * watchdog_thresh; 27 } 28 #endif 29 30 #ifdef arch_trigger_all_cpu_backtrace 31 static void nmi_raise_cpu_backtrace(cpumask_t *mask) 32 { 33 apic->send_IPI_mask(mask, NMI_VECTOR); 34 } 35 36 void arch_trigger_all_cpu_backtrace(bool include_self) 37 { 38 nmi_trigger_all_cpu_backtrace(include_self, nmi_raise_cpu_backtrace); 39 } 40 41 static int 42 arch_trigger_all_cpu_backtrace_handler(unsigned int cmd, struct pt_regs *regs) 43 { 44 if (nmi_cpu_backtrace(regs)) 45 return NMI_HANDLED; 46 47 return NMI_DONE; 48 } 49 NOKPROBE_SYMBOL(arch_trigger_all_cpu_backtrace_handler); 50 51 static int __init register_trigger_all_cpu_backtrace(void) 52 { 53 register_nmi_handler(NMI_LOCAL, arch_trigger_all_cpu_backtrace_handler, 54 0, "arch_bt"); 55 return 0; 56 } 57 early_initcall(register_trigger_all_cpu_backtrace); 58 #endif 59