blob: 932f0f86b4b76252e6e6434ab9c15d81c3b17004 [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);
Don Zickus58687ac2010-05-07 17:11:44 -040020#if !defined(CONFIG_LOCKUP_DETECTOR)
Glauber de Oliveira Costa6d60cd52008-03-19 14:25:36 -030021extern int nmi_watchdog_enabled;
Don Zickus504d7cf2010-02-12 17:19:19 -050022#endif
Glauber de Oliveira Costa6d60cd52008-03-19 14:25:36 -030023extern int avail_to_resrv_perfctr_nmi_bit(unsigned int);
Glauber de Oliveira Costa6d60cd52008-03-19 14:25:36 -030024extern int reserve_perfctr_nmi(unsigned int);
25extern void release_perfctr_nmi(unsigned int);
26extern int reserve_evntsel_nmi(unsigned int);
27extern void release_evntsel_nmi(unsigned int);
Glauber de Oliveira Costa6d60cd52008-03-19 14:25:36 -030028
29extern void setup_apic_nmi_watchdog(void *);
30extern void stop_apic_nmi_watchdog(void *);
31extern void disable_timer_nmi_watchdog(void);
32extern void enable_timer_nmi_watchdog(void);
33extern int nmi_watchdog_tick(struct pt_regs *regs, unsigned reason);
Aristeu Rozanskib3e15bd2008-09-22 13:13:59 -040034extern void cpu_nmi_set_wd_enabled(void);
Glauber de Oliveira Costa6d60cd52008-03-19 14:25:36 -030035
36extern atomic_t nmi_active;
37extern unsigned int nmi_watchdog;
Glauber de Oliveira Costa6d60cd52008-03-19 14:25:36 -030038#define NMI_NONE 0
39#define NMI_IO_APIC 1
40#define NMI_LOCAL_APIC 2
41#define NMI_INVALID 3
Glauber de Oliveira Costa6d60cd52008-03-19 14:25:36 -030042
43struct ctl_table;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -070044extern int proc_nmi_enabled(struct ctl_table *, int ,
Glauber de Oliveira Costa6d60cd52008-03-19 14:25:36 -030045 void __user *, size_t *, loff_t *);
46extern int unknown_nmi_panic;
47
Ingo Molnar47cab6a2009-08-03 09:31:54 +020048void arch_trigger_all_cpu_backtrace(void);
49#define arch_trigger_all_cpu_backtrace arch_trigger_all_cpu_backtrace
Glauber de Oliveira Costa6d60cd52008-03-19 14:25:36 -030050
Maciej W. Rozycki148b5082008-06-06 03:27:41 +010051static inline void localise_nmi_watchdog(void)
52{
53 if (nmi_watchdog == NMI_IO_APIC)
54 nmi_watchdog = NMI_LOCAL_APIC;
55}
Cyrill Gorcunov4de00432008-06-24 22:52:06 +020056
57/* check if nmi_watchdog is active (ie was specified at boot) */
58static inline int nmi_watchdog_active(void)
59{
60 /*
61 * actually it should be:
62 * return (nmi_watchdog == NMI_LOCAL_APIC ||
63 * nmi_watchdog == NMI_IO_APIC)
64 * but since they are power of two we could use a
65 * cheaper way --cvg
66 */
Cyrill Gorcunova4046f82009-06-07 12:19:37 +040067 return nmi_watchdog & (NMI_LOCAL_APIC | NMI_IO_APIC);
Cyrill Gorcunov4de00432008-06-24 22:52:06 +020068}
Glauber de Oliveira Costa6d60cd52008-03-19 14:25:36 -030069#endif
70
71void lapic_watchdog_stop(void);
72int lapic_watchdog_init(unsigned nmi_hz);
73int lapic_wd_event(unsigned nmi_hz);
74unsigned lapic_adjust_nmi_hz(unsigned hz);
Glauber de Oliveira Costa6d60cd52008-03-19 14:25:36 -030075void disable_lapic_nmi_watchdog(void);
76void enable_lapic_nmi_watchdog(void);
77void stop_nmi(void);
78void restart_nmi(void);
79
H. Peter Anvin1965aae2008-10-22 22:26:29 -070080#endif /* _ASM_X86_NMI_H */