diff options
author | Alan Stern <stern@rowland.harvard.edu> | 2010-06-25 14:02:35 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-08-10 14:35:38 -0700 |
commit | ff2f07874362d34684296f2bd5547a099f33c6d4 (patch) | |
tree | f41b8c3fcdd0556f4542058433d82f260928727d /drivers/usb/core/hcd-pci.c | |
parent | ee0b9be829803e3ff5adec7456bd59a08425ffa1 (diff) | |
download | talos-obmc-linux-ff2f07874362d34684296f2bd5547a099f33c6d4.tar.gz talos-obmc-linux-ff2f07874362d34684296f2bd5547a099f33c6d4.zip |
USB: fix race between root-hub wakeup & controller suspend
This patch (as1395) adds code to hcd_pci_suspend() for handling wakeup
races. This is another general race pattern, similar to the "open
vs. unregister" race we're all familiar with. Here, the race is
between suspending a device and receiving a wakeup request from one of
the device's suspended children.
In particular, if a root-hub wakeup is requested at about the same
time as the corresponding USB controller is suspended, and if the
controller is enabled for wakeup, then the controller should either
fail to suspend or else wake right back up again.
During system sleep this won't happen very much, especially since host
controllers generally aren't enabled for wakeup during sleep. However
it is definitely an issue for runtime PM. Something like this will be
needed to prevent the controller from autosuspending while waiting for
a root-hub resume to take place. (That is, in fact, the common case,
for which there is an extra test.)
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/core/hcd-pci.c')
-rw-r--r-- | drivers/usb/core/hcd-pci.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c index e387e394f876..352577baa53d 100644 --- a/drivers/usb/core/hcd-pci.c +++ b/drivers/usb/core/hcd-pci.c @@ -388,8 +388,20 @@ static int hcd_pci_suspend(struct device *dev) if (hcd->driver->pci_suspend) { bool do_wakeup = device_may_wakeup(dev); + /* Optimization: Don't suspend if a root-hub wakeup is + * pending and it would cause the HCD to wake up anyway. + */ + if (do_wakeup && HCD_WAKEUP_PENDING(hcd)) + return -EBUSY; retval = hcd->driver->pci_suspend(hcd, do_wakeup); suspend_report_result(hcd->driver->pci_suspend, retval); + + /* Check again in case wakeup raced with pci_suspend */ + if (retval == 0 && do_wakeup && HCD_WAKEUP_PENDING(hcd)) { + if (hcd->driver->pci_resume) + hcd->driver->pci_resume(hcd, false); + retval = -EBUSY; + } if (retval) return retval; } |