genirq: Add might_sleep() to disable_irq()
authorManfred Spraul <manfred@colorfullife.com>
Fri, 16 Dec 2022 15:04:41 +0000 (16:04 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Wed, 11 Jan 2023 18:35:13 +0000 (19:35 +0100)
With the introduction of threaded interrupt handlers, it is virtually
never safe to call disable_irq() from non-premptible context.

Thus: Update the documentation, add an explicit might_sleep() to catch any
offenders. This is more obvious and straight forward than the implicit
might_sleep() check deeper down in the disable_irq() call chain.

Fixes: 3aa551c9b4c4 ("genirq: add threaded interrupt handler support")
Signed-off-by: Manfred Spraul <manfred@colorfullife.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20221216150441.200533-3-manfred@colorfullife.com
kernel/irq/manage.c

index 5b7cf28df290598824a8f9dfe5a7ea2d5134ef32..8ce75495e04f137ec48f8259d2b3444a3e1c8281 100644 (file)
@@ -723,10 +723,13 @@ EXPORT_SYMBOL(disable_irq_nosync);
  *     to complete before returning. If you use this function while
  *     holding a resource the IRQ handler may need you will deadlock.
  *
- *     This function may be called - with care - from IRQ context.
+ *     Can only be called from preemptible code as it might sleep when
+ *     an interrupt thread is associated to @irq.
+ *
  */
 void disable_irq(unsigned int irq)
 {
+       might_sleep();
        if (!__disable_irq_nosync(irq))
                synchronize_irq(irq);
 }