Skip to contentSkip to conversation

USB:XHCI:skip hub registration

RFC PATCH In review Longfang Liu 3 participants 10 messages Apr 15, 2021 – Apr 17, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 USB:XHCI:skip hub registration

When the number of ports on the USB hub is 0, skip the registration operation of the USB hub.

The current Kunpeng930's XHCI hardware controller is defective. The number of ports on its USB3.0 bus controller is 0, and the number of ports on the USB2.0 bus controller is 1.

In order to solve this problem that the USB3.0 controller does not have a port which causes the registration of the hub to fail, this patch passes the defect information by adding flags in the quirks of xhci and usb_hcd, and finally skips the registration process of the hub directly according to the results of these flags when the hub is initialized.

---
 drivers/usb/core/hub.c      | 6 ++++++
 drivers/usb/host/xhci-pci.c | 4 ++++
 drivers/usb/host/xhci.c     | 5 +++++
 drivers/usb/host/xhci.h     | 1 +
 include/linux/usb/hcd.h     | 1 +
 5 files changed, 17 insertions(+)
drivers/usb/core/hub.c +6 -0
index b1e14be..2d6869d 100644
@@ -1769,9 +1769,15 @@ static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id)
 	struct usb_host_interface *desc;
 	struct usb_device *hdev;
 	struct usb_hub *hub;
+	struct usb_hcd *hcd;
 
 	desc = intf->cur_altsetting;
 	hdev = interface_to_usbdev(intf);
+	hcd = bus_to_hcd(hdev->bus);
+	if (hcd->usb3_no_port) {
+		dev_warn(&intf->dev, "USB hub has no port\n");
+		return -ENODEV;
+	}
 
 	/*
 	 * Set default autosuspend delay as 0 to speedup bus suspend,
drivers/usb/host/xhci-pci.c +4 -0
index ef513c2..63b89a4 100644
@@ -281,6 +281,10 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
 	if (xhci->quirks & XHCI_RESET_ON_RESUME)
 		xhci_dbg_trace(xhci, trace_xhci_dbg_quirks,
 				"QUIRK: Resetting on resume");
+
+	if (pdev->vendor == PCI_VENDOR_ID_HUAWEI &&
+	    pdev->device == 0xa23c)
+		xhci->quirks |= XHCI_USB3_NOPORT;
 }
 
 #ifdef CONFIG_ACPI
drivers/usb/host/xhci.c +5 -0
index bee5dec..e3e3573 100644
@@ -5184,6 +5184,11 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks)
 		/* xHCI private pointer was set in xhci_pci_probe for the second
 		 * registered roothub.
 		 */
+		if (xhci->quirks & XHCI_USB3_NOPORT) {
+			xhci_info(xhci, "xHCI host has no port\n");
+			hcd->usb3_no_port = 1;
+		}
+
 		return 0;
 	}
 
