]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - include/linux/nmi.h
Merge branches 'for-4.11/upstream-fixes', 'for-4.12/accutouch', 'for-4.12/cp2112...
[mirror_ubuntu-artful-kernel.git] / include / linux / nmi.h
CommitLineData
1da177e4
LT
1/*
2 * linux/include/linux/nmi.h
3 */
4#ifndef LINUX_NMI_H
5#define LINUX_NMI_H
6
9938406a 7#include <linux/sched.h>
1da177e4
LT
8#include <asm/irq.h>
9
249e52e3
BM
10/*
11 * The run state of the lockup detectors is controlled by the content of the
12 * 'watchdog_enabled' variable. Each lockup detector has its dedicated bit -
13 * bit 0 for the hard lockup detector and bit 1 for the soft lockup detector.
14 *
15 * 'watchdog_user_enabled', 'nmi_watchdog_enabled' and 'soft_watchdog_enabled'
16 * are variables that are only used as an 'interface' between the parameters
17 * in /proc/sys/kernel and the internal state bits in 'watchdog_enabled'. The
18 * 'watchdog_thresh' variable is handled differently because its value is not
19 * boolean, and the lockup detectors are 'suspended' while 'watchdog_thresh'
20 * is equal zero.
21 */
22#define NMI_WATCHDOG_ENABLED_BIT 0
23#define SOFT_WATCHDOG_ENABLED_BIT 1
24#define NMI_WATCHDOG_ENABLED (1 << NMI_WATCHDOG_ENABLED_BIT)
25#define SOFT_WATCHDOG_ENABLED (1 << SOFT_WATCHDOG_ENABLED_BIT)
26
1da177e4
LT
27/**
28 * touch_nmi_watchdog - restart NMI watchdog timeout.
29 *
30 * If the architecture supports the NMI watchdog, touch_nmi_watchdog()
31 * may be used to reset the timeout - for code which intentionally
32 * disables interrupts for a long time. This call is stateless.
33 */
d314d74c 34#if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR)
bb81a09e 35#include <asm/nmi.h>
96a84c20
DZ
36extern void touch_nmi_watchdog(void);
37#else
5d0e600d
IM
38static inline void touch_nmi_watchdog(void)
39{
40 touch_softlockup_watchdog();
41}
96a84c20 42#endif
1da177e4 43
6e7458a6 44#if defined(CONFIG_HARDLOCKUP_DETECTOR)
692297d8 45extern void hardlockup_detector_disable(void);
6e7458a6 46#else
aacfbe6a 47static inline void hardlockup_detector_disable(void) {}
6e7458a6
UO
48#endif
49
47cab6a7
IM
50/*
51 * Create trigger_all_cpu_backtrace() out of the arch-provided
52 * base function. Return whether such support was available,
53 * to allow calling code to fall back to some other mechanism:
54 */
9a01c3ed 55#ifdef arch_trigger_cpumask_backtrace
47cab6a7
IM
56static inline bool trigger_all_cpu_backtrace(void)
57{
9a01c3ed 58 arch_trigger_cpumask_backtrace(cpu_online_mask, false);
47cab6a7
IM
59 return true;
60}
9a01c3ed 61
f3aca3d0
AT
62static inline bool trigger_allbutself_cpu_backtrace(void)
63{
9a01c3ed
CM
64 arch_trigger_cpumask_backtrace(cpu_online_mask, true);
65 return true;
66}
67
68static inline bool trigger_cpumask_backtrace(struct cpumask *mask)
69{
70 arch_trigger_cpumask_backtrace(mask, false);
71 return true;
72}
73
74static inline bool trigger_single_cpu_backtrace(int cpu)
75{
76 arch_trigger_cpumask_backtrace(cpumask_of(cpu), false);
f3aca3d0
AT
77 return true;
78}
b2c0b2cb
RK
79
80/* generic implementation */
9a01c3ed
CM
81void nmi_trigger_cpumask_backtrace(const cpumask_t *mask,
82 bool exclude_self,
b2c0b2cb
RK
83 void (*raise)(cpumask_t *mask));
84bool nmi_cpu_backtrace(struct pt_regs *regs);
85
47cab6a7
IM
86#else
87static inline bool trigger_all_cpu_backtrace(void)
88{
89 return false;
90}
f3aca3d0
AT
91static inline bool trigger_allbutself_cpu_backtrace(void)
92{
93 return false;
94}
9a01c3ed
CM
95static inline bool trigger_cpumask_backtrace(struct cpumask *mask)
96{
97 return false;
98}
99static inline bool trigger_single_cpu_backtrace(int cpu)
100{
101 return false;
102}
bb81a09e
AM
103#endif
104
58687acb 105#ifdef CONFIG_LOCKUP_DETECTOR
4eec42f3 106u64 hw_nmi_get_sample_period(int watchdog_thresh);
84d56e66
UO
107extern int nmi_watchdog_enabled;
108extern int soft_watchdog_enabled;
3c00ea82 109extern int watchdog_user_enabled;
586692a5 110extern int watchdog_thresh;
249e52e3 111extern unsigned long watchdog_enabled;
fe4ba3c3 112extern unsigned long *watchdog_cpumask_bits;
b94f5118 113extern atomic_t watchdog_park_in_progress;
249e52e3 114#ifdef CONFIG_SMP
ed235875 115extern int sysctl_softlockup_all_cpu_backtrace;
55537871 116extern int sysctl_hardlockup_all_cpu_backtrace;
249e52e3
BM
117#else
118#define sysctl_softlockup_all_cpu_backtrace 0
119#define sysctl_hardlockup_all_cpu_backtrace 0
120#endif
121extern bool is_hardlockup(void);
504d7cf1 122struct ctl_table;
83a80a39
UO
123extern int proc_watchdog(struct ctl_table *, int ,
124 void __user *, size_t *, loff_t *);
125extern int proc_nmi_watchdog(struct ctl_table *, int ,
126 void __user *, size_t *, loff_t *);
127extern int proc_soft_watchdog(struct ctl_table *, int ,
128 void __user *, size_t *, loff_t *);
129extern int proc_watchdog_thresh(struct ctl_table *, int ,
130 void __user *, size_t *, loff_t *);
fe4ba3c3
CM
131extern int proc_watchdog_cpumask(struct ctl_table *, int,
132 void __user *, size_t *, loff_t *);
ec6a9066
UO
133extern int lockup_detector_suspend(void);
134extern void lockup_detector_resume(void);
999bbe49 135#else
ec6a9066 136static inline int lockup_detector_suspend(void)
999bbe49
UO
137{
138 return 0;
139}
140
ec6a9066 141static inline void lockup_detector_resume(void)
999bbe49
UO
142{
143}
84e478c6
DZ
144#endif
145
44a69f61
TN
146#ifdef CONFIG_HAVE_ACPI_APEI_NMI
147#include <asm/nmi.h>
148#endif
149
1da177e4 150#endif