linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] xhci: Suspend ports to U3 directly from U1 or U2
@ 2020-06-10  6:42 Kai-Heng Feng
  2020-06-10  6:42 ` [PATCH 2/2] USB: hub: Suspend and resume port with LPM enabled Kai-Heng Feng
  2020-06-10 14:32 ` [PATCH 1/2] xhci: Suspend ports to U3 directly from U1 or U2 Alan Stern
  0 siblings, 2 replies; 7+ messages in thread
From: Kai-Heng Feng @ 2020-06-10  6:42 UTC (permalink / raw)
  To: mathias.nyman
  Cc: Kai-Heng Feng, Greg Kroah-Hartman, open list:USB XHCI DRIVER, open list

xHCI spec "4.15.1 Port Suspend" states that port can be put to U3 as long
as Enabled bit is set and from U0, U1 or U2 state.

Currently only USB_PORT_FEAT_LINK_STATE puts port to U3 directly, let's
do the same for USB_PORT_FEAT_SUSPEND and bus suspend case.

This is particularly useful for USB2 devices, which may take a very long
time to switch USB2 LPM on and off.

Suggested-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
---
 drivers/usb/host/xhci-hub.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index f37316d2c8fa..f9375b77d17d 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -1196,15 +1196,6 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 		/* FIXME: What new port features do we need to support? */
 		switch (wValue) {
 		case USB_PORT_FEAT_SUSPEND:
-			temp = readl(ports[wIndex]->addr);
-			if ((temp & PORT_PLS_MASK) != XDEV_U0) {
-				/* Resume the port to U0 first */
-				xhci_set_link_state(xhci, ports[wIndex],
-							XDEV_U0);
-				spin_unlock_irqrestore(&xhci->lock, flags);
-				msleep(10);
-				spin_lock_irqsave(&xhci->lock, flags);
-			}
 			/* In spec software should not attempt to suspend
 			 * a port unless the port reports that it is in the
 			 * enabled (PED = ‘1’,PLS < ‘3’) state.
@@ -1645,8 +1636,10 @@ int xhci_bus_suspend(struct usb_hcd *hcd)
 			xhci_dbg(xhci, "Bus suspend bailout, port over-current detected\n");
 			return -EBUSY;
 		}
-		/* suspend ports in U0, or bail out for new connect changes */
-		if ((t1 & PORT_PE) && (t1 & PORT_PLS_MASK) == XDEV_U0) {
+		/* suspend ports in U0/U1/U2, or bail out for new connect changes */
+		if ((t1 & PORT_PE) && ((t1 & PORT_PLS_MASK) == XDEV_U0 ||
+				       (t1 & PORT_PLS_MASK) == XDEV_U1 ||
+				       (t1 & PORT_PLS_MASK) == XDEV_U2)) {
 			if ((t1 & PORT_CSC) && wake_enabled) {
 				bus_state->bus_suspended = 0;
 				spin_unlock_irqrestore(&xhci->lock, flags);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-06-11  7:41 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-10  6:42 [PATCH 1/2] xhci: Suspend ports to U3 directly from U1 or U2 Kai-Heng Feng
2020-06-10  6:42 ` [PATCH 2/2] USB: hub: Suspend and resume port with LPM enabled Kai-Heng Feng
2020-06-10  9:21   ` Sergei Shtylyov
2020-06-10 14:32 ` [PATCH 1/2] xhci: Suspend ports to U3 directly from U1 or U2 Alan Stern
2020-06-10 15:43   ` Kai-Heng Feng
2020-06-10 15:58     ` Mathias Nyman
2020-06-11  7:41       ` Kai-Heng Feng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).