summaryrefslogtreecommitdiff
path: root/drivers/usb/core/port.c
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2014-05-21 05:08:07 +0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-05-28 03:28:03 +0400
commit600856c231ccb0cbf8afcf09066a8ab2a93ab03d (patch)
treeaa8e9074adccb30ecbd6ac8aa2dce377e0c5a834 /drivers/usb/core/port.c
parent342a74934197386e065e8ef00014e6f0cb5effe6 (diff)
downloadlinux-600856c231ccb0cbf8afcf09066a8ab2a93ab03d.tar.xz
USB: mutual exclusion for resetting a hub and power-managing a port
The USB core doesn't properly handle mutual exclusion between resetting a hub and changing the power states of the hub's ports. We need to avoid sending port-power requests to the hub while it is being reset, because such requests cannot succeed. This patch fixes the problem by keeping track of when a reset is in progress. At such times, attempts to suspend (power-off) a port will fail immediately with -EBUSY, and calls to usb_port_runtime_resume() will update the power_is_on flag and return immediately. When the reset is complete, hub_activate() will automatically restore each port to the proper power state. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/core/port.c')
-rw-r--r--drivers/usb/core/port.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
index 51542f852393..37647e080599 100644
--- a/drivers/usb/core/port.c
+++ b/drivers/usb/core/port.c
@@ -81,6 +81,10 @@ static int usb_port_runtime_resume(struct device *dev)
if (!hub)
return -EINVAL;
+ if (hub->in_reset) {
+ port_dev->power_is_on = 1;
+ return 0;
+ }
usb_autopm_get_interface(intf);
set_bit(port1, hub->busy_bits);
@@ -117,6 +121,8 @@ static int usb_port_runtime_suspend(struct device *dev)
if (!hub)
return -EINVAL;
+ if (hub->in_reset)
+ return -EBUSY;
if (dev_pm_qos_flags(&port_dev->dev, PM_QOS_FLAG_NO_POWER_OFF)
== PM_QOS_FLAGS_ALL)