Skip to content

Commit a6d9dac

Browse files
KAGA-KOKOgregkh
authored andcommitted
genirq: Make force irq threading setup more robust
commit d1f0301 upstream. The support of force threading interrupts which are set up with both a primary and a threaded handler wreckaged the setup of regular requested threaded interrupts (primary handler == NULL). The reason is that it does not check whether the primary handler is set to the default handler which wakes the handler thread. Instead it replaces the thread handler with the primary handler as it would do with force threaded interrupts which have been requested via request_irq(). So both the primary and the thread handler become the same which then triggers the warnon that the thread handler tries to wakeup a not configured secondary thread. Fortunately this only happens when the driver omits the IRQF_ONESHOT flag when requesting the threaded interrupt, which is normaly caught by the sanity checks when force irq threading is disabled. Fix it by skipping the force threading setup when a regular threaded interrupt is requested. As a consequence the interrupt request which lacks the IRQ_ONESHOT flag is rejected correctly instead of silently wreckaging it. Fixes: 2a1d3ab ("genirq: Handle force threading of irqs with primary and thread handler") Reported-by: Kurt Kanzenbach <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Tested-by: Kurt Kanzenbach <[email protected]> Cc: [email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent a96feef commit a6d9dac

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

kernel/irq/manage.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1030,14 +1030,21 @@ static int irq_setup_forced_threading(struct irqaction *new)
10301030
if (new->flags & (IRQF_NO_THREAD | IRQF_PERCPU | IRQF_ONESHOT))
10311031
return 0;
10321032

1033+
/*
1034+
* No further action required for interrupts which are requested as
1035+
* threaded interrupts already
1036+
*/
1037+
if (new->handler == irq_default_primary_handler)
1038+
return 0;
1039+
10331040
new->flags |= IRQF_ONESHOT;
10341041

10351042
/*
10361043
* Handle the case where we have a real primary handler and a
10371044
* thread handler. We force thread them as well by creating a
10381045
* secondary action.
10391046
*/
1040-
if (new->handler != irq_default_primary_handler && new->thread_fn) {
1047+
if (new->handler && new->thread_fn) {
10411048
/* Allocate the secondary action */
10421049
new->secondary = kzalloc(sizeof(struct irqaction), GFP_KERNEL);
10431050
if (!new->secondary)

0 commit comments

Comments
 (0)