drivers/usb/host/xhci.h +1 -0
index 2c6c4f8..d3c658f 100644
@@ -1874,6 +1874,7 @@ struct xhci_hcd {
 #define XHCI_RESET_PLL_ON_DISCONNECT	BIT_ULL(34)
 #define XHCI_SNPS_BROKEN_SUSPEND    BIT_ULL(35)
 #define XHCI_RENESAS_FW_QUIRK	BIT_ULL(36)
+#define XHCI_USB3_NOPORT	BIT_ULL(37)
 
 	unsigned int		num_active_eps;
 	unsigned int		limit_active_eps;
include/linux/usb/hcd.h +1 -0
index 3dbb42c..7df23a0f 100644
@@ -172,6 +172,7 @@ struct usb_hcd {
 	unsigned		tpl_support:1; /* OTG & EH TPL support */
 	unsigned		cant_recv_wakeups:1;
 			/* wakeup requests from downstream aren't received */
+	unsigned		usb3_no_port:1; /* xHCI main_hcd has no port */
 
 	unsigned int		irq;		/* irq allocated */
 	void __iomem		*regs;		/* device memory/io */
Signature · 1 line
2.8.1
maintainer
#1 lore raw
Quoted 2 lines · Longfang Liu

When the number of ports on the USB hub is 0, skip the registration operation of the USB hub.

That's crazy. Why not fix the hardware? How has this hub passed the USB certification process?

Quoted 44 lines

The current Kunpeng930's XHCI hardware controller is defective. The number of ports on its USB3.0 bus controller is 0, and the number of ports on the USB2.0 bus controller is 1.

In order to solve this problem that the USB3.0 controller does not have a port which causes the registration of the hub to fail, this patch passes the defect information by adding flags in the quirks of xhci and usb_hcd, and finally skips the registration process of the hub directly according to the results of these flags when the hub is initialized.

---
 drivers/usb/core/hub.c      | 6 ++++++
 drivers/usb/host/xhci-pci.c | 4 ++++
 drivers/usb/host/xhci.c     | 5 +++++
 drivers/usb/host/xhci.h     | 1 +
 include/linux/usb/hcd.h     | 1 +
 5 files changed, 17 insertions(+)
drivers/usb/core/hub.c +6 -0
index b1e14be..2d6869d 100644
@@ -1769,9 +1769,15 @@ static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id)
 	struct usb_host_interface *desc;
 	struct usb_device *hdev;
 	struct usb_hub *hub;
+	struct usb_hcd *hcd;
 
 	desc = intf->cur_altsetting;
 	hdev = interface_to_usbdev(intf);
+	hcd = bus_to_hcd(hdev->bus);
+	if (hcd->usb3_no_port) {
+		dev_warn(&intf->dev, "USB hub has no port\n");
+		return -ENODEV;
+	}
 
 	/*
 	 * Set default autosuspend delay as 0 to speedup bus suspend,
drivers/usb/host/xhci-pci.c +0 -0
index ef513c2..63b89a4 100644

drivers/usb/host/xhci-pci.c static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) · line 287

Quoted 7 lines
drivers/usb/host/xhci-pci.c +4 -0
@@ -281,6 +281,10 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
 	if (xhci->quirks & XHCI_RESET_ON_RESUME)
 		xhci_dbg_trace(xhci, trace_xhci_dbg_quirks,
 				"QUIRK: Resetting on resume");
+
+	if (pdev->vendor == PCI_VENDOR_ID_HUAWEI &&
+	    pdev->device == 0xa23c)
+		xhci->quirks |= XHCI_USB3_NOPORT;

Can't we just detect this normally that there are no ports for this device? Why is the device lying about how many ports it has such that we have to "override" this?

And again, why not fix this broken hardware?

thanks,

greg k-h

#2 lore raw
Quoted 54 lines · Greg KH
Quoted 2 lines · Longfang Liu

When the number of ports on the USB hub is 0, skip the registration operation of the USB hub.

That's crazy. Why not fix the hardware? How has this hub passed the USB certification process?

Quoted 47 lines

The current Kunpeng930's XHCI hardware controller is defective. The number of ports on its USB3.0 bus controller is 0, and the number of ports on the USB2.0 bus controller is 1.

In order to solve this problem that the USB3.0 controller does not have a port which causes the registration of the hub to fail, this patch passes the defect information by adding flags in the quirks of xhci and usb_hcd, and finally skips the registration process of the hub directly according to the results of these flags when the hub is initialized.

---
 drivers/usb/core/hub.c      | 6 ++++++
 drivers/usb/host/xhci-pci.c | 4 ++++
 drivers/usb/host/xhci.c     | 5 +++++
 drivers/usb/host/xhci.h     | 1 +
 include/linux/usb/hcd.h     | 1 +
 5 files changed, 17 insertions(+)
drivers/usb/core/hub.c +6 -0
index b1e14be..2d6869d 100644
@@ -1769,9 +1769,15 @@ static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id)
 	struct usb_host_interface *desc;
 	struct usb_device *hdev;
 	struct usb_hub *hub;
+	struct usb_hcd *hcd;
 
 	desc = intf->cur_altsetting;
 	hdev = interface_to_usbdev(intf);
+	hcd = bus_to_hcd(hdev->bus);
+	if (hcd->usb3_no_port) {
+		dev_warn(&intf->dev, "USB hub has no port\n");
+		return -ENODEV;
+	}
 
 	/*
 	 * Set default autosuspend delay as 0 to speedup bus suspend,
drivers/usb/host/xhci-pci.c +0 -0
index ef513c2..63b89a4 100644
@@ -281,6 +281,10 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
 	if (xhci->quirks & XHCI_RESET_ON_RESUME)
 		xhci_dbg_trace(xhci, trace_xhci_dbg_quirks,
 				"QUIRK: Resetting on resume");
Quoted 9 lines

drivers/usb/host/xhci-pci.c static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) · line 287

Quoted 4 lines
drivers/usb/host/xhci-pci.c +4 -0
+
+	if (pdev->vendor == PCI_VENDOR_ID_HUAWEI &&
+	    pdev->device == 0xa23c)
+		xhci->quirks |= XHCI_USB3_NOPORT;

Can't we just detect this normally that there are no ports for this device? Why is the device lying about how many ports it has such that we have to "override" this?

The hub driver will check the port number in prob(). If there is no port, the driver will report an error log. But we hope this defective device does not print error log.

Quoted 7 lines

And again, why not fix this broken hardware?

thanks,

greg k-h
.
The current generation of hardware can no longer be modified,

this problem will be solved in the next generation of hardware. Thanks,
Longfang.

maintainer
#3 lore raw
Quoted 65 lines · liulongfang
Quoted 54 lines · Greg KH
Quoted 2 lines · Longfang Liu

When the number of ports on the USB hub is 0, skip the registration operation of the USB hub.

That's crazy. Why not fix the hardware? How has this hub passed the USB certification process?

Quoted 47 lines

The current Kunpeng930's XHCI hardware controller is defective. The number of ports on its USB3.0 bus controller is 0, and the number of ports on the USB2.0 bus controller is 1.

In order to solve this problem that the USB3.0 controller does not have a port which causes the registration of the hub to fail, this patch passes the defect information by adding flags in the quirks of xhci and usb_hcd, and finally skips the registration process of the hub directly according to the results of these flags when the hub is initialized.

---
 drivers/usb/core/hub.c      | 6 ++++++
 drivers/usb/host/xhci-pci.c | 4 ++++
 drivers/usb/host/xhci.c     | 5 +++++
 drivers/usb/host/xhci.h     | 1 +
 include/linux/usb/hcd.h     | 1 +
 5 files changed, 17 insertions(+)
drivers/usb/core/hub.c +6 -0
index b1e14be..2d6869d 100644
@@ -1769,9 +1769,15 @@ static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id)
 	struct usb_host_interface *desc;
 	struct usb_device *hdev;
 	struct usb_hub *hub;
+	struct usb_hcd *hcd;
 
 	desc = intf->cur_altsetting;
 	hdev = interface_to_usbdev(intf);
+	hcd = bus_to_hcd(hdev->bus);
+	if (hcd->usb3_no_port) {
+		dev_warn(&intf->dev, "USB hub has no port\n");
+		return -ENODEV;
+	}
 
 	/*
 	 * Set default autosuspend delay as 0 to speedup bus suspend,
drivers/usb/host/xhci-pci.c +0 -0
index ef513c2..63b89a4 100644
@@ -281,6 +281,10 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
 	if (xhci->quirks & XHCI_RESET_ON_RESUME)
 		xhci_dbg_trace(xhci, trace_xhci_dbg_quirks,
 				"QUIRK: Resetting on resume");
Quoted 9 lines

drivers/usb/host/xhci-pci.c static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) · line 287

Quoted 4 lines
drivers/usb/host/xhci-pci.c +4 -0
+
+	if (pdev->vendor == PCI_VENDOR_ID_HUAWEI &&
+	    pdev->device == 0xa23c)
+		xhci->quirks |= XHCI_USB3_NOPORT;

Can't we just detect this normally that there are no ports for this device? Why is the device lying about how many ports it has such that we have to "override" this?

Quoted 3 lines

The hub driver will check the port number in prob(). If there is no port, the driver will report an error log. But we hope this defective device does not print error log.

Defective devices deserve to have errors sent to the error log, otherwise how will people know to tell the companies to fix them?

Again, this device can not pass USB certification, so there's not much we should do to work around that, right?

thanks,

greg k-h

#4 lore raw
In reply to Longfang Liu
Quoted 7 lines · Longfang Liu

When the number of ports on the USB hub is 0, skip the registration operation of the USB hub.

The current Kunpeng930's XHCI hardware controller is defective. The number of ports on its USB3.0 bus controller is 0, and the number of ports on the USB2.0 bus controller is 1.

Quoted 7 lines

In order to solve this problem that the USB3.0 controller does not have a port which causes the registration of the hub to fail, this patch passes the defect information by adding flags in the quirks of xhci and usb_hcd, and finally skips the registration process of the hub directly according to the results of these flags when the hub is initialized.

The objections that Greg raised are all good ones.

But even aside from them, this patch doesn't actually do what the description says. The patch doesn't remove the call to usb_add_hcd for the USB-3 bus. If you simply skipped that call (and the corresponding call to usb_remove_hcd) when there are no ports on the root hub, none of the stuff in this patch would be needed.

Alan Stern

Quoted 86 lines
---
 drivers/usb/core/hub.c      | 6 ++++++
 drivers/usb/host/xhci-pci.c | 4 ++++
 drivers/usb/host/xhci.c     | 5 +++++
 drivers/usb/host/xhci.h     | 1 +
 include/linux/usb/hcd.h     | 1 +
 5 files changed, 17 insertions(+)
drivers/usb/core/hub.c +6 -0
index b1e14be..2d6869d 100644
@@ -1769,9 +1769,15 @@ static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id)
 	struct usb_host_interface *desc;
 	struct usb_device *hdev;
 	struct usb_hub *hub;
+	struct usb_hcd *hcd;
 
 	desc = intf->cur_altsetting;
 	hdev = interface_to_usbdev(intf);
+	hcd = bus_to_hcd(hdev->bus);
+	if (hcd->usb3_no_port) {
+		dev_warn(&intf->dev, "USB hub has no port\n");
+		return -ENODEV;
+	}
 
 	/*
 	 * Set default autosuspend delay as 0 to speedup bus suspend,
drivers/usb/host/xhci-pci.c +4 -0
index ef513c2..63b89a4 100644
@@ -281,6 +281,10 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
 	if (xhci->quirks & XHCI_RESET_ON_RESUME)
 		xhci_dbg_trace(xhci, trace_xhci_dbg_quirks,
 				"QUIRK: Resetting on resume");
+
+	if (pdev->vendor == PCI_VENDOR_ID_HUAWEI &&
+	    pdev->device == 0xa23c)
+		xhci->quirks |= XHCI_USB3_NOPORT;
 }
 
 #ifdef CONFIG_ACPI
drivers/usb/host/xhci.c +5 -0
index bee5dec..e3e3573 100644
@@ -5184,6 +5184,11 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks)
 		/* xHCI private pointer was set in xhci_pci_probe for the second
 		 * registered roothub.
 		 */
+		if (xhci->quirks & XHCI_USB3_NOPORT) {
+			xhci_info(xhci, "xHCI host has no port\n");
+			hcd->usb3_no_port = 1;
+		}
+
 		return 0;
 	}
 
