diff mbox series

[RFC,3/5] usb: core: hcd: Add support for registering secondary RH along with primary HCD

Message ID 20210824105302.25382-4-kishon@ti.com
State New
Headers show
Series Fix cold plugged USB device on certain PCIe USB cards | expand

Commit Message

Kishon Vijay Abraham I Aug. 24, 2021, 10:53 a.m. UTC
Add support for registering secondary roothub (RH) along with primary HCD.
It has been observed with certain PCIe USB cards that as soon as the
primary HCD is registered, port status change is handled leading to cold
plug devices getting not detected. For such cases, registering both the
root hubs along with the second HCD is useful.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Suggested-by: Alan Stern <stern@rowland.harvard.edu>
---
 drivers/usb/core/hcd.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
diff mbox series

Patch

diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 4d7a9f0e2caa..9c8df22a7d9a 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -2799,6 +2799,7 @@  int __usb_add_hcd(struct usb_hcd *hcd, unsigned int irqnum, unsigned long irqfla
 {
 	int retval;
 	struct usb_device *rhdev;
+	struct usb_hcd *shared_hcd = NULL;
 
 	if (!hcd->skip_phy_initialization && usb_hcd_is_primary_hcd(hcd)) {
 		hcd->phy_roothub = usb_phy_roothub_alloc(hcd->self.sysdev);
@@ -2961,6 +2962,15 @@  int __usb_add_hcd(struct usb_hcd *hcd, unsigned int irqnum, unsigned long irqfla
 
 	/* starting here, usbcore will pay attention to this root hub */
 	if (register_hub) {
+		shared_hcd = hcd->shared_hcd;
+		if (shared_hcd) {
+			retval = register_root_hub(shared_hcd);
+			if (retval != 0)
+				goto err_register_shared_root_hub;
+			if (shared_hcd->uses_new_polling && HCD_POLL_RH(shared_hcd))
+				usb_hcd_poll_rh_status(shared_hcd);
+		}
+
 		retval = register_root_hub(hcd);
 		if (retval != 0)
 			goto err_register_root_hub;
@@ -2972,6 +2982,8 @@  int __usb_add_hcd(struct usb_hcd *hcd, unsigned int irqnum, unsigned long irqfla
 
 err_register_root_hub:
 	usb_stop_hcd(hcd);
+err_register_shared_root_hub:
+	usb_stop_hcd(shared_hcd);
 err_hcd_driver_start:
 	if (usb_hcd_is_primary_hcd(hcd) && hcd->irq > 0)
 		free_irq(irqnum, hcd);