genirq: Fix long-term regression in genirq irq_set_irq_type() handling
[linux-flexiantxendom0-3.2.10.git] / kernel / irq / chip.c
1 /*
2  * linux/kernel/irq/chip.c
3  *
4  * Copyright (C) 1992, 1998-2006 Linus Torvalds, Ingo Molnar
5  * Copyright (C) 2005-2006, Thomas Gleixner, Russell King
6  *
7  * This file contains the core interrupt handling code, for irq-chip
8  * based architectures.
9  *
10  * Detailed information is available in Documentation/DocBook/genericirq
11  */
12
13 #include <linux/irq.h>
14 #include <linux/msi.h>
15 #include <linux/module.h>
16 #include <linux/interrupt.h>
17 #include <linux/kernel_stat.h>
18
19 #include "internals.h"
20
21 /**
22  *      irq_set_chip - set the irq chip for an irq
23  *      @irq:   irq number
24  *      @chip:  pointer to irq chip description structure
25  */
26 int irq_set_chip(unsigned int irq, struct irq_chip *chip)
27 {
28         unsigned long flags;
29         struct irq_desc *desc = irq_get_desc_lock(irq, &flags, 0);
30
31         if (!desc)
32                 return -EINVAL;
33
34         if (!chip)
35                 chip = &no_irq_chip;
36
37         desc->irq_data.chip = chip;
38         irq_put_desc_unlock(desc, flags);
39         /*
40          * For !CONFIG_SPARSE_IRQ make the irq show up in
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);
45         return 0;
46 }
47 EXPORT_SYMBOL(irq_set_chip);
48
49 /**
50  *      irq_set_type - set the irq trigger type for an irq
51  *      @irq:   irq number
52  *      @type:  IRQ_TYPE_{LEVEL,EDGE}_* value - see include/linux/irq.h
53  */
54 int irq_set_irq_type(unsigned int irq, unsigned int type)
55 {
56         unsigned long flags;
57         struct irq_desc *desc = irq_get_desc_buslock(irq, &flags, IRQ_GET_DESC_CHECK_GLOBAL);
58         int ret = 0;
59
60         if (!desc)
61                 return -EINVAL;
62
63         type &= IRQ_TYPE_SENSE_MASK;
64         ret = __irq_set_trigger(desc, irq, type);
65         irq_put_desc_busunlock(desc, flags);
66         return ret;
67 }
68 EXPORT_SYMBOL(irq_set_irq_type);
69
70 /**
71  *      irq_set_handler_data - set irq handler data for an irq
72  *      @irq:   Interrupt number
73  *      @data:  Pointer to interrupt specific data
74  *
75  *      Set the hardware irq controller data for an irq
76  */
77 int irq_set_handler_data(unsigned int irq, void *data)
78 {
79         unsigned long flags;
80         struct irq_desc *desc = irq_get_desc_lock(irq, &flags, 0);
81
82         if (!desc)
83                 return -EINVAL;
84         desc->irq_data.handler_data = data;
85         irq_put_desc_unlock(desc, flags);
86         return 0;
87 }
88 EXPORT_SYMBOL(irq_set_handler_data);
89
90 /**
91  *      irq_set_msi_desc - set MSI descriptor data for an irq
92  *      @irq:   Interrupt number
93  *      @entry: Pointer to MSI descriptor data
94  *
95  *      Set the MSI descriptor entry for an irq
96  */
97 int irq_set_msi_desc(unsigned int irq, struct msi_desc *entry)
98 {
99         unsigned long flags;
100         struct irq_desc *desc = irq_get_desc_lock(irq, &flags, IRQ_GET_DESC_CHECK_GLOBAL);
101
102         if (!desc)
103                 return -EINVAL;
104         desc->irq_data.msi_desc = entry;
105         if (entry)
106                 entry->irq = irq;
107         irq_put_desc_unlock(desc, flags);
108         return 0;
109 }
110
111 /**
112  *      irq_set_chip_data - set irq chip data for an irq
113  *      @irq:   Interrupt number
114  *      @data:  Pointer to chip specific data
115  *
116  *      Set the hardware irq chip data for an irq
117  */
118 int irq_set_chip_data(unsigned int irq, void *data)
119 {
120         unsigned long flags;
121         struct irq_desc *desc = irq_get_desc_lock(irq, &flags, 0);
122
123         if (!desc)
124                 return -EINVAL;
125         desc->irq_data.chip_data = data;
126         irq_put_desc_unlock(desc, flags);
127         return 0;
128 }
129 EXPORT_SYMBOL(irq_set_chip_data);
130
131 struct irq_data *irq_get_irq_data(unsigned int irq)
132 {
133         struct irq_desc *desc = irq_to_desc(irq);
134
135         return desc ? &desc->irq_data : NULL;
136 }
137 EXPORT_SYMBOL_GPL(irq_get_irq_data);
138
139 static void irq_state_clr_disabled(struct irq_desc *desc)
140 {
141         irqd_clear(&desc->irq_data, IRQD_IRQ_DISABLED);
142 }
143
144 static void irq_state_set_disabled(struct irq_desc *desc)
145 {
146         irqd_set(&desc->irq_data, IRQD_IRQ_DISABLED);
147 }
148
149 static void irq_state_clr_masked(struct irq_desc *desc)
150 {
151         irqd_clear(&desc->irq_data, IRQD_IRQ_MASKED);
152 }
153
154 static void irq_state_set_masked(struct irq_desc *desc)
155 {
156         irqd_set(&desc->irq_data, IRQD_IRQ_MASKED);
157 }
158
159 int irq_startup(struct irq_desc *desc)
160 {
161         irq_state_clr_disabled(desc);
162         desc->depth = 0;
163
164         if (desc->irq_data.chip->irq_startup) {
165                 int ret = desc->irq_data.chip->irq_startup(&desc->irq_data);
166                 irq_state_clr_masked(desc);
167                 return ret;
168         }
169
170         irq_enable(desc);
171         return 0;
172 }
173
174 void irq_shutdown(struct irq_desc *desc)
175 {
176         irq_state_set_disabled(desc);
177         desc->depth = 1;
178         if (desc->irq_data.chip->irq_shutdown)
179                 desc->irq_data.chip->irq_shutdown(&desc->irq_data);
180         else if (desc->irq_data.chip->irq_disable)
181                 desc->irq_data.chip->irq_disable(&desc->irq_data);
182         else
183                 desc->irq_data.chip->irq_mask(&desc->irq_data);
184         irq_state_set_masked(desc);
185 }
186
187 void irq_enable(struct irq_desc *desc)
188 {
189         irq_state_clr_disabled(desc);
190         if (desc->irq_data.chip->irq_enable)
191                 desc->irq_data.chip->irq_enable(&desc->irq_data);
192         else
193                 desc->irq_data.chip->irq_unmask(&desc->irq_data);
194         irq_state_clr_masked(desc);
195 }
196
197 void irq_disable(struct irq_desc *desc)
198 {
199         irq_state_set_disabled(desc);
200         if (desc->irq_data.chip->irq_disable) {
201                 desc->irq_data.chip->irq_disable(&desc->irq_data);
202                 irq_state_set_masked(desc);
203         }
204 }
205
206 void irq_percpu_enable(struct irq_desc *desc, unsigned int cpu)
207 {
208         if (desc->irq_data.chip->irq_enable)
209                 desc->irq_data.chip->irq_enable(&desc->irq_data);
210         else
211                 desc->irq_data.chip->irq_unmask(&desc->irq_data);
212         cpumask_set_cpu(cpu, desc->percpu_enabled);
213 }
214
215 void irq_percpu_disable(struct irq_desc *desc, unsigned int cpu)
216 {
217         if (desc->irq_data.chip->irq_disable)
218                 desc->irq_data.chip->irq_disable(&desc->irq_data);
219         else
220                 desc->irq_data.chip->irq_mask(&desc->irq_data);
221         cpumask_clear_cpu(cpu, desc->percpu_enabled);
222 }
223
224 static inline void mask_ack_irq(struct irq_desc *desc)
225 {
226         if (desc->irq_data.chip->irq_mask_ack)
227                 desc->irq_data.chip->irq_mask_ack(&desc->irq_data);
228         else {
229                 desc->irq_data.chip->irq_mask(&desc->irq_data);
230                 if (desc->irq_data.chip->irq_ack)
231                         desc->irq_data.chip->irq_ack(&desc->irq_data);
232         }
233         irq_state_set_masked(desc);
234 }
235
236 void mask_irq(struct irq_desc *desc)
237 {
238         if (desc->irq_data.chip->irq_mask) {
239                 desc->irq_data.chip->irq_mask(&desc->irq_data);
240                 irq_state_set_masked(desc);
241         }
242 }
243
244 void unmask_irq(struct irq_desc *desc)
245 {
246         if (desc->irq_data.chip->irq_unmask) {
247                 desc->irq_data.chip->irq_unmask(&desc->irq_data);
248                 irq_state_clr_masked(desc);
249         }
250 }
251
252 /*
253  *      handle_nested_irq - Handle a nested irq from a irq thread
254  *      @irq:   the interrupt number
255  *
256  *      Handle interrupts which are nested into a threaded interrupt
257  *      handler. The handler function is called inside the calling
258  *      threads context.
259  */
260 void handle_nested_irq(unsigned int irq)
261 {
262         struct irq_desc *desc = irq_to_desc(irq);
263         struct irqaction *action;
264         irqreturn_t action_ret;
265
266         might_sleep();
267
268         raw_spin_lock_irq(&desc->lock);
269
270         kstat_incr_irqs_this_cpu(irq, desc);
271
272         action = desc->action;
273         if (unlikely(!action || irqd_irq_disabled(&desc->irq_data)))
274                 goto out_unlock;
275
276         irqd_set(&desc->irq_data, IRQD_IRQ_INPROGRESS);
277         raw_spin_unlock_irq(&desc->lock);
278
279         action_ret = action->thread_fn(action->irq, action->dev_id);
280         if (!noirqdebug)
281                 note_interrupt(irq, desc, action_ret);
282
283         raw_spin_lock_irq(&desc->lock);
284         irqd_clear(&desc->irq_data, IRQD_IRQ_INPROGRESS);
285
286 out_unlock:
287         raw_spin_unlock_irq(&desc->lock);
288 }
289 EXPORT_SYMBOL_GPL(handle_nested_irq);
290
291 static bool irq_check_poll(struct irq_desc *desc)
292 {
293         if (!(desc->istate & IRQS_POLL_INPROGRESS))
294                 return false;
295         return irq_wait_for_poll(desc);
296 }
297
298 /**
299  *      handle_simple_irq - Simple and software-decoded IRQs.
300  *      @irq:   the interrupt number
301  *      @desc:  the interrupt description structure for this irq
302  *
303  *      Simple interrupts are either sent from a demultiplexing interrupt
304  *      handler or come from hardware, where no interrupt hardware control
305  *      is necessary.
306  *
307  *      Note: The caller is expected to handle the ack, clear, mask and
308  *      unmask issues if necessary.
309  */
310 void
311 handle_simple_irq(unsigned int irq, struct irq_desc *desc)
312 {
313         raw_spin_lock(&desc->lock);
314
315         if (unlikely(irqd_irq_inprogress(&desc->irq_data)))
316                 if (!irq_check_poll(desc))
317                         goto out_unlock;
318
319         desc->istate &= ~(IRQS_REPLAY | IRQS_WAITING);
320         kstat_incr_irqs_this_cpu(irq, desc);
321
322         if (unlikely(!desc->action || irqd_irq_disabled(&desc->irq_data)))
323                 goto out_unlock;
324
325         handle_irq_event(desc);
326
327 out_unlock:
328         raw_spin_unlock(&desc->lock);
329 }
330 EXPORT_SYMBOL_GPL(handle_simple_irq);
331
332 /**
333  *      handle_level_irq - Level type irq handler
334  *      @irq:   the interrupt number
335  *      @desc:  the interrupt description structure for this irq
336  *
337  *      Level type interrupts are active as long as the hardware line has
338  *      the active level. This may require to mask the interrupt and unmask
339  *      it after the associated handler has acknowledged the device, so the
340  *      interrupt line is back to inactive.
341  */
342 void
343 handle_level_irq(unsigned int irq, struct irq_desc *desc)
344 {
345         raw_spin_lock(&desc->lock);
346         mask_ack_irq(desc);
347
348         if (unlikely(irqd_irq_inprogress(&desc->irq_data)))
349                 if (!irq_check_poll(desc))
350                         goto out_unlock;
351
352         desc->istate &= ~(IRQS_REPLAY | IRQS_WAITING);
353         kstat_incr_irqs_this_cpu(irq, desc);
354
355         /*
356          * If its disabled or no action available
357          * keep it masked and get out of here
358          */
359         if (unlikely(!desc->action || irqd_irq_disabled(&desc->irq_data)))
360                 goto out_unlock;
361
362         handle_irq_event(desc);
363
364         if (!irqd_irq_disabled(&desc->irq_data) && !(desc->istate & IRQS_ONESHOT))
365                 unmask_irq(desc);
366 out_unlock:
367         raw_spin_unlock(&desc->lock);
368 }
369 EXPORT_SYMBOL_GPL(handle_level_irq);
370
371 #ifdef CONFIG_IRQ_PREFLOW_FASTEOI
372 static inline void preflow_handler(struct irq_desc *desc)
373 {
374         if (desc->preflow_handler)
375                 desc->preflow_handler(&desc->irq_data);
376 }
377 #else
378 static inline void preflow_handler(struct irq_desc *desc) { }
379 #endif
380
381 /**
382  *      handle_fasteoi_irq - irq handler for transparent controllers
383  *      @irq:   the interrupt number
384  *      @desc:  the interrupt description structure for this irq
385  *
386  *      Only a single callback will be issued to the chip: an ->eoi()
387  *      call when the interrupt has been serviced. This enables support
388  *      for modern forms of interrupt handlers, which handle the flow
389  *      details in hardware, transparently.
390  */
391 void
392 handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc)
393 {
394         raw_spin_lock(&desc->lock);
395
396         if (unlikely(irqd_irq_inprogress(&desc->irq_data)))
397                 if (!irq_check_poll(desc))
398                         goto out;
399
400         desc->istate &= ~(IRQS_REPLAY | IRQS_WAITING);
401         kstat_incr_irqs_this_cpu(irq, desc);
402
403         /*
404          * If its disabled or no action available
405          * then mask it and get out of here:
406          */
407         if (unlikely(!desc->action || irqd_irq_disabled(&desc->irq_data))) {
408                 desc->istate |= IRQS_PENDING;
409                 mask_irq(desc);
410                 goto out;
411         }
412
413         if (desc->istate & IRQS_ONESHOT)
414                 mask_irq(desc);
415
416         preflow_handler(desc);
417         handle_irq_event(desc);
418
419 out_eoi:
420         desc->irq_data.chip->irq_eoi(&desc->irq_data);
421 out_unlock:
422         raw_spin_unlock(&desc->lock);
423         return;
424 out:
425         if (!(desc->irq_data.chip->flags & IRQCHIP_EOI_IF_HANDLED))
426                 goto out_eoi;
427         goto out_unlock;
428 }
429
430 /**
431  *      handle_edge_irq - edge type IRQ handler
432  *      @irq:   the interrupt number
433  *      @desc:  the interrupt description structure for this irq
434  *
435  *      Interrupt occures on the falling and/or rising edge of a hardware
436  *      signal. The occurrence is latched into the irq controller hardware
437  *      and must be acked in order to be reenabled. After the ack another
438  *      interrupt can happen on the same source even before the first one
439  *      is handled by the associated event handler. If this happens it
440  *      might be necessary to disable (mask) the interrupt depending on the
441  *      controller hardware. This requires to reenable the interrupt inside
442  *      of the loop which handles the interrupts which have arrived while
443  *      the handler was running. If all pending interrupts are handled, the
444  *      loop is left.
445  */
446 void
447 handle_edge_irq(unsigned int irq, struct irq_desc *desc)
448 {
449         raw_spin_lock(&desc->lock);
450
451         desc->istate &= ~(IRQS_REPLAY | IRQS_WAITING);
452         /*
453          * If we're currently running this IRQ, or its disabled,
454          * we shouldn't process the IRQ. Mark it pending, handle
455          * the necessary masking and go out
456          */
457         if (unlikely(irqd_irq_disabled(&desc->irq_data) ||
458                      irqd_irq_inprogress(&desc->irq_data) || !desc->action)) {
459                 if (!irq_check_poll(desc)) {
460                         desc->istate |= IRQS_PENDING;
461                         mask_ack_irq(desc);
462                         goto out_unlock;
463                 }
464         }
465         kstat_incr_irqs_this_cpu(irq, desc);
466
467         /* Start handling the irq */
468         desc->irq_data.chip->irq_ack(&desc->irq_data);
469
470         do {
471                 if (unlikely(!desc->action)) {
472                         mask_irq(desc);
473                         goto out_unlock;
474                 }
475
476                 /*
477                  * When another irq arrived while we were handling
478                  * one, we could have masked the irq.
479                  * Renable it, if it was not disabled in meantime.
480                  */
481                 if (unlikely(desc->istate & IRQS_PENDING)) {
482                         if (!irqd_irq_disabled(&desc->irq_data) &&
483                             irqd_irq_masked(&desc->irq_data))
484                                 unmask_irq(desc);
485                 }
486
487                 handle_irq_event(desc);
488
489         } while ((desc->istate & IRQS_PENDING) &&
490                  !irqd_irq_disabled(&desc->irq_data));
491
492 out_unlock:
493         raw_spin_unlock(&desc->lock);
494 }
495
496 #ifdef CONFIG_IRQ_EDGE_EOI_HANDLER
497 /**
498  *      handle_edge_eoi_irq - edge eoi type IRQ handler
499  *      @irq:   the interrupt number
500  *      @desc:  the interrupt description structure for this irq
501  *
502  * Similar as the above handle_edge_irq, but using eoi and w/o the
503  * mask/unmask logic.
504  */
505 void handle_edge_eoi_irq(unsigned int irq, struct irq_desc *desc)
506 {
507         struct irq_chip *chip = irq_desc_get_chip(desc);
508
509         raw_spin_lock(&desc->lock);
510
511         desc->istate &= ~(IRQS_REPLAY | IRQS_WAITING);
512         /*
513          * If we're currently running this IRQ, or its disabled,
514          * we shouldn't process the IRQ. Mark it pending, handle
515          * the necessary masking and go out
516          */
517         if (unlikely(irqd_irq_disabled(&desc->irq_data) ||
518                      irqd_irq_inprogress(&desc->irq_data) || !desc->action)) {
519                 if (!irq_check_poll(desc)) {
520                         desc->istate |= IRQS_PENDING;
521                         goto out_eoi;
522                 }
523         }
524         kstat_incr_irqs_this_cpu(irq, desc);
525
526         do {
527                 if (unlikely(!desc->action))
528                         goto out_eoi;
529
530                 handle_irq_event(desc);
531
532         } while ((desc->istate & IRQS_PENDING) &&
533                  !irqd_irq_disabled(&desc->irq_data));
534
535 out_eoi:
536         chip->irq_eoi(&desc->irq_data);
537         raw_spin_unlock(&desc->lock);
538 }
539 #endif
540
541 /**
542  *      handle_percpu_irq - Per CPU local irq handler
543  *      @irq:   the interrupt number
544  *      @desc:  the interrupt description structure for this irq
545  *
546  *      Per CPU interrupts on SMP machines without locking requirements
547  */
548 void
549 handle_percpu_irq(unsigned int irq, struct irq_desc *desc)
550 {
551         struct irq_chip *chip = irq_desc_get_chip(desc);
552
553         kstat_incr_irqs_this_cpu(irq, desc);
554
555         if (chip->irq_ack)
556                 chip->irq_ack(&desc->irq_data);
557
558         handle_irq_event_percpu(desc, desc->action);
559
560         if (chip->irq_eoi)
561                 chip->irq_eoi(&desc->irq_data);
562 }
563
564 /**
565  * handle_percpu_devid_irq - Per CPU local irq handler with per cpu dev ids
566  * @irq:        the interrupt number
567  * @desc:       the interrupt description structure for this irq
568  *
569  * Per CPU interrupts on SMP machines without locking requirements. Same as
570  * handle_percpu_irq() above but with the following extras:
571  *
572  * action->percpu_dev_id is a pointer to percpu variables which
573  * contain the real device id for the cpu on which this handler is
574  * called
575  */
576 void handle_percpu_devid_irq(unsigned int irq, struct irq_desc *desc)
577 {
578         struct irq_chip *chip = irq_desc_get_chip(desc);
579         struct irqaction *action = desc->action;
580         void *dev_id = __this_cpu_ptr(action->percpu_dev_id);
581         irqreturn_t res;
582
583         kstat_incr_irqs_this_cpu(irq, desc);
584
585         if (chip->irq_ack)
586                 chip->irq_ack(&desc->irq_data);
587
588         trace_irq_handler_entry(irq, action);
589         res = action->handler(irq, dev_id);
590         trace_irq_handler_exit(irq, action, res);
591
592         if (chip->irq_eoi)
593                 chip->irq_eoi(&desc->irq_data);
594 }
595
596 void
597 __irq_set_handler(unsigned int irq, irq_flow_handler_t handle, int is_chained,
598                   const char *name)
599 {
600         unsigned long flags;
601         struct irq_desc *desc = irq_get_desc_buslock(irq, &flags, 0);
602
603         if (!desc)
604                 return;
605
606         if (!handle) {
607                 handle = handle_bad_irq;
608         } else {
609                 if (WARN_ON(desc->irq_data.chip == &no_irq_chip))
610                         goto out;
611         }
612
613         /* Uninstall? */
614         if (handle == handle_bad_irq) {
615                 if (desc->irq_data.chip != &no_irq_chip)
616                         mask_ack_irq(desc);
617                 irq_state_set_disabled(desc);
618                 desc->depth = 1;
619         }
620         desc->handle_irq = handle;
621         desc->name = name;
622
623         if (handle != handle_bad_irq && is_chained) {
624                 irq_settings_set_noprobe(desc);
625                 irq_settings_set_norequest(desc);
626                 irq_settings_set_nothread(desc);
627                 irq_startup(desc);
628         }
629 out:
630         irq_put_desc_busunlock(desc, flags);
631 }
632 EXPORT_SYMBOL_GPL(__irq_set_handler);
633
634 void
635 irq_set_chip_and_handler_name(unsigned int irq, struct irq_chip *chip,
636                               irq_flow_handler_t handle, const char *name)
637 {
638         irq_set_chip(irq, chip);
639         __irq_set_handler(irq, handle, 0, name);
640 }
641
642 void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set)
643 {
644         unsigned long flags;
645         struct irq_desc *desc = irq_get_desc_lock(irq, &flags, 0);
646
647         if (!desc)
648                 return;
649         irq_settings_clr_and_set(desc, clr, set);
650
651         irqd_clear(&desc->irq_data, IRQD_NO_BALANCING | IRQD_PER_CPU |
652                    IRQD_TRIGGER_MASK | IRQD_LEVEL | IRQD_MOVE_PCNTXT);
653         if (irq_settings_has_no_balance_set(desc))
654                 irqd_set(&desc->irq_data, IRQD_NO_BALANCING);
655         if (irq_settings_is_per_cpu(desc))
656                 irqd_set(&desc->irq_data, IRQD_PER_CPU);
657         if (irq_settings_can_move_pcntxt(desc))
658                 irqd_set(&desc->irq_data, IRQD_MOVE_PCNTXT);
659         if (irq_settings_is_level(desc))
660                 irqd_set(&desc->irq_data, IRQD_LEVEL);
661
662         irqd_set(&desc->irq_data, irq_settings_get_trigger_mask(desc));
663
664         irq_put_desc_unlock(desc, flags);
665 }
666 EXPORT_SYMBOL_GPL(irq_modify_status);
667
668 /**
669  *      irq_cpu_online - Invoke all irq_cpu_online functions.
670  *
671  *      Iterate through all irqs and invoke the chip.irq_cpu_online()
672  *      for each.
673  */
674 void irq_cpu_online(void)
675 {
676         struct irq_desc *desc;
677         struct irq_chip *chip;
678         unsigned long flags;
679         unsigned int irq;
680
681         for_each_active_irq(irq) {
682                 desc = irq_to_desc(irq);
683                 if (!desc)
684                         continue;
685
686                 raw_spin_lock_irqsave(&desc->lock, flags);
687
688                 chip = irq_data_get_irq_chip(&desc->irq_data);
689                 if (chip && chip->irq_cpu_online &&
690                     (!(chip->flags & IRQCHIP_ONOFFLINE_ENABLED) ||
691                      !irqd_irq_disabled(&desc->irq_data)))
692                         chip->irq_cpu_online(&desc->irq_data);
693
694                 raw_spin_unlock_irqrestore(&desc->lock, flags);
695         }
696 }
697
698 /**
699  *      irq_cpu_offline - Invoke all irq_cpu_offline functions.
700  *
701  *      Iterate through all irqs and invoke the chip.irq_cpu_offline()
702  *      for each.
703  */
704 void irq_cpu_offline(void)
705 {
706         struct irq_desc *desc;
707         struct irq_chip *chip;
708         unsigned long flags;
709         unsigned int irq;
710
711         for_each_active_irq(irq) {
712                 desc = irq_to_desc(irq);
713                 if (!desc)
714                         continue;
715
716                 raw_spin_lock_irqsave(&desc->lock, flags);
717
718                 chip = irq_data_get_irq_chip(&desc->irq_data);
719                 if (chip && chip->irq_cpu_offline &&
720                     (!(chip->flags & IRQCHIP_ONOFFLINE_ENABLED) ||
721                      !irqd_irq_disabled(&desc->irq_data)))
722                         chip->irq_cpu_offline(&desc->irq_data);
723
724                 raw_spin_unlock_irqrestore(&desc->lock, flags);
725         }
726 }