Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
1da177e4 LT |
2 | #ifndef LINUX_HARDIRQ_H |
3 | #define LINUX_HARDIRQ_H | |
4 | ||
92cf2118 | 5 | #include <linux/preempt.h> |
fbb9ce95 | 6 | #include <linux/lockdep.h> |
6a60dd12 | 7 | #include <linux/ftrace_irq.h> |
dcbf832e | 8 | #include <linux/vtime.h> |
0bd3a173 | 9 | #include <asm/hardirq.h> |
1da177e4 | 10 | |
1da177e4 | 11 | |
1da177e4 | 12 | extern void synchronize_irq(unsigned int irq); |
02cea395 | 13 | extern bool synchronize_hardirq(unsigned int irq); |
1da177e4 | 14 | |
127781d1 | 15 | #if defined(CONFIG_TINY_RCU) |
9b1d82fa PM |
16 | |
17 | static inline void rcu_nmi_enter(void) | |
18 | { | |
19 | } | |
20 | ||
21 | static inline void rcu_nmi_exit(void) | |
22 | { | |
23 | } | |
24 | ||
25 | #else | |
64db4cff PM |
26 | extern void rcu_nmi_enter(void); |
27 | extern void rcu_nmi_exit(void); | |
9b1d82fa | 28 | #endif |
2232c2d8 | 29 | |
de30a2b3 IM |
30 | /* |
31 | * It is safe to do non-atomic ops on ->hardirq_context, | |
32 | * because NMI handlers may not preempt and the ops are | |
33 | * always balanced, so the interrupted value of ->hardirq_context | |
34 | * will always be restored. | |
35 | */ | |
79bf2bb3 TG |
36 | #define __irq_enter() \ |
37 | do { \ | |
6a61671b | 38 | account_irq_enter_time(current); \ |
bdb43806 | 39 | preempt_count_add(HARDIRQ_OFFSET); \ |
79bf2bb3 TG |
40 | trace_hardirq_enter(); \ |
41 | } while (0) | |
42 | ||
43 | /* | |
44 | * Enter irq context (on NO_HZ, update jiffies): | |
45 | */ | |
dde4b2b5 | 46 | extern void irq_enter(void); |
de30a2b3 IM |
47 | |
48 | /* | |
49 | * Exit irq context without processing softirqs: | |
50 | */ | |
51 | #define __irq_exit() \ | |
52 | do { \ | |
53 | trace_hardirq_exit(); \ | |
6a61671b | 54 | account_irq_exit_time(current); \ |
bdb43806 | 55 | preempt_count_sub(HARDIRQ_OFFSET); \ |
1da177e4 LT |
56 | } while (0) |
57 | ||
de30a2b3 IM |
58 | /* |
59 | * Exit irq context and process softirqs if needed: | |
60 | */ | |
1da177e4 LT |
61 | extern void irq_exit(void); |
62 | ||
a8aac659 JT |
63 | #ifndef arch_nmi_enter |
64 | #define arch_nmi_enter() do { } while (0) | |
65 | #define arch_nmi_exit() do { } while (0) | |
66 | #endif | |
67 | ||
2a7b8df0 SR |
68 | #define nmi_enter() \ |
69 | do { \ | |
a8aac659 | 70 | arch_nmi_enter(); \ |
42a0bb3f | 71 | printk_nmi_enter(); \ |
0f1ac8fd | 72 | lockdep_off(); \ |
2a7b8df0 SR |
73 | ftrace_nmi_enter(); \ |
74 | BUG_ON(in_nmi()); \ | |
bdb43806 | 75 | preempt_count_add(NMI_OFFSET + HARDIRQ_OFFSET); \ |
2a7b8df0 SR |
76 | rcu_nmi_enter(); \ |
77 | trace_hardirq_enter(); \ | |
17666f02 | 78 | } while (0) |
5f34fe1c | 79 | |
2a7b8df0 SR |
80 | #define nmi_exit() \ |
81 | do { \ | |
82 | trace_hardirq_exit(); \ | |
83 | rcu_nmi_exit(); \ | |
2a7b8df0 | 84 | BUG_ON(!in_nmi()); \ |
bdb43806 | 85 | preempt_count_sub(NMI_OFFSET + HARDIRQ_OFFSET); \ |
2a7b8df0 | 86 | ftrace_nmi_exit(); \ |
0f1ac8fd | 87 | lockdep_on(); \ |
42a0bb3f | 88 | printk_nmi_exit(); \ |
a8aac659 | 89 | arch_nmi_exit(); \ |
17666f02 | 90 | } while (0) |
de30a2b3 | 91 | |
1da177e4 | 92 | #endif /* LINUX_HARDIRQ_H */ |