Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

genirq: Add might_sleep() to disable_irq()

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


authored by

Manfred Spraul and committed by
Thomas Gleixner
17549b0f b7bfaa76

+4 -1
+4 -1
kernel/irq/manage.c
··· 723 723 * to complete before returning. If you use this function while 724 724 * holding a resource the IRQ handler may need you will deadlock. 725 725 * 726 - * This function may be called - with care - from IRQ context. 726 + * Can only be called from preemptible code as it might sleep when 727 + * an interrupt thread is associated to @irq. 728 + * 727 729 */ 728 730 void disable_irq(unsigned int irq) 729 731 { 732 + might_sleep(); 730 733 if (!__disable_irq_nosync(irq)) 731 734 synchronize_irq(irq); 732 735 }