blob: cfe767ca154501460f9f7e757c08d881611e9c95 [file] [log] [blame]
Andrew Mortonc777ac52006-03-25 03:07:36 -08001
Christoph Hellwigd824e662006-04-10 22:54:04 -07002#include <linux/irq.h>
Yinghai Lu57b150c2009-04-27 17:59:53 -07003#include <linux/interrupt.h>
4
5#include "internals.h"
Andrew Mortonc777ac52006-03-25 03:07:36 -08006
Eric W. Biedermane7b946e2006-10-04 02:16:29 -07007void move_masked_irq(int irq)
Andrew Mortonc777ac52006-03-25 03:07:36 -08008{
Yinghai Lu08678b02008-08-19 20:50:05 -07009 struct irq_desc *desc = irq_to_desc(irq);
Andrew Mortonc777ac52006-03-25 03:07:36 -080010
Eric W. Biedermana24ceab2006-10-04 02:16:27 -070011 if (likely(!(desc->status & IRQ_MOVE_PENDING)))
Andrew Mortonc777ac52006-03-25 03:07:36 -080012 return;
13
Bryan Holty501f2492006-03-25 03:07:37 -080014 /*
15 * Paranoia: cpu-local interrupts shouldn't be calling in here anyway.
16 */
17 if (CHECK_IRQ_PER_CPU(desc->status)) {
18 WARN_ON(1);
19 return;
20 }
21
Eric W. Biedermana24ceab2006-10-04 02:16:27 -070022 desc->status &= ~IRQ_MOVE_PENDING;
Andrew Mortonc777ac52006-03-25 03:07:36 -080023
Mike Travis7f7ace02009-01-10 21:58:08 -080024 if (unlikely(cpumask_empty(desc->pending_mask)))
Andrew Mortonc777ac52006-03-25 03:07:36 -080025 return;
26
Ingo Molnard1bef4e2006-06-29 02:24:36 -070027 if (!desc->chip->set_affinity)
Andrew Mortonc777ac52006-03-25 03:07:36 -080028 return;
29
Bryan Holty501f2492006-03-25 03:07:37 -080030 assert_spin_locked(&desc->lock);
31
Andrew Mortonc777ac52006-03-25 03:07:36 -080032 /*
33 * If there was a valid mask to work with, please
34 * do the disable, re-program, enable sequence.
35 * This is *not* particularly important for level triggered
36 * but in a edge trigger case, we might be setting rte
37 * when an active trigger is comming in. This could
38 * cause some ioapics to mal-function.
39 * Being paranoid i guess!
Eric W. Biedermane7b946e2006-10-04 02:16:29 -070040 *
41 * For correct operation this depends on the caller
42 * masking the irqs.
Andrew Mortonc777ac52006-03-25 03:07:36 -080043 */
Mike Travis7f7ace02009-01-10 21:58:08 -080044 if (likely(cpumask_any_and(desc->pending_mask, cpu_online_mask)
Yinghai Lu57b150c2009-04-27 17:59:53 -070045 < nr_cpu_ids))
46 if (!desc->chip->set_affinity(irq, desc->pending_mask)) {
47 cpumask_copy(desc->affinity, desc->pending_mask);
48 irq_set_thread_affinity(desc, desc->pending_mask);
49 }
50
Mike Travis7f7ace02009-01-10 21:58:08 -080051 cpumask_clear(desc->pending_mask);
Andrew Mortonc777ac52006-03-25 03:07:36 -080052}
Eric W. Biedermane7b946e2006-10-04 02:16:29 -070053
54void move_native_irq(int irq)
55{
Yinghai Lu08678b02008-08-19 20:50:05 -070056 struct irq_desc *desc = irq_to_desc(irq);
Eric W. Biedermane7b946e2006-10-04 02:16:29 -070057
58 if (likely(!(desc->status & IRQ_MOVE_PENDING)))
59 return;
60
Eric W. Biederman2a786b42007-02-23 04:46:20 -070061 if (unlikely(desc->status & IRQ_DISABLED))
62 return;
Eric W. Biedermane7b946e2006-10-04 02:16:29 -070063
Eric W. Biederman2a786b42007-02-23 04:46:20 -070064 desc->chip->mask(irq);
Eric W. Biedermane7b946e2006-10-04 02:16:29 -070065 move_masked_irq(irq);
Eric W. Biederman2a786b42007-02-23 04:46:20 -070066 desc->chip->unmask(irq);
Eric W. Biedermane7b946e2006-10-04 02:16:29 -070067}
68