From: Sebastian Andrzej Siewior Date: Mon, 12 Jan 2026 13:40:13 +0000 (+0100) Subject: genirq: Warn about using IRQF_ONESHOT without a threaded handler X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aef30c8d569c0f31715447525640044c74feb26f;p=thirdparty%2Flinux.git genirq: Warn about using IRQF_ONESHOT without a threaded handler IRQF_ONESHOT disables the interrupt source until after the threaded handler completed its work. This is needed to allow the threaded handler to run - otherwise the CPU will get back to the interrupt handler because the interrupt source remains active and the threaded handler will not able to do its work. Specifying IRQF_ONESHOT without a threaded handler does not make sense. It could be a leftover if the handler _was_ threaded and changed back to primary and the flag was not removed. This can be problematic in the `threadirqs' case because the handler is exempt from forced-threading. This in turn can become a problem on a PREEMPT_RT system if the handler attempts to acquire sleeping locks. Warn about missing threaded handlers with the IRQF_ONESHOT flag. Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Thomas Gleixner Reviewed-by: Laurent Pinchart Link: https://patch.msgid.link/20260112134013.eQWyReHR@linutronix.de --- diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index bc2d36b6b13b0..dde1aa62ffe80 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -1473,6 +1473,13 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new) if (!(new->flags & IRQF_TRIGGER_MASK)) new->flags |= irqd_get_trigger_type(&desc->irq_data); + /* + * IRQF_ONESHOT means the interrupt source in the IRQ chip will be + * masked until the threaded handled is done. If there is no thread + * handler then it makes no sense to have IRQF_ONESHOT. + */ + WARN_ON_ONCE(new->flags & IRQF_ONESHOT && !new->thread_fn); + /* * Check whether the interrupt nests into another interrupt * thread.