diff options
Diffstat (limited to 'kernel/irq/chip.c')
-rw-r--r-- | kernel/irq/chip.c | 737 |
1 files changed, 327 insertions, 410 deletions
diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c index b7091d5ca2f8..d5a3009da71a 100644 --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c | |||
@@ -18,363 +18,217 @@ | |||
18 | 18 | ||
19 | #include "internals.h" | 19 | #include "internals.h" |
20 | 20 | ||
21 | static void dynamic_irq_init_x(unsigned int irq, bool keep_chip_data) | ||
22 | { | ||
23 | struct irq_desc *desc; | ||
24 | unsigned long flags; | ||
25 | |||
26 | desc = irq_to_desc(irq); | ||
27 | if (!desc) { | ||
28 | WARN(1, KERN_ERR "Trying to initialize invalid IRQ%d\n", irq); | ||
29 | return; | ||
30 | } | ||
31 | |||
32 | /* Ensure we don't have left over values from a previous use of this irq */ | ||
33 | raw_spin_lock_irqsave(&desc->lock, flags); | ||
34 | desc->status = IRQ_DISABLED; | ||
35 | desc->chip = &no_irq_chip; | ||
36 | desc->handle_irq = handle_bad_irq; | ||
37 | desc->depth = 1; | ||
38 | desc->msi_desc = NULL; | ||
39 | desc->handler_data = NULL; | ||
40 | if (!keep_chip_data) | ||
41 | desc->chip_data = NULL; | ||
42 | desc->action = NULL; | ||
43 | desc->irq_count = 0; | ||
44 | desc->irqs_unhandled = 0; | ||
45 | #ifdef CONFIG_SMP | ||
46 | cpumask_setall(desc->affinity); | ||
47 | #ifdef CONFIG_GENERIC_PENDING_IRQ | ||
48 | cpumask_clear(desc->pending_mask); | ||
49 | #endif | ||
50 | #endif | ||
51 | raw_spin_unlock_irqrestore(&desc->lock, flags); | ||
52 | } | ||
53 | |||
54 | /** | 21 | /** |
55 | * dynamic_irq_init - initialize a dynamically allocated irq | 22 | * irq_set_chip - set the irq chip for an irq |
56 | * @irq: irq number to initialize | ||
57 | */ | ||
58 | void dynamic_irq_init(unsigned int irq) | ||
59 | { | ||
60 | dynamic_irq_init_x(irq, false); | ||
61 | } | ||
62 | |||
63 | /** | ||
64 | * dynamic_irq_init_keep_chip_data - initialize a dynamically allocated irq | ||
65 | * @irq: irq number to initialize | ||
66 | * | ||
67 | * does not set irq_to_desc(irq)->chip_data to NULL | ||
68 | */ | ||
69 | void dynamic_irq_init_keep_chip_data(unsigned int irq) | ||
70 | { | ||
71 | dynamic_irq_init_x(irq, true); | ||
72 | } | ||
73 | |||
74 | static void dynamic_irq_cleanup_x(unsigned int irq, bool keep_chip_data) | ||
75 | { | ||
76 | struct irq_desc *desc = irq_to_desc(irq); | ||
77 | unsigned long flags; | ||
78 | |||
79 | if (!desc) { | ||
80 | WARN(1, KERN_ERR "Trying to cleanup invalid IRQ%d\n", irq); | ||
81 | return; | ||
82 | } | ||
83 | |||
84 | raw_spin_lock_irqsave(&desc->lock, flags); | ||
85 | if (desc->action) { | ||
86 | raw_spin_unlock_irqrestore(&desc->lock, flags); | ||
87 | WARN(1, KERN_ERR "Destroying IRQ%d without calling free_irq\n", | ||
88 | irq); | ||
89 | return; | ||
90 | } | ||
91 | desc->msi_desc = NULL; | ||
92 | desc->handler_data = NULL; | ||
93 | if (!keep_chip_data) | ||
94 | desc->chip_data = NULL; | ||
95 | desc->handle_irq = handle_bad_irq; | ||
96 | desc->chip = &no_irq_chip; | ||
97 | desc->name = NULL; | ||
98 | clear_kstat_irqs(desc); | ||
99 | raw_spin_unlock_irqrestore(&desc->lock, flags); | ||
100 | } | ||
101 | |||
102 | /** | ||
103 | * dynamic_irq_cleanup - cleanup a dynamically allocated irq | ||
104 | * @irq: irq number to initialize | ||
105 | */ | ||
106 | void dynamic_irq_cleanup(unsigned int irq) | ||
107 | { | ||
108 | dynamic_irq_cleanup_x(irq, false); | ||
109 | } | ||
110 | |||
111 | /** | ||
112 | * dynamic_irq_cleanup_keep_chip_data - cleanup a dynamically allocated irq | ||
113 | * @irq: irq number to initialize | ||
114 | * | ||
115 | * does not set irq_to_desc(irq)->chip_data to NULL | ||
116 | */ | ||
117 | void dynamic_irq_cleanup_keep_chip_data(unsigned int irq) | ||
118 | { | ||
119 | dynamic_irq_cleanup_x(irq, true); | ||
120 | } | ||
121 | |||
122 | |||
123 | /** | ||
124 | * set_irq_chip - set the irq chip for an irq | ||
125 | * @irq: irq number | 23 | * @irq: irq number |
126 | * @chip: pointer to irq chip description structure | 24 | * @chip: pointer to irq chip description structure |
127 | */ | 25 | */ |
128 | int set_irq_chip(unsigned int irq, struct irq_chip *chip) | 26 | int irq_set_chip(unsigned int irq, struct irq_chip *chip) |
129 | { | 27 | { |
130 | struct irq_desc *desc = irq_to_desc(irq); | ||
131 | unsigned long flags; | 28 | unsigned long flags; |
29 | struct irq_desc *desc = irq_get_desc_lock(irq, &flags); | ||
132 | 30 | ||
133 | if (!desc) { | 31 | if (!desc) |
134 | WARN(1, KERN_ERR "Trying to install chip for IRQ%d\n", irq); | ||
135 | return -EINVAL; | 32 | return -EINVAL; |
136 | } | ||
137 | 33 | ||
138 | if (!chip) | 34 | if (!chip) |
139 | chip = &no_irq_chip; | 35 | chip = &no_irq_chip; |
140 | 36 | ||
141 | raw_spin_lock_irqsave(&desc->lock, flags); | 37 | desc->irq_data.chip = chip; |
142 | irq_chip_set_defaults(chip); | 38 | irq_put_desc_unlock(desc, flags); |
143 | desc->chip = chip; | 39 | /* |
144 | raw_spin_unlock_irqrestore(&desc->lock, flags); | 40 | * For !CONFIG_SPARSE_IRQ make the irq show up in |
145 | 41 | * allocated_irqs. For the CONFIG_SPARSE_IRQ case, it is | |
42 | * already marked, and this call is harmless. | ||
43 | */ | ||
44 | irq_reserve_irq(irq); | ||
146 | return 0; | 45 | return 0; |
147 | } | 46 | } |
148 | EXPORT_SYMBOL(set_irq_chip); | 47 | EXPORT_SYMBOL(irq_set_chip); |
149 | 48 | ||
150 | /** | 49 | /** |
151 | * set_irq_type - set the irq trigger type for an irq | 50 | * irq_set_type - set the irq trigger type for an irq |
152 | * @irq: irq number | 51 | * @irq: irq number |
153 | * @type: IRQ_TYPE_{LEVEL,EDGE}_* value - see include/linux/irq.h | 52 | * @type: IRQ_TYPE_{LEVEL,EDGE}_* value - see include/linux/irq.h |
154 | */ | 53 | */ |
155 | int set_irq_type(unsigned int irq, unsigned int type) | 54 | int irq_set_irq_type(unsigned int irq, unsigned int type) |
156 | { | 55 | { |
157 | struct irq_desc *desc = irq_to_desc(irq); | ||
158 | unsigned long flags; | 56 | unsigned long flags; |
159 | int ret = -ENXIO; | 57 | struct irq_desc *desc = irq_get_desc_buslock(irq, &flags); |
58 | int ret = 0; | ||
160 | 59 | ||
161 | if (!desc) { | 60 | if (!desc) |
162 | printk(KERN_ERR "Trying to set irq type for IRQ%d\n", irq); | 61 | return -EINVAL; |
163 | return -ENODEV; | ||
164 | } | ||
165 | 62 | ||
166 | type &= IRQ_TYPE_SENSE_MASK; | 63 | type &= IRQ_TYPE_SENSE_MASK; |
167 | if (type == IRQ_TYPE_NONE) | 64 | if (type != IRQ_TYPE_NONE) |
168 | return 0; | 65 | ret = __irq_set_trigger(desc, irq, type); |
169 | 66 | irq_put_desc_busunlock(desc, flags); | |
170 | raw_spin_lock_irqsave(&desc->lock, flags); | ||
171 | ret = __irq_set_trigger(desc, irq, type); | ||
172 | raw_spin_unlock_irqrestore(&desc->lock, flags); | ||
173 | return ret; | 67 | return ret; |
174 | } | 68 | } |
175 | EXPORT_SYMBOL(set_irq_type); | 69 | EXPORT_SYMBOL(irq_set_irq_type); |
176 | 70 | ||
177 | /** | 71 | /** |
178 | * set_irq_data - set irq type data for an irq | 72 | * irq_set_handler_data - set irq handler data for an irq |
179 | * @irq: Interrupt number | 73 | * @irq: Interrupt number |
180 | * @data: Pointer to interrupt specific data | 74 | * @data: Pointer to interrupt specific data |
181 | * | 75 | * |
182 | * Set the hardware irq controller data for an irq | 76 | * Set the hardware irq controller data for an irq |
183 | */ | 77 | */ |
184 | int set_irq_data(unsigned int irq, void *data) | 78 | int irq_set_handler_data(unsigned int irq, void *data) |
185 | { | 79 | { |
186 | struct irq_desc *desc = irq_to_desc(irq); | ||
187 | unsigned long flags; | 80 | unsigned long flags; |
81 | struct irq_desc *desc = irq_get_desc_lock(irq, &flags); | ||
188 | 82 | ||
189 | if (!desc) { | 83 | if (!desc) |
190 | printk(KERN_ERR | ||
191 | "Trying to install controller data for IRQ%d\n", irq); | ||
192 | return -EINVAL; | 84 | return -EINVAL; |
193 | } | 85 | desc->irq_data.handler_data = data; |
194 | 86 | irq_put_desc_unlock(desc, flags); | |
195 | raw_spin_lock_irqsave(&desc->lock, flags); | ||
196 | desc->handler_data = data; | ||
197 | raw_spin_unlock_irqrestore(&desc->lock, flags); | ||
198 | return 0; | 87 | return 0; |
199 | } | 88 | } |
200 | EXPORT_SYMBOL(set_irq_data); | 89 | EXPORT_SYMBOL(irq_set_handler_data); |
201 | 90 | ||
202 | /** | 91 | /** |
203 | * set_irq_msi - set MSI descriptor data for an irq | 92 | * irq_set_msi_desc - set MSI descriptor data for an irq |
204 | * @irq: Interrupt number | 93 | * @irq: Interrupt number |
205 | * @entry: Pointer to MSI descriptor data | 94 | * @entry: Pointer to MSI descriptor data |
206 | * | 95 | * |
207 | * Set the MSI descriptor entry for an irq | 96 | * Set the MSI descriptor entry for an irq |
208 | */ | 97 | */ |
209 | int set_irq_msi(unsigned int irq, struct msi_desc *entry) | 98 | int irq_set_msi_desc(unsigned int irq, struct msi_desc *entry) |
210 | { | 99 | { |
211 | struct irq_desc *desc = irq_to_desc(irq); | ||
212 | unsigned long flags; | 100 | unsigned long flags; |
101 | struct irq_desc *desc = irq_get_desc_lock(irq, &flags); | ||
213 | 102 | ||
214 | if (!desc) { | 103 | if (!desc) |
215 | printk(KERN_ERR | ||
216 | "Trying to install msi data for IRQ%d\n", irq); | ||
217 | return -EINVAL; | 104 | return -EINVAL; |
218 | } | 105 | desc->irq_data.msi_desc = entry; |
219 | |||
220 | raw_spin_lock_irqsave(&desc->lock, flags); | ||
221 | desc->msi_desc = entry; | ||
222 | if (entry) | 106 | if (entry) |
223 | entry->irq = irq; | 107 | entry->irq = irq; |
224 | raw_spin_unlock_irqrestore(&desc->lock, flags); | 108 | irq_put_desc_unlock(desc, flags); |
225 | return 0; | 109 | return 0; |
226 | } | 110 | } |
227 | 111 | ||
228 | /** | 112 | /** |
229 | * set_irq_chip_data - set irq chip data for an irq | 113 | * irq_set_chip_data - set irq chip data for an irq |
230 | * @irq: Interrupt number | 114 | * @irq: Interrupt number |
231 | * @data: Pointer to chip specific data | 115 | * @data: Pointer to chip specific data |
232 | * | 116 | * |
233 | * Set the hardware irq chip data for an irq | 117 | * Set the hardware irq chip data for an irq |
234 | */ | 118 | */ |
235 | int set_irq_chip_data(unsigned int irq, void *data) | 119 | int irq_set_chip_data(unsigned int irq, void *data) |
236 | { | 120 | { |
237 | struct irq_desc *desc = irq_to_desc(irq); | ||
238 | unsigned long flags; | 121 | unsigned long flags; |
122 | struct irq_desc *desc = irq_get_desc_lock(irq, &flags); | ||
239 | 123 | ||
240 | if (!desc) { | 124 | if (!desc) |
241 | printk(KERN_ERR | ||
242 | "Trying to install chip data for IRQ%d\n", irq); | ||
243 | return -EINVAL; | ||
244 | } | ||
245 | |||
246 | if (!desc->chip) { | ||
247 | printk(KERN_ERR "BUG: bad set_irq_chip_data(IRQ#%d)\n", irq); | ||
248 | return -EINVAL; | 125 | return -EINVAL; |
249 | } | 126 | desc->irq_data.chip_data = data; |
250 | 127 | irq_put_desc_unlock(desc, flags); | |
251 | raw_spin_lock_irqsave(&desc->lock, flags); | ||
252 | desc->chip_data = data; | ||
253 | raw_spin_unlock_irqrestore(&desc->lock, flags); | ||
254 | |||
255 | return 0; | 128 | return 0; |
256 | } | 129 | } |
257 | EXPORT_SYMBOL(set_irq_chip_data); | 130 | EXPORT_SYMBOL(irq_set_chip_data); |
258 | 131 | ||
259 | /** | 132 | struct irq_data *irq_get_irq_data(unsigned int irq) |
260 | * set_irq_nested_thread - Set/Reset the IRQ_NESTED_THREAD flag of an irq | ||
261 | * | ||
262 | * @irq: Interrupt number | ||
263 | * @nest: 0 to clear / 1 to set the IRQ_NESTED_THREAD flag | ||
264 | * | ||
265 | * The IRQ_NESTED_THREAD flag indicates that on | ||
266 | * request_threaded_irq() no separate interrupt thread should be | ||
267 | * created for the irq as the handler are called nested in the | ||
268 | * context of a demultiplexing interrupt handler thread. | ||
269 | */ | ||
270 | void set_irq_nested_thread(unsigned int irq, int nest) | ||
271 | { | 133 | { |
272 | struct irq_desc *desc = irq_to_desc(irq); | 134 | struct irq_desc *desc = irq_to_desc(irq); |
273 | unsigned long flags; | ||
274 | 135 | ||
275 | if (!desc) | 136 | return desc ? &desc->irq_data : NULL; |
276 | return; | 137 | } |
138 | EXPORT_SYMBOL_GPL(irq_get_irq_data); | ||
277 | 139 | ||
278 | raw_spin_lock_irqsave(&desc->lock, flags); | 140 | static void irq_state_clr_disabled(struct irq_desc *desc) |
279 | if (nest) | 141 | { |
280 | desc->status |= IRQ_NESTED_THREAD; | 142 | irqd_clear(&desc->irq_data, IRQD_IRQ_DISABLED); |
281 | else | ||
282 | desc->status &= ~IRQ_NESTED_THREAD; | ||
283 | raw_spin_unlock_irqrestore(&desc->lock, flags); | ||
284 | } | 143 | } |
285 | EXPORT_SYMBOL_GPL(set_irq_nested_thread); | ||
286 | 144 | ||
287 | /* | 145 | static void irq_state_set_disabled(struct irq_desc *desc) |
288 | * default enable function | ||
289 | */ | ||
290 | static void default_enable(unsigned int irq) | ||
291 | { | 146 | { |
292 | struct irq_desc *desc = irq_to_desc(irq); | 147 | irqd_set(&desc->irq_data, IRQD_IRQ_DISABLED); |
148 | } | ||
293 | 149 | ||
294 | desc->chip->unmask(irq); | 150 | static void irq_state_clr_masked(struct irq_desc *desc) |
295 | desc->status &= ~IRQ_MASKED; | 151 | { |
152 | irqd_clear(&desc->irq_data, IRQD_IRQ_MASKED); | ||
296 | } | 153 | } |
297 | 154 | ||
298 | /* | 155 | static void irq_state_set_masked(struct irq_desc *desc) |
299 | * default disable function | ||
300 | */ | ||
301 | static void default_disable(unsigned int irq) | ||
302 | { | 156 | { |
157 | irqd_set(&desc->irq_data, IRQD_IRQ_MASKED); | ||
303 | } | 158 | } |
304 | 159 | ||
305 | /* | 160 | int irq_startup(struct irq_desc *desc) |
306 | * default startup function | ||
307 | */ | ||
308 | static unsigned int default_startup(unsigned int irq) | ||
309 | { | 161 | { |
310 | struct irq_desc *desc = irq_to_desc(irq); | 162 | irq_state_clr_disabled(desc); |
163 | desc->depth = 0; | ||
311 | 164 | ||
312 | desc->chip->enable(irq); | 165 | if (desc->irq_data.chip->irq_startup) { |
166 | int ret = desc->irq_data.chip->irq_startup(&desc->irq_data); | ||
167 | irq_state_clr_masked(desc); | ||
168 | return ret; | ||
169 | } | ||
170 | |||
171 | irq_enable(desc); | ||
313 | return 0; | 172 | return 0; |
314 | } | 173 | } |
315 | 174 | ||
316 | /* | 175 | void irq_shutdown(struct irq_desc *desc) |
317 | * default shutdown function | ||
318 | */ | ||
319 | static void default_shutdown(unsigned int irq) | ||
320 | { | 176 | { |
321 | struct irq_desc *desc = irq_to_desc(irq); | 177 | irq_state_set_disabled(desc); |
178 | desc->depth = 1; | ||
179 | if (desc->irq_data.chip->irq_shutdown) | ||
180 | desc->irq_data.chip->irq_shutdown(&desc->irq_data); | ||
181 | if (desc->irq_data.chip->irq_disable) | ||
182 | desc->irq_data.chip->irq_disable(&desc->irq_data); | ||
183 | else | ||
184 | desc->irq_data.chip->irq_mask(&desc->irq_data); | ||
185 | irq_state_set_masked(desc); | ||
186 | } | ||
322 | 187 | ||
323 | desc->chip->mask(irq); | 188 | void irq_enable(struct irq_desc *desc) |
324 | desc->status |= IRQ_MASKED; | 189 | { |
190 | irq_state_clr_disabled(desc); | ||
191 | if (desc->irq_data.chip->irq_enable) | ||
192 | desc->irq_data.chip->irq_enable(&desc->irq_data); | ||
193 | else | ||
194 | desc->irq_data.chip->irq_unmask(&desc->irq_data); | ||
195 | irq_state_clr_masked(desc); | ||
325 | } | 196 | } |
326 | 197 | ||
327 | /* | 198 | void irq_disable(struct irq_desc *desc) |
328 | * Fixup enable/disable function pointers | ||
329 | */ | ||
330 | void irq_chip_set_defaults(struct irq_chip *chip) | ||
331 | { | 199 | { |
332 | if (!chip->enable) | 200 | irq_state_set_disabled(desc); |
333 | chip->enable = default_enable; | 201 | if (desc->irq_data.chip->irq_disable) { |
334 | if (!chip->disable) | 202 | desc->irq_data.chip->irq_disable(&desc->irq_data); |
335 | chip->disable = default_disable; | 203 | irq_state_set_masked(desc); |
336 | if (!chip->startup) | 204 | } |
337 | chip->startup = default_startup; | ||
338 | /* | ||
339 | * We use chip->disable, when the user provided its own. When | ||
340 | * we have default_disable set for chip->disable, then we need | ||
341 | * to use default_shutdown, otherwise the irq line is not | ||
342 | * disabled on free_irq(): | ||
343 | */ | ||
344 | if (!chip->shutdown) | ||
345 | chip->shutdown = chip->disable != default_disable ? | ||
346 | chip->disable : default_shutdown; | ||
347 | if (!chip->name) | ||
348 | chip->name = chip->typename; | ||
349 | if (!chip->end) | ||
350 | chip->end = dummy_irq_chip.end; | ||
351 | } | 205 | } |
352 | 206 | ||
353 | static inline void mask_ack_irq(struct irq_desc *desc, int irq) | 207 | static inline void mask_ack_irq(struct irq_desc *desc) |
354 | { | 208 | { |
355 | if (desc->chip->mask_ack) | 209 | if (desc->irq_data.chip->irq_mask_ack) |
356 | desc->chip->mask_ack(irq); | 210 | desc->irq_data.chip->irq_mask_ack(&desc->irq_data); |
357 | else { | 211 | else { |
358 | desc->chip->mask(irq); | 212 | desc->irq_data.chip->irq_mask(&desc->irq_data); |
359 | if (desc->chip->ack) | 213 | if (desc->irq_data.chip->irq_ack) |
360 | desc->chip->ack(irq); | 214 | desc->irq_data.chip->irq_ack(&desc->irq_data); |
361 | } | 215 | } |
362 | desc->status |= IRQ_MASKED; | 216 | irq_state_set_masked(desc); |
363 | } | 217 | } |
364 | 218 | ||
365 | static inline void mask_irq(struct irq_desc *desc, int irq) | 219 | void mask_irq(struct irq_desc *desc) |
366 | { | 220 | { |
367 | if (desc->chip->mask) { | 221 | if (desc->irq_data.chip->irq_mask) { |
368 | desc->chip->mask(irq); | 222 | desc->irq_data.chip->irq_mask(&desc->irq_data); |
369 | desc->status |= IRQ_MASKED; | 223 | irq_state_set_masked(desc); |
370 | } | 224 | } |
371 | } | 225 | } |
372 | 226 | ||
373 | static inline void unmask_irq(struct irq_desc *desc, int irq) | 227 | void unmask_irq(struct irq_desc *desc) |
374 | { | 228 | { |
375 | if (desc->chip->unmask) { | 229 | if (desc->irq_data.chip->irq_unmask) { |
376 | desc->chip->unmask(irq); | 230 | desc->irq_data.chip->irq_unmask(&desc->irq_data); |
377 | desc->status &= ~IRQ_MASKED; | 231 | irq_state_clr_masked(desc); |
378 | } | 232 | } |
379 | } | 233 | } |
380 | 234 | ||
@@ -399,10 +253,10 @@ void handle_nested_irq(unsigned int irq) | |||
399 | kstat_incr_irqs_this_cpu(irq, desc); | 253 | kstat_incr_irqs_this_cpu(irq, desc); |
400 | 254 | ||
401 | action = desc->action; | 255 | action = desc->action; |
402 | if (unlikely(!action || (desc->status & IRQ_DISABLED))) | 256 | if (unlikely(!action || irqd_irq_disabled(&desc->irq_data))) |
403 | goto out_unlock; | 257 | goto out_unlock; |
404 | 258 | ||
405 | desc->status |= IRQ_INPROGRESS; | 259 | irqd_set(&desc->irq_data, IRQD_IRQ_INPROGRESS); |
406 | raw_spin_unlock_irq(&desc->lock); | 260 | raw_spin_unlock_irq(&desc->lock); |
407 | 261 | ||
408 | action_ret = action->thread_fn(action->irq, action->dev_id); | 262 | action_ret = action->thread_fn(action->irq, action->dev_id); |
@@ -410,13 +264,20 @@ void handle_nested_irq(unsigned int irq) | |||
410 | note_interrupt(irq, desc, action_ret); | 264 | note_interrupt(irq, desc, action_ret); |
411 | 265 | ||
412 | raw_spin_lock_irq(&desc->lock); | 266 | raw_spin_lock_irq(&desc->lock); |
413 | desc->status &= ~IRQ_INPROGRESS; | 267 | irqd_clear(&desc->irq_data, IRQD_IRQ_INPROGRESS); |
414 | 268 | ||
415 | out_unlock: | 269 | out_unlock: |
416 | raw_spin_unlock_irq(&desc->lock); | 270 | raw_spin_unlock_irq(&desc->lock); |
417 | } | 271 | } |
418 | EXPORT_SYMBOL_GPL(handle_nested_irq); | 272 | EXPORT_SYMBOL_GPL(handle_nested_irq); |
419 | 273 | ||
274 | static bool irq_check_poll(struct irq_desc *desc) | ||
275 | { | ||
276 | if (!(desc->istate & IRQS_POLL_INPROGRESS)) | ||
277 | return false; | ||
278 | return irq_wait_for_poll(desc); | ||
279 | } | ||
280 | |||
420 | /** | 281 | /** |
421 | * handle_simple_irq - Simple and software-decoded IRQs. | 282 | * handle_simple_irq - Simple and software-decoded IRQs. |
422 | * @irq: the interrupt number | 283 | * @irq: the interrupt number |
@@ -432,32 +293,24 @@ EXPORT_SYMBOL_GPL(handle_nested_irq); | |||
432 | void | 293 | void |
433 | handle_simple_irq(unsigned int irq, struct irq_desc *desc) | 294 | handle_simple_irq(unsigned int irq, struct irq_desc *desc) |
434 | { | 295 | { |
435 | struct irqaction *action; | ||
436 | irqreturn_t action_ret; | ||
437 | |||
438 | raw_spin_lock(&desc->lock); | 296 | raw_spin_lock(&desc->lock); |
439 | 297 | ||
440 | if (unlikely(desc->status & IRQ_INPROGRESS)) | 298 | if (unlikely(irqd_irq_inprogress(&desc->irq_data))) |
441 | goto out_unlock; | 299 | if (!irq_check_poll(desc)) |
442 | desc->status &= ~(IRQ_REPLAY | IRQ_WAITING); | 300 | goto out_unlock; |
301 | |||
302 | desc->istate &= ~(IRQS_REPLAY | IRQS_WAITING); | ||
443 | kstat_incr_irqs_this_cpu(irq, desc); | 303 | kstat_incr_irqs_this_cpu(irq, desc); |
444 | 304 | ||
445 | action = desc->action; | 305 | if (unlikely(!desc->action || irqd_irq_disabled(&desc->irq_data))) |
446 | if (unlikely(!action || (desc->status & IRQ_DISABLED))) | ||
447 | goto out_unlock; | 306 | goto out_unlock; |
448 | 307 | ||
449 | desc->status |= IRQ_INPROGRESS; | 308 | handle_irq_event(desc); |
450 | raw_spin_unlock(&desc->lock); | ||
451 | 309 | ||
452 | action_ret = handle_IRQ_event(irq, action); | ||
453 | if (!noirqdebug) | ||
454 | note_interrupt(irq, desc, action_ret); | ||
455 | |||
456 | raw_spin_lock(&desc->lock); | ||
457 | desc->status &= ~IRQ_INPROGRESS; | ||
458 | out_unlock: | 310 | out_unlock: |
459 | raw_spin_unlock(&desc->lock); | 311 | raw_spin_unlock(&desc->lock); |
460 | } | 312 | } |
313 | EXPORT_SYMBOL_GPL(handle_simple_irq); | ||
461 | 314 | ||
462 | /** | 315 | /** |
463 | * handle_level_irq - Level type irq handler | 316 | * handle_level_irq - Level type irq handler |
@@ -472,42 +325,42 @@ out_unlock: | |||
472 | void | 325 | void |
473 | handle_level_irq(unsigned int irq, struct irq_desc *desc) | 326 | handle_level_irq(unsigned int irq, struct irq_desc *desc) |
474 | { | 327 | { |
475 | struct irqaction *action; | ||
476 | irqreturn_t action_ret; | ||
477 | |||
478 | raw_spin_lock(&desc->lock); | 328 | raw_spin_lock(&desc->lock); |
479 | mask_ack_irq(desc, irq); | 329 | mask_ack_irq(desc); |
480 | 330 | ||
481 | if (unlikely(desc->status & IRQ_INPROGRESS)) | 331 | if (unlikely(irqd_irq_inprogress(&desc->irq_data))) |
482 | goto out_unlock; | 332 | if (!irq_check_poll(desc)) |
483 | desc->status &= ~(IRQ_REPLAY | IRQ_WAITING); | 333 | goto out_unlock; |
334 | |||
335 | desc->istate &= ~(IRQS_REPLAY | IRQS_WAITING); | ||
484 | kstat_incr_irqs_this_cpu(irq, desc); | 336 | kstat_incr_irqs_this_cpu(irq, desc); |
485 | 337 | ||
486 | /* | 338 | /* |
487 | * If its disabled or no action available | 339 | * If its disabled or no action available |
488 | * keep it masked and get out of here | 340 | * keep it masked and get out of here |
489 | */ | 341 | */ |
490 | action = desc->action; | 342 | if (unlikely(!desc->action || irqd_irq_disabled(&desc->irq_data))) |
491 | if (unlikely(!action || (desc->status & IRQ_DISABLED))) | ||
492 | goto out_unlock; | 343 | goto out_unlock; |
493 | 344 | ||
494 | desc->status |= IRQ_INPROGRESS; | 345 | handle_irq_event(desc); |
495 | raw_spin_unlock(&desc->lock); | ||
496 | |||
497 | action_ret = handle_IRQ_event(irq, action); | ||
498 | if (!noirqdebug) | ||
499 | note_interrupt(irq, desc, action_ret); | ||
500 | |||
501 | raw_spin_lock(&desc->lock); | ||
502 | desc->status &= ~IRQ_INPROGRESS; | ||
503 | 346 | ||
504 | if (!(desc->status & (IRQ_DISABLED | IRQ_ONESHOT))) | 347 | if (!irqd_irq_disabled(&desc->irq_data) && !(desc->istate & IRQS_ONESHOT)) |
505 | unmask_irq(desc, irq); | 348 | unmask_irq(desc); |
506 | out_unlock: | 349 | out_unlock: |
507 | raw_spin_unlock(&desc->lock); | 350 | raw_spin_unlock(&desc->lock); |
508 | } | 351 | } |
509 | EXPORT_SYMBOL_GPL(handle_level_irq); | 352 | EXPORT_SYMBOL_GPL(handle_level_irq); |
510 | 353 | ||
354 | #ifdef CONFIG_IRQ_PREFLOW_FASTEOI | ||
355 | static inline void preflow_handler(struct irq_desc *desc) | ||
356 | { | ||
357 | if (desc->preflow_handler) | ||
358 | desc->preflow_handler(&desc->irq_data); | ||
359 | } | ||
360 | #else | ||
361 | static inline void preflow_handler(struct irq_desc *desc) { } | ||
362 | #endif | ||
363 | |||
511 | /** | 364 | /** |
512 | * handle_fasteoi_irq - irq handler for transparent controllers | 365 | * handle_fasteoi_irq - irq handler for transparent controllers |
513 | * @irq: the interrupt number | 366 | * @irq: the interrupt number |
@@ -521,42 +374,40 @@ EXPORT_SYMBOL_GPL(handle_level_irq); | |||
521 | void | 374 | void |
522 | handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc) | 375 | handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc) |
523 | { | 376 | { |
524 | struct irqaction *action; | ||
525 | irqreturn_t action_ret; | ||
526 | |||
527 | raw_spin_lock(&desc->lock); | 377 | raw_spin_lock(&desc->lock); |
528 | 378 | ||
529 | if (unlikely(desc->status & IRQ_INPROGRESS)) | 379 | if (unlikely(irqd_irq_inprogress(&desc->irq_data))) |
530 | goto out; | 380 | if (!irq_check_poll(desc)) |
381 | goto out; | ||
531 | 382 | ||
532 | desc->status &= ~(IRQ_REPLAY | IRQ_WAITING); | 383 | desc->istate &= ~(IRQS_REPLAY | IRQS_WAITING); |
533 | kstat_incr_irqs_this_cpu(irq, desc); | 384 | kstat_incr_irqs_this_cpu(irq, desc); |
534 | 385 | ||
535 | /* | 386 | /* |
536 | * If its disabled or no action available | 387 | * If its disabled or no action available |
537 | * then mask it and get out of here: | 388 | * then mask it and get out of here: |
538 | */ | 389 | */ |
539 | action = desc->action; | 390 | if (unlikely(!desc->action || irqd_irq_disabled(&desc->irq_data))) { |
540 | if (unlikely(!action || (desc->status & IRQ_DISABLED))) { | 391 | desc->istate |= IRQS_PENDING; |
541 | desc->status |= IRQ_PENDING; | 392 | mask_irq(desc); |
542 | mask_irq(desc, irq); | ||
543 | goto out; | 393 | goto out; |
544 | } | 394 | } |
545 | 395 | ||
546 | desc->status |= IRQ_INPROGRESS; | 396 | if (desc->istate & IRQS_ONESHOT) |
547 | desc->status &= ~IRQ_PENDING; | 397 | mask_irq(desc); |
548 | raw_spin_unlock(&desc->lock); | ||
549 | |||
550 | action_ret = handle_IRQ_event(irq, action); | ||
551 | if (!noirqdebug) | ||
552 | note_interrupt(irq, desc, action_ret); | ||
553 | 398 | ||
554 | raw_spin_lock(&desc->lock); | 399 | preflow_handler(desc); |
555 | desc->status &= ~IRQ_INPROGRESS; | 400 | handle_irq_event(desc); |
556 | out: | ||
557 | desc->chip->eoi(irq); | ||
558 | 401 | ||
402 | out_eoi: | ||
403 | desc->irq_data.chip->irq_eoi(&desc->irq_data); | ||
404 | out_unlock: | ||
559 | raw_spin_unlock(&desc->lock); | 405 | raw_spin_unlock(&desc->lock); |
406 | return; | ||
407 | out: | ||
408 | if (!(desc->irq_data.chip->flags & IRQCHIP_EOI_IF_HANDLED)) | ||
409 | goto out_eoi; | ||
410 | goto out_unlock; | ||
560 | } | 411 | } |
561 | 412 | ||
562 | /** | 413 | /** |
@@ -565,7 +416,7 @@ out: | |||
565 | * @desc: the interrupt description structure for this irq | 416 | * @desc: the interrupt description structure for this irq |
566 | * | 417 | * |
567 | * Interrupt occures on the falling and/or rising edge of a hardware | 418 | * Interrupt occures on the falling and/or rising edge of a hardware |
568 | * signal. The occurence is latched into the irq controller hardware | 419 | * signal. The occurrence is latched into the irq controller hardware |
569 | * and must be acked in order to be reenabled. After the ack another | 420 | * and must be acked in order to be reenabled. After the ack another |
570 | * interrupt can happen on the same source even before the first one | 421 | * interrupt can happen on the same source even before the first one |
571 | * is handled by the associated event handler. If this happens it | 422 | * is handled by the associated event handler. If this happens it |
@@ -580,34 +431,28 @@ handle_edge_irq(unsigned int irq, struct irq_desc *desc) | |||
580 | { | 431 | { |
581 | raw_spin_lock(&desc->lock); | 432 | raw_spin_lock(&desc->lock); |
582 | 433 | ||
583 | desc->status &= ~(IRQ_REPLAY | IRQ_WAITING); | 434 | desc->istate &= ~(IRQS_REPLAY | IRQS_WAITING); |
584 | |||
585 | /* | 435 | /* |
586 | * If we're currently running this IRQ, or its disabled, | 436 | * If we're currently running this IRQ, or its disabled, |
587 | * we shouldn't process the IRQ. Mark it pending, handle | 437 | * we shouldn't process the IRQ. Mark it pending, handle |
588 | * the necessary masking and go out | 438 | * the necessary masking and go out |
589 | */ | 439 | */ |
590 | if (unlikely((desc->status & (IRQ_INPROGRESS | IRQ_DISABLED)) || | 440 | if (unlikely(irqd_irq_disabled(&desc->irq_data) || |
591 | !desc->action)) { | 441 | irqd_irq_inprogress(&desc->irq_data) || !desc->action)) { |
592 | desc->status |= (IRQ_PENDING | IRQ_MASKED); | 442 | if (!irq_check_poll(desc)) { |
593 | mask_ack_irq(desc, irq); | 443 | desc->istate |= IRQS_PENDING; |
594 | goto out_unlock; | 444 | mask_ack_irq(desc); |
445 | goto out_unlock; | ||
446 | } | ||
595 | } | 447 | } |
596 | kstat_incr_irqs_this_cpu(irq, desc); | 448 | kstat_incr_irqs_this_cpu(irq, desc); |
597 | 449 | ||
598 | /* Start handling the irq */ | 450 | /* Start handling the irq */ |
599 | if (desc->chip->ack) | 451 | desc->irq_data.chip->irq_ack(&desc->irq_data); |
600 | desc->chip->ack(irq); | ||
601 | |||
602 | /* Mark the IRQ currently in progress.*/ | ||
603 | desc->status |= IRQ_INPROGRESS; | ||
604 | 452 | ||
605 | do { | 453 | do { |
606 | struct irqaction *action = desc->action; | 454 | if (unlikely(!desc->action)) { |
607 | irqreturn_t action_ret; | 455 | mask_irq(desc); |
608 | |||
609 | if (unlikely(!action)) { | ||
610 | mask_irq(desc, irq); | ||
611 | goto out_unlock; | 456 | goto out_unlock; |
612 | } | 457 | } |
613 | 458 | ||
@@ -616,26 +461,66 @@ handle_edge_irq(unsigned int irq, struct irq_desc *desc) | |||
616 | * one, we could have masked the irq. | 461 | * one, we could have masked the irq. |
617 | * Renable it, if it was not disabled in meantime. | 462 | * Renable it, if it was not disabled in meantime. |
618 | */ | 463 | */ |
619 | if (unlikely((desc->status & | 464 | if (unlikely(desc->istate & IRQS_PENDING)) { |
620 | (IRQ_PENDING | IRQ_MASKED | IRQ_DISABLED)) == | 465 | if (!irqd_irq_disabled(&desc->irq_data) && |
621 | (IRQ_PENDING | IRQ_MASKED))) { | 466 | irqd_irq_masked(&desc->irq_data)) |
622 | unmask_irq(desc, irq); | 467 | unmask_irq(desc); |
623 | } | 468 | } |
624 | 469 | ||
625 | desc->status &= ~IRQ_PENDING; | 470 | handle_irq_event(desc); |
626 | raw_spin_unlock(&desc->lock); | ||
627 | action_ret = handle_IRQ_event(irq, action); | ||
628 | if (!noirqdebug) | ||
629 | note_interrupt(irq, desc, action_ret); | ||
630 | raw_spin_lock(&desc->lock); | ||
631 | 471 | ||
632 | } while ((desc->status & (IRQ_PENDING | IRQ_DISABLED)) == IRQ_PENDING); | 472 | } while ((desc->istate & IRQS_PENDING) && |
473 | !irqd_irq_disabled(&desc->irq_data)); | ||
633 | 474 | ||
634 | desc->status &= ~IRQ_INPROGRESS; | ||
635 | out_unlock: | 475 | out_unlock: |
636 | raw_spin_unlock(&desc->lock); | 476 | raw_spin_unlock(&desc->lock); |
637 | } | 477 | } |
638 | 478 | ||
479 | #ifdef CONFIG_IRQ_EDGE_EOI_HANDLER | ||
480 | /** | ||
481 | * handle_edge_eoi_irq - edge eoi type IRQ handler | ||
482 | * @irq: the interrupt number | ||
483 | * @desc: the interrupt description structure for this irq | ||
484 | * | ||
485 | * Similar as the above handle_edge_irq, but using eoi and w/o the | ||
486 | * mask/unmask logic. | ||
487 | */ | ||
488 | void handle_edge_eoi_irq(unsigned int irq, struct irq_desc *desc) | ||
489 | { | ||
490 | struct irq_chip *chip = irq_desc_get_chip(desc); | ||
491 | |||
492 | raw_spin_lock(&desc->lock); | ||
493 | |||
494 | desc->istate &= ~(IRQS_REPLAY | IRQS_WAITING); | ||
495 | /* | ||
496 | * If we're currently running this IRQ, or its disabled, | ||
497 | * we shouldn't process the IRQ. Mark it pending, handle | ||
498 | * the necessary masking and go out | ||
499 | */ | ||
500 | if (unlikely(irqd_irq_disabled(&desc->irq_data) || | ||
501 | irqd_irq_inprogress(&desc->irq_data) || !desc->action)) { | ||
502 | if (!irq_check_poll(desc)) { | ||
503 | desc->istate |= IRQS_PENDING; | ||
504 | goto out_eoi; | ||
505 | } | ||
506 | } | ||
507 | kstat_incr_irqs_this_cpu(irq, desc); | ||
508 | |||
509 | do { | ||
510 | if (unlikely(!desc->action)) | ||
511 | goto out_eoi; | ||
512 | |||
513 | handle_irq_event(desc); | ||
514 | |||
515 | } while ((desc->istate & IRQS_PENDING) && | ||
516 | !irqd_irq_disabled(&desc->irq_data)); | ||
517 | |||
518 | out_eoi: | ||
519 | chip->irq_eoi(&desc->irq_data); | ||
520 | raw_spin_unlock(&desc->lock); | ||
521 | } | ||
522 | #endif | ||
523 | |||
639 | /** | 524 | /** |
640 | * handle_percpu_irq - Per CPU local irq handler | 525 | * handle_percpu_irq - Per CPU local irq handler |
641 | * @irq: the interrupt number | 526 | * @irq: the interrupt number |
@@ -646,115 +531,147 @@ out_unlock: | |||
646 | void | 531 | void |
647 | handle_percpu_irq(unsigned int irq, struct irq_desc *desc) | 532 | handle_percpu_irq(unsigned int irq, struct irq_desc *desc) |
648 | { | 533 | { |
649 | irqreturn_t action_ret; | 534 | struct irq_chip *chip = irq_desc_get_chip(desc); |
650 | 535 | ||
651 | kstat_incr_irqs_this_cpu(irq, desc); | 536 | kstat_incr_irqs_this_cpu(irq, desc); |
652 | 537 | ||
653 | if (desc->chip->ack) | 538 | if (chip->irq_ack) |
654 | desc->chip->ack(irq); | 539 | chip->irq_ack(&desc->irq_data); |
655 | 540 | ||
656 | action_ret = handle_IRQ_event(irq, desc->action); | 541 | handle_irq_event_percpu(desc, desc->action); |
657 | if (!noirqdebug) | ||
658 | note_interrupt(irq, desc, action_ret); | ||
659 | 542 | ||
660 | if (desc->chip->eoi) | 543 | if (chip->irq_eoi) |
661 | desc->chip->eoi(irq); | 544 | chip->irq_eoi(&desc->irq_data); |
662 | } | 545 | } |
663 | 546 | ||
664 | void | 547 | void |
665 | __set_irq_handler(unsigned int irq, irq_flow_handler_t handle, int is_chained, | 548 | __irq_set_handler(unsigned int irq, irq_flow_handler_t handle, int is_chained, |
666 | const char *name) | 549 | const char *name) |
667 | { | 550 | { |
668 | struct irq_desc *desc = irq_to_desc(irq); | ||
669 | unsigned long flags; | 551 | unsigned long flags; |
552 | struct irq_desc *desc = irq_get_desc_buslock(irq, &flags); | ||
670 | 553 | ||
671 | if (!desc) { | 554 | if (!desc) |
672 | printk(KERN_ERR | ||
673 | "Trying to install type control for IRQ%d\n", irq); | ||
674 | return; | 555 | return; |
675 | } | ||
676 | 556 | ||
677 | if (!handle) | 557 | if (!handle) { |
678 | handle = handle_bad_irq; | 558 | handle = handle_bad_irq; |
679 | else if (desc->chip == &no_irq_chip) { | 559 | } else { |
680 | printk(KERN_WARNING "Trying to install %sinterrupt handler " | 560 | if (WARN_ON(desc->irq_data.chip == &no_irq_chip)) |
681 | "for IRQ%d\n", is_chained ? "chained " : "", irq); | 561 | goto out; |
682 | /* | ||
683 | * Some ARM implementations install a handler for really dumb | ||
684 | * interrupt hardware without setting an irq_chip. This worked | ||
685 | * with the ARM no_irq_chip but the check in setup_irq would | ||
686 | * prevent us to setup the interrupt at all. Switch it to | ||
687 | * dummy_irq_chip for easy transition. | ||
688 | */ | ||
689 | desc->chip = &dummy_irq_chip; | ||
690 | } | 562 | } |
691 | 563 | ||
692 | chip_bus_lock(irq, desc); | ||
693 | raw_spin_lock_irqsave(&desc->lock, flags); | ||
694 | |||
695 | /* Uninstall? */ | 564 | /* Uninstall? */ |
696 | if (handle == handle_bad_irq) { | 565 | if (handle == handle_bad_irq) { |
697 | if (desc->chip != &no_irq_chip) | 566 | if (desc->irq_data.chip != &no_irq_chip) |
698 | mask_ack_irq(desc, irq); | 567 | mask_ack_irq(desc); |
699 | desc->status |= IRQ_DISABLED; | 568 | irq_state_set_disabled(desc); |
700 | desc->depth = 1; | 569 | desc->depth = 1; |
701 | } | 570 | } |
702 | desc->handle_irq = handle; | 571 | desc->handle_irq = handle; |
703 | desc->name = name; | 572 | desc->name = name; |
704 | 573 | ||
705 | if (handle != handle_bad_irq && is_chained) { | 574 | if (handle != handle_bad_irq && is_chained) { |
706 | desc->status &= ~IRQ_DISABLED; | 575 | irq_settings_set_noprobe(desc); |
707 | desc->status |= IRQ_NOREQUEST | IRQ_NOPROBE; | 576 | irq_settings_set_norequest(desc); |
708 | desc->depth = 0; | 577 | irq_settings_set_nothread(desc); |
709 | desc->chip->startup(irq); | 578 | irq_startup(desc); |
710 | } | 579 | } |
711 | raw_spin_unlock_irqrestore(&desc->lock, flags); | 580 | out: |
712 | chip_bus_sync_unlock(irq, desc); | 581 | irq_put_desc_busunlock(desc, flags); |
713 | } | 582 | } |
714 | EXPORT_SYMBOL_GPL(__set_irq_handler); | 583 | EXPORT_SYMBOL_GPL(__irq_set_handler); |
715 | 584 | ||
716 | void | 585 | void |
717 | set_irq_chip_and_handler(unsigned int irq, struct irq_chip *chip, | 586 | irq_set_chip_and_handler_name(unsigned int irq, struct irq_chip *chip, |
718 | irq_flow_handler_t handle) | 587 | irq_flow_handler_t handle, const char *name) |
719 | { | 588 | { |
720 | set_irq_chip(irq, chip); | 589 | irq_set_chip(irq, chip); |
721 | __set_irq_handler(irq, handle, 0, NULL); | 590 | __irq_set_handler(irq, handle, 0, name); |
722 | } | 591 | } |
723 | 592 | ||
724 | void | 593 | void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set) |
725 | set_irq_chip_and_handler_name(unsigned int irq, struct irq_chip *chip, | ||
726 | irq_flow_handler_t handle, const char *name) | ||
727 | { | 594 | { |
728 | set_irq_chip(irq, chip); | 595 | unsigned long flags; |
729 | __set_irq_handler(irq, handle, 0, name); | 596 | struct irq_desc *desc = irq_get_desc_lock(irq, &flags); |
597 | |||
598 | if (!desc) | ||
599 | return; | ||
600 | irq_settings_clr_and_set(desc, clr, set); | ||
601 | |||
602 | irqd_clear(&desc->irq_data, IRQD_NO_BALANCING | IRQD_PER_CPU | | ||
603 | IRQD_TRIGGER_MASK | IRQD_LEVEL | IRQD_MOVE_PCNTXT); | ||
604 | if (irq_settings_has_no_balance_set(desc)) | ||
605 | irqd_set(&desc->irq_data, IRQD_NO_BALANCING); | ||
606 | if (irq_settings_is_per_cpu(desc)) | ||
607 | irqd_set(&desc->irq_data, IRQD_PER_CPU); | ||
608 | if (irq_settings_can_move_pcntxt(desc)) | ||
609 | irqd_set(&desc->irq_data, IRQD_MOVE_PCNTXT); | ||
610 | if (irq_settings_is_level(desc)) | ||
611 | irqd_set(&desc->irq_data, IRQD_LEVEL); | ||
612 | |||
613 | irqd_set(&desc->irq_data, irq_settings_get_trigger_mask(desc)); | ||
614 | |||
615 | irq_put_desc_unlock(desc, flags); | ||
730 | } | 616 | } |
617 | EXPORT_SYMBOL_GPL(irq_modify_status); | ||
731 | 618 | ||
732 | void set_irq_noprobe(unsigned int irq) | 619 | /** |
620 | * irq_cpu_online - Invoke all irq_cpu_online functions. | ||
621 | * | ||
622 | * Iterate through all irqs and invoke the chip.irq_cpu_online() | ||
623 | * for each. | ||
624 | */ | ||
625 | void irq_cpu_online(void) | ||
733 | { | 626 | { |
734 | struct irq_desc *desc = irq_to_desc(irq); | 627 | struct irq_desc *desc; |
628 | struct irq_chip *chip; | ||
735 | unsigned long flags; | 629 | unsigned long flags; |
630 | unsigned int irq; | ||
736 | 631 | ||
737 | if (!desc) { | 632 | for_each_active_irq(irq) { |
738 | printk(KERN_ERR "Trying to mark IRQ%d non-probeable\n", irq); | 633 | desc = irq_to_desc(irq); |
739 | return; | 634 | if (!desc) |
740 | } | 635 | continue; |
636 | |||
637 | raw_spin_lock_irqsave(&desc->lock, flags); | ||
741 | 638 | ||
742 | raw_spin_lock_irqsave(&desc->lock, flags); | 639 | chip = irq_data_get_irq_chip(&desc->irq_data); |
743 | desc->status |= IRQ_NOPROBE; | 640 | if (chip && chip->irq_cpu_online && |
744 | raw_spin_unlock_irqrestore(&desc->lock, flags); | 641 | (!(chip->flags & IRQCHIP_ONOFFLINE_ENABLED) || |
642 | !irqd_irq_disabled(&desc->irq_data))) | ||
643 | chip->irq_cpu_online(&desc->irq_data); | ||
644 | |||
645 | raw_spin_unlock_irqrestore(&desc->lock, flags); | ||
646 | } | ||
745 | } | 647 | } |
746 | 648 | ||
747 | void set_irq_probe(unsigned int irq) | 649 | /** |
650 | * irq_cpu_offline - Invoke all irq_cpu_offline functions. | ||
651 | * | ||
652 | * Iterate through all irqs and invoke the chip.irq_cpu_offline() | ||
653 | * for each. | ||
654 | */ | ||
655 | void irq_cpu_offline(void) | ||
748 | { | 656 | { |
749 | struct irq_desc *desc = irq_to_desc(irq); | 657 | struct irq_desc *desc; |
658 | struct irq_chip *chip; | ||
750 | unsigned long flags; | 659 | unsigned long flags; |
660 | unsigned int irq; | ||
751 | 661 | ||
752 | if (!desc) { | 662 | for_each_active_irq(irq) { |
753 | printk(KERN_ERR "Trying to mark IRQ%d probeable\n", irq); | 663 | desc = irq_to_desc(irq); |
754 | return; | 664 | if (!desc) |
755 | } | 665 | continue; |
666 | |||
667 | raw_spin_lock_irqsave(&desc->lock, flags); | ||
756 | 668 | ||
757 | raw_spin_lock_irqsave(&desc->lock, flags); | 669 | chip = irq_data_get_irq_chip(&desc->irq_data); |
758 | desc->status &= ~IRQ_NOPROBE; | 670 | if (chip && chip->irq_cpu_offline && |
759 | raw_spin_unlock_irqrestore(&desc->lock, flags); | 671 | (!(chip->flags & IRQCHIP_ONOFFLINE_ENABLED) || |
672 | !irqd_irq_disabled(&desc->irq_data))) | ||
673 | chip->irq_cpu_offline(&desc->irq_data); | ||
674 | |||
675 | raw_spin_unlock_irqrestore(&desc->lock, flags); | ||
676 | } | ||
760 | } | 677 | } |