1#ifndef _LINUX_IRQDESC_H
2#define _LINUX_IRQDESC_H
3
4#include <linux/rcupdate.h>
5
6
7
8
9
10struct irq_affinity_notify;
11struct proc_dir_entry;
12struct module;
13struct irq_desc;
14struct irq_domain;
15struct pt_regs;
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49struct irq_desc {
50 struct irq_common_data irq_common_data;
51 struct irq_data irq_data;
52 unsigned int __percpu *kstat_irqs;
53 irq_flow_handler_t handle_irq;
54#ifdef CONFIG_IRQ_PREFLOW_FASTEOI
55 irq_preflow_handler_t preflow_handler;
56#endif
57 struct irqaction *action;
58 unsigned int status_use_accessors;
59 unsigned int core_internal_state__do_not_mess_with_it;
60 unsigned int depth;
61 unsigned int wake_depth;
62 unsigned int irq_count;
63 unsigned long last_unhandled;
64 unsigned int irqs_unhandled;
65 atomic_t threads_handled;
66 int threads_handled_last;
67 raw_spinlock_t lock;
68 struct cpumask *percpu_enabled;
69#ifdef CONFIG_SMP
70 const struct cpumask *affinity_hint;
71 struct irq_affinity_notify *affinity_notify;
72#ifdef CONFIG_GENERIC_PENDING_IRQ
73 cpumask_var_t pending_mask;
74#endif
75#endif
76 unsigned long threads_oneshot;
77 atomic_t threads_active;
78 wait_queue_head_t wait_for_threads;
79#ifdef CONFIG_PM_SLEEP
80 unsigned int nr_actions;
81 unsigned int no_suspend_depth;
82 unsigned int cond_suspend_depth;
83 unsigned int force_resume_depth;
84#endif
85#ifdef CONFIG_PROC_FS
86 struct proc_dir_entry *dir;
87#endif
88#ifdef CONFIG_SPARSE_IRQ
89 struct rcu_head rcu;
90#endif
91 int parent_irq;
92 struct module *owner;
93 const char *name;
94} ____cacheline_internodealigned_in_smp;
95
96#ifdef CONFIG_SPARSE_IRQ
97extern void irq_lock_sparse(void);
98extern void irq_unlock_sparse(void);
99#else
100static inline void irq_lock_sparse(void) { }
101static inline void irq_unlock_sparse(void) { }
102extern struct irq_desc irq_desc[NR_IRQS];
103#endif
104
105static inline struct irq_desc *irq_data_to_desc(struct irq_data *data)
106{
107 return container_of(data->common, struct irq_desc, irq_common_data);
108}
109
110static inline unsigned int irq_desc_get_irq(struct irq_desc *desc)
111{
112 return desc->irq_data.irq;
113}
114
115static inline struct irq_data *irq_desc_get_irq_data(struct irq_desc *desc)
116{
117 return &desc->irq_data;
118}
119
120static inline struct irq_chip *irq_desc_get_chip(struct irq_desc *desc)
121{
122 return desc->irq_data.chip;
123}
124
125static inline void *irq_desc_get_chip_data(struct irq_desc *desc)
126{
127 return desc->irq_data.chip_data;
128}
129
130static inline void *irq_desc_get_handler_data(struct irq_desc *desc)
131{
132 return desc->irq_common_data.handler_data;
133}
134
135static inline struct msi_desc *irq_desc_get_msi_desc(struct irq_desc *desc)
136{
137 return desc->irq_common_data.msi_desc;
138}
139
140
141
142
143
144static inline void generic_handle_irq_desc(struct irq_desc *desc)
145{
146 desc->handle_irq(desc);
147}
148
149int generic_handle_irq(unsigned int irq);
150
151#ifdef CONFIG_HANDLE_DOMAIN_IRQ
152
153
154
155
156
157
158int __handle_domain_irq(struct irq_domain *domain, unsigned int hwirq,
159 bool lookup, struct pt_regs *regs);
160
161static inline int handle_domain_irq(struct irq_domain *domain,
162 unsigned int hwirq, struct pt_regs *regs)
163{
164 return __handle_domain_irq(domain, hwirq, true, regs);
165}
166#endif
167
168
169static inline int irq_desc_has_action(struct irq_desc *desc)
170{
171 return desc->action != NULL;
172}
173
174static inline int irq_has_action(unsigned int irq)
175{
176 return irq_desc_has_action(irq_to_desc(irq));
177}
178
179
180
181
182
183
184
185
186
187
188
189static inline void irq_set_handler_locked(struct irq_data *data,
190 irq_flow_handler_t handler)
191{
192 struct irq_desc *desc = irq_data_to_desc(data);
193
194 desc->handle_irq = handler;
195}
196
197
198
199
200
201
202
203
204
205
206
207
208
209static inline void
210irq_set_chip_handler_name_locked(struct irq_data *data, struct irq_chip *chip,
211 irq_flow_handler_t handler, const char *name)
212{
213 struct irq_desc *desc = irq_data_to_desc(data);
214
215 desc->handle_irq = handler;
216 desc->name = name;
217 data->chip = chip;
218}
219
220static inline int irq_balancing_disabled(unsigned int irq)
221{
222 struct irq_desc *desc;
223
224 desc = irq_to_desc(irq);
225 return desc->status_use_accessors & IRQ_NO_BALANCING_MASK;
226}
227
228static inline int irq_is_percpu(unsigned int irq)
229{
230 struct irq_desc *desc;
231
232 desc = irq_to_desc(irq);
233 return desc->status_use_accessors & IRQ_PER_CPU;
234}
235
236static inline void
237irq_set_lockdep_class(unsigned int irq, struct lock_class_key *class)
238{
239 struct irq_desc *desc = irq_to_desc(irq);
240
241 if (desc)
242 lockdep_set_class(&desc->lock, class);
243}
244
245#ifdef CONFIG_IRQ_PREFLOW_FASTEOI
246static inline void
247__irq_set_preflow_handler(unsigned int irq, irq_preflow_handler_t handler)
248{
249 struct irq_desc *desc;
250
251 desc = irq_to_desc(irq);
252 desc->preflow_handler = handler;
253}
254#endif
255
256#endif
257