aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryan Holty <lgeek@frontiernet.net>2006-03-25 06:07:37 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-25 11:22:55 -0500
commit501f2499b897ca4be68b1acc7a4bc8cf66f5fd24 (patch)
tree279014a8fd8ce1ca43f036e416063e6a795e5889
parentc777ac5594f772ac760e02c3ac71d067616b579d (diff)
[PATCH] IRQ: prevent enabling of previously disabled interrupt
This fix prevents re-disabling and enabling of a previously disabled interrupt. On an SMP system with irq balancing enabled; If an interrupt is disabled from within its own interrupt context with disable_irq_nosync and is also earmarked for processor migration, the interrupt is blindly moved to the other processor and enabled without regard for its current "enabled" state. If there is an interrupt pending, it will unexpectedly invoke the irq handler on the new irq owning processor (even though the irq was previously disabled) The more intuitive fix would be to invoke disable_irq_nosync and enable_irq, but since we already have the desc->lock from __do_IRQ, we cannot call them directly. Instead we can use the same logic to disable and enable found in disable_irq_nosync and enable_irq, with regards to the desc->depth. This now prevents a disabled interrupt from being re-disabled, and more importantly prevents a disabled interrupt from being incorrectly enabled on a different processor. Signed-off-by: Bryan Holty <lgeek@frontiernet.net> Cc: Andi Kleen <ak@muc.de> Cc: "Luck, Tony" <tony.luck@intel.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--kernel/irq/migration.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/kernel/irq/migration.c b/kernel/irq/migration.c
index 6bdd03c524c7..52a8655fa080 100644
--- a/kernel/irq/migration.c
+++ b/kernel/irq/migration.c
@@ -18,9 +18,17 @@ void move_native_irq(int irq)
18 cpumask_t tmp; 18 cpumask_t tmp;
19 irq_desc_t *desc = irq_descp(irq); 19 irq_desc_t *desc = irq_descp(irq);
20 20
21 if (likely (!desc->move_irq)) 21 if (likely(!desc->move_irq))
22 return; 22 return;
23 23
24 /*
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
24 desc->move_irq = 0; 32 desc->move_irq = 0;
25 33
26 if (likely(cpus_empty(pending_irq_cpumask[irq]))) 34 if (likely(cpus_empty(pending_irq_cpumask[irq])))
@@ -29,7 +37,8 @@ void move_native_irq(int irq)
29 if (!desc->handler->set_affinity) 37 if (!desc->handler->set_affinity)
30 return; 38 return;
31 39
32 /* note - we hold the desc->lock */ 40 assert_spin_locked(&desc->lock);
41
33 cpus_and(tmp, pending_irq_cpumask[irq], cpu_online_map); 42 cpus_and(tmp, pending_irq_cpumask[irq], cpu_online_map);
34 43
35 /* 44 /*
@@ -42,9 +51,13 @@ void move_native_irq(int irq)
42 * Being paranoid i guess! 51 * Being paranoid i guess!
43 */ 52 */
44 if (unlikely(!cpus_empty(tmp))) { 53 if (unlikely(!cpus_empty(tmp))) {
45 desc->handler->disable(irq); 54 if (likely(!(desc->status & IRQ_DISABLED)))
55 desc->handler->disable(irq);
56
46 desc->handler->set_affinity(irq,tmp); 57 desc->handler->set_affinity(irq,tmp);
47 desc->handler->enable(irq); 58
59 if (likely(!(desc->status & IRQ_DISABLED)))
60 desc->handler->enable(irq);
48 } 61 }
49 cpus_clear(pending_irq_cpumask[irq]); 62 cpus_clear(pending_irq_cpumask[irq]);
50} 63}