On 26/03/2021 11:09, Hanjun Guo wrote:
On 2021/3/25 18:09, LeoLiu-oc wrote:
Some Zhaoxin xHCI controllers follow usb3.1 spec, but only support gen1 speed 5G. While in Linux kernel, if xHCI suspport usb3.1,root hub speed will show on 10G. To fix this issue, read usb speed ID supported by xHCI to determine root hub speed.
The patch is scheduled to be submitted to the kernel mainline in 2021.
Signed-off-by: LeoLiu-oc LeoLiu-oc@zhaoxin.com
drivers/usb/host/xhci.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 69617b8f5e00..af659b15258e 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -5059,6 +5059,8 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks) */ struct device *dev = hcd->self.sysdev; unsigned int minor_rev; + struct pci_dev *pdev = to_pci_dev(dev); + u8 ssp_support = 1, i, j; int retval;
/* Accept arbitrarily long scatter-gather lists */ @@ -5113,9 +5115,27 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks) hcd->self.root_hub->speed = USB_SPEED_SUPER_PLUS; break; }
+ /* usb3.1 has gen1 and gen2, Some zx's xHCI controller that follow usb3.1 spec + * but only support gen1 + */ + if (pdev->vendor == PCI_VENDOR_ID_ZHAOXIN) { + ssp_support = 0; + for (j = 0; j < xhci->num_port_caps; j++) { + for (i = 0; i < xhci->port_caps[j].psi_count; i++) { + if (XHCI_EXT_PORT_PSIV(xhci->port_caps[j].psi[i]) >= 5) + ssp_support = 1; + } + if (ssp_support != 1) { + hcd->speed = HCD_USB3; + hcd->self.root_hub->speed = USB_SPEED_SUPER; + } + } + }
Same here, XHCI could be a platform device, not always PCI based, so it will introduce compile error if you not enable CONFIG_USB_PCI.
Will adjust patch code in V2. Thanks
xhci_info(xhci, "Host supports USB 3.%x %sSuperSpeed\n", minor_rev, - minor_rev ? "Enhanced " : ""); + ssp_support ? "Enhanced " : "");
Please use minor_rev and not introduce a new one, and don't break other the behaviour of the previous code.
Got it.
Sincerely TonyWWangoc
Thanks Hanjun
xhci->usb3_rhub.hcd = hcd; /* xHCI private pointer was set in xhci_pci_probe for the second
.