drivers/usb/host/xhci.h +1 -0
index 2c6c4f8..d3c658f 100644
@@ -1874,6 +1874,7 @@ struct xhci_hcd {
 #define XHCI_RESET_PLL_ON_DISCONNECT	BIT_ULL(34)
 #define XHCI_SNPS_BROKEN_SUSPEND    BIT_ULL(35)
 #define XHCI_RENESAS_FW_QUIRK	BIT_ULL(36)
+#define XHCI_USB3_NOPORT	BIT_ULL(37)
 
 	unsigned int		num_active_eps;
 	unsigned int		limit_active_eps;
include/linux/usb/hcd.h +1 -0
index 3dbb42c..7df23a0f 100644
@@ -172,6 +172,7 @@ struct usb_hcd {
 	unsigned		tpl_support:1; /* OTG & EH TPL support */
 	unsigned		cant_recv_wakeups:1;
 			/* wakeup requests from downstream aren't received */
+	unsigned		usb3_no_port:1; /* xHCI main_hcd has no port */
 
 	unsigned int		irq;		/* irq allocated */
 	void __iomem		*regs;		/* device memory/io */
Signature · 1 line
2.8.1
#5 lore raw
Quoted 18 lines · Alan Stern
Quoted 7 lines · Longfang Liu

When the number of ports on the USB hub is 0, skip the registration operation of the USB hub.

The current Kunpeng930's XHCI hardware controller is defective. The number of ports on its USB3.0 bus controller is 0, and the number of ports on the USB2.0 bus controller is 1.

Quoted 7 lines

In order to solve this problem that the USB3.0 controller does not have a port which causes the registration of the hub to fail, this patch passes the defect information by adding flags in the quirks of xhci and usb_hcd, and finally skips the registration process of the hub directly according to the results of these flags when the hub is initialized.

The objections that Greg raised are all good ones.

Quoted 8 lines

But even aside from them, this patch doesn't actually do what the description says. The patch doesn't remove the call to usb_add_hcd for the USB-3 bus. If you simply skipped that call (and the corresponding call to usb_remove_hcd) when there are no ports on the root hub, none of the stuff in this patch would be needed.

Alan Stern

"[RFC PATCH] USB:XHCI:Adjust the log level of hub"
The current method is an improved method of the above patch.
This patch just make it skip registering USB-3 root hub if that hub has no ports, after skipping registering, no port will not report error log,the goal of this patch is reached without error log output.
Thanks.
Longfang.

Quoted 88 lines
Quoted 86 lines
---
 drivers/usb/core/hub.c      | 6 ++++++
 drivers/usb/host/xhci-pci.c | 4 ++++
 drivers/usb/host/xhci.c     | 5 +++++
 drivers/usb/host/xhci.h     | 1 +
 include/linux/usb/hcd.h     | 1 +
 5 files changed, 17 insertions(+)
drivers/usb/core/hub.c +6 -0
index b1e14be..2d6869d 100644
@@ -1769,9 +1769,15 @@ static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id)
 	struct usb_host_interface *desc;
 	struct usb_device *hdev;
 	struct usb_hub *hub;
+	struct usb_hcd *hcd;
 
 	desc = intf->cur_altsetting;
 	hdev = interface_to_usbdev(intf);
+	hcd = bus_to_hcd(hdev->bus);
+	if (hcd->usb3_no_port) {
+		dev_warn(&intf->dev, "USB hub has no port\n");
+		return -ENODEV;
+	}
 
 	/*
 	 * Set default autosuspend delay as 0 to speedup bus suspend,
drivers/usb/host/xhci-pci.c +4 -0
index ef513c2..63b89a4 100644
@@ -281,6 +281,10 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
 	if (xhci->quirks & XHCI_RESET_ON_RESUME)
 		xhci_dbg_trace(xhci, trace_xhci_dbg_quirks,
 				"QUIRK: Resetting on resume");
+
+	if (pdev->vendor == PCI_VENDOR_ID_HUAWEI &&
+	    pdev->device == 0xa23c)
+		xhci->quirks |= XHCI_USB3_NOPORT;
 }
 
 #ifdef CONFIG_ACPI
drivers/usb/host/xhci.c +5 -0
index bee5dec..e3e3573 100644
@@ -5184,6 +5184,11 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks)
 		/* xHCI private pointer was set in xhci_pci_probe for the second
 		 * registered roothub.
 		 */
+		if (xhci->quirks & XHCI_USB3_NOPORT) {
+			xhci_info(xhci, "xHCI host has no port\n");
+			hcd->usb3_no_port = 1;
+		}
+
 		return 0;
 	}
 
