diff options
author | Sarah Sharp <sarah.a.sharp@linux.intel.com> | 2013-09-30 10:26:28 -0400 |
---|---|---|
committer | Sarah Sharp <sarah.a.sharp@linux.intel.com> | 2013-10-16 15:24:19 -0400 |
commit | de68bab4fa96014cfaa6fcbcdb9750e32969fb86 (patch) | |
tree | fae95986070b2c2a21366bf8ae568aa224787adb /drivers/usb/core | |
parent | 58e21f73975ec927119370635bf68b9023831c56 (diff) |
usb: Don't enable USB 2.0 Link PM by default.
How it's supposed to work:
--------------------------
USB 2.0 Link PM is a lower power state that some newer USB 2.0 devices
support. USB 3.0 devices certified by the USB-IF are required to
support it if they are plugged into a USB 2.0 only port, or a USB 2.0
cable is used. USB 2.0 Link PM requires both a USB device and a host
controller that supports USB 2.0 hardware-enabled LPM.
USB 2.0 Link PM is designed to be enabled once by software, and the host
hardware handles transitions to the L1 state automatically. The premise
of USB 2.0 Link PM is to be able to put the device into a lower power
link state when the bus is idle or the device NAKs USB IN transfers for
a specified amount of time.
...but hardware is broken:
--------------------------
It turns out many USB 3.0 devices claim to support USB 2.0 Link PM (by
setting the LPM bit in their USB 2.0 BOS descriptor), but they don't
actually implement it correctly. This manifests as the USB device
refusing to respond to transfers when it is plugged into a USB 2.0 only
port under the Haswell-ULT/Lynx Point LP xHCI host.
These devices pass the xHCI driver's simple test to enable USB 2.0 Link
PM, wait for the port to enter L1, and then bring it back into L0. They
only start to break when L1 entry is interleaved with transfers.
Some devices then fail to respond to the next control transfer (usually
a Set Configuration). This results in devices never enumerating.
Other mass storage devices (such as a later model Western Digital My
Passport USB 3.0 hard drive) respond fine to going into L1 between
control transfers. They ACK the entry, come out of L1 when the host
needs to send a control transfer, and respond properly to those control
transfers. However, when the first READ10 SCSI command is sent, the
device NAKs the data phase while it's reading from the spinning disk.
Eventually, the host requests to put the link into L1, and the device
ACKs that request. Then it never responds to the data phase of the
READ10 command. This results in not being able to read from the drive.
Some mass storage devices (like the Corsair Survivor USB 3.0 flash
drive) are well behaved. They ACK the entry into L1 during control
transfers, and when SCSI commands start coming in, they NAK the requests
to go into L1, because they need to be at full power.
Not all USB 3.0 devices advertise USB 2.0 link PM support. My Point
Grey USB 3.0 webcam advertises itself as a USB 2.1 device, but doesn't
have a USB 2.0 BOS descriptor, so we don't enable USB 2.0 Link PM. I
suspect that means the device isn't certified.
What do we do about it?
-----------------------
There's really no good way for the kernel to test these devices.
Therefore, the kernel needs to disable USB 2.0 Link PM by default, and
distros will have to enable it by writing 1 to the sysfs file
/sys/bus/usb/devices/../power/usb2_hardware_lpm. Rip out the xHCI Link
PM test, since it's not sufficient to detect these buggy devices, and
don't automatically enable LPM after the device is addressed.
This patch should be backported to kernels as old as 3.11, that
contain the commit a558ccdcc71c7770c5e80c926a31cfe8a3892a09 "usb: xhci:
add USB2 Link power management BESL support". Without this fix, some
USB 3.0 devices will not enumerate or work properly under USB 2.0 ports
on Haswell-ULT systems.
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Cc: stable@vger.kernel.org
Diffstat (limited to 'drivers/usb/core')
-rw-r--r-- | drivers/usb/core/driver.c | 3 | ||||
-rw-r--r-- | drivers/usb/core/hub.c | 1 | ||||
-rw-r--r-- | drivers/usb/core/sysfs.c | 6 |
3 files changed, 8 insertions, 2 deletions
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c index f7841d44feda..689433cdef25 100644 --- a/drivers/usb/core/driver.c +++ b/drivers/usb/core/driver.c | |||
@@ -1790,6 +1790,9 @@ int usb_set_usb2_hardware_lpm(struct usb_device *udev, int enable) | |||
1790 | struct usb_hcd *hcd = bus_to_hcd(udev->bus); | 1790 | struct usb_hcd *hcd = bus_to_hcd(udev->bus); |
1791 | int ret = -EPERM; | 1791 | int ret = -EPERM; |
1792 | 1792 | ||
1793 | if (enable && !udev->usb2_hw_lpm_allowed) | ||
1794 | return 0; | ||
1795 | |||
1793 | if (hcd->driver->set_usb2_hw_lpm) { | 1796 | if (hcd->driver->set_usb2_hw_lpm) { |
1794 | ret = hcd->driver->set_usb2_hw_lpm(hcd, udev, enable); | 1797 | ret = hcd->driver->set_usb2_hw_lpm(hcd, udev, enable); |
1795 | if (!ret) | 1798 | if (!ret) |
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index d3a1d79d663d..9be1a2d5fba6 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c | |||
@@ -5203,6 +5203,7 @@ static int usb_reset_and_verify_device(struct usb_device *udev) | |||
5203 | 5203 | ||
5204 | done: | 5204 | done: |
5205 | /* Now that the alt settings are re-installed, enable LTM and LPM. */ | 5205 | /* Now that the alt settings are re-installed, enable LTM and LPM. */ |
5206 | usb_set_usb2_hardware_lpm(udev, 1); | ||
5206 | usb_unlocked_enable_lpm(udev); | 5207 | usb_unlocked_enable_lpm(udev); |
5207 | usb_enable_ltm(udev); | 5208 | usb_enable_ltm(udev); |
5208 | usb_release_bos_descriptor(udev); | 5209 | usb_release_bos_descriptor(udev); |
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c index 5cf431b0424c..52a97adf02a0 100644 --- a/drivers/usb/core/sysfs.c +++ b/drivers/usb/core/sysfs.c | |||
@@ -458,7 +458,7 @@ static ssize_t usb2_hardware_lpm_show(struct device *dev, | |||
458 | struct usb_device *udev = to_usb_device(dev); | 458 | struct usb_device *udev = to_usb_device(dev); |
459 | const char *p; | 459 | const char *p; |
460 | 460 | ||
461 | if (udev->usb2_hw_lpm_enabled == 1) | 461 | if (udev->usb2_hw_lpm_allowed == 1) |
462 | p = "enabled"; | 462 | p = "enabled"; |
463 | else | 463 | else |
464 | p = "disabled"; | 464 | p = "disabled"; |
@@ -478,8 +478,10 @@ static ssize_t usb2_hardware_lpm_store(struct device *dev, | |||
478 | 478 | ||
479 | ret = strtobool(buf, &value); | 479 | ret = strtobool(buf, &value); |
480 | 480 | ||
481 | if (!ret) | 481 | if (!ret) { |
482 | udev->usb2_hw_lpm_allowed = value; | ||
482 | ret = usb_set_usb2_hardware_lpm(udev, value); | 483 | ret = usb_set_usb2_hardware_lpm(udev, value); |
484 | } | ||
483 | 485 | ||
484 | usb_unlock_device(udev); | 486 | usb_unlock_device(udev); |
485 | 487 | ||