blob: 52a8655fa080047a64cf3dc39635d28c2183abb7 [file] [log] [blame]
Andrew Mortonc777ac52006-03-25 03:07:36 -08001#include <linux/irq.h>
2
3#if defined(CONFIG_GENERIC_PENDING_IRQ)
4
5void set_pending_irq(unsigned int irq, cpumask_t mask)
6{
7 irq_desc_t *desc = irq_desc + irq;
8 unsigned long flags;
9
10 spin_lock_irqsave(&desc->lock, flags);
11 desc->move_irq = 1;
12 pending_irq_cpumask[irq] = mask;
13 spin_unlock_irqrestore(&desc->lock, flags);
14}
15
16void move_native_irq(int irq)
17{
18 cpumask_t tmp;
19 irq_desc_t *desc = irq_descp(irq);
20
Bryan Holty501f2492006-03-25 03:07:37 -080021 if (likely(!desc->move_irq))
Andrew Mortonc777ac52006-03-25 03:07:36 -080022 return;
23
Bryan Holty501f2492006-03-25 03:07:37 -080024 /*
25 * Paranoia: cpu-local interrupts shouldn't be calling in here anyway.
26 */
27 if (CHECK_IRQ_PER_CPU(desc->status)) {
28 WARN_ON(1);
29 return;
30 }
31
Andrew Mortonc777ac52006-03-25 03:07:36 -080032 desc->move_irq = 0;
33
34 if (likely(cpus_empty(pending_irq_cpumask[irq])))
35 return;
36
37 if (!desc->handler->set_affinity)
38 return;
39
Bryan Holty501f2492006-03-25 03:07:37 -080040 assert_spin_locked(&desc->lock);
41
Andrew Mortonc777ac52006-03-25 03:07:36 -080042 cpus_and(tmp, pending_irq_cpumask[irq], cpu_online_map);
43
44 /*
45 * If there was a valid mask to work with, please
46 * do the disable, re-program, enable sequence.
47 * This is *not* particularly important for level triggered
48 * but in a edge trigger case, we might be setting rte
49 * when an active trigger is comming in. This could
50 * cause some ioapics to mal-function.
51 * Being paranoid i guess!
52 */
53 if (unlikely(!cpus_empty(tmp))) {
Bryan Holty501f2492006-03-25 03:07:37 -080054 if (likely(!(desc->status & IRQ_DISABLED)))
55 desc->handler->disable(irq);
56
Andrew Mortonc777ac52006-03-25 03:07:36 -080057 desc->handler->set_affinity(irq,tmp);
Bryan Holty501f2492006-03-25 03:07:37 -080058
59 if (likely(!(desc->status & IRQ_DISABLED)))
60 desc->handler->enable(irq);
Andrew Mortonc777ac52006-03-25 03:07:36 -080061 }
62 cpus_clear(pending_irq_cpumask[irq]);
63}
64
65#endif