Skip to contentSkip to conversation

irq: warn about (IRQF_DISABLED|IRQF_SHARED)

PATCH New David Brownell 1 participant 1 message Jul 29, 2008 IRQ

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 irq: warn about (IRQF_DISABLED|IRQF_SHARED)

From: David Brownell <[email protected]>

We periodically waste time tracking down problems caused by the IRQ framework not respecting IRQF_DISABLED for some shared IRQ cases. Linus views this as "will not fix", but we're still left with the bugs caused by this misbehavior.

This patch adds a nag message in request_irq(), so that drivers can fix their IRQ handlers to avoid this problem.

Note that developers will never see the relevant bugs when they run with LOCKDEP, so it's no wonder these bugs are hard to find. (That also means LOCKDEP is overlooking some IRQ-related bugs involving IRQ handlers that don't set IRQF_DISABLED...)

---
This was the root cause of some USB oopsing a while back ...

 kernel/irq/manage.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)
kernel/irq/manage.c +12 -0
@@ -597,6 +597,18 @@ int request_irq(unsigned int irq, irq_ha
 	struct irqaction *action;
 	int retval;
 
+	/*
+	 * handle_IRQ_event() always ignores IRQF_DISABLED except for
+	 * the _first_ irqaction (sigh).  That can cause oopsing, but
+	 * the behavior is classified as "will not fix" so we need to
+	 * start nudging drivers away from using that idiom.
+	 */
+	if ((irqflags & (IRQF_SHARED|IRQF_DISABLED))
+			== (IRQF_SHARED|IRQF_DISABLED))
+		pr_warning("IRQ %d/%s: IRQF_DISABLED is not "
+				"guaranteed on shared IRQs\n",
+				irq, devname);
+
 #ifdef CONFIG_LOCKDEP
 	/*
 	 * Lockdep wants atomic interrupt handlers: