1 /*
2 * linux/include/linux/nmi.h
3 */
4 #ifndef LINUX_NMI_H
5 #define LINUX_NMI_H
6
7 #include <linux/sched.h>
8 #include <asm/irq.h>
9
10 /**
11 * touch_nmi_watchdog - restart NMI watchdog timeout.
12 *
13 * If the architecture supports the NMI watchdog, touch_nmi_watchdog()
14 * may be used to reset the timeout - for code which intentionally
15 * disables interrupts for a long time. This call is stateless.
16 */
17 #if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR_NMI)
18 #include <asm/nmi.h>
19 #endif
20
21 #if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR)
22 extern void touch_nmi_watchdog(void);
23 #else
touch_nmi_watchdog(void)24 static inline void touch_nmi_watchdog(void)
25 {
26 touch_softlockup_watchdog();
27 }
28 #endif
29
30 #if defined(CONFIG_HARDLOCKUP_DETECTOR)
31 extern void hardlockup_detector_disable(void);
32 #else
hardlockup_detector_disable(void)33 static inline void hardlockup_detector_disable(void) {}
34 #endif
35
36 /*
37 * Create trigger_all_cpu_backtrace() out of the arch-provided
38 * base function. Return whether such support was available,
39 * to allow calling code to fall back to some other mechanism:
40 */
41 #ifdef arch_trigger_all_cpu_backtrace
trigger_all_cpu_backtrace(void)42 static inline bool trigger_all_cpu_backtrace(void)
43 {
44 arch_trigger_all_cpu_backtrace(true);
45
46 return true;
47 }
trigger_allbutself_cpu_backtrace(void)48 static inline bool trigger_allbutself_cpu_backtrace(void)
49 {
50 arch_trigger_all_cpu_backtrace(false);
51 return true;
52 }
53
54 /* generic implementation */
55 void nmi_trigger_all_cpu_backtrace(bool include_self,
56 void (*raise)(cpumask_t *mask));
57 bool nmi_cpu_backtrace(struct pt_regs *regs);
58
59 #else
trigger_all_cpu_backtrace(void)60 static inline bool trigger_all_cpu_backtrace(void)
61 {
62 return false;
63 }
trigger_allbutself_cpu_backtrace(void)64 static inline bool trigger_allbutself_cpu_backtrace(void)
65 {
66 return false;
67 }
68 #endif
69
70 #ifdef CONFIG_LOCKUP_DETECTOR
71 int hw_nmi_is_cpu_stuck(struct pt_regs *);
72 u64 hw_nmi_get_sample_period(int watchdog_thresh);
73 extern int nmi_watchdog_enabled;
74 extern int soft_watchdog_enabled;
75 extern int watchdog_user_enabled;
76 extern int watchdog_thresh;
77 extern unsigned long *watchdog_cpumask_bits;
78 extern int sysctl_softlockup_all_cpu_backtrace;
79 extern int sysctl_hardlockup_all_cpu_backtrace;
80 struct ctl_table;
81 extern int proc_watchdog(struct ctl_table *, int ,
82 void __user *, size_t *, loff_t *);
83 extern int proc_nmi_watchdog(struct ctl_table *, int ,
84 void __user *, size_t *, loff_t *);
85 extern int proc_soft_watchdog(struct ctl_table *, int ,
86 void __user *, size_t *, loff_t *);
87 extern int proc_watchdog_thresh(struct ctl_table *, int ,
88 void __user *, size_t *, loff_t *);
89 extern int proc_watchdog_cpumask(struct ctl_table *, int,
90 void __user *, size_t *, loff_t *);
91 extern int lockup_detector_suspend(void);
92 extern void lockup_detector_resume(void);
93 #else
lockup_detector_suspend(void)94 static inline int lockup_detector_suspend(void)
95 {
96 return 0;
97 }
98
lockup_detector_resume(void)99 static inline void lockup_detector_resume(void)
100 {
101 }
102 #endif
103
104 #ifdef CONFIG_HAVE_ACPI_APEI_NMI
105 #include <asm/nmi.h>
106 #endif
107
108 #endif
109