Re: [PATCH] USB: fix interrupt disabling for HCDs with shared interrupt handlers

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Alan Stern <stern@...>
Cc: Stefan Becker <Stefan.Becker@...>, <linux-kernel@...>, <linux-usb@...>, Linus Torvalds <torvalds@...>
Date: Monday, June 30, 2008 - 4:31 pm

On Monday 30 June 2008, Alan Stern wrote:

How about this one instead?  I think it's probably almost midnight
where Stefan is, so I'd not expect Stefan to have an updated
patch very soon ... :)

- dave


====== CUT HERE
Add a workaround for the way the IRQ framework can disregard
IRQF_DISABLED when IRQF_SHARED is set and lockdep isn't in use.

This leaves IRQF_DISABLED active for unshared IRQs, but clears
that flag otherwise (since the genirq code should eventually
start warning folk about that bad combination of flags).

(Thanks to Stefan Becker <Stefan.Becker@nokia.com> for tracking
down the source of hard lockups on his hardware; on some systems
this problem could lead to oopsing.)

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
---
UNTESTED but "obviously right" yes?  Candidate for 2.6.26-rc8+ ...

 drivers/usb/core/hcd.c |   22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

--- a/drivers/usb/core/hcd.c	2008-06-30 13:09:00.000000000 -0700
+++ b/drivers/usb/core/hcd.c	2008-06-30 13:28:04.000000000 -0700
@@ -1687,19 +1687,31 @@ EXPORT_SYMBOL_GPL(usb_bus_start_enum);
 irqreturn_t usb_hcd_irq (int irq, void *__hcd)
 {
 	struct usb_hcd		*hcd = __hcd;
-	int			start = hcd->state;
+	int			start;
+	unsigned long		flags;
+	irqreturn_t		value = IRQ_NONE;
+
+	/* IRQF_DISABLED doesn't work correctly with shared IRQs
+	 * when the first handler doesn't use it.  So let's just
+	 * assume it's never used.
+	 */
+	local_irq_save(flags);
 
+	start = hcd->state;
 	if (unlikely(start == HC_STATE_HALT ||
 	    !test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)))
-		return IRQ_NONE;
+		goto done;
 	if (hcd->driver->irq (hcd) == IRQ_NONE)
-		return IRQ_NONE;
+		goto done;
 
+	value = IRQ_HANDLED;
 	set_bit(HCD_FLAG_SAW_IRQ, &hcd->flags);
 
 	if (unlikely(hcd->state == HC_STATE_HALT))
 		usb_hc_died (hcd);
-	return IRQ_HANDLED;
+done:
+	local_irq_restore(flags);
+	return value;
 }
 
 /*-------------------------------------------------------------------------*/
@@ -1865,6 +1877,8 @@ int usb_add_hcd(struct usb_hcd *hcd,
 	if (hcd->driver->irq) {
 		snprintf(hcd->irq_descr, sizeof(hcd->irq_descr), "%s:usb%d",
 				hcd->driver->description, hcd->self.busnum);
+		/* work around (IRQF_SHARED|IRQF_DISABLED) misbehavior.. */
+		irqflags &= ~IRQF_DISABLED;
 		if ((retval = request_irq(irqnum, &usb_hcd_irq, irqflags,
 				hcd->irq_descr, hcd)) != 0) {
 			dev_err(hcd->self.controller,
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
BUG in 2.6.26-rc8 interrupt handling, Becker Stefan (Nokia-D/Salo)..., (Sat Jun 28, 3:34 pm)
Re: BUG in 2.6.26-rc8 interrupt handling, David Brownell, (Sat Jun 28, 3:51 pm)
PATCH: 2.6.26-rc8: Fix IRQF_DISABLED for shared interrupts, Stefan Becker, (Sun Jun 29, 10:57 am)
Re: [PATCH] USB: fix interrupt disabling for HCDs with share..., David Brownell, (Mon Jun 30, 4:31 pm)
Re: [PATCH] USB: fix interrupt disabling for HCDs with share..., Leonardo Chiquitto, (Tue Jul 1, 10:19 am)
Re: PATCH: 2.6.26-rc8: Fix IRQF_DISABLED for shared interrupts, Henrique de Moraes Holschuh..., (Mon Jun 30, 10:28 am)