rpms/kernel/F-9 linux-2.6-usb-fix-interrupt-disabling.patch, NONE, 1.1 kernel.spec, 1.704, 1.705

Chuck Ebbert (cebbert) fedora-extras-commits at redhat.com
Mon Jul 7 23:56:51 UTC 2008


Author: cebbert

Update of /cvs/pkgs/rpms/kernel/F-9
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv12098

Modified Files:
	kernel.spec 
Added Files:
	linux-2.6-usb-fix-interrupt-disabling.patch 
Log Message:
* Mon Jul 07 2008 Chuck Ebbert <cebbert at redhat.com> 2.6.25.9-86
- Fix USB interrupt handling with shared interrupts.


linux-2.6-usb-fix-interrupt-disabling.patch:

--- NEW FILE linux-2.6-usb-fix-interrupt-disabling.patch ---
From: Stefan Becker <Stefan.Becker at nokia.com>
Date: Tue, 1 Jul 2008 16:19:22 +0000 (+0300)
Subject: USB: fix interrupt disabling for HCDs with shared interrupt handlers
X-Git-Tag: v2.6.26-rc9~62^2~5
X-Git-Url: http://git.kernel.org/?p=linux%2Fkernel%2Fgit%2Ftorvalds%2Flinux-2.6.git;a=commitdiff_plain;h=de85422b94ddb23c021126815ea49414047c13dc

USB: fix interrupt disabling for HCDs with shared interrupt handlers

USB: fix interrupt disabling for HCDs with shared interrupt handlers

As has been discussed several times on LKML, IRQF_SHARED | IRQF_DISABLED
doesn't work reliably, i.e. a shared interrupt handler CAN'T be certain to
be called with interrupts disabled. Most USB HCD handlers use IRQF_DISABLED
and therefore havoc can break out if they share their interrupt with a
handler that doesn't use it.

On my test machine the yenta_socket interrupt handler (no IRQF_DISABLED)
was registered before ehci_hcd and one uhci_hcd instance. Therefore all
usb_hcd_irq() invocations for ehci_hcd and for one uhci_hcd instance
happened with interrupts enabled. That led to random lockups as USB core
HCD functions that acquire the same spinlock could be called twice
from interrupt handlers.

This patch updates usb_hcd_irq() to always disable/restore interrupts.
usb_add_hcd() will silently remove any IRQF_DISABLED requested from HCD code.

Signed-off-by: Stefan Becker <stefan.becker at nokia.com>
Cc: stable <stable at kernel.org>
Acked-by: David Brownell <david-b at pacbell.net>
Acked-by: Alan Stern <stern at rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh at suse.de>
---

diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 09a53e7..7158dbb 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -1684,19 +1684,30 @@ 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;
+	unsigned long		flags;
+	irqreturn_t		rc;
 
-	if (unlikely(start == HC_STATE_HALT ||
-	    !test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)))
-		return IRQ_NONE;
-	if (hcd->driver->irq (hcd) == IRQ_NONE)
-		return 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);
 
-	set_bit(HCD_FLAG_SAW_IRQ, &hcd->flags);
+	if (unlikely(hcd->state == HC_STATE_HALT ||
+		     !test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags))) {
+		rc = IRQ_NONE;
+	} else if (hcd->driver->irq(hcd) == IRQ_NONE) {
+		rc = IRQ_NONE;
+	} else {
+		set_bit(HCD_FLAG_SAW_IRQ, &hcd->flags);
 
-	if (unlikely(hcd->state == HC_STATE_HALT))
-		usb_hc_died (hcd);
-	return IRQ_HANDLED;
+		if (unlikely(hcd->state == HC_STATE_HALT))
+			usb_hc_died(hcd);
+		rc = IRQ_HANDLED;
+	}
+
+	local_irq_restore(flags);
+	return rc;
 }
 
 /*-------------------------------------------------------------------------*/
@@ -1860,6 +1871,13 @@ int usb_add_hcd(struct usb_hcd *hcd,
 
 	/* enable irqs just before we start the controller */
 	if (hcd->driver->irq) {
+
+		/* IRQF_DISABLED doesn't work as advertised when used together
+		 * with IRQF_SHARED. As usb_hcd_irq() will always disable
+		 * interrupts we can remove it here.
+		 */
+		irqflags &= ~IRQF_DISABLED;
+
 		snprintf(hcd->irq_descr, sizeof(hcd->irq_descr), "%s:usb%d",
 				hcd->driver->description, hcd->self.busnum);
 		if ((retval = request_irq(irqnum, &usb_hcd_irq, irqflags,


Index: kernel.spec
===================================================================
RCS file: /cvs/pkgs/rpms/kernel/F-9/kernel.spec,v
retrieving revision 1.704
retrieving revision 1.705
diff -u -r1.704 -r1.705
--- kernel.spec	4 Jul 2008 20:21:44 -0000	1.704
+++ kernel.spec	7 Jul 2008 23:55:57 -0000	1.705
@@ -688,6 +688,8 @@
 Patch2301: linux-2.6-ms-wireless-receiver.patch
 # https://bugzilla.redhat.com/show_bug.cgi?id=454028
 Patch2302: linux-2.6-usb-storage-nikond80-quirk.patch
+# fix interrupt handling
+Patch2303: linux-2.6-usb-fix-interrupt-disabling.patch
 
 # usb video
 Patch2400: linux-2.6-uvcvideo.patch
@@ -1102,6 +1104,7 @@
 # USB
 ApplyPatch linux-2.6-usb-ehci-hcd-respect-nousb.patch
 ApplyPatch linux-2.6-usb-storage-nikond80-quirk.patch
+ApplyPatch linux-2.6-usb-fix-interrupt-disabling.patch
 
 # ACPI
 # acpi has a bug in the sizeof function causing thermal panics (from 2.6.26)
@@ -1864,6 +1867,9 @@
 %kernel_variant_files -a /%{image_install_path}/xen*-%{KVERREL}.xen -e /etc/ld.so.conf.d/kernelcap-%{KVERREL}.xen.conf %{with_xen} xen
 
 %changelog
+* Mon Jul 07 2008 Chuck Ebbert <cebbert at redhat.com> 2.6.25.9-86
+- Fix USB interrupt handling with shared interrupts.
+
 * Fri Jul 04 2008 John W. Linville <linville at redhat.com> 2.6.25.9-85
 - Upstream wireless fixes from 2008-07-02
   (http://marc.info/?l=linux-netdev&m=121503163124089&w=2)




More information about the fedora-extras-commits mailing list