blob: fc418249f01fc439c21d859f0f740b2ec49708f5 [file] [log] [blame]
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -07001/*
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>
Michael Ellerman7fe37302007-04-18 19:39:21 +100014#include <linux/msi.h>
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -070015#include <linux/module.h>
16#include <linux/interrupt.h>
17#include <linux/kernel_stat.h>
18
Steven Rostedtf0696862012-01-25 20:18:55 -050019#include <trace/events/irq.h>
20
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -070021#include "internals.h"
22
Eric W. Biederman3a16d712006-10-04 02:16:37 -070023/**
Thomas Gleixnera0cd9ca2011-02-10 11:36:33 +010024 * irq_set_chip - set the irq chip for an irq
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -070025 * @irq: irq number
26 * @chip: pointer to irq chip description structure
27 */
Thomas Gleixnera0cd9ca2011-02-10 11:36:33 +010028int irq_set_chip(unsigned int irq, struct irq_chip *chip)
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -070029{
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -070030 unsigned long flags;
Marc Zyngier31d9d9b2011-09-23 17:03:06 +010031 struct irq_desc *desc = irq_get_desc_lock(irq, &flags, 0);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -070032
Thomas Gleixner02725e72011-02-12 10:37:36 +010033 if (!desc)
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -070034 return -EINVAL;
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -070035
36 if (!chip)
37 chip = &no_irq_chip;
38
Thomas Gleixner6b8ff312010-10-01 12:58:38 +020039 desc->irq_data.chip = chip;
Thomas Gleixner02725e72011-02-12 10:37:36 +010040 irq_put_desc_unlock(desc, flags);
David Daneyd72274e2011-03-25 12:38:48 -070041 /*
42 * For !CONFIG_SPARSE_IRQ make the irq show up in
43 * allocated_irqs. For the CONFIG_SPARSE_IRQ case, it is
44 * already marked, and this call is harmless.
45 */
46 irq_reserve_irq(irq);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -070047 return 0;
48}
Thomas Gleixnera0cd9ca2011-02-10 11:36:33 +010049EXPORT_SYMBOL(irq_set_chip);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -070050
51/**
Thomas Gleixnera0cd9ca2011-02-10 11:36:33 +010052 * irq_set_type - set the irq trigger type for an irq
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -070053 * @irq: irq number
David Brownell0c5d1eb2008-10-01 14:46:18 -070054 * @type: IRQ_TYPE_{LEVEL,EDGE}_* value - see include/linux/irq.h
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -070055 */
Thomas Gleixnera0cd9ca2011-02-10 11:36:33 +010056int irq_set_irq_type(unsigned int irq, unsigned int type)
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -070057{
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -070058 unsigned long flags;
Marc Zyngier31d9d9b2011-09-23 17:03:06 +010059 struct irq_desc *desc = irq_get_desc_buslock(irq, &flags, IRQ_GET_DESC_CHECK_GLOBAL);
Thomas Gleixner02725e72011-02-12 10:37:36 +010060 int ret = 0;
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -070061
Thomas Gleixner02725e72011-02-12 10:37:36 +010062 if (!desc)
63 return -EINVAL;
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -070064
David Brownellf2b662d2008-12-01 14:31:38 -080065 type &= IRQ_TYPE_SENSE_MASK;
Thomas Gleixner02725e72011-02-12 10:37:36 +010066 if (type != IRQ_TYPE_NONE)
67 ret = __irq_set_trigger(desc, irq, type);
68 irq_put_desc_busunlock(desc, flags);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -070069 return ret;
70}
Thomas Gleixnera0cd9ca2011-02-10 11:36:33 +010071EXPORT_SYMBOL(irq_set_irq_type);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -070072
73/**
Thomas Gleixnera0cd9ca2011-02-10 11:36:33 +010074 * irq_set_handler_data - set irq handler data for an irq
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -070075 * @irq: Interrupt number
76 * @data: Pointer to interrupt specific data
77 *
78 * Set the hardware irq controller data for an irq
79 */
Thomas Gleixnera0cd9ca2011-02-10 11:36:33 +010080int irq_set_handler_data(unsigned int irq, void *data)
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -070081{
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -070082 unsigned long flags;
Marc Zyngier31d9d9b2011-09-23 17:03:06 +010083 struct irq_desc *desc = irq_get_desc_lock(irq, &flags, 0);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -070084
Thomas Gleixner02725e72011-02-12 10:37:36 +010085 if (!desc)
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -070086 return -EINVAL;
Thomas Gleixner6b8ff312010-10-01 12:58:38 +020087 desc->irq_data.handler_data = data;
Thomas Gleixner02725e72011-02-12 10:37:36 +010088 irq_put_desc_unlock(desc, flags);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -070089 return 0;
90}
Thomas Gleixnera0cd9ca2011-02-10 11:36:33 +010091EXPORT_SYMBOL(irq_set_handler_data);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -070092
93/**
Thomas Gleixnera0cd9ca2011-02-10 11:36:33 +010094 * irq_set_msi_desc - set MSI descriptor data for an irq
Eric W. Biederman5b912c12007-01-28 12:52:03 -070095 * @irq: Interrupt number
Randy Dunlap472900b2007-02-16 01:28:25 -080096 * @entry: Pointer to MSI descriptor data
Eric W. Biederman5b912c12007-01-28 12:52:03 -070097 *
Liuweni24b26d42009-11-04 20:11:05 +080098 * Set the MSI descriptor entry for an irq
Eric W. Biederman5b912c12007-01-28 12:52:03 -070099 */
Thomas Gleixnera0cd9ca2011-02-10 11:36:33 +0100100int irq_set_msi_desc(unsigned int irq, struct msi_desc *entry)
Eric W. Biederman5b912c12007-01-28 12:52:03 -0700101{
Eric W. Biederman5b912c12007-01-28 12:52:03 -0700102 unsigned long flags;
Marc Zyngier31d9d9b2011-09-23 17:03:06 +0100103 struct irq_desc *desc = irq_get_desc_lock(irq, &flags, IRQ_GET_DESC_CHECK_GLOBAL);
Eric W. Biederman5b912c12007-01-28 12:52:03 -0700104
Thomas Gleixner02725e72011-02-12 10:37:36 +0100105 if (!desc)
Eric W. Biederman5b912c12007-01-28 12:52:03 -0700106 return -EINVAL;
Thomas Gleixner6b8ff312010-10-01 12:58:38 +0200107 desc->irq_data.msi_desc = entry;
Michael Ellerman7fe37302007-04-18 19:39:21 +1000108 if (entry)
109 entry->irq = irq;
Thomas Gleixner02725e72011-02-12 10:37:36 +0100110 irq_put_desc_unlock(desc, flags);
Eric W. Biederman5b912c12007-01-28 12:52:03 -0700111 return 0;
112}
113
114/**
Thomas Gleixnera0cd9ca2011-02-10 11:36:33 +0100115 * irq_set_chip_data - set irq chip data for an irq
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700116 * @irq: Interrupt number
117 * @data: Pointer to chip specific data
118 *
119 * Set the hardware irq chip data for an irq
120 */
Thomas Gleixnera0cd9ca2011-02-10 11:36:33 +0100121int irq_set_chip_data(unsigned int irq, void *data)
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700122{
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700123 unsigned long flags;
Marc Zyngier31d9d9b2011-09-23 17:03:06 +0100124 struct irq_desc *desc = irq_get_desc_lock(irq, &flags, 0);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700125
Thomas Gleixner02725e72011-02-12 10:37:36 +0100126 if (!desc)
Yinghai Lu7d94f7c2008-08-19 20:50:14 -0700127 return -EINVAL;
Thomas Gleixner6b8ff312010-10-01 12:58:38 +0200128 desc->irq_data.chip_data = data;
Thomas Gleixner02725e72011-02-12 10:37:36 +0100129 irq_put_desc_unlock(desc, flags);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700130 return 0;
131}
Thomas Gleixnera0cd9ca2011-02-10 11:36:33 +0100132EXPORT_SYMBOL(irq_set_chip_data);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700133
Thomas Gleixnerf303a6d2010-09-28 17:34:01 +0200134struct irq_data *irq_get_irq_data(unsigned int irq)
135{
136 struct irq_desc *desc = irq_to_desc(irq);
137
138 return desc ? &desc->irq_data : NULL;
139}
140EXPORT_SYMBOL_GPL(irq_get_irq_data);
141
Thomas Gleixnerc1594b72011-02-07 22:11:30 +0100142static void irq_state_clr_disabled(struct irq_desc *desc)
143{
Thomas Gleixner801a0e92011-03-27 11:02:49 +0200144 irqd_clear(&desc->irq_data, IRQD_IRQ_DISABLED);
Thomas Gleixnerc1594b72011-02-07 22:11:30 +0100145}
146
147static void irq_state_set_disabled(struct irq_desc *desc)
148{
Thomas Gleixner801a0e92011-03-27 11:02:49 +0200149 irqd_set(&desc->irq_data, IRQD_IRQ_DISABLED);
Thomas Gleixnerc1594b72011-02-07 22:11:30 +0100150}
151
Thomas Gleixner6e402622011-02-08 12:36:06 +0100152static void irq_state_clr_masked(struct irq_desc *desc)
153{
Thomas Gleixner32f41252011-03-28 14:10:52 +0200154 irqd_clear(&desc->irq_data, IRQD_IRQ_MASKED);
Thomas Gleixner6e402622011-02-08 12:36:06 +0100155}
156
157static void irq_state_set_masked(struct irq_desc *desc)
158{
Thomas Gleixner32f41252011-03-28 14:10:52 +0200159 irqd_set(&desc->irq_data, IRQD_IRQ_MASKED);
Thomas Gleixner6e402622011-02-08 12:36:06 +0100160}
161
Thomas Gleixner46999232011-02-02 21:41:14 +0000162int irq_startup(struct irq_desc *desc)
163{
Thomas Gleixnerc1594b72011-02-07 22:11:30 +0100164 irq_state_clr_disabled(desc);
Thomas Gleixner46999232011-02-02 21:41:14 +0000165 desc->depth = 0;
166
Thomas Gleixner3aae9942011-02-04 10:17:52 +0100167 if (desc->irq_data.chip->irq_startup) {
168 int ret = desc->irq_data.chip->irq_startup(&desc->irq_data);
Thomas Gleixner6e402622011-02-08 12:36:06 +0100169 irq_state_clr_masked(desc);
Thomas Gleixner3aae9942011-02-04 10:17:52 +0100170 return ret;
171 }
Thomas Gleixner46999232011-02-02 21:41:14 +0000172
Thomas Gleixner87923472011-02-03 12:27:44 +0100173 irq_enable(desc);
Thomas Gleixner46999232011-02-02 21:41:14 +0000174 return 0;
175}
176
177void irq_shutdown(struct irq_desc *desc)
178{
Thomas Gleixnerc1594b72011-02-07 22:11:30 +0100179 irq_state_set_disabled(desc);
Thomas Gleixner46999232011-02-02 21:41:14 +0000180 desc->depth = 1;
Thomas Gleixner50f7c032011-02-03 13:23:54 +0100181 if (desc->irq_data.chip->irq_shutdown)
182 desc->irq_data.chip->irq_shutdown(&desc->irq_data);
Geert Uytterhoevened585a62011-09-11 13:59:27 +0200183 else if (desc->irq_data.chip->irq_disable)
Thomas Gleixner50f7c032011-02-03 13:23:54 +0100184 desc->irq_data.chip->irq_disable(&desc->irq_data);
185 else
186 desc->irq_data.chip->irq_mask(&desc->irq_data);
Thomas Gleixner6e402622011-02-08 12:36:06 +0100187 irq_state_set_masked(desc);
Thomas Gleixner46999232011-02-02 21:41:14 +0000188}
189
Thomas Gleixner87923472011-02-03 12:27:44 +0100190void irq_enable(struct irq_desc *desc)
191{
Thomas Gleixnerc1594b72011-02-07 22:11:30 +0100192 irq_state_clr_disabled(desc);
Thomas Gleixner50f7c032011-02-03 13:23:54 +0100193 if (desc->irq_data.chip->irq_enable)
194 desc->irq_data.chip->irq_enable(&desc->irq_data);
195 else
196 desc->irq_data.chip->irq_unmask(&desc->irq_data);
Thomas Gleixner6e402622011-02-08 12:36:06 +0100197 irq_state_clr_masked(desc);
Thomas Gleixner87923472011-02-03 12:27:44 +0100198}
199
200void irq_disable(struct irq_desc *desc)
201{
Thomas Gleixnerc1594b72011-02-07 22:11:30 +0100202 irq_state_set_disabled(desc);
Thomas Gleixner50f7c032011-02-03 13:23:54 +0100203 if (desc->irq_data.chip->irq_disable) {
204 desc->irq_data.chip->irq_disable(&desc->irq_data);
Thomas Gleixnera61d8252011-02-21 12:54:34 +0100205 irq_state_set_masked(desc);
Thomas Gleixner50f7c032011-02-03 13:23:54 +0100206 }
Thomas Gleixner89d694b2008-02-18 18:25:17 +0100207}
208
Marc Zyngier31d9d9b2011-09-23 17:03:06 +0100209void irq_percpu_enable(struct irq_desc *desc, unsigned int cpu)
210{
211 if (desc->irq_data.chip->irq_enable)
212 desc->irq_data.chip->irq_enable(&desc->irq_data);
213 else
214 desc->irq_data.chip->irq_unmask(&desc->irq_data);
215 cpumask_set_cpu(cpu, desc->percpu_enabled);
216}
217
218void irq_percpu_disable(struct irq_desc *desc, unsigned int cpu)
219{
220 if (desc->irq_data.chip->irq_disable)
221 desc->irq_data.chip->irq_disable(&desc->irq_data);
222 else
223 desc->irq_data.chip->irq_mask(&desc->irq_data);
224 cpumask_clear_cpu(cpu, desc->percpu_enabled);
225}
226
Thomas Gleixner9205e312010-09-27 12:44:50 +0000227static inline void mask_ack_irq(struct irq_desc *desc)
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700228{
Thomas Gleixner9205e312010-09-27 12:44:50 +0000229 if (desc->irq_data.chip->irq_mask_ack)
230 desc->irq_data.chip->irq_mask_ack(&desc->irq_data);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700231 else {
Thomas Gleixnere2c0f8f2010-09-27 12:44:42 +0000232 desc->irq_data.chip->irq_mask(&desc->irq_data);
Thomas Gleixner22a49162010-09-27 12:44:47 +0000233 if (desc->irq_data.chip->irq_ack)
234 desc->irq_data.chip->irq_ack(&desc->irq_data);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700235 }
Thomas Gleixner6e402622011-02-08 12:36:06 +0100236 irq_state_set_masked(desc);
Thomas Gleixner0b1adaa2010-03-09 19:45:54 +0100237}
238
Thomas Gleixnerd4d5e082011-02-10 13:16:14 +0100239void mask_irq(struct irq_desc *desc)
Thomas Gleixner0b1adaa2010-03-09 19:45:54 +0100240{
Thomas Gleixnere2c0f8f2010-09-27 12:44:42 +0000241 if (desc->irq_data.chip->irq_mask) {
242 desc->irq_data.chip->irq_mask(&desc->irq_data);
Thomas Gleixner6e402622011-02-08 12:36:06 +0100243 irq_state_set_masked(desc);
Thomas Gleixner0b1adaa2010-03-09 19:45:54 +0100244 }
245}
246
Thomas Gleixnerd4d5e082011-02-10 13:16:14 +0100247void unmask_irq(struct irq_desc *desc)
Thomas Gleixner0b1adaa2010-03-09 19:45:54 +0100248{
Thomas Gleixner0eda58b2010-09-27 12:44:44 +0000249 if (desc->irq_data.chip->irq_unmask) {
250 desc->irq_data.chip->irq_unmask(&desc->irq_data);
Thomas Gleixner6e402622011-02-08 12:36:06 +0100251 irq_state_clr_masked(desc);
Thomas Gleixner0b1adaa2010-03-09 19:45:54 +0100252 }
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700253}
254
Thomas Gleixner399b5da2009-08-13 13:21:38 +0200255/*
256 * handle_nested_irq - Handle a nested irq from a irq thread
257 * @irq: the interrupt number
258 *
259 * Handle interrupts which are nested into a threaded interrupt
260 * handler. The handler function is called inside the calling
261 * threads context.
262 */
263void handle_nested_irq(unsigned int irq)
264{
265 struct irq_desc *desc = irq_to_desc(irq);
266 struct irqaction *action;
267 irqreturn_t action_ret;
268
269 might_sleep();
270
Thomas Gleixner239007b2009-11-17 16:46:45 +0100271 raw_spin_lock_irq(&desc->lock);
Thomas Gleixner399b5da2009-08-13 13:21:38 +0200272
273 kstat_incr_irqs_this_cpu(irq, desc);
274
275 action = desc->action;
Thomas Gleixner32f41252011-03-28 14:10:52 +0200276 if (unlikely(!action || irqd_irq_disabled(&desc->irq_data)))
Thomas Gleixner399b5da2009-08-13 13:21:38 +0200277 goto out_unlock;
278
Thomas Gleixner32f41252011-03-28 14:10:52 +0200279 irqd_set(&desc->irq_data, IRQD_IRQ_INPROGRESS);
Thomas Gleixner239007b2009-11-17 16:46:45 +0100280 raw_spin_unlock_irq(&desc->lock);
Thomas Gleixner399b5da2009-08-13 13:21:38 +0200281
282 action_ret = action->thread_fn(action->irq, action->dev_id);
283 if (!noirqdebug)
284 note_interrupt(irq, desc, action_ret);
285
Thomas Gleixner239007b2009-11-17 16:46:45 +0100286 raw_spin_lock_irq(&desc->lock);
Thomas Gleixner32f41252011-03-28 14:10:52 +0200287 irqd_clear(&desc->irq_data, IRQD_IRQ_INPROGRESS);
Thomas Gleixner399b5da2009-08-13 13:21:38 +0200288
289out_unlock:
Thomas Gleixner239007b2009-11-17 16:46:45 +0100290 raw_spin_unlock_irq(&desc->lock);
Thomas Gleixner399b5da2009-08-13 13:21:38 +0200291}
292EXPORT_SYMBOL_GPL(handle_nested_irq);
293
Thomas Gleixnerfe200ae2011-02-07 10:34:30 +0100294static bool irq_check_poll(struct irq_desc *desc)
295{
Thomas Gleixner6954b752011-02-07 20:55:35 +0100296 if (!(desc->istate & IRQS_POLL_INPROGRESS))
Thomas Gleixnerfe200ae2011-02-07 10:34:30 +0100297 return false;
298 return irq_wait_for_poll(desc);
299}
300
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700301/**
302 * handle_simple_irq - Simple and software-decoded IRQs.
303 * @irq: the interrupt number
304 * @desc: the interrupt description structure for this irq
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700305 *
306 * Simple interrupts are either sent from a demultiplexing interrupt
307 * handler or come from hardware, where no interrupt hardware control
308 * is necessary.
309 *
310 * Note: The caller is expected to handle the ack, clear, mask and
311 * unmask issues if necessary.
312 */
Harvey Harrison7ad5b3a2008-02-08 04:19:53 -0800313void
David Howells7d12e782006-10-05 14:55:46 +0100314handle_simple_irq(unsigned int irq, struct irq_desc *desc)
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700315{
Thomas Gleixner239007b2009-11-17 16:46:45 +0100316 raw_spin_lock(&desc->lock);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700317
Thomas Gleixner32f41252011-03-28 14:10:52 +0200318 if (unlikely(irqd_irq_inprogress(&desc->irq_data)))
Thomas Gleixnerfe200ae2011-02-07 10:34:30 +0100319 if (!irq_check_poll(desc))
320 goto out_unlock;
321
Thomas Gleixner163ef302011-02-08 11:39:15 +0100322 desc->istate &= ~(IRQS_REPLAY | IRQS_WAITING);
Thomas Gleixnerd6c88a52008-10-15 15:27:23 +0200323 kstat_incr_irqs_this_cpu(irq, desc);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700324
Thomas Gleixner32f41252011-03-28 14:10:52 +0200325 if (unlikely(!desc->action || irqd_irq_disabled(&desc->irq_data)))
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700326 goto out_unlock;
327
Thomas Gleixner107781e2011-02-07 01:21:02 +0100328 handle_irq_event(desc);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700329
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700330out_unlock:
Thomas Gleixner239007b2009-11-17 16:46:45 +0100331 raw_spin_unlock(&desc->lock);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700332}
Jonathan Cameronedf76f82011-05-18 10:39:04 +0100333EXPORT_SYMBOL_GPL(handle_simple_irq);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700334
335/**
336 * handle_level_irq - Level type irq handler
337 * @irq: the interrupt number
338 * @desc: the interrupt description structure for this irq
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700339 *
340 * Level type interrupts are active as long as the hardware line has
341 * the active level. This may require to mask the interrupt and unmask
342 * it after the associated handler has acknowledged the device, so the
343 * interrupt line is back to inactive.
344 */
Harvey Harrison7ad5b3a2008-02-08 04:19:53 -0800345void
David Howells7d12e782006-10-05 14:55:46 +0100346handle_level_irq(unsigned int irq, struct irq_desc *desc)
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700347{
Thomas Gleixner239007b2009-11-17 16:46:45 +0100348 raw_spin_lock(&desc->lock);
Thomas Gleixner9205e312010-09-27 12:44:50 +0000349 mask_ack_irq(desc);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700350
Thomas Gleixner32f41252011-03-28 14:10:52 +0200351 if (unlikely(irqd_irq_inprogress(&desc->irq_data)))
Thomas Gleixnerfe200ae2011-02-07 10:34:30 +0100352 if (!irq_check_poll(desc))
353 goto out_unlock;
354
Thomas Gleixner163ef302011-02-08 11:39:15 +0100355 desc->istate &= ~(IRQS_REPLAY | IRQS_WAITING);
Thomas Gleixnerd6c88a52008-10-15 15:27:23 +0200356 kstat_incr_irqs_this_cpu(irq, desc);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700357
358 /*
359 * If its disabled or no action available
360 * keep it masked and get out of here
361 */
Thomas Gleixner32f41252011-03-28 14:10:52 +0200362 if (unlikely(!desc->action || irqd_irq_disabled(&desc->irq_data)))
Ingo Molnar86998aa2006-09-19 11:14:34 +0200363 goto out_unlock;
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700364
Thomas Gleixner15298662011-02-07 01:22:17 +0100365 handle_irq_event(desc);
Thomas Gleixnerb25c3402009-08-13 12:17:22 +0200366
Thomas Gleixner32f41252011-03-28 14:10:52 +0200367 if (!irqd_irq_disabled(&desc->irq_data) && !(desc->istate & IRQS_ONESHOT))
Thomas Gleixner0eda58b2010-09-27 12:44:44 +0000368 unmask_irq(desc);
Ingo Molnar86998aa2006-09-19 11:14:34 +0200369out_unlock:
Thomas Gleixner239007b2009-11-17 16:46:45 +0100370 raw_spin_unlock(&desc->lock);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700371}
Ingo Molnar14819ea2009-01-14 12:34:21 +0100372EXPORT_SYMBOL_GPL(handle_level_irq);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700373
Thomas Gleixner78129572011-02-10 15:14:20 +0100374#ifdef CONFIG_IRQ_PREFLOW_FASTEOI
375static inline void preflow_handler(struct irq_desc *desc)
376{
377 if (desc->preflow_handler)
378 desc->preflow_handler(&desc->irq_data);
379}
380#else
381static inline void preflow_handler(struct irq_desc *desc) { }
382#endif
383
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700384/**
Ingo Molnar47c2a3a2006-06-29 02:25:03 -0700385 * handle_fasteoi_irq - irq handler for transparent controllers
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700386 * @irq: the interrupt number
387 * @desc: the interrupt description structure for this irq
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700388 *
Ingo Molnar47c2a3a2006-06-29 02:25:03 -0700389 * Only a single callback will be issued to the chip: an ->eoi()
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700390 * call when the interrupt has been serviced. This enables support
391 * for modern forms of interrupt handlers, which handle the flow
392 * details in hardware, transparently.
393 */
Harvey Harrison7ad5b3a2008-02-08 04:19:53 -0800394void
David Howells7d12e782006-10-05 14:55:46 +0100395handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc)
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700396{
Thomas Gleixner239007b2009-11-17 16:46:45 +0100397 raw_spin_lock(&desc->lock);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700398
Thomas Gleixner32f41252011-03-28 14:10:52 +0200399 if (unlikely(irqd_irq_inprogress(&desc->irq_data)))
Thomas Gleixnerfe200ae2011-02-07 10:34:30 +0100400 if (!irq_check_poll(desc))
401 goto out;
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700402
Thomas Gleixner163ef302011-02-08 11:39:15 +0100403 desc->istate &= ~(IRQS_REPLAY | IRQS_WAITING);
Thomas Gleixnerd6c88a52008-10-15 15:27:23 +0200404 kstat_incr_irqs_this_cpu(irq, desc);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700405
406 /*
407 * If its disabled or no action available
Ingo Molnar76d21602007-02-16 01:28:24 -0800408 * then mask it and get out of here:
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700409 */
Thomas Gleixner32f41252011-03-28 14:10:52 +0200410 if (unlikely(!desc->action || irqd_irq_disabled(&desc->irq_data))) {
Thomas Gleixner2a0d6fb2011-02-08 12:17:57 +0100411 desc->istate |= IRQS_PENDING;
Thomas Gleixnere2c0f8f2010-09-27 12:44:42 +0000412 mask_irq(desc);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700413 goto out;
Benjamin Herrenschmidt98bb2442006-06-29 02:25:01 -0700414 }
Thomas Gleixnerc69e3752011-03-02 11:49:21 +0100415
416 if (desc->istate & IRQS_ONESHOT)
417 mask_irq(desc);
418
Thomas Gleixner78129572011-02-10 15:14:20 +0100419 preflow_handler(desc);
Thomas Gleixnera7ae4de2011-02-07 01:23:07 +0100420 handle_irq_event(desc);
Thomas Gleixner77694b42011-02-15 10:33:57 +0100421
422out_eoi:
Thomas Gleixner0c5c1552010-09-27 12:44:53 +0000423 desc->irq_data.chip->irq_eoi(&desc->irq_data);
Thomas Gleixner77694b42011-02-15 10:33:57 +0100424out_unlock:
Thomas Gleixner239007b2009-11-17 16:46:45 +0100425 raw_spin_unlock(&desc->lock);
Thomas Gleixner77694b42011-02-15 10:33:57 +0100426 return;
427out:
428 if (!(desc->irq_data.chip->flags & IRQCHIP_EOI_IF_HANDLED))
429 goto out_eoi;
430 goto out_unlock;
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700431}
432
433/**
434 * handle_edge_irq - edge type IRQ handler
435 * @irq: the interrupt number
436 * @desc: the interrupt description structure for this irq
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700437 *
438 * Interrupt occures on the falling and/or rising edge of a hardware
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300439 * signal. The occurrence is latched into the irq controller hardware
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700440 * and must be acked in order to be reenabled. After the ack another
441 * interrupt can happen on the same source even before the first one
Uwe Kleine-Königdfff0612010-02-12 21:58:11 +0100442 * is handled by the associated event handler. If this happens it
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700443 * might be necessary to disable (mask) the interrupt depending on the
444 * controller hardware. This requires to reenable the interrupt inside
445 * of the loop which handles the interrupts which have arrived while
446 * the handler was running. If all pending interrupts are handled, the
447 * loop is left.
448 */
Harvey Harrison7ad5b3a2008-02-08 04:19:53 -0800449void
David Howells7d12e782006-10-05 14:55:46 +0100450handle_edge_irq(unsigned int irq, struct irq_desc *desc)
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700451{
Thomas Gleixner239007b2009-11-17 16:46:45 +0100452 raw_spin_lock(&desc->lock);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700453
Thomas Gleixner163ef302011-02-08 11:39:15 +0100454 desc->istate &= ~(IRQS_REPLAY | IRQS_WAITING);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700455 /*
456 * If we're currently running this IRQ, or its disabled,
457 * we shouldn't process the IRQ. Mark it pending, handle
458 * the necessary masking and go out
459 */
Thomas Gleixner32f41252011-03-28 14:10:52 +0200460 if (unlikely(irqd_irq_disabled(&desc->irq_data) ||
461 irqd_irq_inprogress(&desc->irq_data) || !desc->action)) {
Thomas Gleixnerfe200ae2011-02-07 10:34:30 +0100462 if (!irq_check_poll(desc)) {
Thomas Gleixner2a0d6fb2011-02-08 12:17:57 +0100463 desc->istate |= IRQS_PENDING;
Thomas Gleixnerfe200ae2011-02-07 10:34:30 +0100464 mask_ack_irq(desc);
465 goto out_unlock;
466 }
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700467 }
Thomas Gleixnerd6c88a52008-10-15 15:27:23 +0200468 kstat_incr_irqs_this_cpu(irq, desc);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700469
470 /* Start handling the irq */
Thomas Gleixner22a49162010-09-27 12:44:47 +0000471 desc->irq_data.chip->irq_ack(&desc->irq_data);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700472
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700473 do {
Thomas Gleixnera60a5dc2011-02-07 01:24:07 +0100474 if (unlikely(!desc->action)) {
Thomas Gleixnere2c0f8f2010-09-27 12:44:42 +0000475 mask_irq(desc);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700476 goto out_unlock;
477 }
478
479 /*
480 * When another irq arrived while we were handling
481 * one, we could have masked the irq.
482 * Renable it, if it was not disabled in meantime.
483 */
Thomas Gleixner2a0d6fb2011-02-08 12:17:57 +0100484 if (unlikely(desc->istate & IRQS_PENDING)) {
Thomas Gleixner32f41252011-03-28 14:10:52 +0200485 if (!irqd_irq_disabled(&desc->irq_data) &&
486 irqd_irq_masked(&desc->irq_data))
Thomas Gleixnerc1594b72011-02-07 22:11:30 +0100487 unmask_irq(desc);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700488 }
489
Thomas Gleixnera60a5dc2011-02-07 01:24:07 +0100490 handle_irq_event(desc);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700491
Thomas Gleixner2a0d6fb2011-02-08 12:17:57 +0100492 } while ((desc->istate & IRQS_PENDING) &&
Thomas Gleixner32f41252011-03-28 14:10:52 +0200493 !irqd_irq_disabled(&desc->irq_data));
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700494
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700495out_unlock:
Thomas Gleixner239007b2009-11-17 16:46:45 +0100496 raw_spin_unlock(&desc->lock);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700497}
498
Thomas Gleixner0521c8f2011-03-28 16:13:24 +0200499#ifdef CONFIG_IRQ_EDGE_EOI_HANDLER
500/**
501 * handle_edge_eoi_irq - edge eoi type IRQ handler
502 * @irq: the interrupt number
503 * @desc: the interrupt description structure for this irq
504 *
505 * Similar as the above handle_edge_irq, but using eoi and w/o the
506 * mask/unmask logic.
507 */
508void handle_edge_eoi_irq(unsigned int irq, struct irq_desc *desc)
509{
510 struct irq_chip *chip = irq_desc_get_chip(desc);
511
512 raw_spin_lock(&desc->lock);
513
514 desc->istate &= ~(IRQS_REPLAY | IRQS_WAITING);
515 /*
516 * If we're currently running this IRQ, or its disabled,
517 * we shouldn't process the IRQ. Mark it pending, handle
518 * the necessary masking and go out
519 */
520 if (unlikely(irqd_irq_disabled(&desc->irq_data) ||
521 irqd_irq_inprogress(&desc->irq_data) || !desc->action)) {
522 if (!irq_check_poll(desc)) {
523 desc->istate |= IRQS_PENDING;
524 goto out_eoi;
525 }
526 }
527 kstat_incr_irqs_this_cpu(irq, desc);
528
529 do {
530 if (unlikely(!desc->action))
531 goto out_eoi;
532
533 handle_irq_event(desc);
534
535 } while ((desc->istate & IRQS_PENDING) &&
536 !irqd_irq_disabled(&desc->irq_data));
537
Stephen Rothwellac0e0442011-03-30 10:55:12 +1100538out_eoi:
Thomas Gleixner0521c8f2011-03-28 16:13:24 +0200539 chip->irq_eoi(&desc->irq_data);
540 raw_spin_unlock(&desc->lock);
541}
542#endif
543
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700544/**
Liuweni24b26d42009-11-04 20:11:05 +0800545 * handle_percpu_irq - Per CPU local irq handler
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700546 * @irq: the interrupt number
547 * @desc: the interrupt description structure for this irq
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700548 *
549 * Per CPU interrupts on SMP machines without locking requirements
550 */
Harvey Harrison7ad5b3a2008-02-08 04:19:53 -0800551void
David Howells7d12e782006-10-05 14:55:46 +0100552handle_percpu_irq(unsigned int irq, struct irq_desc *desc)
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700553{
Thomas Gleixner35e857c2011-02-10 12:20:23 +0100554 struct irq_chip *chip = irq_desc_get_chip(desc);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700555
Thomas Gleixnerd6c88a52008-10-15 15:27:23 +0200556 kstat_incr_irqs_this_cpu(irq, desc);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700557
Thomas Gleixner849f0612011-02-07 01:25:41 +0100558 if (chip->irq_ack)
559 chip->irq_ack(&desc->irq_data);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700560
Thomas Gleixner849f0612011-02-07 01:25:41 +0100561 handle_irq_event_percpu(desc, desc->action);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700562
Thomas Gleixner849f0612011-02-07 01:25:41 +0100563 if (chip->irq_eoi)
564 chip->irq_eoi(&desc->irq_data);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700565}
566
Marc Zyngier31d9d9b2011-09-23 17:03:06 +0100567/**
568 * handle_percpu_devid_irq - Per CPU local irq handler with per cpu dev ids
569 * @irq: the interrupt number
570 * @desc: the interrupt description structure for this irq
571 *
572 * Per CPU interrupts on SMP machines without locking requirements. Same as
573 * handle_percpu_irq() above but with the following extras:
574 *
575 * action->percpu_dev_id is a pointer to percpu variables which
576 * contain the real device id for the cpu on which this handler is
577 * called
578 */
579void handle_percpu_devid_irq(unsigned int irq, struct irq_desc *desc)
580{
581 struct irq_chip *chip = irq_desc_get_chip(desc);
582 struct irqaction *action = desc->action;
583 void *dev_id = __this_cpu_ptr(action->percpu_dev_id);
584 irqreturn_t res;
585
586 kstat_incr_irqs_this_cpu(irq, desc);
587
588 if (chip->irq_ack)
589 chip->irq_ack(&desc->irq_data);
590
591 trace_irq_handler_entry(irq, action);
592 res = action->handler(irq, dev_id);
593 trace_irq_handler_exit(irq, action, res);
594
595 if (chip->irq_eoi)
596 chip->irq_eoi(&desc->irq_data);
597}
598
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700599void
Thomas Gleixner3836ca02011-02-14 20:09:19 +0100600__irq_set_handler(unsigned int irq, irq_flow_handler_t handle, int is_chained,
Ingo Molnara460e742006-10-17 00:10:03 -0700601 const char *name)
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700602{
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700603 unsigned long flags;
Marc Zyngier31d9d9b2011-09-23 17:03:06 +0100604 struct irq_desc *desc = irq_get_desc_buslock(irq, &flags, 0);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700605
Thomas Gleixner02725e72011-02-12 10:37:36 +0100606 if (!desc)
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700607 return;
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700608
Thomas Gleixner091738a2011-02-14 20:16:43 +0100609 if (!handle) {
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700610 handle = handle_bad_irq;
Thomas Gleixner091738a2011-02-14 20:16:43 +0100611 } else {
612 if (WARN_ON(desc->irq_data.chip == &no_irq_chip))
Thomas Gleixner02725e72011-02-12 10:37:36 +0100613 goto out;
Thomas Gleixnerf8b54732006-07-01 22:30:08 +0100614 }
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700615
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700616 /* Uninstall? */
617 if (handle == handle_bad_irq) {
Thomas Gleixner6b8ff312010-10-01 12:58:38 +0200618 if (desc->irq_data.chip != &no_irq_chip)
Thomas Gleixner9205e312010-09-27 12:44:50 +0000619 mask_ack_irq(desc);
Thomas Gleixner801a0e92011-03-27 11:02:49 +0200620 irq_state_set_disabled(desc);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700621 desc->depth = 1;
622 }
623 desc->handle_irq = handle;
Ingo Molnara460e742006-10-17 00:10:03 -0700624 desc->name = name;
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700625
626 if (handle != handle_bad_irq && is_chained) {
Thomas Gleixner1ccb4e62011-02-09 14:44:17 +0100627 irq_settings_set_noprobe(desc);
628 irq_settings_set_norequest(desc);
Paul Mundt7f1b1242011-04-07 06:01:44 +0900629 irq_settings_set_nothread(desc);
Thomas Gleixner46999232011-02-02 21:41:14 +0000630 irq_startup(desc);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700631 }
Thomas Gleixner02725e72011-02-12 10:37:36 +0100632out:
633 irq_put_desc_busunlock(desc, flags);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700634}
Thomas Gleixner3836ca02011-02-14 20:09:19 +0100635EXPORT_SYMBOL_GPL(__irq_set_handler);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700636
637void
Thomas Gleixner3836ca02011-02-14 20:09:19 +0100638irq_set_chip_and_handler_name(unsigned int irq, struct irq_chip *chip,
Ingo Molnara460e742006-10-17 00:10:03 -0700639 irq_flow_handler_t handle, const char *name)
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700640{
Thomas Gleixner35e857c2011-02-10 12:20:23 +0100641 irq_set_chip(irq, chip);
Thomas Gleixner3836ca02011-02-14 20:09:19 +0100642 __irq_set_handler(irq, handle, 0, name);
Thomas Gleixnerdd87eb32006-06-29 02:24:53 -0700643}
Ralf Baechle46f4f8f2008-02-08 04:22:01 -0800644
Thomas Gleixner44247182010-09-28 10:40:18 +0200645void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set)
Ralf Baechle46f4f8f2008-02-08 04:22:01 -0800646{
Ralf Baechle46f4f8f2008-02-08 04:22:01 -0800647 unsigned long flags;
Marc Zyngier31d9d9b2011-09-23 17:03:06 +0100648 struct irq_desc *desc = irq_get_desc_lock(irq, &flags, 0);
Ralf Baechle46f4f8f2008-02-08 04:22:01 -0800649
Thomas Gleixner44247182010-09-28 10:40:18 +0200650 if (!desc)
Ralf Baechle46f4f8f2008-02-08 04:22:01 -0800651 return;
Thomas Gleixnera0056772011-02-08 17:11:03 +0100652 irq_settings_clr_and_set(desc, clr, set);
653
Thomas Gleixner876dbd42011-02-08 17:28:12 +0100654 irqd_clear(&desc->irq_data, IRQD_NO_BALANCING | IRQD_PER_CPU |
Thomas Gleixnere1ef8242011-02-10 22:25:31 +0100655 IRQD_TRIGGER_MASK | IRQD_LEVEL | IRQD_MOVE_PCNTXT);
Thomas Gleixnera0056772011-02-08 17:11:03 +0100656 if (irq_settings_has_no_balance_set(desc))
657 irqd_set(&desc->irq_data, IRQD_NO_BALANCING);
658 if (irq_settings_is_per_cpu(desc))
659 irqd_set(&desc->irq_data, IRQD_PER_CPU);
Thomas Gleixnere1ef8242011-02-10 22:25:31 +0100660 if (irq_settings_can_move_pcntxt(desc))
661 irqd_set(&desc->irq_data, IRQD_MOVE_PCNTXT);
Thomas Gleixner0ef5ca12011-03-28 21:59:37 +0200662 if (irq_settings_is_level(desc))
663 irqd_set(&desc->irq_data, IRQD_LEVEL);
Thomas Gleixnera0056772011-02-08 17:11:03 +0100664
Thomas Gleixner876dbd42011-02-08 17:28:12 +0100665 irqd_set(&desc->irq_data, irq_settings_get_trigger_mask(desc));
666
Thomas Gleixner02725e72011-02-12 10:37:36 +0100667 irq_put_desc_unlock(desc, flags);
Ralf Baechle46f4f8f2008-02-08 04:22:01 -0800668}
Jonathan Cameronedf76f82011-05-18 10:39:04 +0100669EXPORT_SYMBOL_GPL(irq_modify_status);
David Daney0fdb4b22011-03-25 12:38:49 -0700670
671/**
672 * irq_cpu_online - Invoke all irq_cpu_online functions.
673 *
674 * Iterate through all irqs and invoke the chip.irq_cpu_online()
675 * for each.
676 */
677void irq_cpu_online(void)
678{
679 struct irq_desc *desc;
680 struct irq_chip *chip;
681 unsigned long flags;
682 unsigned int irq;
683
684 for_each_active_irq(irq) {
685 desc = irq_to_desc(irq);
686 if (!desc)
687 continue;
688
689 raw_spin_lock_irqsave(&desc->lock, flags);
690
691 chip = irq_data_get_irq_chip(&desc->irq_data);
Thomas Gleixnerb3d42232011-03-27 16:05:36 +0200692 if (chip && chip->irq_cpu_online &&
693 (!(chip->flags & IRQCHIP_ONOFFLINE_ENABLED) ||
Thomas Gleixner32f41252011-03-28 14:10:52 +0200694 !irqd_irq_disabled(&desc->irq_data)))
David Daney0fdb4b22011-03-25 12:38:49 -0700695 chip->irq_cpu_online(&desc->irq_data);
696
697 raw_spin_unlock_irqrestore(&desc->lock, flags);
698 }
699}
700
701/**
702 * irq_cpu_offline - Invoke all irq_cpu_offline functions.
703 *
704 * Iterate through all irqs and invoke the chip.irq_cpu_offline()
705 * for each.
706 */
707void irq_cpu_offline(void)
708{
709 struct irq_desc *desc;
710 struct irq_chip *chip;
711 unsigned long flags;
712 unsigned int irq;
713
714 for_each_active_irq(irq) {
715 desc = irq_to_desc(irq);
716 if (!desc)
717 continue;
718
719 raw_spin_lock_irqsave(&desc->lock, flags);
720
721 chip = irq_data_get_irq_chip(&desc->irq_data);
Thomas Gleixnerb3d42232011-03-27 16:05:36 +0200722 if (chip && chip->irq_cpu_offline &&
723 (!(chip->flags & IRQCHIP_ONOFFLINE_ENABLED) ||
Thomas Gleixner32f41252011-03-28 14:10:52 +0200724 !irqd_irq_disabled(&desc->irq_data)))
David Daney0fdb4b22011-03-25 12:38:49 -0700725 chip->irq_cpu_offline(&desc->irq_data);
726
727 raw_spin_unlock_irqrestore(&desc->lock, flags);
728 }
729}