aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Becker <Stefan.Becker@nokia.com>2008-07-01 12:19:22 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2008-07-03 21:20:37 -0400
commitde85422b94ddb23c021126815ea49414047c13dc (patch)
tree421ade6d60f496d092779d264df2daac7bfc6e1f
parent2542335ccf34cfb442d3fd842d7e78ca5e649951 (diff)
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@nokia.com> Cc: stable <stable@kernel.org> Acked-by: David Brownell <david-b@pacbell.net> Acked-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/usb/core/hcd.c38
1 files changed, 28 insertions, 10 deletions
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 09a53e7f332..7158dbb6e4b 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -1684,19 +1684,30 @@ EXPORT_SYMBOL_GPL(usb_bus_start_enum);
1684irqreturn_t usb_hcd_irq (int irq, void *__hcd) 1684irqreturn_t usb_hcd_irq (int irq, void *__hcd)
1685{ 1685{
1686 struct usb_hcd *hcd = __hcd; 1686 struct usb_hcd *hcd = __hcd;
1687 int start = hcd->state; 1687 unsigned long flags;
1688 irqreturn_t rc;
1688 1689
1689 if (unlikely(start == HC_STATE_HALT || 1690 /* IRQF_DISABLED doesn't work correctly with shared IRQs
1690 !test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags))) 1691 * when the first handler doesn't use it. So let's just
1691 return IRQ_NONE; 1692 * assume it's never used.
1692 if (hcd->driver->irq (hcd) == IRQ_NONE) 1693 */
1693 return IRQ_NONE; 1694 local_irq_save(flags);
1694 1695
1695 set_bit(HCD_FLAG_SAW_IRQ, &hcd->flags); 1696 if (unlikely(hcd->state == HC_STATE_HALT ||
1697 !test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags))) {
1698 rc = IRQ_NONE;
1699 } else if (hcd->driver->irq(hcd) == IRQ_NONE) {
1700 rc = IRQ_NONE;
1701 } else {
1702 set_bit(HCD_FLAG_SAW_IRQ, &hcd->flags);
1696 1703
1697 if (unlikely(hcd->state == HC_STATE_HALT)) 1704 if (unlikely(hcd->state == HC_STATE_HALT))
1698 usb_hc_died (hcd); 1705 usb_hc_died(hcd);
1699 return IRQ_HANDLED; 1706 rc = IRQ_HANDLED;
1707 }
1708
1709 local_irq_restore(flags);
1710 return rc;
1700} 1711}
1701 1712
1702/*-------------------------------------------------------------------------*/ 1713/*-------------------------------------------------------------------------*/
@@ -1860,6 +1871,13 @@ int usb_add_hcd(struct usb_hcd *hcd,
1860 1871
1861 /* enable irqs just before we start the controller */ 1872 /* enable irqs just before we start the controller */
1862 if (hcd->driver->irq) { 1873 if (hcd->driver->irq) {
1874
1875 /* IRQF_DISABLED doesn't work as advertised when used together
1876 * with IRQF_SHARED. As usb_hcd_irq() will always disable
1877 * interrupts we can remove it here.
1878 */
1879 irqflags &= ~IRQF_DISABLED;
1880
1863 snprintf(hcd->irq_descr, sizeof(hcd->irq_descr), "%s:usb%d", 1881 snprintf(hcd->irq_descr, sizeof(hcd->irq_descr), "%s:usb%d",
1864 hcd->driver->description, hcd->self.busnum); 1882 hcd->driver->description, hcd->self.busnum);
1865 if ((retval = request_irq(irqnum, &usb_hcd_irq, irqflags, 1883 if ((retval = request_irq(irqnum, &usb_hcd_irq, irqflags,