ChangeSet 1.2171, 2004/12/09 12:23:36-08:00, [EMAIL PROTECTED]

[PATCH] USB: OHCI "resume"/smp fix

I noticed an SMP deadlock when connecting devices to
an autosuspended root hub.

This fix just makes the OHCI hub status reporting logic (used
exclusively by khubd) be a NOP until after the worker task
(keventd) finishes resuming the port, so they can't deadlock.

Signed-off-by: David Brownell <[EMAIL PROTECTED]>
Signed-off-by: Greg Kroah-Hartman <[EMAIL PROTECTED]>


 drivers/usb/host/ohci-hub.c |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)


diff -Nru a/drivers/usb/host/ohci-hub.c b/drivers/usb/host/ohci-hub.c
--- a/drivers/usb/host/ohci-hub.c       2004-12-09 14:54:15 -08:00
+++ b/drivers/usb/host/ohci-hub.c       2004-12-09 14:54:15 -08:00
@@ -306,17 +306,25 @@
        struct ohci_hcd *ohci = hcd_to_ohci (hcd);
        int             ports, i, changed = 0, length = 1;
        int             can_suspend = 1;
+       unsigned long   flags;
 
-       /* if !USB_SUSPEND, root hub timers won't get shut down ... */
-       if (!HCD_IS_RUNNING(ohci->hcd.state))
-               return 0;
+       spin_lock_irqsave (&ohci->lock, flags);
+
+       /* handle autosuspended root:  finish resuming before
+        * letting khubd or root hub timer see state changes.
+        */
+       if ((ohci->hc_control & OHCI_CTRL_HCFS) != OHCI_USB_OPER
+                       || !HCD_IS_RUNNING(ohci->hcd.state)) {
+               can_suspend = 0;
+               goto done;
+       }
 
        ports = roothub_a (ohci) & RH_A_NDP; 
        if (ports > MAX_ROOT_PORTS) {
                ohci_err (ohci, "bogus NDP=%d, rereads as NDP=%d\n", ports,
                          ohci_readl (ohci, &ohci->regs->roothub.a) & RH_A_NDP);
                /* retry later; "should not happen" */
-               return 0;
+               goto done;
        }
 
        /* init status */
@@ -352,6 +360,8 @@
                        continue;
                can_suspend = 0;
        }
+done:
+       spin_unlock_irqrestore (&ohci->lock, flags);
 
 #ifdef CONFIG_PM
        /* save power by suspending idle root hubs;



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://productguide.itmanagersjournal.com/
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to