drivers/usb/host/xhci.h +1 -0
index 2c6c4f8..d3c658f 100644
@@ -1874,6 +1874,7 @@ struct xhci_hcd {
 #define XHCI_RESET_PLL_ON_DISCONNECT	BIT_ULL(34)
 #define XHCI_SNPS_BROKEN_SUSPEND    BIT_ULL(35)
 #define XHCI_RENESAS_FW_QUIRK	BIT_ULL(36)
+#define XHCI_USB3_NOPORT	BIT_ULL(37)
 
 	unsigned int		num_active_eps;
 	unsigned int		limit_active_eps;
include/linux/usb/hcd.h +1 -0
index 3dbb42c..7df23a0f 100644
@@ -172,6 +172,7 @@ struct usb_hcd {
 	unsigned		tpl_support:1; /* OTG & EH TPL support */
 	unsigned		cant_recv_wakeups:1;
 			/* wakeup requests from downstream aren't received */
+	unsigned		usb3_no_port:1; /* xHCI main_hcd has no port */
 
 	unsigned int		irq;		/* irq allocated */
 	void __iomem		*regs;		/* device memory/io */
Signature · 1 line
2.8.1

.

#6 lore raw
Quoted 25 lines · liulongfang
Quoted 24 lines · Alan Stern
Quoted 7 lines · Longfang Liu

When the number of ports on the USB hub is 0, skip the registration operation of the USB hub.

The current Kunpeng930's XHCI hardware controller is defective. The number of ports on its USB3.0 bus controller is 0, and the number of ports on the USB2.0 bus controller is 1.

Quoted 7 lines

In order to solve this problem that the USB3.0 controller does not have a port which causes the registration of the hub to fail, this patch passes the defect information by adding flags in the quirks of xhci and usb_hcd, and finally skips the registration process of the hub directly according to the results of these flags when the hub is initialized.

The objections that Greg raised are all good ones.

But even aside from them, this patch doesn't actually do what the description says. The patch doesn't remove the call to usb_add_hcd for the USB-3 bus. If you simply skipped that call (and the corresponding call to usb_remove_hcd) when there are no ports on the root hub, none of the stuff in this patch would be needed.

Quoted 4 lines
Quoted 2 lines

Alan Stern

"[RFC PATCH] USB:XHCI:Adjust the log level of hub"

I don't understand. What patch is that? Do you have a URL for it?

Quoted 2 lines

The current method is an improved method of the above patch.
This patch just make it skip registering USB-3 root hub if that hub has no ports,

No, that isn't what this patch does.

If the root hub wasn't registered, hub_probe wouldn't get called. But with your patch, the system tries to register the root hub, and it does call hub_probe, and then that function fails with a warning message.

The way to _really_ akip registering the root hub is to change the xhci-hcd code. Make it skip calling usb_add_hcd.

Quoted 2 lines

after skipping registering, no port will not report error log,the goal of this patch is reached without error log output.

Why do you want to get rid of the error log output? There really _is_ an error, because the USB-3 hardware on your controller is defective. Since the hardware is buggy, we _should_ print an error message in the kernel log.

Alan Stern

#7 lore raw
Quoted 26 lines · Alan Stern
Quoted 25 lines · liulongfang
Quoted 24 lines · Alan Stern
Quoted 7 lines · Longfang Liu

When the number of ports on the USB hub is 0, skip the registration operation of the USB hub.

The current Kunpeng930's XHCI hardware controller is defective. The number of ports on its USB3.0 bus controller is 0, and the number of ports on the USB2.0 bus controller is 1.

Quoted 7 lines

In order to solve this problem that the USB3.0 controller does not have a port which causes the registration of the hub to fail, this patch passes the defect information by adding flags in the quirks of xhci and usb_hcd, and finally skips the registration process of the hub directly according to the results of these flags when the hub is initialized.

The objections that Greg raised are all good ones.

But even aside from them, this patch doesn't actually do what the description says. The patch doesn't remove the call to usb_add_hcd for the USB-3 bus. If you simply skipped that call (and the corresponding call to usb_remove_hcd) when there are no ports on the root hub, none of the stuff in this patch would be needed.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Alan Stern

"[RFC PATCH] USB:XHCI:Adjust the log level of hub"

I don't understand. What patch is that? Do you have a URL for it?

URL: https://patchwork.kernel.org/project/linux-usb/patch/[email protected]/
Thanks
Longfang.

Quoted 23 lines
Quoted 2 lines

The current method is an improved method of the above patch.
This patch just make it skip registering USB-3 root hub if that hub has no ports,

No, that isn't what this patch does.

If the root hub wasn't registered, hub_probe wouldn't get called. But with your patch, the system tries to register the root hub, and it does call hub_probe, and then that function fails with a warning message.

The way to _really_ akip registering the root hub is to change the xhci-hcd code. Make it skip calling usb_add_hcd.

Quoted 2 lines

after skipping registering, no port will not report error log,the goal of this patch is reached without error log output.

Why do you want to get rid of the error log output? There really _is_ an error, because the USB-3 hardware on your controller is defective. Since the hardware is buggy, we _should_ print an error message in the kernel log.

Alan Stern
.

#8 lore raw
In reply to Alan Stern
Quoted 36 lines · Alan Stern
Quoted 25 lines · liulongfang
Quoted 24 lines · Alan Stern
Quoted 7 lines · Longfang Liu

When the number of ports on the USB hub is 0, skip the registration operation of the USB hub.

The current Kunpeng930's XHCI hardware controller is defective. The number of ports on its USB3.0 bus controller is 0, and the number of ports on the USB2.0 bus controller is 1.

Quoted 7 lines

In order to solve this problem that the USB3.0 controller does not have a port which causes the registration of the hub to fail, this patch passes the defect information by adding flags in the quirks of xhci and usb_hcd, and finally skips the registration process of the hub directly according to the results of these flags when the hub is initialized.

The objections that Greg raised are all good ones.

But even aside from them, this patch doesn't actually do what the description says. The patch doesn't remove the call to usb_add_hcd for the USB-3 bus. If you simply skipped that call (and the corresponding call to usb_remove_hcd) when there are no ports on the root hub, none of the stuff in this patch would be needed.

Quoted 4 lines
Quoted 2 lines

Alan Stern

"[RFC PATCH] USB:XHCI:Adjust the log level of hub"

I don't understand. What patch is that? Do you have a URL for it?

Quoted 2 lines

The current method is an improved method of the above patch.
This patch just make it skip registering USB-3 root hub if that hub has no ports,

Quoted 9 lines

No, that isn't what this patch does.

If the root hub wasn't registered, hub_probe wouldn't get called. But with your patch, the system tries to register the root hub, and it does call hub_probe, and then that function fails with a warning message.

The way to _really_ akip registering the root hub is to change the xhci-hcd code. Make it skip calling usb_add_hcd.

If you do not register in the root hub, this will return an error code, which will make all the XHCI drivers unregister, causing the USB2.0 controllers on the xhci to be unavailable.
Thanks,
Longfang.

Quoted 11 lines
Quoted 2 lines

after skipping registering, no port will not report error log,the goal of this patch is reached without error log output.

Why do you want to get rid of the error log output? There really _is_ an error, because the USB-3 hardware on your controller is defective. Since the hardware is buggy, we _should_ print an error message in the kernel log.

Alan Stern
.

#9 lore raw
Quoted 11 lines · liulongfang
Quoted 10 lines · Alan Stern
Quoted 2 lines · liulongfang

The current method is an improved method of the above patch.
This patch just make it skip registering USB-3 root hub if that hub has no ports,

No, that isn't what this patch does.

If the root hub wasn't registered, hub_probe wouldn't get called. But with your patch, the system tries to register the root hub, and it does call hub_probe, and then that function fails with a warning message.

Quoted 5 lines
Quoted 3 lines

The way to _really_ akip registering the root hub is to change the xhci-hcd code. Make it skip calling usb_add_hcd.

If you do not register in the root hub, this will return an error code,

What will return an error code? Are you talking about xhci_pci_probe()? You oight to be able to figure out how to make it work.

Quoted 2 lines

which will make all the XHCI drivers unregister, causing the USB2.0 controllers on the xhci to be unavailable.

Alan Stern