aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host/ohci-pci.c
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2005-11-24 17:59:46 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2005-11-30 00:39:23 -0500
commit8de98402652c01839ae321be6cb3054cf5735d83 (patch)
tree6d4856ddb60be0dcd361441f0794596709553dd1 /drivers/usb/host/ohci-pci.c
parentd3420ba4930d61f4ec4abc046765de274182b4ed (diff)
[PATCH] USB: Fix USB suspend/resume crasher (#2)
This patch closes the IRQ race and makes various other OHCI & EHCI code path safer vs. suspend/resume. I've been able to (finally !) successfully suspend and resume various Mac models, with or without USB mouse plugged, or plugging while asleep, or unplugging while asleep etc... all without a crash. Alan, please verify the UHCI bit I did, I only verified that it builds. It's very simple so I wouldn't expect any issue there. If you aren't confident, then just drop the hunks that change uhci-hcd.c I also made the patch a little bit more "safer" by making sure the store to the interrupt register that disables interrupts is not posted before I set the flag and drop the spinlock. Without this patch, you cannot reliably sleep/wakeup any recent Mac, and I suspect PCs have some more sneaky issues too (they don't frankly crash with machine checks because x86 tend to silently swallow PCI errors but that won't last afaik, at least PCI Express will blow up in those situations, but the USB code may still misbehave). Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/host/ohci-pci.c')
-rw-r--r--drivers/usb/host/ohci-pci.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c
index 5f22e6590cd1..1b09dde068e1 100644
--- a/drivers/usb/host/ohci-pci.c
+++ b/drivers/usb/host/ohci-pci.c
@@ -105,13 +105,36 @@ ohci_pci_start (struct usb_hcd *hcd)
105 105
106static int ohci_pci_suspend (struct usb_hcd *hcd, pm_message_t message) 106static int ohci_pci_suspend (struct usb_hcd *hcd, pm_message_t message)
107{ 107{
108 /* root hub was already suspended */ 108 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
109 return 0; 109 unsigned long flags;
110 int rc = 0;
111
112 /* Root hub was already suspended. Disable irq emission and
113 * mark HW unaccessible, bail out if RH has been resumed. Use
114 * the spinlock to properly synchronize with possible pending
115 * RH suspend or resume activity.
116 *
117 * This is still racy as hcd->state is manipulated outside of
118 * any locks =P But that will be a different fix.
119 */
120 spin_lock_irqsave (&ohci->lock, flags);
121 if (hcd->state != HC_STATE_SUSPENDED) {
122 rc = -EINVAL;
123 goto bail;
124 }
125 ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable);
126 (void)ohci_readl(ohci, &ohci->regs->intrdisable);
127 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
128 bail:
129 spin_unlock_irqrestore (&ohci->lock, flags);
130
131 return rc;
110} 132}
111 133
112 134
113static int ohci_pci_resume (struct usb_hcd *hcd) 135static int ohci_pci_resume (struct usb_hcd *hcd)
114{ 136{
137 set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
115 usb_hcd_resume_root_hub(hcd); 138 usb_hcd_resume_root_hub(hcd);
116 return 0; 139 return 0;
117} 140}