[SRU][B/OEM][PATCH 0/2][v2]: SRU: xhci hang when resume from S3

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[SRU][B/OEM][PATCH 0/2][v2]: SRU: xhci hang when resume from S3

Aaron Ma
BugLink: https://bugs.launchpad.net/bugs/1805344

Chnangelog:
V2:
Add BugLink.

[Impact]
On some thinkpad laptops, Realtek USB3.0 Card Reader [0bda:0328] reports wrong port status on
Cannon lake PCH USB3.1 xHCI [8086:a36d] after resume from S3, then kernel hang.

[Fix]
Restrict the USB2 resume status check in USB2 roothub to fix hang issue.

[Test Case]
Suspend/resume 30 times OK.

[Regression Potential]
Low, upstream fix backported/cherry-picked.

These 2 patches are already Cc: [hidden email], cosmic and future kernel will get these 2 patches.

Aaron Ma (2):
  usb: xhci: fix uninitialized completion when USB3 port got wrong
    status
  usb: xhci: fix timeout for transition from RExit to U0

 drivers/usb/host/xhci-hub.c  | 6 +++---
 drivers/usb/host/xhci-ring.c | 2 +-
 drivers/usb/host/xhci.h      | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

--
2.17.1


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[PATCH 1/2] usb: xhci: fix uninitialized completion when USB3 port got wrong status

Aaron Ma
BugLink: https://bugs.launchpad.net/bugs/1805344

Realtek USB3.0 Card Reader [0bda:0328] reports wrong port status on
Cannon lake PCH USB3.1 xHCI [8086:a36d] after resume from S3,
after clear port reset it works fine.

Since this device is registered on USB3 roothub at boot,
when port status reports not superspeed, xhci_get_port_status will call
an uninitialized completion in bus_state[0].
Kernel will hang because of NULL pointer.

Restrict the USB2 resume status check in USB2 roothub to fix hang issue.

