Commit 4da7e4d4 authored by LeoLiu-oc's avatar LeoLiu-oc Committed by Zheng Zengkai
Browse files

xhci: Show Zhaoxin XHCI root hub speed correctly

zhaoxin inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I40QDN


CVE: NA

----------------------------------------------------------------

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.

Signed-off-by: default avatarLeoLiu-oc <LeoLiu-oc@zhaoxin.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
Reviewed-by: default avatarHanjun Guo <guohanjun@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent 4f4136d2
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -5186,6 +5186,7 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks)
	 */
	struct device		*dev = hcd->self.sysdev;
	unsigned int		minor_rev;
	u8			i, j;
	int			retval;

	/* Accept arbitrarily long scatter-gather lists */
@@ -5240,6 +5241,24 @@ 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 (xhci->quirks & XHCI_ZHAOXIN_HOST) {
			minor_rev = 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)
						minor_rev = 1;
				}
				if (minor_rev != 1) {
					hcd->speed = HCD_USB3;
					hcd->self.root_hub->speed = USB_SPEED_SUPER;
				}
			}
		}

		xhci_info(xhci, "Host supports USB 3.%x %sSuperSpeed\n",
			  minor_rev,
			  minor_rev ? "Enhanced " : "");