[PATCH 0/2] xhci: Add quirk to workaround the errata seen on Cavium Thunder-X2 Soc

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

[PATCH 0/2] xhci: Add quirk to workaround the errata seen on Cavium Thunder-X2 Soc

Ike Panhc
BugLink: http://bugs.launchpad.net/bugs/1806534

Here is the fix for xhci host on Cavium/Broadcom platform, which
USB 2 device may come up as USB 1

This patch is backported from mainline kernel commit 11644a7659
and already in disco master-next branch as commit 556a227c

Patches here are for bionic and cosmic

Cherian, George (1):
  xhci: Add quirk to workaround the errata seen on Cavium Thunder-X2 Soc

 drivers/usb/host/xhci-pci.c  |  5 +++++
 drivers/usb/host/xhci-ring.c | 35 ++++++++++++++++++++++++++++++++++-
 drivers/usb/host/xhci.h      |  1 +
 3 files changed, 40 insertions(+), 1 deletion(-)

--
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][Bionic] xhci: Add quirk to workaround the errata seen on Cavium Thunder-X2 Soc

Ike Panhc
From: "Cherian, George" <[hidden email]>

BugLink: http://bugs.launchpad.net/bugs/1806534

Implement workaround for ThunderX2 Errata-129 (documented in
CN99XX Known Issues" available at Cavium support site).
As per ThunderX2errata-129, USB 2 device may come up as USB 1
if a connection to a USB 1 device is followed by another connection to
a USB 2 device, the link will come up as USB 1 for the USB 2 device.

Resolution: Reset the PHY after the USB 1 device is disconnected.
The PHY reset sequence is done using private registers in XHCI register
space. After the PHY is reset we check for the PLL lock status and retry
the operation if it fails. From our tests, retrying 4 times is sufficient.

Add a new quirk flag XHCI_RESET_PLL_ON_DISCONNECT to invoke the workaround
in handle_xhci_port_status().

Cc: [hidden email]
Signed-off-by: George Cherian <[hidden email]>
Signed-off-by: Mathias Nyman <[hidden email]>
Signed-off-by: Greg Kroah-Hartman <[hidden email]>
(backported from commit 11644a7659529730eaf2f166efaabe7c3dc7af8c)
Signed-off-by: Ike Panhc <[hidden email]>
---
 drivers/usb/host/xhci-pci.c  |  5 +++++
 drivers/usb/host/xhci-ring.c | 35 ++++++++++++++++++++++++++++++++++-
 drivers/usb/host/xhci.h      |  1 +
 3 files changed, 40 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index c62fa1424601..c25e3e55d8e0 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -226,6 +226,11 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
  if (pdev->vendor == PCI_VENDOR_ID_TI && pdev->device == 0x8241)
  xhci->quirks |= XHCI_LIMIT_ENDPOINT_INTERVAL_7;
 
+ if ((pdev->vendor == PCI_VENDOR_ID_BROADCOM ||
+     pdev->vendor == PCI_VENDOR_ID_CAVIUM) &&
+     pdev->device == 0x9026)
+ xhci->quirks |= XHCI_RESET_PLL_ON_DISCONNECT;
+
  if (xhci->quirks & XHCI_RESET_ON_RESUME)
  xhci_dbg_trace(xhci, trace_xhci_dbg_quirks,
  "QUIRK: Resetting on resume");
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 43409ae24ac4..7d4e76d0d094 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -1554,6 +1554,35 @@ static void handle_device_notification(struct xhci_hcd *xhci,
  usb_wakeup_notification(udev->parent, udev->portnum);
 }
 
+/*
+ * Quirk hanlder for errata seen on Cavium ThunderX2 processor XHCI
+ * Controller.
+ * As per ThunderX2errata-129 USB 2 device may come up as USB 1
+ * If a connection to a USB 1 device is followed by another connection
+ * to a USB 2 device.
+ *
+ * Reset the PHY after the USB device is disconnected if device speed
+ * is less than HCD_USB3.
+ * Retry the reset sequence max of 4 times checking the PLL lock status.
+ *
+ */
+static void xhci_cavium_reset_phy_quirk(struct xhci_hcd *xhci)
+{
+ struct usb_hcd *hcd = xhci_to_hcd(xhci);
+ u32 pll_lock_check;
+ u32 retry_count = 4;
+
+ do {
+ /* Assert PHY reset */
+ writel(0x6F, hcd->regs + 0x1048);
+ udelay(10);
+ /* De-assert the PHY reset */
+ writel(0x7F, hcd->regs + 0x1048);
+ udelay(200);
+ pll_lock_check = readl(hcd->regs + 0x1070);
+ } while (!(pll_lock_check & 0x1) && --retry_count);
+}
+
 static void handle_port_status(struct xhci_hcd *xhci,
  union xhci_trb *event)
 {
@@ -1716,9 +1745,13 @@ static void handle_port_status(struct xhci_hcd *xhci,
  goto cleanup;
  }
 
- if (hcd->speed < HCD_USB3)
+ if (hcd->speed < HCD_USB3) {
  xhci_test_and_clear_bit(xhci, port_array, faked_port_index,
  PORT_PLC);
+ if ((xhci->quirks & XHCI_RESET_PLL_ON_DISCONNECT) &&
+    (portsc & PORT_CSC) && !(portsc & PORT_CONNECT))
+ xhci_cavium_reset_phy_quirk(xhci);
+ }
 
 cleanup:
  /* Update event ring dequeue pointer before dropping the lock */
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 269b2f4a9039..d4b8078d27ed 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1825,6 +1825,7 @@ struct xhci_hcd {
 #define XHCI_ASMEDIA_MODIFY_FLOWCONTROL BIT_ULL(28)
 #define XHCI_HW_LPM_DISABLE BIT_ULL(29)
 #define XHCI_SUSPEND_DELAY BIT_ULL(30)
+#define XHCI_RESET_PLL_ON_DISCONNECT BIT_ULL(34)
 #define XHCI_SNPS_BROKEN_SUSPEND    BIT_ULL(35)
 
  unsigned int num_active_eps;
--
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][Cosmic] xhci: Add quirk to workaround the errata seen on Cavium Thunder-X2 Soc

Ike Panhc
In reply to this post by Ike Panhc
From: "Cherian, George" <[hidden email]>

BugLink: http://bugs.launchpad.net/bugs/1806534

Implement workaround for ThunderX2 Errata-129 (documented in
CN99XX Known Issues" available at Cavium support site).
As per ThunderX2errata-129, USB 2 device may come up as USB 1
if a connection to a USB 1 device is followed by another connection to
a USB 2 device, the link will come up as USB 1 for the USB 2 device.

Resolution: Reset the PHY after the USB 1 device is disconnected.
The PHY reset sequence is done using private registers in XHCI register
space. After the PHY is reset we check for the PLL lock status and retry
the operation if it fails. From our tests, retrying 4 times is sufficient.

Add a new quirk flag XHCI_RESET_PLL_ON_DISCONNECT to invoke the workaround
in handle_xhci_port_status().

Cc: [hidden email]
Signed-off-by: George Cherian <[hidden email]>
Signed-off-by: Mathias Nyman <[hidden email]>
Signed-off-by: Greg Kroah-Hartman <[hidden email]>
(backported from commit 11644a7659529730eaf2f166efaabe7c3dc7af8c)
Signed-off-by: Ike Panhc <[hidden email]>
---
 drivers/usb/host/xhci-pci.c  |  5 +++++
 drivers/usb/host/xhci-ring.c | 35 ++++++++++++++++++++++++++++++++++-
 drivers/usb/host/xhci.h      |  1 +
 3 files changed, 40 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index 722860eb5a91..196b96649ac2 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -229,6 +229,11 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
  if (pdev->vendor == PCI_VENDOR_ID_TI && pdev->device == 0x8241)
  xhci->quirks |= XHCI_LIMIT_ENDPOINT_INTERVAL_7;
 
+ if ((pdev->vendor == PCI_VENDOR_ID_BROADCOM ||
+     pdev->vendor == PCI_VENDOR_ID_CAVIUM) &&
+     pdev->device == 0x9026)
+ xhci->quirks |= XHCI_RESET_PLL_ON_DISCONNECT;
+
  if (xhci->quirks & XHCI_RESET_ON_RESUME)
  xhci_dbg_trace(xhci, trace_xhci_dbg_quirks,
  "QUIRK: Resetting on resume");
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index f0a99aa0ac58..b43486998aa7 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -1517,6 +1517,35 @@ static void handle_device_notification(struct xhci_hcd *xhci,
  usb_wakeup_notification(udev->parent, udev->portnum);
 }
 
+/*
+ * Quirk hanlder for errata seen on Cavium ThunderX2 processor XHCI
+ * Controller.
+ * As per ThunderX2errata-129 USB 2 device may come up as USB 1
+ * If a connection to a USB 1 device is followed by another connection
+ * to a USB 2 device.
+ *
+ * Reset the PHY after the USB device is disconnected if device speed
+ * is less than HCD_USB3.
+ * Retry the reset sequence max of 4 times checking the PLL lock status.
+ *
+ */
+static void xhci_cavium_reset_phy_quirk(struct xhci_hcd *xhci)
+{
+ struct usb_hcd *hcd = xhci_to_hcd(xhci);
+ u32 pll_lock_check;
+ u32 retry_count = 4;
+
+ do {
+ /* Assert PHY reset */
+ writel(0x6F, hcd->regs + 0x1048);
+ udelay(10);
+ /* De-assert the PHY reset */
+ writel(0x7F, hcd->regs + 0x1048);
+ udelay(200);
+ pll_lock_check = readl(hcd->regs + 0x1070);
+ } while (!(pll_lock_check & 0x1) && --retry_count);
+}
+
 static void handle_port_status(struct xhci_hcd *xhci,
  union xhci_trb *event)
 {
@@ -1642,8 +1671,12 @@ static void handle_port_status(struct xhci_hcd *xhci,
  goto cleanup;
  }
 
- if (hcd->speed < HCD_USB3)
+ if (hcd->speed < HCD_USB3) {
  xhci_test_and_clear_bit(xhci, port, PORT_PLC);
+ if ((xhci->quirks & XHCI_RESET_PLL_ON_DISCONNECT) &&
+    (portsc & PORT_CSC) && !(portsc & PORT_CONNECT))
+ xhci_cavium_reset_phy_quirk(xhci);
+ }
 
 cleanup:
  /* Update event ring dequeue pointer before dropping the lock */
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 841e89ffe2e9..91313dc41523 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1846,6 +1846,7 @@ struct xhci_hcd {
 #define XHCI_SUSPEND_DELAY BIT_ULL(30)
 #define XHCI_INTEL_USB_ROLE_SW BIT_ULL(31)
 #define XHCI_ZERO_64B_REGS BIT_ULL(32)
+#define XHCI_RESET_PLL_ON_DISCONNECT BIT_ULL(34)
 
  unsigned int num_active_eps;
  unsigned int limit_active_eps;
--
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: [PATCH 0/2] xhci: Add quirk to workaround the errata seen on Cavium Thunder-X2 Soc

Kleber Souza
In reply to this post by Ike Panhc
On 12/7/18 10:21 AM, Ike Panhc wrote:

> BugLink: http://bugs.launchpad.net/bugs/1806534
>
> Here is the fix for xhci host on Cavium/Broadcom platform, which
> USB 2 device may come up as USB 1
>
> This patch is backported from mainline kernel commit 11644a7659
> and already in disco master-next branch as commit 556a227c
>
> Patches here are for bionic and cosmic
>
> Cherian, George (1):
>   xhci: Add quirk to workaround the errata seen on Cavium Thunder-X2 Soc
>
>  drivers/usb/host/xhci-pci.c  |  5 +++++
>  drivers/usb/host/xhci-ring.c | 35 ++++++++++++++++++++++++++++++++++-
>  drivers/usb/host/xhci.h      |  1 +
>  3 files changed, 40 insertions(+), 1 deletion(-)
>
Limited scope, upstream fix already in Disco.

Acked-by: Kleber Sacilotto de Souza <[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: [PATCH 0/2] xhci: Add quirk to workaround the errata seen on Cavium Thunder-X2 Soc

Stefan Bader-2
In reply to this post by Ike Panhc
On 07.12.18 10:21, Ike Panhc wrote:

> BugLink: http://bugs.launchpad.net/bugs/1806534
>
> Here is the fix for xhci host on Cavium/Broadcom platform, which
> USB 2 device may come up as USB 1
>
> This patch is backported from mainline kernel commit 11644a7659
> and already in disco master-next branch as commit 556a227c
>
> Patches here are for bionic and cosmic
>
> Cherian, George (1):
>   xhci: Add quirk to workaround the errata seen on Cavium Thunder-X2 Soc
>
>  drivers/usb/host/xhci-pci.c  |  5 +++++
>  drivers/usb/host/xhci-ring.c | 35 ++++++++++++++++++++++++++++++++++-
>  drivers/usb/host/xhci.h      |  1 +
>  3 files changed, 40 insertions(+), 1 deletion(-)
>
Acked-by: Stefan Bader <[hidden email]>


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

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

APPLIED(B,C): [PATCH 0/2] xhci: Add quirk to workaround the errata seen on Cavium Thunder-X2 Soc

Khaled Elmously
In reply to this post by Ike Panhc
On 2018-12-07 17:21:18 , Ike Panhc wrote:

> BugLink: http://bugs.launchpad.net/bugs/1806534
>
> Here is the fix for xhci host on Cavium/Broadcom platform, which
> USB 2 device may come up as USB 1
>
> This patch is backported from mainline kernel commit 11644a7659
> and already in disco master-next branch as commit 556a227c
>
> Patches here are for bionic and cosmic
>
> Cherian, George (1):
>   xhci: Add quirk to workaround the errata seen on Cavium Thunder-X2 Soc
>
>  drivers/usb/host/xhci-pci.c  |  5 +++++
>  drivers/usb/host/xhci-ring.c | 35 ++++++++++++++++++++++++++++++++++-
>  drivers/usb/host/xhci.h      |  1 +
>  3 files changed, 40 insertions(+), 1 deletion(-)
>
> --
> 2.17.1
>
>
> --
> kernel-team mailing list
> [hidden email]
> https://lists.ubuntu.com/mailman/listinfo/kernel-team

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