All of lore.kernel.org
 help / color / mirror / Atom feed
* FAILED: patch "[PATCH] xhci: Poll for U0 after disabling USB2 LPM" failed to apply to 4.14-stable tree
@ 2020-06-28 15:38 gregkh
  2020-06-28 22:01 ` Sasha Levin
  0 siblings, 1 reply; 2+ messages in thread
From: gregkh @ 2020-06-28 15:38 UTC (permalink / raw)
  To: kai.heng.feng, gregkh, mathias.nyman; +Cc: stable


The patch below does not apply to the 4.14-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From b3d71abd135e6919ca0b6cab463738472653ddfb Mon Sep 17 00:00:00 2001
From: Kai-Heng Feng <kai.heng.feng@canonical.com>
Date: Wed, 24 Jun 2020 16:59:49 +0300
Subject: [PATCH] xhci: Poll for U0 after disabling USB2 LPM

USB2 devices with LPM enabled may interrupt the system suspend:
[  932.510475] usb 1-7: usb suspend, wakeup 0
[  932.510549] hub 1-0:1.0: hub_suspend
[  932.510581] usb usb1: bus suspend, wakeup 0
[  932.510590] xhci_hcd 0000:00:14.0: port 9 not suspended
[  932.510593] xhci_hcd 0000:00:14.0: port 8 not suspended
..
[  932.520323] xhci_hcd 0000:00:14.0: Port change event, 1-7, id 7, portsc: 0x400e03
..
[  932.591405] PM: pci_pm_suspend(): hcd_pci_suspend+0x0/0x30 returns -16
[  932.591414] PM: dpm_run_callback(): pci_pm_suspend+0x0/0x160 returns -16
[  932.591418] PM: Device 0000:00:14.0 failed to suspend async: error -16

During system suspend, USB core will let HC suspends the device if it
doesn't have remote wakeup enabled and doesn't have any children.
However, from the log above we can see that the usb 1-7 doesn't get bus
suspended due to not in U0. After a while the port finished U2 -> U0
transition, interrupts the suspend process.

The observation is that after disabling LPM, port doesn't transit to U0
immediately and can linger in U2. xHCI spec 4.23.5.2 states that the
maximum exit latency for USB2 LPM should be BESL + 10us. The BESL for
the affected device is advertised as 400us, which is still not enough
based on my testing result.

So let's use the maximum permitted latency, 10000, to poll for U0
status to solve the issue.

Cc: stable@vger.kernel.org
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Link: https://lore.kernel.org/r/20200624135949.22611-6-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index f97106e2860f..ed468eed299c 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -4475,6 +4475,9 @@ static int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd,
 			mutex_lock(hcd->bandwidth_mutex);
 			xhci_change_max_exit_latency(xhci, udev, 0);
 			mutex_unlock(hcd->bandwidth_mutex);
+			readl_poll_timeout(ports[port_num]->addr, pm_val,
+					   (pm_val & PORT_PLS_MASK) == XDEV_U0,
+					   100, 10000);
 			return 0;
 		}
 	}


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

* Re: FAILED: patch "[PATCH] xhci: Poll for U0 after disabling USB2 LPM" failed to apply to 4.14-stable tree
  2020-06-28 15:38 FAILED: patch "[PATCH] xhci: Poll for U0 after disabling USB2 LPM" failed to apply to 4.14-stable tree gregkh
@ 2020-06-28 22:01 ` Sasha Levin
  0 siblings, 0 replies; 2+ messages in thread
From: Sasha Levin @ 2020-06-28 22:01 UTC (permalink / raw)
  To: gregkh; +Cc: kai.heng.feng, mathias.nyman, stable

On Sun, Jun 28, 2020 at 05:38:19PM +0200, gregkh@linuxfoundation.org wrote:
>
>The patch below does not apply to the 4.14-stable tree.
>If someone wants it applied there, or to any other stable or longterm
>tree, then please email the backport, including the original git commit
>id to <stable@vger.kernel.org>.
>
>thanks,
>
>greg k-h
>
>------------------ original commit in Linus's tree ------------------
>
>From b3d71abd135e6919ca0b6cab463738472653ddfb Mon Sep 17 00:00:00 2001
>From: Kai-Heng Feng <kai.heng.feng@canonical.com>
>Date: Wed, 24 Jun 2020 16:59:49 +0300
>Subject: [PATCH] xhci: Poll for U0 after disabling USB2 LPM
>
>USB2 devices with LPM enabled may interrupt the system suspend:
>[  932.510475] usb 1-7: usb suspend, wakeup 0
>[  932.510549] hub 1-0:1.0: hub_suspend
>[  932.510581] usb usb1: bus suspend, wakeup 0
>[  932.510590] xhci_hcd 0000:00:14.0: port 9 not suspended
>[  932.510593] xhci_hcd 0000:00:14.0: port 8 not suspended
>..
>[  932.520323] xhci_hcd 0000:00:14.0: Port change event, 1-7, id 7, portsc: 0x400e03
>..
>[  932.591405] PM: pci_pm_suspend(): hcd_pci_suspend+0x0/0x30 returns -16
>[  932.591414] PM: dpm_run_callback(): pci_pm_suspend+0x0/0x160 returns -16
>[  932.591418] PM: Device 0000:00:14.0 failed to suspend async: error -16
>
>During system suspend, USB core will let HC suspends the device if it
>doesn't have remote wakeup enabled and doesn't have any children.
>However, from the log above we can see that the usb 1-7 doesn't get bus
>suspended due to not in U0. After a while the port finished U2 -> U0
>transition, interrupts the suspend process.
>
>The observation is that after disabling LPM, port doesn't transit to U0
>immediately and can linger in U2. xHCI spec 4.23.5.2 states that the
>maximum exit latency for USB2 LPM should be BESL + 10us. The BESL for
>the affected device is advertised as 400us, which is still not enough
>based on my testing result.
>
>So let's use the maximum permitted latency, 10000, to poll for U0
>status to solve the issue.
>
>Cc: stable@vger.kernel.org
>Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
>Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
>Link: https://lore.kernel.org/r/20200624135949.22611-6-mathias.nyman@linux.intel.com
>Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

I've adjusted the patch to missing 38986ffa6a74 ("xhci: use port
structures instead of port arrays in xhci.c functions") and queued it
for 4.14, 4.9, and 4.4.

-- 
Thanks,
Sasha

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

end of thread, other threads:[~2020-06-28 22:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-06-28 15:38 FAILED: patch "[PATCH] xhci: Poll for U0 after disabling USB2 LPM" failed to apply to 4.14-stable tree gregkh
2020-06-28 22:01 ` Sasha Levin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.