blob: 1e041063b22654aa375630bf36282d10059d7bec [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef LINUX_HARDIRQ_H
2#define LINUX_HARDIRQ_H
3
Frederic Weisbecker2d4b8472013-07-29 20:29:43 +02004#include <linux/preempt_mask.h>
Ingo Molnarfbb9ce952006-07-03 00:24:50 -07005#include <linux/lockdep.h>
Steven Rostedt6a60dd12008-11-06 15:55:21 -05006#include <linux/ftrace_irq.h>
Frederic Weisbeckerdcbf8322012-10-05 23:07:19 +02007#include <linux/vtime.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008
Linus Torvalds1da177e2005-04-16 15:20:36 -07009
Linus Torvalds1da177e2005-04-16 15:20:36 -070010extern void synchronize_irq(unsigned int irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -070011
Paul E. McKenney127781d2013-03-27 08:44:00 -070012#if defined(CONFIG_TINY_RCU)
Paul E. McKenney9b1d82f2009-10-25 19:03:50 -070013
14static inline void rcu_nmi_enter(void)
15{
16}
17
18static inline void rcu_nmi_exit(void)
19{
20}
21
22#else
Paul E. McKenney64db4cf2008-12-18 21:55:32 +010023extern void rcu_nmi_enter(void);
24extern void rcu_nmi_exit(void);
Paul E. McKenney9b1d82f2009-10-25 19:03:50 -070025#endif
Steven Rostedt2232c2d2008-02-29 18:46:50 +010026
Ingo Molnarde30a2b2006-07-03 00:24:42 -070027/*
28 * It is safe to do non-atomic ops on ->hardirq_context,
29 * because NMI handlers may not preempt and the ops are
30 * always balanced, so the interrupted value of ->hardirq_context
31 * will always be restored.
32 */
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -080033#define __irq_enter() \
34 do { \
Frederic Weisbecker6a616712012-12-16 20:00:34 +010035 account_irq_enter_time(current); \
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -080036 add_preempt_count(HARDIRQ_OFFSET); \
37 trace_hardirq_enter(); \
38 } while (0)
39
40/*
41 * Enter irq context (on NO_HZ, update jiffies):
42 */
Ingo Molnardde4b2b2007-02-16 01:27:45 -080043extern void irq_enter(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070044
Ingo Molnarde30a2b2006-07-03 00:24:42 -070045/*
46 * Exit irq context without processing softirqs:
47 */
48#define __irq_exit() \
49 do { \
50 trace_hardirq_exit(); \
Frederic Weisbecker6a616712012-12-16 20:00:34 +010051 account_irq_exit_time(current); \
Ingo Molnarde30a2b2006-07-03 00:24:42 -070052 sub_preempt_count(HARDIRQ_OFFSET); \
53 } while (0)
54
55/*
56 * Exit irq context and process softirqs if needed:
57 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070058extern void irq_exit(void);
59
Steven Rostedt2a7b8df2009-02-12 14:16:46 -050060#define nmi_enter() \
61 do { \
Steven Rostedt0f1ac8f2013-01-15 22:11:19 -050062 lockdep_off(); \
Steven Rostedt2a7b8df2009-02-12 14:16:46 -050063 ftrace_nmi_enter(); \
64 BUG_ON(in_nmi()); \
65 add_preempt_count(NMI_OFFSET + HARDIRQ_OFFSET); \
Steven Rostedt2a7b8df2009-02-12 14:16:46 -050066 rcu_nmi_enter(); \
67 trace_hardirq_enter(); \
Steven Rostedt17666f02008-10-30 16:08:32 -040068 } while (0)
Linus Torvalds5f34fe12008-12-30 16:10:19 -080069
Steven Rostedt2a7b8df2009-02-12 14:16:46 -050070#define nmi_exit() \
71 do { \
72 trace_hardirq_exit(); \
73 rcu_nmi_exit(); \
Steven Rostedt2a7b8df2009-02-12 14:16:46 -050074 BUG_ON(!in_nmi()); \
75 sub_preempt_count(NMI_OFFSET + HARDIRQ_OFFSET); \
76 ftrace_nmi_exit(); \
Steven Rostedt0f1ac8f2013-01-15 22:11:19 -050077 lockdep_on(); \
Steven Rostedt17666f02008-10-30 16:08:32 -040078 } while (0)
Ingo Molnarde30a2b2006-07-03 00:24:42 -070079
Linus Torvalds1da177e2005-04-16 15:20:36 -070080#endif /* LINUX_HARDIRQ_H */