All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Brownell <david-b@pacbell.net>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Stefan Becker <Stefan.Becker@nokia.com>,
	linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCH] USB: fix interrupt disabling for HCDs with shared interrupt handlers
Date: Mon, 30 Jun 2008 13:31:20 -0700	[thread overview]
Message-ID: <200806301331.21077.david-b@pacbell.net> (raw)
In-Reply-To: <Pine.LNX.4.44L0.0806301532500.2138-100000@iolanthe.rowland.org>

On Monday 30 June 2008, Alan Stern wrote:
> Don't bother with this extra stuff.  All USB host controller drivers
> want to have interrupts disabled when their IRQ handlers run.

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,

  reply	other threads:[~2008-06-30 20:31 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-22 16:55 [REGRESSION] 2.6.24/25: random lockups when accessing external USB harddrive Stefan Becker
2008-06-22 17:42 ` Rene Herman
2008-06-22 19:31   ` Alan Stern
2008-06-23 15:52     ` Stefan Becker
2008-06-23 18:10       ` Alan Stern
2008-06-24 18:41         ` Stefan Becker
2008-06-24 21:15           ` Alan Stern
2008-06-25 15:52             ` Stefan Becker
2008-06-25 18:38               ` Alan Stern
2008-06-26  6:31                 ` Stefan Becker
2008-06-26 14:25                   ` Alan Stern
2008-06-26 22:07                     ` Stefan Becker
2008-06-27 16:07                       ` David Brownell
2008-06-28 14:31                         ` Stefan Becker
2008-06-27 16:10                       ` Alan Stern
2008-06-28 14:36                         ` Stefan Becker
2008-06-28 15:39                         ` Stefan Becker
2008-06-28 16:53                           ` Alan Stern
2008-06-28 19:34                             ` BUG in 2.6.26-rc8 interrupt handling Becker Stefan (Nokia-D/Salo)
2008-06-28 19:51                               ` David Brownell
2008-06-29 14:57                                 ` PATCH: 2.6.26-rc8: Fix IRQF_DISABLED for shared interrupts Stefan Becker
2008-06-30  3:09                                   ` David Brownell
2008-06-30  5:22                                     ` Stefan Becker
2008-06-30 14:28                                       ` Henrique de Moraes Holschuh
2008-06-30 14:26                                         ` Alan Cox
2008-06-30  9:34                                     ` Stefan Becker
2008-06-30 11:15                                       ` David Brownell
2008-06-30 14:37                                         ` Alan Stern
2008-06-30 18:53                                           ` [PATCH] USB: fix interrupt disabling for HCDs with shared interrupt handlers Stefan Becker
2008-06-30 19:35                                             ` Alan Stern
2008-06-30 20:31                                               ` David Brownell [this message]
2008-06-30 21:26                                                 ` Stefan Becker
2008-07-01 14:11                                                   ` Alan Stern
2008-07-01 14:19                                                     ` Leonardo Chiquitto
2008-07-01 16:19                                                     ` Stefan Becker
2008-07-01 18:25                                                       ` Greg KH
2008-07-01 18:59                                                         ` Alan Stern
2008-07-01 19:13                                                           ` Greg KH
2008-07-01 19:21                                                           ` David Brownell
2008-07-01 19:15                                                         ` Stefan Becker
2008-07-01 19:51                                                           ` Greg KH
2008-07-01 16:22                                                     ` David Brownell
2008-06-30 21:29                                                 ` Alan Stern
2008-06-30 21:48                                                   ` David Brownell
2008-06-30 19:57                                         ` PATCH: 2.6.26-rc8: Fix IRQF_DISABLED for shared interrupts David Brownell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200806301331.21077.david-b@pacbell.net \
    --to=david-b@pacbell.net \
    --cc=Stefan.Becker@nokia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.