blob: 93da9c3f334120b64165a8124b79b09e71365bf4 [file] [log] [blame]
H. Peter Anvin1965aae2008-10-22 22:26:29 -07001#ifndef _ASM_X86_NMI_H
2#define _ASM_X86_NMI_H
Glauber de Oliveira Costa6d60cd52008-03-19 14:25:36 -03003
4#include <linux/pm.h>
5#include <asm/irq.h>
6#include <asm/io.h>
7
8#ifdef ARCH_HAS_NMI_WATCHDOG
9
10/**
11 * do_nmi_callback
12 *
13 * Check to see if a callback exists and execute it. Return 1
14 * if the handler exists and was handled successfully.
15 */
16int do_nmi_callback(struct pt_regs *regs, int cpu);
17
Cyrill Gorcunovddca03c2008-05-24 19:36:31 +040018extern void die_nmi(char *str, struct pt_regs *regs, int do_panic);
Glauber de Oliveira Costa6d60cd52008-03-19 14:25:36 -030019extern int check_nmi_watchdog(void);
20extern int nmi_watchdog_enabled;
Glauber de Oliveira Costa6d60cd52008-03-19 14:25:36 -030021extern int avail_to_resrv_perfctr_nmi_bit(unsigned int);
Glauber de Oliveira Costa6d60cd52008-03-19 14:25:36 -030022extern int reserve_perfctr_nmi(unsigned int);
23extern void release_perfctr_nmi(unsigned int);
24extern int reserve_evntsel_nmi(unsigned int);
25extern void release_evntsel_nmi(unsigned int);
Glauber de Oliveira Costa6d60cd52008-03-19 14:25:36 -030026
27extern void setup_apic_nmi_watchdog(void *);
28extern void stop_apic_nmi_watchdog(void *);
29extern void disable_timer_nmi_watchdog(void);
30extern void enable_timer_nmi_watchdog(void);
31extern int nmi_watchdog_tick(struct pt_regs *regs, unsigned reason);
Aristeu Rozanskib3e15bd2008-09-22 13:13:59 -040032extern void cpu_nmi_set_wd_enabled(void);
Glauber de Oliveira Costa6d60cd52008-03-19 14:25:36 -030033
34extern atomic_t nmi_active;
35extern unsigned int nmi_watchdog;
Glauber de Oliveira Costa6d60cd52008-03-19 14:25:36 -030036#define NMI_NONE 0
37#define NMI_IO_APIC 1
38#define NMI_LOCAL_APIC 2
39#define NMI_INVALID 3
Glauber de Oliveira Costa6d60cd52008-03-19 14:25:36 -030040
41struct ctl_table;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -070042extern int proc_nmi_enabled(struct ctl_table *, int ,
Glauber de Oliveira Costa6d60cd52008-03-19 14:25:36 -030043 void __user *, size_t *, loff_t *);
44extern int unknown_nmi_panic;
45
Ingo Molnar47cab6a2009-08-03 09:31:54 +020046void arch_trigger_all_cpu_backtrace(void);
47#define arch_trigger_all_cpu_backtrace arch_trigger_all_cpu_backtrace
Glauber de Oliveira Costa6d60cd52008-03-19 14:25:36 -030048
Maciej W. Rozycki148b5082008-06-06 03:27:41 +010049static inline void localise_nmi_watchdog(void)
50{
51 if (nmi_watchdog == NMI_IO_APIC)
52 nmi_watchdog = NMI_LOCAL_APIC;
53}
Cyrill Gorcunov4de00432008-06-24 22:52:06 +020054
55/* check if nmi_watchdog is active (ie was specified at boot) */
56static inline int nmi_watchdog_active(void)
57{
58 /*
59 * actually it should be:
60 * return (nmi_watchdog == NMI_LOCAL_APIC ||
61 * nmi_watchdog == NMI_IO_APIC)
62 * but since they are power of two we could use a
63 * cheaper way --cvg
64 */
Cyrill Gorcunova4046f82009-06-07 12:19:37 +040065 return nmi_watchdog & (NMI_LOCAL_APIC | NMI_IO_APIC);
Cyrill Gorcunov4de00432008-06-24 22:52:06 +020066}
Glauber de Oliveira Costa6d60cd52008-03-19 14:25:36 -030067#endif
68
69void lapic_watchdog_stop(void);
70int lapic_watchdog_init(unsigned nmi_hz);
71int lapic_wd_event(unsigned nmi_hz);
72unsigned lapic_adjust_nmi_hz(unsigned hz);
Glauber de Oliveira Costa6d60cd52008-03-19 14:25:36 -030073void disable_lapic_nmi_watchdog(void);
74void enable_lapic_nmi_watchdog(void);
75void stop_nmi(void);
76void restart_nmi(void);
77
H. Peter Anvin1965aae2008-10-22 22:26:29 -070078#endif /* _ASM_X86_NMI_H */