diff options
author | Takamasa Ohtake <ohtake-txa@necst.nec.co.jp> | 2006-12-06 20:04:15 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-12-20 13:14:27 -0500 |
commit | 23d10a9e376d6a9cd4afd4e27e5e403864f6729b (patch) | |
tree | ed13d347496c39fc25a0688385b83e1f0b17a302 | |
parent | ee269d98a9248fbb729c20ffda0f1b97e82c5c37 (diff) |
USB: ohci handles hardware faults during root port resets
I have found a problem where the root_port_reset() goes into an infinite
loop and stalls the kernel.
This happens when a hardware fault inside the machine occurs during a small
timing window. In case of USB device connection, if a USB device responds to
hcd_submit_urb(), and later the controller fails before root_port_reset(),
root_port_reset() will loop infinitely because ohci_readl() will always
return "-1". Such a failure can include ejecting a CardBus OHCI controller.
The probability of this problem is low, but it will increase if PnP type
usage is frequent. The attached patch can solve this problem and I believe
that it is better to fix this problem.
Signed-off-by: Takamasa Ohtake <ohtake-txa@necst.nec.co.jp>
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/usb/host/ohci-hub.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/usb/host/ohci-hub.c b/drivers/usb/host/ohci-hub.c index f9748b67e5e7..216c9c9d4d6d 100644 --- a/drivers/usb/host/ohci-hub.c +++ b/drivers/usb/host/ohci-hub.c | |||
@@ -555,7 +555,7 @@ static void start_hnp(struct ohci_hcd *ohci); | |||
555 | #define tick_before(t1,t2) ((s16)(((s16)(t1))-((s16)(t2))) < 0) | 555 | #define tick_before(t1,t2) ((s16)(((s16)(t1))-((s16)(t2))) < 0) |
556 | 556 | ||
557 | /* called from some task, normally khubd */ | 557 | /* called from some task, normally khubd */ |
558 | static inline void root_port_reset (struct ohci_hcd *ohci, unsigned port) | 558 | static inline int root_port_reset (struct ohci_hcd *ohci, unsigned port) |
559 | { | 559 | { |
560 | __hc32 __iomem *portstat = &ohci->regs->roothub.portstatus [port]; | 560 | __hc32 __iomem *portstat = &ohci->regs->roothub.portstatus [port]; |
561 | u32 temp; | 561 | u32 temp; |
@@ -570,6 +570,9 @@ static inline void root_port_reset (struct ohci_hcd *ohci, unsigned port) | |||
570 | /* spin until any current reset finishes */ | 570 | /* spin until any current reset finishes */ |
571 | for (;;) { | 571 | for (;;) { |
572 | temp = ohci_readl (ohci, portstat); | 572 | temp = ohci_readl (ohci, portstat); |
573 | /* handle e.g. CardBus eject */ | ||
574 | if (temp == ~(u32)0) | ||
575 | return -ESHUTDOWN; | ||
573 | if (!(temp & RH_PS_PRS)) | 576 | if (!(temp & RH_PS_PRS)) |
574 | break; | 577 | break; |
575 | udelay (500); | 578 | udelay (500); |
@@ -586,6 +589,8 @@ static inline void root_port_reset (struct ohci_hcd *ohci, unsigned port) | |||
586 | now = ohci_readl(ohci, &ohci->regs->fmnumber); | 589 | now = ohci_readl(ohci, &ohci->regs->fmnumber); |
587 | } while (tick_before(now, reset_done)); | 590 | } while (tick_before(now, reset_done)); |
588 | /* caller synchronizes using PRSC */ | 591 | /* caller synchronizes using PRSC */ |
592 | |||
593 | return 0; | ||
589 | } | 594 | } |
590 | 595 | ||
591 | static int ohci_hub_control ( | 596 | static int ohci_hub_control ( |
@@ -702,7 +707,7 @@ static int ohci_hub_control ( | |||
702 | &ohci->regs->roothub.portstatus [wIndex]); | 707 | &ohci->regs->roothub.portstatus [wIndex]); |
703 | break; | 708 | break; |
704 | case USB_PORT_FEAT_RESET: | 709 | case USB_PORT_FEAT_RESET: |
705 | root_port_reset (ohci, wIndex); | 710 | retval = root_port_reset (ohci, wIndex); |
706 | break; | 711 | break; |
707 | default: | 712 | default: |
708 | goto error; | 713 | goto error; |