Cc: [hidden email]
Signed-off-by: Aaron Ma <[hidden email]>
Signed-off-by: Mathias Nyman <[hidden email]>
Signed-off-by: Greg Kroah-Hartman <[hidden email]>
(backported from commit 958c0bd86075d4ef1c936998deefe1947e539240)
Signed-off-by: Aaron Ma <[hidden email]>
---
 drivers/usb/host/xhci-hub.c  | 2 +-
 drivers/usb/host/xhci-ring.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index 0fb3fec94e04..83db2c475748 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -883,7 +883,7 @@ static u32 xhci_get_port_status(struct usb_hcd *hcd,
  status |= USB_PORT_STAT_SUSPEND;
  }
  if ((raw_port_status & PORT_PLS_MASK) == XDEV_RESUME &&
- !DEV_SUPERSPEED_ANY(raw_port_status)) {
+ !DEV_SUPERSPEED_ANY(raw_port_status) && hcd->speed < HCD_USB3) {
  if ((raw_port_status & PORT_RESET) ||
  !(raw_port_status & PORT_PE))
  return 0xffffffff;
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 43409ae24ac4..773e0bdf4235 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -1708,7 +1708,7 @@ static void handle_port_status(struct xhci_hcd *xhci,
  * RExit to a disconnect state).  If so, let the the driver know it's
  * out of the RExit state.
  */
- if (!DEV_SUPERSPEED_ANY(portsc) &&
+ if (!DEV_SUPERSPEED_ANY(portsc) && hcd->speed < HCD_USB3 &&
  test_and_clear_bit(faked_port_index,
  &bus_state->rexit_ports)) {
  complete(&bus_state->rexit_done[faked_port_index]);
--
2.17.1


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[PATCH 2/2] usb: xhci: fix timeout for transition from RExit to U0

Aaron Ma
In reply to this post by Aaron Ma
BugLink: https://bugs.launchpad.net/bugs/1805344

This definition is used by msecs_to_jiffies in milliseconds.
According to the comments, max rexit timeout should be 20ms.
Align with the comments to properly calculate the delay.

Verified on Sunrise Point-LP and Cannon Lake.

Cc: [hidden email]
Signed-off-by: Aaron Ma <[hidden email]>
Signed-off-by: Mathias Nyman <[hidden email]>
Signed-off-by: Greg Kroah-Hartman <[hidden email]>
(cherry picked from commit a5baeaeabcca3244782a9b6382ebab6f8a58f583)
Signed-off-by: Aaron Ma <[hidden email]>
---
 drivers/usb/host/xhci-hub.c | 4 ++--
 drivers/usb/host/xhci.h     | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index 83db2c475748..1d3d8e0fc5ee 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -929,7 +929,7 @@ static u32 xhci_get_port_status(struct usb_hcd *hcd,
  time_left = wait_for_completion_timeout(
  &bus_state->rexit_done[wIndex],
  msecs_to_jiffies(
- XHCI_MAX_REXIT_TIMEOUT));
+ XHCI_MAX_REXIT_TIMEOUT_MS));
  spin_lock_irqsave(&xhci->lock, flags);
 
  if (time_left) {
@@ -943,7 +943,7 @@ static u32 xhci_get_port_status(struct usb_hcd *hcd,
  } else {
  int port_status = readl(port_array[wIndex]);
  xhci_warn(xhci, "Port resume took longer than %i msec, port status = 0x%x\n",
- XHCI_MAX_REXIT_TIMEOUT,
+ XHCI_MAX_REXIT_TIMEOUT_MS,
  port_status);
  status |= USB_PORT_STAT_SUSPEND;
  clear_bit(wIndex, &bus_state->rexit_ports);
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 1703473aad7a..891ec8b152f9 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1672,7 +1672,7 @@ struct xhci_bus_state {
  * It can take up to 20 ms to transition from RExit to U0 on the
  * Intel Lynx Point LP xHCI host.
  */
-#define XHCI_MAX_REXIT_TIMEOUT (20 * 1000)
+#define XHCI_MAX_REXIT_TIMEOUT_MS 20
 
 static inline unsigned int hcd_index(struct usb_hcd *hcd)
 {
--
2.17.1


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

ACK: [SRU][B/OEM][PATCH 0/2][v2]: SRU: xhci hang when resume from S3

AceLan Kao
In reply to this post by Aaron Ma
Acked-By: AceLan Kao <[hidden email]>

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

ACK: [SRU][B/OEM][PATCH 0/2][v2]: SRU: xhci hang when resume from S3

Hui Wang
In reply to this post by Aaron Ma
Acked-by: Hui Wang <[hidden email]>

On 2018/11/28 下午11:29, Aaron Ma wrote:

> BugLink: https://bugs.launchpad.net/bugs/1805344
>
> Chnangelog:
> V2:
> Add BugLink.
>
> [Impact]
> On some thinkpad laptops, Realtek USB3.0 Card Reader [0bda:0328] reports wrong port status on
> Cannon lake PCH USB3.1 xHCI [8086:a36d] after resume from S3, then kernel hang.
>
> [Fix]
> Restrict the USB2 resume status check in USB2 roothub to fix hang issue.
>
> [Test Case]
> Suspend/resume 30 times OK.
>
> [Regression Potential]
> Low, upstream fix backported/cherry-picked.
>
> These 2 patches are already Cc: [hidden email], cosmic and future kernel will get these 2 patches.
>
> Aaron Ma (2):
>    usb: xhci: fix uninitialized completion when USB3 port got wrong
>      status
>    usb: xhci: fix timeout for transition from RExit to U0
>
>   drivers/usb/host/xhci-hub.c  | 6 +++---
>   drivers/usb/host/xhci-ring.c | 2 +-
>   drivers/usb/host/xhci.h      | 2 +-
>   3 files changed, 5 insertions(+), 5 deletions(-)
>


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

APPLIED[OEM-B]: [SRU][B/OEM][PATCH 0/2][v2]: SRU: xhci hang when resume from S3

AceLan Kao
In reply to this post by Aaron Ma
Applied on oem kernel 4.15.0-1029.34

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

APPLIED: [SRU][B/OEM][PATCH 0/2][v2]: SRU: xhci hang when resume from S3

Kleber Souza
In reply to this post by Aaron Ma
On 11/28/18 4:29 PM, Aaron Ma wrote:

> BugLink: https://bugs.launchpad.net/bugs/1805344
>
> Chnangelog:
> V2:
> Add BugLink.
>
> [Impact]
> On some thinkpad laptops, Realtek USB3.0 Card Reader [0bda:0328] reports wrong port status on
> Cannon lake PCH USB3.1 xHCI [8086:a36d] after resume from S3, then kernel hang.
>
> [Fix]
> Restrict the USB2 resume status check in USB2 roothub to fix hang issue.
>
> [Test Case]
> Suspend/resume 30 times OK.
>
> [Regression Potential]
> Low, upstream fix backported/cherry-picked.
>
> These 2 patches are already Cc: [hidden email], cosmic and future kernel will get these 2 patches.
>
> Aaron Ma (2):
>   usb: xhci: fix uninitialized completion when USB3 port got wrong
>     status
>   usb: xhci: fix timeout for transition from RExit to U0
>
>  drivers/usb/host/xhci-hub.c  | 6 +++---
>  drivers/usb/host/xhci-ring.c | 2 +-
>  drivers/usb/host/xhci.h      | 2 +-
>  3 files changed, 5 insertions(+), 5 deletions(-)
>

Applied to bionic/master-next branch.

Thanks,
Kleber


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team