Skip to content

Commit

Permalink
genirq: Make force irq threading setup more robust
Browse files Browse the repository at this point in the history
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]
  • Loading branch information
KAGA-KOKO committed Aug 3, 2018
1 parent 6b47037 commit d1f0301
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion kernel/irq/manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -1068,14 +1068,21 @@ static int irq_setup_forced_threading(struct irqaction *new)
if (new->flags & (IRQF_NO_THREAD | IRQF_PERCPU | IRQF_ONESHOT))
return 0;

/*
* No further action required for interrupts which are requested as
* threaded interrupts already
*/
if (new->handler == irq_default_primary_handler)
return 0;

new->flags |= IRQF_ONESHOT;

/*
* Handle the case where we have a real primary handler and a
* thread handler. We force thread them as well by creating a
* secondary action.
*/
if (new->handler != irq_default_primary_handler && new->thread_fn) {
if (new->handler && new->thread_fn) {
/* Allocate the secondary action */
new->secondary = kzalloc(sizeof(struct irqaction), GFP_KERNEL);
if (!new->secondary)
Expand Down

0 comments on commit d1f0301

Please sign in to comment.