]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - include/linux/irqflags.h
ACPI: fix acpi_find_child_device() invocation in acpi_preset_companion()
[mirror_ubuntu-bionic-kernel.git] / include / linux / irqflags.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
de30a2b3
IM
2/*
3 * include/linux/irqflags.h
4 *
5 * IRQ flags tracing: follow the state of the hardirq and softirq flags and
6 * provide callbacks for transitions between ON and OFF states.
7 *
8 * This file gets included from lowlevel asm headers too, to provide
9 * wrapped versions of the local_irq_*() APIs, based on the
10 * raw_local_irq_*() macros from the lowlevel headers.
11 */
12#ifndef _LINUX_TRACE_IRQFLAGS_H
13#define _LINUX_TRACE_IRQFLAGS_H
14
3f307891 15#include <linux/typecheck.h>
df9ee292 16#include <asm/irqflags.h>
3f307891 17
de30a2b3 18#ifdef CONFIG_TRACE_IRQFLAGS
de30a2b3
IM
19 extern void trace_softirqs_on(unsigned long ip);
20 extern void trace_softirqs_off(unsigned long ip);
81d68a96
SR
21 extern void trace_hardirqs_on(void);
22 extern void trace_hardirqs_off(void);
de30a2b3
IM
23# define trace_hardirq_context(p) ((p)->hardirq_context)
24# define trace_softirq_context(p) ((p)->softirq_context)
25# define trace_hardirqs_enabled(p) ((p)->hardirqs_enabled)
26# define trace_softirqs_enabled(p) ((p)->softirqs_enabled)
b09be676
BP
27# define trace_hardirq_enter() \
28do { \
29 current->hardirq_context++; \
b09be676
BP
30} while (0)
31# define trace_hardirq_exit() \
32do { \
33 current->hardirq_context--; \
b09be676
BP
34} while (0)
35# define lockdep_softirq_enter() \
36do { \
37 current->softirq_context++; \
b09be676
BP
38} while (0)
39# define lockdep_softirq_exit() \
40do { \
41 current->softirq_context--; \
b09be676 42} while (0)
de30a2b3
IM
43# define INIT_TRACE_IRQFLAGS .softirqs_enabled = 1,
44#else
45# define trace_hardirqs_on() do { } while (0)
46# define trace_hardirqs_off() do { } while (0)
47# define trace_softirqs_on(ip) do { } while (0)
48# define trace_softirqs_off(ip) do { } while (0)
49# define trace_hardirq_context(p) 0
50# define trace_softirq_context(p) 0
51# define trace_hardirqs_enabled(p) 0
52# define trace_softirqs_enabled(p) 0
53# define trace_hardirq_enter() do { } while (0)
54# define trace_hardirq_exit() do { } while (0)
d820ac4c
IM
55# define lockdep_softirq_enter() do { } while (0)
56# define lockdep_softirq_exit() do { } while (0)
de30a2b3
IM
57# define INIT_TRACE_IRQFLAGS
58#endif
59
6cd8a4bb
SR
60#if defined(CONFIG_IRQSOFF_TRACER) || \
61 defined(CONFIG_PREEMPT_TRACER)
81d68a96
SR
62 extern void stop_critical_timings(void);
63 extern void start_critical_timings(void);
64#else
65# define stop_critical_timings() do { } while (0)
66# define start_critical_timings() do { } while (0)
67#endif
68
df9ee292
DH
69/*
70 * Wrap the arch provided IRQ routines to provide appropriate checks.
71 */
72#define raw_local_irq_disable() arch_local_irq_disable()
73#define raw_local_irq_enable() arch_local_irq_enable()
74#define raw_local_irq_save(flags) \
75 do { \
76 typecheck(unsigned long, flags); \
77 flags = arch_local_irq_save(); \
78 } while (0)
79#define raw_local_irq_restore(flags) \
80 do { \
81 typecheck(unsigned long, flags); \
82 arch_local_irq_restore(flags); \
83 } while (0)
84#define raw_local_save_flags(flags) \
85 do { \
86 typecheck(unsigned long, flags); \
87 flags = arch_local_save_flags(); \
88 } while (0)
89#define raw_irqs_disabled_flags(flags) \
90 ({ \
91 typecheck(unsigned long, flags); \
92 arch_irqs_disabled_flags(flags); \
93 })
94#define raw_irqs_disabled() (arch_irqs_disabled())
95#define raw_safe_halt() arch_safe_halt()
de30a2b3 96
df9ee292
DH
97/*
98 * The local_irq_*() APIs are equal to the raw_local_irq*()
99 * if !TRACE_IRQFLAGS.
100 */
db2dcb4f 101#ifdef CONFIG_TRACE_IRQFLAGS
de30a2b3
IM
102#define local_irq_enable() \
103 do { trace_hardirqs_on(); raw_local_irq_enable(); } while (0)
104#define local_irq_disable() \
105 do { raw_local_irq_disable(); trace_hardirqs_off(); } while (0)
3f307891
SR
106#define local_irq_save(flags) \
107 do { \
3f307891
SR
108 raw_local_irq_save(flags); \
109 trace_hardirqs_off(); \
110 } while (0)
de30a2b3 111
3f307891
SR
112
113#define local_irq_restore(flags) \
114 do { \
3f307891
SR
115 if (raw_irqs_disabled_flags(flags)) { \
116 raw_local_irq_restore(flags); \
117 trace_hardirqs_off(); \
118 } else { \
119 trace_hardirqs_on(); \
120 raw_local_irq_restore(flags); \
121 } \
de30a2b3 122 } while (0)
df9ee292
DH
123
124#define safe_halt() \
125 do { \
126 trace_hardirqs_on(); \
127 raw_safe_halt(); \
3f307891 128 } while (0)
de30a2b3 129
de30a2b3 130
db2dcb4f 131#else /* !CONFIG_TRACE_IRQFLAGS */
df9ee292
DH
132
133#define local_irq_enable() do { raw_local_irq_enable(); } while (0)
134#define local_irq_disable() do { raw_local_irq_disable(); } while (0)
135#define local_irq_save(flags) \
136 do { \
137 raw_local_irq_save(flags); \
138 } while (0)
139#define local_irq_restore(flags) do { raw_local_irq_restore(flags); } while (0)
df9ee292
DH
140#define safe_halt() do { raw_safe_halt(); } while (0)
141
db2dcb4f
JB
142#endif /* CONFIG_TRACE_IRQFLAGS */
143
144#define local_save_flags(flags) raw_local_save_flags(flags)
145
146/*
147 * Some architectures don't define arch_irqs_disabled(), so even if either
148 * definition would be fine we need to use different ones for the time being
149 * to avoid build issues.
150 */
151#ifdef CONFIG_TRACE_IRQFLAGS_SUPPORT
152#define irqs_disabled() \
153 ({ \
154 unsigned long _flags; \
155 raw_local_save_flags(_flags); \
156 raw_irqs_disabled_flags(_flags); \
157 })
158#else /* !CONFIG_TRACE_IRQFLAGS_SUPPORT */
159#define irqs_disabled() raw_irqs_disabled()
40b1f4e5 160#endif /* CONFIG_TRACE_IRQFLAGS_SUPPORT */
de30a2b3 161
db2dcb4f
JB
162#define irqs_disabled_flags(flags) raw_irqs_disabled_flags(flags)
163
de30a2b3 164#endif