Skip to content

Commit 501f249

Browse files
Bryan HoltyLinus Torvalds
authored andcommitted
[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>
1 parent c777ac5 commit 501f249

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

‎kernel/irq/migration.c‎

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,17 @@ void move_native_irq(int irq)
1818
cpumask_t tmp;
1919
irq_desc_t *desc = irq_descp(irq);
2020

21-
if (likely (!desc->move_irq))
21+
if (likely(!desc->move_irq))
2222
return;
2323

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+
2432
desc->move_irq = 0;
2533

2634
if (likely(cpus_empty(pending_irq_cpumask[irq])))
@@ -29,7 +37,8 @@ void move_native_irq(int irq)
2937
if (!desc->handler->set_affinity)
3038
return;
3139

32-
/* note - we hold the desc->lock */
40+
assert_spin_locked(&desc->lock);
41+
3342
cpus_and(tmp, pending_irq_cpumask[irq], cpu_online_map);
3443

3544
/*
@@ -42,9 +51,13 @@ void move_native_irq(int irq)
4251
* Being paranoid i guess!
4352
*/
4453
if (unlikely(!cpus_empty(tmp))) {
45-
desc->handler->disable(irq);
54+
if (likely(!(desc->status & IRQ_DISABLED)))
55+
desc->handler->disable(irq);
56+
4657
desc->handler->set_affinity(irq,tmp);
47-
desc->handler->enable(irq);
58+
59+
if (likely(!(desc->status & IRQ_DISABLED)))
60+
desc->handler->enable(irq);
4861
}
4962
cpus_clear(pending_irq_cpumask[irq]);
5063
}

0 commit comments

Comments
 (0)