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/init.h> 20 #include <linux/delay.h> 21 22 #ifdef CONFIG_HARDLOCKUP_DETECTOR 23 u64 hw_nmi_get_sample_period(int watchdog_thresh) 24 { 25 return (u64)(cpu_khz) * 1000 * watchdog_thresh; 26 } 27 #endif 28 29 #ifdef arch_trigger_all_cpu_backtrace 30 static void nmi_raise_cpu_backtrace(cpumask_t *mask) 31 { 32 apic->send_IPI_mask(mask, NMI_VECTOR); 33 } 34 35 void arch_trigger_all_cpu_backtrace(bool include_self) 36 { 37 nmi_trigger_all_cpu_backtrace(include_self, nmi_raise_cpu_backtrace); 38 } 39 40 static int 41 arch_trigger_all_cpu_backtrace_handler(unsigned int cmd, struct pt_regs *regs) 42 { 43 if (nmi_cpu_backtrace(regs)) 44 return NMI_HANDLED; 45 46 return NMI_DONE; 47 } 48 NOKPROBE_SYMBOL(arch_trigger_all_cpu_backtrace_handler); 49 50 static int __init register_trigger_all_cpu_backtrace(void) 51 { 52 register_nmi_handler(NMI_LOCAL, arch_trigger_all_cpu_backtrace_handler, 53 0, "arch_bt"); 54 return 0; 55 } 56 early_initcall(register_trigger_all_cpu_backtrace); 57 #endif 58