Skip to content

Commit

Permalink
usb: Avoid unnecessary LPM enabling and disabling during suspend and …
Browse files Browse the repository at this point in the history
…resume

The original motivation for disabling/enabling Link PM at device
suspend/resume was to force link state to go via U0 before suspend sets
the link state to U3. Going directly from U2 to U3 is not allowed.

Disabling LPM will forced the link state to U0, but will send a lot of
Set port feature requests for evert suspend and resume.

This is not needed as Hub hardware will take care of going via U0
when a U2 -> U3 transition is requested [1]

[1] USB 3.1 specification section 10.16.2.10 Set Port Feature:

"If the value is 3, then host software wants to selectively suspend the
device connected to this port. The hub shall transition the link to U3
from any of the other U states using allowed link state transitions.
If the port is not already in the U0 state, then it shall transition the
port to the U0 state and then initiate the transition to U3.
While this state is active, the hub does not propagate downstream-directed
traffic to this port, but the hub will respond to resume signaling from the
port"

Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Mathias Nyman authored and Greg Kroah-Hartman committed Jun 15, 2017
1 parent ce046e5 commit d590c23
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions drivers/usb/core/hub.c
Original file line number Diff line number Diff line change
Expand Up @@ -3155,12 +3155,6 @@ int usb_port_suspend(struct usb_device *udev, pm_message_t msg)
if (PMSG_IS_AUTO(msg))
goto err_ltm;
}
if (usb_unlocked_disable_lpm(udev)) {
dev_err(&udev->dev, "Failed to disable LPM before suspend\n.");
status = -ENOMEM;
if (PMSG_IS_AUTO(msg))
goto err_lpm3;
}

/* see 7.1.7.6 */
if (hub_is_superspeed(hub->hdev))
Expand All @@ -3187,9 +3181,7 @@ int usb_port_suspend(struct usb_device *udev, pm_message_t msg)
if (status) {
dev_dbg(&port_dev->dev, "can't suspend, status %d\n", status);

/* Try to enable USB3 LPM and LTM again */
usb_unlocked_enable_lpm(udev);
err_lpm3:
/* Try to enable USB3 LTM again */
usb_enable_ltm(udev);
err_ltm:
/* Try to enable USB2 hardware LPM again */
Expand Down Expand Up @@ -3473,9 +3465,8 @@ int usb_port_resume(struct usb_device *udev, pm_message_t msg)
if (udev->usb2_hw_lpm_capable == 1)
usb_set_usb2_hardware_lpm(udev, 1);

/* Try to enable USB3 LTM and LPM */
/* Try to enable USB3 LTM */
usb_enable_ltm(udev);
usb_unlocked_enable_lpm(udev);
}

usb_unlock_port(port_dev);
Expand Down

0 comments on commit d590c23

Please sign in to comment.