blob: 9db681d95814baa2662fdccba0755b09579577cf [file] [log] [blame]
Andrew Mortonc777ac52006-03-25 03:07:36 -08001
Christoph Hellwigd824e662006-04-10 22:54:04 -07002#include <linux/irq.h>
Andrew Mortonc777ac52006-03-25 03:07:36 -08003
Eric W. Biedermane7b946e2006-10-04 02:16:29 -07004void move_masked_irq(int irq)
Andrew Mortonc777ac52006-03-25 03:07:36 -08005{
Yinghai Lu08678b02008-08-19 20:50:05 -07006 struct irq_desc *desc = irq_to_desc(irq);
Andrew Mortonc777ac52006-03-25 03:07:36 -08007 cpumask_t tmp;
Andrew Mortonc777ac52006-03-25 03:07:36 -08008
Eric W. Biedermana24ceab2006-10-04 02:16:27 -07009 if (likely(!(desc->status & IRQ_MOVE_PENDING)))
Andrew Mortonc777ac52006-03-25 03:07:36 -080010 return;
11
Bryan Holty501f2492006-03-25 03:07:37 -080012 /*
13 * Paranoia: cpu-local interrupts shouldn't be calling in here anyway.
14 */
15 if (CHECK_IRQ_PER_CPU(desc->status)) {
16 WARN_ON(1);
17 return;
18 }
19
Eric W. Biedermana24ceab2006-10-04 02:16:27 -070020 desc->status &= ~IRQ_MOVE_PENDING;
Andrew Mortonc777ac52006-03-25 03:07:36 -080021
Yinghai Lu08678b02008-08-19 20:50:05 -070022 if (unlikely(cpus_empty(desc->pending_mask)))
Andrew Mortonc777ac52006-03-25 03:07:36 -080023 return;
24
Ingo Molnard1bef4e2006-06-29 02:24:36 -070025 if (!desc->chip->set_affinity)
Andrew Mortonc777ac52006-03-25 03:07:36 -080026 return;
27
Bryan Holty501f2492006-03-25 03:07:37 -080028 assert_spin_locked(&desc->lock);
29
Yinghai Lu08678b02008-08-19 20:50:05 -070030 cpus_and(tmp, desc->pending_mask, cpu_online_map);
Andrew Mortonc777ac52006-03-25 03:07:36 -080031
32 /*
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 */
Daniel Walker89d0cf02006-06-23 02:05:29 -070044 if (likely(!cpus_empty(tmp))) {
Ingo Molnard1bef4e2006-06-29 02:24:36 -070045 desc->chip->set_affinity(irq,tmp);
Andrew Mortonc777ac52006-03-25 03:07:36 -080046 }
Yinghai Lu08678b02008-08-19 20:50:05 -070047 cpus_clear(desc->pending_mask);
Andrew Mortonc777ac52006-03-25 03:07:36 -080048}
Eric W. Biedermane7b946e2006-10-04 02:16:29 -070049
50void move_native_irq(int irq)
51{
Yinghai Lu08678b02008-08-19 20:50:05 -070052 struct irq_desc *desc = irq_to_desc(irq);
Eric W. Biedermane7b946e2006-10-04 02:16:29 -070053
54 if (likely(!(desc->status & IRQ_MOVE_PENDING)))
55 return;
56
Eric W. Biederman2a786b42007-02-23 04:46:20 -070057 if (unlikely(desc->status & IRQ_DISABLED))
58 return;
Eric W. Biedermane7b946e2006-10-04 02:16:29 -070059
Eric W. Biederman2a786b42007-02-23 04:46:20 -070060 desc->chip->mask(irq);
Eric W. Biedermane7b946e2006-10-04 02:16:29 -070061 move_masked_irq(irq);
Eric W. Biederman2a786b42007-02-23 04:46:20 -070062 desc->chip->unmask(irq);
Eric W. Biedermane7b946e2006-10-04 02:16:29 -070063}
64