All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 0/5] Fix cold plugged USB device on certain PCIe USB cards
@ 2021-08-24 10:52 Kishon Vijay Abraham I
  2021-08-24 10:52 ` [RFC PATCH 1/5] usb: core: hcd: Modularize HCD stop configuration in usb_stop_hcd() Kishon Vijay Abraham I
                   ` (4 more replies)
  0 siblings, 5 replies; 17+ messages in thread
From: Kishon Vijay Abraham I @ 2021-08-24 10:52 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Mathias Nyman, Alan Stern
  Cc: linux-usb, linux-kernel, chris.chiu

Cold plugged USB device was not detected on certain PCIe USB cards
(like Inateck card connected to AM64 EVM or connected to J7200 EVM).

Re-plugging the USB device always gets it enumerated.

This issue was discussed in
https://lore.kernel.org/r/772e4001-178e-4918-032c-6e625bdded24@ti.com
and
https://bugzilla.kernel.org/show_bug.cgi?id=214021

So the suggested solution is to register both root hubs along with the
second hcd for xhci. This series performs some cleanups and implements
the suggested solution.

Kishon Vijay Abraham I (5):
  usb: core: hcd: Modularize HCD stop configuration in usb_stop_hcd()
  usb: core: hcd: Let usb_add_hcd() indicate if roothub has to be
    registered
  usb: core: hcd: Add support for registering secondary RH along with
    primary HCD
  usb: core: hcd-pci: Let usb_hcd_pci_probe() indicate if RH has to be
    registered
  xhci-pci: Use flag to not register roothub while adding primary HCD

 drivers/usb/core/hcd-pci.c  | 11 +++---
 drivers/usb/core/hcd.c      | 72 ++++++++++++++++++++++++-------------
 drivers/usb/host/xhci-pci.c |  2 +-
 include/linux/usb/hcd.h     | 16 ++++++---
 4 files changed, 65 insertions(+), 36 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [RFC PATCH 1/5] usb: core: hcd: Modularize HCD stop configuration in usb_stop_hcd()
  2021-08-24 10:52 [RFC PATCH 0/5] Fix cold plugged USB device on certain PCIe USB cards Kishon Vijay Abraham I
@ 2021-08-24 10:52 ` Kishon Vijay Abraham I
  2021-08-24 13:06   ` Greg Kroah-Hartman
  2021-08-24 10:52 ` [RFC PATCH 2/5] usb: core: hcd: Let usb_add_hcd() indicate if roothub has to be registered Kishon Vijay Abraham I
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 17+ messages in thread
From: Kishon Vijay Abraham I @ 2021-08-24 10:52 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Mathias Nyman, Alan Stern
  Cc: linux-usb, linux-kernel, chris.chiu

No functional change. Since configuration to stop HCD is invoked from
multiple places, group all of them in usb_stop_hcd().

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
 drivers/usb/core/hcd.c | 42 +++++++++++++++++++++++++-----------------
 1 file changed, 25 insertions(+), 17 deletions(-)

diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 0f8b7c93310e..c036ba5311b3 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -2760,6 +2760,29 @@ static void usb_put_invalidate_rhdev(struct usb_hcd *hcd)
 	usb_put_dev(rhdev);
 }
 
+/**
+ * usb_stop_hcd - Halt the HCD
+ * @hcd: the usb_hcd that has to be halted
+ *
+ * Stop the timer and invoke ->stop() callback on the HCD
+ */
+static void usb_stop_hcd(struct usb_hcd *hcd)
+{
+	if (!hcd)
+		return;
+
+	hcd->rh_pollable = 0;
+	clear_bit(HCD_FLAG_POLL_RH, &hcd->flags);
+	del_timer_sync(&hcd->rh_timer);
+
+	hcd->driver->stop(hcd);
+	hcd->state = HC_STATE_HALT;
+
+	/* In case the HCD restarted the timer, stop it again. */
+	clear_bit(HCD_FLAG_POLL_RH, &hcd->flags);
+	del_timer_sync(&hcd->rh_timer);
+}
+
 /**
  * usb_add_hcd - finish generic HCD structure initialization and register
  * @hcd: the usb_hcd structure to initialize
@@ -2946,13 +2969,7 @@ int usb_add_hcd(struct usb_hcd *hcd,
 	return retval;
 
 err_register_root_hub:
-	hcd->rh_pollable = 0;
-	clear_bit(HCD_FLAG_POLL_RH, &hcd->flags);
-	del_timer_sync(&hcd->rh_timer);
-	hcd->driver->stop(hcd);
-	hcd->state = HC_STATE_HALT;
-	clear_bit(HCD_FLAG_POLL_RH, &hcd->flags);
-	del_timer_sync(&hcd->rh_timer);
+	usb_stop_hcd(hcd);
 err_hcd_driver_start:
 	if (usb_hcd_is_primary_hcd(hcd) && hcd->irq > 0)
 		free_irq(irqnum, hcd);
@@ -3022,16 +3039,7 @@ void usb_remove_hcd(struct usb_hcd *hcd)
 	 * interrupt occurs), but usb_hcd_poll_rh_status() won't invoke
 	 * the hub_status_data() callback.
 	 */
-	hcd->rh_pollable = 0;
-	clear_bit(HCD_FLAG_POLL_RH, &hcd->flags);
-	del_timer_sync(&hcd->rh_timer);
-
-	hcd->driver->stop(hcd);
-	hcd->state = HC_STATE_HALT;
-
-	/* In case the HCD restarted the timer, stop it again. */
-	clear_bit(HCD_FLAG_POLL_RH, &hcd->flags);
-	del_timer_sync(&hcd->rh_timer);
+	usb_stop_hcd(hcd);
 
 	if (usb_hcd_is_primary_hcd(hcd)) {
 		if (hcd->irq > 0)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [RFC PATCH 2/5] usb: core: hcd: Let usb_add_hcd() indicate if roothub has to be registered
  2021-08-24 10:52 [RFC PATCH 0/5] Fix cold plugged USB device on certain PCIe USB cards Kishon Vijay Abraham I
  2021-08-24 10:52 ` [RFC PATCH 1/5] usb: core: hcd: Modularize HCD stop configuration in usb_stop_hcd() Kishon Vijay Abraham I
@ 2021-08-24 10:52 ` Kishon Vijay Abraham I
  2021-08-24 12:17   ` kernel test robot
                     ` (3 more replies)
  2021-08-24 10:53 ` [RFC PATCH 3/5] usb: core: hcd: Add support for registering secondary RH along with primary HCD Kishon Vijay Abraham I
                   ` (2 subsequent siblings)
  4 siblings, 4 replies; 17+ messages in thread
From: Kishon Vijay Abraham I @ 2021-08-24 10:52 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Mathias Nyman, Alan Stern
  Cc: linux-usb, linux-kernel, chris.chiu

No functional change. Add __usb_add_hcd() which takes "register_hub"
flag that indicates if roothub has to be registered or not. This is in
preparation for allowing xhci to register roothub after the shared hcd
is created. The interface for usb_add_hcd() is not modified to make sure
there is no USB subsystem wide changes.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
 drivers/usb/core/hcd.c  | 20 +++++++++++---------
 include/linux/usb/hcd.h |  8 ++++++--
 2 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index c036ba5311b3..4d7a9f0e2caa 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -2788,13 +2788,14 @@ static void usb_stop_hcd(struct usb_hcd *hcd)
  * @hcd: the usb_hcd structure to initialize
  * @irqnum: Interrupt line to allocate
  * @irqflags: Interrupt type flags
+ * @register_hub: Flag to indicate if roothub has to be registered.
  *
  * Finish the remaining parts of generic HCD initialization: allocate the
  * buffers of consistent memory, register the bus, request the IRQ line,
  * and call the driver's reset() and start() routines.
  */
-int usb_add_hcd(struct usb_hcd *hcd,
-		unsigned int irqnum, unsigned long irqflags)
+int __usb_add_hcd(struct usb_hcd *hcd, unsigned int irqnum, unsigned long irqflags,
+		  bool register_hub)
 {
 	int retval;
 	struct usb_device *rhdev;
@@ -2959,12 +2960,13 @@ int usb_add_hcd(struct usb_hcd *hcd,
 	}
 
 	/* starting here, usbcore will pay attention to this root hub */
-	retval = register_root_hub(hcd);
-	if (retval != 0)
-		goto err_register_root_hub;
-
-	if (hcd->uses_new_polling && HCD_POLL_RH(hcd))
-		usb_hcd_poll_rh_status(hcd);
+	if (register_hub) {
+		retval = register_root_hub(hcd);
+		if (retval != 0)
+			goto err_register_root_hub;
+		if (hcd->uses_new_polling && HCD_POLL_RH(hcd))
+			usb_hcd_poll_rh_status(hcd);
+	}
 
 	return retval;
 
@@ -2988,7 +2990,7 @@ int usb_add_hcd(struct usb_hcd *hcd,
 
 	return retval;
 }
-EXPORT_SYMBOL_GPL(usb_add_hcd);
+EXPORT_SYMBOL_GPL(__usb_add_hcd);
 
 /**
  * usb_remove_hcd - shutdown processing for generic HCDs
diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
index 548a028f2dab..2c99cfe20531 100644
--- a/include/linux/usb/hcd.h
+++ b/include/linux/usb/hcd.h
@@ -468,8 +468,8 @@ extern struct usb_hcd *usb_create_shared_hcd(const struct hc_driver *driver,
 extern struct usb_hcd *usb_get_hcd(struct usb_hcd *hcd);
 extern void usb_put_hcd(struct usb_hcd *hcd);
 extern int usb_hcd_is_primary_hcd(struct usb_hcd *hcd);
-extern int usb_add_hcd(struct usb_hcd *hcd,
-		unsigned int irqnum, unsigned long irqflags);
+extern int __usb_add_hcd(struct usb_hcd *hcd, unsigned int irqnum, unsigned long irqflags,
+			 bool register_hub);
 extern void usb_remove_hcd(struct usb_hcd *hcd);
 extern int usb_hcd_find_raw_port_number(struct usb_hcd *hcd, int port1);
 int usb_hcd_setup_local_mem(struct usb_hcd *hcd, phys_addr_t phys_addr,
@@ -477,6 +477,10 @@ int usb_hcd_setup_local_mem(struct usb_hcd *hcd, phys_addr_t phys_addr,
 
 struct platform_device;
 extern void usb_hcd_platform_shutdown(struct platform_device *dev);
+
+#define usb_add_hcd(hcd, irqnum, irqflags) \
+	__usb_add_hcd(hcd, irqnum, irqflags, true)
+
 #ifdef CONFIG_USB_HCD_TEST_MODE
 extern int ehset_single_step_set_feature(struct usb_hcd *hcd, int port);
 #else
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [RFC PATCH 3/5] usb: core: hcd: Add support for registering secondary RH along with primary HCD
  2021-08-24 10:52 [RFC PATCH 0/5] Fix cold plugged USB device on certain PCIe USB cards Kishon Vijay Abraham I
  2021-08-24 10:52 ` [RFC PATCH 1/5] usb: core: hcd: Modularize HCD stop configuration in usb_stop_hcd() Kishon Vijay Abraham I
  2021-08-24 10:52 ` [RFC PATCH 2/5] usb: core: hcd: Let usb_add_hcd() indicate if roothub has to be registered Kishon Vijay Abraham I
@ 2021-08-24 10:53 ` Kishon Vijay Abraham I
  2021-08-24 11:55   ` Mathias Nyman
  2021-08-24 10:53 ` [RFC PATCH 4/5] usb: core: hcd-pci: Let usb_hcd_pci_probe() indicate if RH has to be registered Kishon Vijay Abraham I
  2021-08-24 10:53 ` [RFC PATCH 5/5] xhci-pci: Use flag to not register roothub while adding primary HCD Kishon Vijay Abraham I
  4 siblings, 1 reply; 17+ messages in thread
From: Kishon Vijay Abraham I @ 2021-08-24 10:53 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Mathias Nyman, Alan Stern
  Cc: linux-usb, linux-kernel, chris.chiu

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 --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);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [RFC PATCH 4/5] usb: core: hcd-pci: Let usb_hcd_pci_probe() indicate if RH has to be registered
  2021-08-24 10:52 [RFC PATCH 0/5] Fix cold plugged USB device on certain PCIe USB cards Kishon Vijay Abraham I
                   ` (2 preceding siblings ...)
  2021-08-24 10:53 ` [RFC PATCH 3/5] usb: core: hcd: Add support for registering secondary RH along with primary HCD Kishon Vijay Abraham I
@ 2021-08-24 10:53 ` Kishon Vijay Abraham I
  2021-08-24 13:09   ` Greg Kroah-Hartman
                     ` (2 more replies)
  2021-08-24 10:53 ` [RFC PATCH 5/5] xhci-pci: Use flag to not register roothub while adding primary HCD Kishon Vijay Abraham I
  4 siblings, 3 replies; 17+ messages in thread
From: Kishon Vijay Abraham I @ 2021-08-24 10:53 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Mathias Nyman, Alan Stern
  Cc: linux-usb, linux-kernel, chris.chiu

No functional change. Add __usb_hcd_pci_probe() which takes "register_hub"
flag that indicates if roothub (RH) has to be registered or not. This is in
preparation for allowing xhci-pci to register roothub after the shared hcd
is created. The interface for usb_hcd_pci_probe() is not modified to make
sure there are minimal code changes.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
 drivers/usb/core/hcd-pci.c | 11 ++++++-----
 include/linux/usb/hcd.h    |  8 +++++---
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c
index d630cccd2e6e..65c1f9aee4d1 100644
--- a/drivers/usb/core/hcd-pci.c
+++ b/drivers/usb/core/hcd-pci.c
@@ -160,6 +160,7 @@ static void ehci_wait_for_companions(struct pci_dev *pdev, struct usb_hcd *hcd,
  * @dev: USB Host Controller being probed
  * @id: pci hotplug id connecting controller to HCD framework
  * @driver: USB HC driver handle
+ * @register_hub: Flag to indicate of roothub has to be registered or not
  *
  * Context: task context, might sleep
  *
@@ -171,8 +172,8 @@ static void ehci_wait_for_companions(struct pci_dev *pdev, struct usb_hcd *hcd,
  *
  * Return: 0 if successful.
  */
-int usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id,
-		      const struct hc_driver *driver)
+int __usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id,
+			const struct hc_driver *driver, bool register_hub)
 {
 	struct usb_hcd		*hcd;
 	int			retval;
@@ -262,7 +263,7 @@ int usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id,
 		down_write(&companions_rwsem);
 		dev_set_drvdata(&dev->dev, hcd);
 		for_each_companion(dev, hcd, ehci_pre_add);
-		retval = usb_add_hcd(hcd, hcd_irq, IRQF_SHARED);
+		retval = __usb_add_hcd(hcd, hcd_irq, IRQF_SHARED, register_hub);
 		if (retval != 0)
 			dev_set_drvdata(&dev->dev, NULL);
 		for_each_companion(dev, hcd, ehci_post_add);
@@ -270,7 +271,7 @@ int usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id,
 	} else {
 		down_read(&companions_rwsem);
 		dev_set_drvdata(&dev->dev, hcd);
-		retval = usb_add_hcd(hcd, hcd_irq, IRQF_SHARED);
+		retval = __usb_add_hcd(hcd, hcd_irq, IRQF_SHARED, register_hub);
 		if (retval != 0)
 			dev_set_drvdata(&dev->dev, NULL);
 		else
@@ -296,7 +297,7 @@ int usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id,
 	dev_err(&dev->dev, "init %s fail, %d\n", pci_name(dev), retval);
 	return retval;
 }
-EXPORT_SYMBOL_GPL(usb_hcd_pci_probe);
+EXPORT_SYMBOL_GPL(__usb_hcd_pci_probe);
 
 
 /* may be called without controller electrically present */
diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
index 2c99cfe20531..49c1a8d56b2c 100644
--- a/include/linux/usb/hcd.h
+++ b/include/linux/usb/hcd.h
@@ -493,14 +493,16 @@ static inline int ehset_single_step_set_feature(struct usb_hcd *hcd, int port)
 #ifdef CONFIG_USB_PCI
 struct pci_dev;
 struct pci_device_id;
-extern int usb_hcd_pci_probe(struct pci_dev *dev,
-			     const struct pci_device_id *id,
-			     const struct hc_driver *driver);
+extern int __usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id,
+			       const struct hc_driver *driver, bool register_hub);
 extern void usb_hcd_pci_remove(struct pci_dev *dev);
 extern void usb_hcd_pci_shutdown(struct pci_dev *dev);
 
 extern int usb_hcd_amd_remote_wakeup_quirk(struct pci_dev *dev);
 
+#define usb_hcd_pci_probe(dev, id, driver) \
+	__usb_hcd_pci_probe(dev, id, driver, true)
+
 #ifdef CONFIG_PM
 extern const struct dev_pm_ops usb_hcd_pci_pm_ops;
 #endif
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [RFC PATCH 5/5] xhci-pci: Use flag to not register roothub while adding primary HCD
  2021-08-24 10:52 [RFC PATCH 0/5] Fix cold plugged USB device on certain PCIe USB cards Kishon Vijay Abraham I
                   ` (3 preceding siblings ...)
  2021-08-24 10:53 ` [RFC PATCH 4/5] usb: core: hcd-pci: Let usb_hcd_pci_probe() indicate if RH has to be registered Kishon Vijay Abraham I
@ 2021-08-24 10:53 ` Kishon Vijay Abraham I
  4 siblings, 0 replies; 17+ messages in thread
From: Kishon Vijay Abraham I @ 2021-08-24 10:53 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Mathias Nyman, Alan Stern
  Cc: linux-usb, linux-kernel, chris.chiu

Invoke __usb_hcd_pci_probe() without setting "register_hub" so that
primary roothub is not registered here. Instead it will be registered
along with secondary roothub. This is required for cold plugged USB
devices to be detected in certain PCIe USB cards (like Inateck USB
card).

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
 drivers/usb/host/xhci-pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index 1c9a7957c45c..7734ff13aea9 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -397,7 +397,7 @@ static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
 	 * to say USB 2.0, but I'm not sure what the implications would be in
 	 * the other parts of the HCD code.
 	 */
-	retval = usb_hcd_pci_probe(dev, id, &xhci_pci_hc_driver);
+	retval = __usb_hcd_pci_probe(dev, id, &xhci_pci_hc_driver, 0);
 
 	if (retval)
 		goto put_runtime_pm;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [RFC PATCH 3/5] usb: core: hcd: Add support for registering secondary RH along with primary HCD
  2021-08-24 10:53 ` [RFC PATCH 3/5] usb: core: hcd: Add support for registering secondary RH along with primary HCD Kishon Vijay Abraham I
@ 2021-08-24 11:55   ` Mathias Nyman
  0 siblings, 0 replies; 17+ messages in thread
From: Mathias Nyman @ 2021-08-24 11:55 UTC (permalink / raw)
  To: Kishon Vijay Abraham I, Greg Kroah-Hartman, Mathias Nyman, Alan Stern
  Cc: linux-usb, linux-kernel, chris.chiu

On 24.8.2021 13.53, Kishon Vijay Abraham I wrote:
> 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 --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);

There is a possibility we try yo register the shared roothub before it is properly set up here.

For example the mediatek driver (xhci-mtk.c) creates both hcds before adding them,
so hcd->shared_hcd exists when usb_add_hcd() is called for the primary hcd,
causing this code to register the hcd->shared_hcd roothub which is not properly added yet.

How about skipping the new __usb_hcd_pci_probe() and __usb_add_hcd() and instead add a new
flag to hcd->flags, something like HCD_FLAG_DEFER_PRI_RH_REGISTER?

The host controller driver can set this flag in the hcd->driver->start(hcd) callback called
before roothub registration here from usb_add_hcd(). If flag is set we skip the roothub registration.

So something like:
shared_hcd = hcd->share_hcd;

if (!usb_hcd_is_primary_hcd(hcd) && shared_hcd && shared_hcd->flags & HCD_FLAG_DEFER_PRI_RH_REGISTER)
        register_root_hub(shared_hcd)
if (!(hcd->flags & HCD_FLAG_DEFER_PRI_RH_REGISTER))
        register_root_hub(hcd)

-Mathias 

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [RFC PATCH 2/5] usb: core: hcd: Let usb_add_hcd() indicate if roothub has to be registered
  2021-08-24 10:52 ` [RFC PATCH 2/5] usb: core: hcd: Let usb_add_hcd() indicate if roothub has to be registered Kishon Vijay Abraham I
@ 2021-08-24 12:17   ` kernel test robot
  2021-08-24 13:08   ` Greg Kroah-Hartman
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 17+ messages in thread
From: kernel test robot @ 2021-08-24 12:17 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 20237 bytes --]

Hi Kishon,

[FYI, it's a private test report for your RFC patch.]
[auto build test WARNING on usb/usb-testing]
[also build test WARNING on v5.14-rc7 next-20210824]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Kishon-Vijay-Abraham-I/Fix-cold-plugged-USB-device-on-certain-PCIe-USB-cards/20210824-185502
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
config: powerpc-akebono_defconfig (attached as .config)
compiler: powerpc-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/fe4b8457078ee059441628dfa331b8e3e145e335
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Kishon-Vijay-Abraham-I/Fix-cold-plugged-USB-device-on-certain-PCIe-USB-cards/20210824-185502
        git checkout fe4b8457078ee059441628dfa331b8e3e145e335
        # save the attached .config to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=powerpc SHELL=/bin/bash drivers/usb/core/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> drivers/usb/core/hcd.c:2799: warning: expecting prototype for usb_add_hcd(). Prototype was for __usb_add_hcd() instead


vim +2799 drivers/usb/core/hcd.c

c8195df4a79699 Kishon Vijay Abraham I    2021-08-24  2785  
^1da177e4c3f41 Linus Torvalds            2005-04-16  2786  /**
^1da177e4c3f41 Linus Torvalds            2005-04-16  2787   * usb_add_hcd - finish generic HCD structure initialization and register
^1da177e4c3f41 Linus Torvalds            2005-04-16  2788   * @hcd: the usb_hcd structure to initialize
^1da177e4c3f41 Linus Torvalds            2005-04-16  2789   * @irqnum: Interrupt line to allocate
^1da177e4c3f41 Linus Torvalds            2005-04-16  2790   * @irqflags: Interrupt type flags
fe4b8457078ee0 Kishon Vijay Abraham I    2021-08-24  2791   * @register_hub: Flag to indicate if roothub has to be registered.
^1da177e4c3f41 Linus Torvalds            2005-04-16  2792   *
^1da177e4c3f41 Linus Torvalds            2005-04-16  2793   * Finish the remaining parts of generic HCD initialization: allocate the
^1da177e4c3f41 Linus Torvalds            2005-04-16  2794   * buffers of consistent memory, register the bus, request the IRQ line,
^1da177e4c3f41 Linus Torvalds            2005-04-16  2795   * and call the driver's reset() and start() routines.
^1da177e4c3f41 Linus Torvalds            2005-04-16  2796   */
fe4b8457078ee0 Kishon Vijay Abraham I    2021-08-24  2797  int __usb_add_hcd(struct usb_hcd *hcd, unsigned int irqnum, unsigned long irqflags,
fe4b8457078ee0 Kishon Vijay Abraham I    2021-08-24  2798  		  bool register_hub)
^1da177e4c3f41 Linus Torvalds            2005-04-16 @2799  {
^1da177e4c3f41 Linus Torvalds            2005-04-16  2800  	int retval;
8ec8d20b21f00a Alan Stern                2005-04-25  2801  	struct usb_device *rhdev;
^1da177e4c3f41 Linus Torvalds            2005-04-16  2802  
29bca25e1bc474 Chunfeng Yun              2018-03-22  2803  	if (!hcd->skip_phy_initialization && usb_hcd_is_primary_hcd(hcd)) {
63cb03f5c11eef Martin Blumenstingl       2018-04-18  2804  		hcd->phy_roothub = usb_phy_roothub_alloc(hcd->self.sysdev);
bc40f53417410b Johan Hovold              2018-04-18  2805  		if (IS_ERR(hcd->phy_roothub))
bc40f53417410b Johan Hovold              2018-04-18  2806  			return PTR_ERR(hcd->phy_roothub);
178a0bce05cbc1 Martin Blumenstingl       2018-03-03  2807  
63cb03f5c11eef Martin Blumenstingl       2018-04-18  2808  		retval = usb_phy_roothub_init(hcd->phy_roothub);
63cb03f5c11eef Martin Blumenstingl       2018-04-18  2809  		if (retval)
890fa45d01eb89 Greg Kroah-Hartman        2018-04-30  2810  			return retval;
63cb03f5c11eef Martin Blumenstingl       2018-04-18  2811  
b97a31348379f7 Miquel Raynal             2019-01-29  2812  		retval = usb_phy_roothub_set_mode(hcd->phy_roothub,
b97a31348379f7 Miquel Raynal             2019-01-29  2813  						  PHY_MODE_USB_HOST_SS);
e671765e521c57 Chen-Yu Tsai              2019-03-22  2814  		if (retval)
e671765e521c57 Chen-Yu Tsai              2019-03-22  2815  			retval = usb_phy_roothub_set_mode(hcd->phy_roothub,
e671765e521c57 Chen-Yu Tsai              2019-03-22  2816  							  PHY_MODE_USB_HOST);
b97a31348379f7 Miquel Raynal             2019-01-29  2817  		if (retval)
b97a31348379f7 Miquel Raynal             2019-01-29  2818  			goto err_usb_phy_roothub_power_on;
b97a31348379f7 Miquel Raynal             2019-01-29  2819  
178a0bce05cbc1 Martin Blumenstingl       2018-03-03  2820  		retval = usb_phy_roothub_power_on(hcd->phy_roothub);
178a0bce05cbc1 Martin Blumenstingl       2018-03-03  2821  		if (retval)
178a0bce05cbc1 Martin Blumenstingl       2018-03-03  2822  			goto err_usb_phy_roothub_power_on;
178a0bce05cbc1 Martin Blumenstingl       2018-03-03  2823  	}
178a0bce05cbc1 Martin Blumenstingl       2018-03-03  2824  
^1da177e4c3f41 Linus Torvalds            2005-04-16  2825  	dev_info(hcd->self.controller, "%s\n", hcd->product_desc);
^1da177e4c3f41 Linus Torvalds            2005-04-16  2826  
7bae0432a64aa7 Dmitry Torokhov           2019-02-16  2827  	switch (authorized_default) {
7bae0432a64aa7 Dmitry Torokhov           2019-02-16  2828  	case USB_AUTHORIZE_NONE:
7bae0432a64aa7 Dmitry Torokhov           2019-02-16  2829  		hcd->dev_policy = USB_DEVICE_AUTHORIZE_NONE;
7bae0432a64aa7 Dmitry Torokhov           2019-02-16  2830  		break;
7bae0432a64aa7 Dmitry Torokhov           2019-02-16  2831  
7bae0432a64aa7 Dmitry Torokhov           2019-02-16  2832  	case USB_AUTHORIZE_ALL:
7bae0432a64aa7 Dmitry Torokhov           2019-02-16  2833  		hcd->dev_policy = USB_DEVICE_AUTHORIZE_ALL;
7bae0432a64aa7 Dmitry Torokhov           2019-02-16  2834  		break;
7bae0432a64aa7 Dmitry Torokhov           2019-02-16  2835  
7bae0432a64aa7 Dmitry Torokhov           2019-02-16  2836  	case USB_AUTHORIZE_INTERNAL:
7bae0432a64aa7 Dmitry Torokhov           2019-02-16  2837  		hcd->dev_policy = USB_DEVICE_AUTHORIZE_INTERNAL;
7bae0432a64aa7 Dmitry Torokhov           2019-02-16  2838  		break;
7bae0432a64aa7 Dmitry Torokhov           2019-02-16  2839  
7bae0432a64aa7 Dmitry Torokhov           2019-02-16  2840  	case USB_AUTHORIZE_WIRED:
7bae0432a64aa7 Dmitry Torokhov           2019-02-16  2841  	default:
7bae0432a64aa7 Dmitry Torokhov           2019-02-16  2842  		hcd->dev_policy = hcd->wireless ?
7bae0432a64aa7 Dmitry Torokhov           2019-02-16  2843  			USB_DEVICE_AUTHORIZE_NONE : USB_DEVICE_AUTHORIZE_ALL;
7bae0432a64aa7 Dmitry Torokhov           2019-02-16  2844  		break;
ff8e2c560eca32 Stefan Koch               2015-08-25  2845  	}
7bae0432a64aa7 Dmitry Torokhov           2019-02-16  2846  
8de98402652c01 Benjamin Herrenschmidt    2005-11-25  2847  	set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
8de98402652c01 Benjamin Herrenschmidt    2005-11-25  2848  
6b2bd3c8c69c48 Stefan Koch               2015-08-25  2849  	/* per default all interfaces are authorized */
6b2bd3c8c69c48 Stefan Koch               2015-08-25  2850  	set_bit(HCD_FLAG_INTF_AUTHORIZED, &hcd->flags);
6b2bd3c8c69c48 Stefan Koch               2015-08-25  2851  
b1e8f0a6a8805c David Brownell            2006-01-23  2852  	/* HC is in reset state, but accessible.  Now do the one-time init,
37ebb54915dc42 Petr Mladek               2014-09-19  2853  	 * bottom up so that hcds can customize the root hubs before hub_wq
b1e8f0a6a8805c David Brownell            2006-01-23  2854  	 * starts talking to them.  (Note, bus id is assigned early too.)
b1e8f0a6a8805c David Brownell            2006-01-23  2855  	 */
0faaad461547e2 Kris Borer                2015-07-14  2856  	retval = hcd_buffer_create(hcd);
0faaad461547e2 Kris Borer                2015-07-14  2857  	if (retval != 0) {
a8c06e407ef969 Arnd Bergmann             2017-03-13  2858  		dev_dbg(hcd->self.sysdev, "pool alloc failed\n");
00433254952221 Sergei Shtylyov           2014-09-24  2859  		goto err_create_buf;
^1da177e4c3f41 Linus Torvalds            2005-04-16  2860  	}
^1da177e4c3f41 Linus Torvalds            2005-04-16  2861  
0faaad461547e2 Kris Borer                2015-07-14  2862  	retval = usb_register_bus(&hcd->self);
0faaad461547e2 Kris Borer                2015-07-14  2863  	if (retval < 0)
8ec8d20b21f00a Alan Stern                2005-04-25  2864  		goto err_register_bus;
^1da177e4c3f41 Linus Torvalds            2005-04-16  2865  
c688d6211f57e1 Greg Kroah-Hartman        2015-04-30  2866  	rhdev = usb_alloc_dev(NULL, &hcd->self, 0);
c688d6211f57e1 Greg Kroah-Hartman        2015-04-30  2867  	if (rhdev == NULL) {
a8c06e407ef969 Arnd Bergmann             2017-03-13  2868  		dev_err(hcd->self.sysdev, "unable to allocate root hub\n");
b1e8f0a6a8805c David Brownell            2006-01-23  2869  		retval = -ENOMEM;
b1e8f0a6a8805c David Brownell            2006-01-23  2870  		goto err_allocate_root_hub;
b1e8f0a6a8805c David Brownell            2006-01-23  2871  	}
d8521afe35862f Dan Williams              2014-05-20  2872  	mutex_lock(&usb_port_peer_mutex);
6d88e679257449 Alan Stern                2010-06-09  2873  	hcd->self.root_hub = rhdev;
d8521afe35862f Dan Williams              2014-05-20  2874  	mutex_unlock(&usb_port_peer_mutex);
6b403b020c1f42 Sarah Sharp               2009-04-27  2875  
a2d49572e11ef5 Mathias Nyman             2018-04-19  2876  	rhdev->rx_lanes = 1;
a2d49572e11ef5 Mathias Nyman             2018-04-19  2877  	rhdev->tx_lanes = 1;
0299809be41556 Thinh Nguyen              2021-03-10  2878  	rhdev->ssp_rate = USB_SSP_GEN_UNKNOWN;
a2d49572e11ef5 Mathias Nyman             2018-04-19  2879  
83de4b2b90887b Sarah Sharp               2010-12-02  2880  	switch (hcd->speed) {
6b403b020c1f42 Sarah Sharp               2009-04-27  2881  	case HCD_USB11:
6b403b020c1f42 Sarah Sharp               2009-04-27  2882  		rhdev->speed = USB_SPEED_FULL;
6b403b020c1f42 Sarah Sharp               2009-04-27  2883  		break;
6b403b020c1f42 Sarah Sharp               2009-04-27  2884  	case HCD_USB2:
6b403b020c1f42 Sarah Sharp               2009-04-27  2885  		rhdev->speed = USB_SPEED_HIGH;
6b403b020c1f42 Sarah Sharp               2009-04-27  2886  		break;
1a81f8814cbc79 Thomas Pugliese           2013-05-31  2887  	case HCD_USB25:
1a81f8814cbc79 Thomas Pugliese           2013-05-31  2888  		rhdev->speed = USB_SPEED_WIRELESS;
1a81f8814cbc79 Thomas Pugliese           2013-05-31  2889  		break;
6b403b020c1f42 Sarah Sharp               2009-04-27  2890  	case HCD_USB3:
6b403b020c1f42 Sarah Sharp               2009-04-27  2891  		rhdev->speed = USB_SPEED_SUPER;
6b403b020c1f42 Sarah Sharp               2009-04-27  2892  		break;
ffe95371d2a84f Mathias Nyman             2018-04-19  2893  	case HCD_USB32:
a2d49572e11ef5 Mathias Nyman             2018-04-19  2894  		rhdev->rx_lanes = 2;
a2d49572e11ef5 Mathias Nyman             2018-04-19  2895  		rhdev->tx_lanes = 2;
0299809be41556 Thinh Nguyen              2021-03-10  2896  		rhdev->ssp_rate = USB_SSP_GEN_2x2;
0299809be41556 Thinh Nguyen              2021-03-10  2897  		rhdev->speed = USB_SPEED_SUPER_PLUS;
0299809be41556 Thinh Nguyen              2021-03-10  2898  		break;
5f9c3a668b3f75 Mathias Nyman             2015-12-10  2899  	case HCD_USB31:
0299809be41556 Thinh Nguyen              2021-03-10  2900  		rhdev->ssp_rate = USB_SSP_GEN_2x1;
5f9c3a668b3f75 Mathias Nyman             2015-12-10  2901  		rhdev->speed = USB_SPEED_SUPER_PLUS;
5f9c3a668b3f75 Mathias Nyman             2015-12-10  2902  		break;
6b403b020c1f42 Sarah Sharp               2009-04-27  2903  	default:
1d15ee4cd7c9dd Sebastian Andrzej Siewior 2011-04-14  2904  		retval = -EINVAL;
96e077ae347912 Alan Stern                2010-06-09  2905  		goto err_set_rh_speed;
6b403b020c1f42 Sarah Sharp               2009-04-27  2906  	}
b1e8f0a6a8805c David Brownell            2006-01-23  2907  
db4cefaaea4c6d David Brownell            2006-05-01  2908  	/* wakeup flag init defaults to "everything works" for root hubs,
db4cefaaea4c6d David Brownell            2006-05-01  2909  	 * but drivers can override it in reset() if needed, along with
db4cefaaea4c6d David Brownell            2006-05-01  2910  	 * recording the overall controller's system wakeup capability.
db4cefaaea4c6d David Brownell            2006-05-01  2911  	 */
a6eeeb9f45b5a4 Alan Stern                2011-09-26  2912  	device_set_wakeup_capable(&rhdev->dev, 1);
db4cefaaea4c6d David Brownell            2006-05-01  2913  
9b37596a2e8604 Alan Stern                2011-03-07  2914  	/* HCD_FLAG_RH_RUNNING doesn't matter until the root hub is
9b37596a2e8604 Alan Stern                2011-03-07  2915  	 * registered.  But since the controller can die at any time,
9b37596a2e8604 Alan Stern                2011-03-07  2916  	 * let's initialize the flag before touching the hardware.
9b37596a2e8604 Alan Stern                2011-03-07  2917  	 */
9b37596a2e8604 Alan Stern                2011-03-07  2918  	set_bit(HCD_FLAG_RH_RUNNING, &hcd->flags);
9b37596a2e8604 Alan Stern                2011-03-07  2919  
b1e8f0a6a8805c David Brownell            2006-01-23  2920  	/* "reset" is misnamed; its role is now one-time init. the controller
b1e8f0a6a8805c David Brownell            2006-01-23  2921  	 * should already have been reset (and boot firmware kicked off etc).
b1e8f0a6a8805c David Brownell            2006-01-23  2922  	 */
0faaad461547e2 Kris Borer                2015-07-14  2923  	if (hcd->driver->reset) {
0faaad461547e2 Kris Borer                2015-07-14  2924  		retval = hcd->driver->reset(hcd);
0faaad461547e2 Kris Borer                2015-07-14  2925  		if (retval < 0) {
0faaad461547e2 Kris Borer                2015-07-14  2926  			dev_err(hcd->self.controller, "can't setup: %d\n",
0faaad461547e2 Kris Borer                2015-07-14  2927  					retval);
b1e8f0a6a8805c David Brownell            2006-01-23  2928  			goto err_hcd_driver_setup;
b1e8f0a6a8805c David Brownell            2006-01-23  2929  		}
0faaad461547e2 Kris Borer                2015-07-14  2930  	}
6d88e679257449 Alan Stern                2010-06-09  2931  	hcd->rh_pollable = 1;
b1e8f0a6a8805c David Brownell            2006-01-23  2932  
34c7ed72f4f04e Marek Szyprowski          2019-08-29  2933  	retval = usb_phy_roothub_calibrate(hcd->phy_roothub);
34c7ed72f4f04e Marek Szyprowski          2019-08-29  2934  	if (retval)
34c7ed72f4f04e Marek Szyprowski          2019-08-29  2935  		goto err_hcd_driver_setup;
34c7ed72f4f04e Marek Szyprowski          2019-08-29  2936  
fb669cc01ed778 David Brownell            2006-01-24  2937  	/* NOTE: root hub and controller capabilities may not be the same */
fb669cc01ed778 David Brownell            2006-01-24  2938  	if (device_can_wakeup(hcd->self.controller)
fb669cc01ed778 David Brownell            2006-01-24  2939  			&& device_can_wakeup(&hcd->self.root_hub->dev))
b1e8f0a6a8805c David Brownell            2006-01-23  2940  		dev_dbg(hcd->self.controller, "supports USB remote wakeup\n");
b1e8f0a6a8805c David Brownell            2006-01-23  2941  
94dfd7edfd5c9b Ming Lei                  2013-07-03  2942  	/* initialize tasklets */
94dfd7edfd5c9b Ming Lei                  2013-07-03  2943  	init_giveback_urb_bh(&hcd->high_prio_bh);
94dfd7edfd5c9b Ming Lei                  2013-07-03  2944  	init_giveback_urb_bh(&hcd->low_prio_bh);
94dfd7edfd5c9b Ming Lei                  2013-07-03  2945  
68d07f64b8a11a Sarah Sharp               2012-02-13  2946  	/* enable irqs just before we start the controller,
68d07f64b8a11a Sarah Sharp               2012-02-13  2947  	 * if the BIOS provides legacy PCI irqs.
68d07f64b8a11a Sarah Sharp               2012-02-13  2948  	 */
68d07f64b8a11a Sarah Sharp               2012-02-13  2949  	if (usb_hcd_is_primary_hcd(hcd) && irqnum) {
23e0d1066f429a Sarah Sharp               2010-10-21  2950  		retval = usb_hcd_request_irqs(hcd, irqnum, irqflags);
23e0d1066f429a Sarah Sharp               2010-10-21  2951  		if (retval)
8ec8d20b21f00a Alan Stern                2005-04-25  2952  			goto err_request_irq;
c56354378426e5 Sarah Sharp               2010-10-28  2953  	}
^1da177e4c3f41 Linus Torvalds            2005-04-16  2954  
4814030ce11f08 Sarah Sharp               2011-03-11  2955  	hcd->state = HC_STATE_RUNNING;
abc4f9b099e9e7 Sarah Sharp               2010-12-01  2956  	retval = hcd->driver->start(hcd);
abc4f9b099e9e7 Sarah Sharp               2010-12-01  2957  	if (retval < 0) {
^1da177e4c3f41 Linus Torvalds            2005-04-16  2958  		dev_err(hcd->self.controller, "startup error %d\n", retval);
8ec8d20b21f00a Alan Stern                2005-04-25  2959  		goto err_hcd_driver_start;
^1da177e4c3f41 Linus Torvalds            2005-04-16  2960  	}
^1da177e4c3f41 Linus Torvalds            2005-04-16  2961  
b1e8f0a6a8805c David Brownell            2006-01-23  2962  	/* starting here, usbcore will pay attention to this root hub */
fe4b8457078ee0 Kishon Vijay Abraham I    2021-08-24  2963  	if (register_hub) {
0faaad461547e2 Kris Borer                2015-07-14  2964  		retval = register_root_hub(hcd);
0faaad461547e2 Kris Borer                2015-07-14  2965  		if (retval != 0)
8ec8d20b21f00a Alan Stern                2005-04-25  2966  			goto err_register_root_hub;
541c7d432f7677 Alan Stern                2010-06-22  2967  		if (hcd->uses_new_polling && HCD_POLL_RH(hcd))
d5926ae7a827bd Alan Stern                2005-04-21  2968  			usb_hcd_poll_rh_status(hcd);
fe4b8457078ee0 Kishon Vijay Abraham I    2021-08-24  2969  	}
a6eeeb9f45b5a4 Alan Stern                2011-09-26  2970  
^1da177e4c3f41 Linus Torvalds            2005-04-16  2971  	return retval;
^1da177e4c3f41 Linus Torvalds            2005-04-16  2972  
8ec8d20b21f00a Alan Stern                2005-04-25  2973  err_register_root_hub:
c8195df4a79699 Kishon Vijay Abraham I    2021-08-24  2974  	usb_stop_hcd(hcd);
8ec8d20b21f00a Alan Stern                2005-04-25  2975  err_hcd_driver_start:
cd70469d084fde Felipe Balbi              2012-02-29  2976  	if (usb_hcd_is_primary_hcd(hcd) && hcd->irq > 0)
^1da177e4c3f41 Linus Torvalds            2005-04-16  2977  		free_irq(irqnum, hcd);
8ec8d20b21f00a Alan Stern                2005-04-25  2978  err_request_irq:
b1e8f0a6a8805c David Brownell            2006-01-23  2979  err_hcd_driver_setup:
96e077ae347912 Alan Stern                2010-06-09  2980  err_set_rh_speed:
d8521afe35862f Dan Williams              2014-05-20  2981  	usb_put_invalidate_rhdev(hcd);
b1e8f0a6a8805c David Brownell            2006-01-23  2982  err_allocate_root_hub:
^1da177e4c3f41 Linus Torvalds            2005-04-16  2983  	usb_deregister_bus(&hcd->self);
8ec8d20b21f00a Alan Stern                2005-04-25  2984  err_register_bus:
^1da177e4c3f41 Linus Torvalds            2005-04-16  2985  	hcd_buffer_destroy(hcd);
00433254952221 Sergei Shtylyov           2014-09-24  2986  err_create_buf:
178a0bce05cbc1 Martin Blumenstingl       2018-03-03  2987  	usb_phy_roothub_power_off(hcd->phy_roothub);
178a0bce05cbc1 Martin Blumenstingl       2018-03-03  2988  err_usb_phy_roothub_power_on:
178a0bce05cbc1 Martin Blumenstingl       2018-03-03  2989  	usb_phy_roothub_exit(hcd->phy_roothub);
bc40f53417410b Johan Hovold              2018-04-18  2990  
^1da177e4c3f41 Linus Torvalds            2005-04-16  2991  	return retval;
^1da177e4c3f41 Linus Torvalds            2005-04-16  2992  }
fe4b8457078ee0 Kishon Vijay Abraham I    2021-08-24  2993  EXPORT_SYMBOL_GPL(__usb_add_hcd);
^1da177e4c3f41 Linus Torvalds            2005-04-16  2994  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 17763 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [RFC PATCH 1/5] usb: core: hcd: Modularize HCD stop configuration in usb_stop_hcd()
  2021-08-24 10:52 ` [RFC PATCH 1/5] usb: core: hcd: Modularize HCD stop configuration in usb_stop_hcd() Kishon Vijay Abraham I
@ 2021-08-24 13:06   ` Greg Kroah-Hartman
  2021-08-24 15:18     ` Kishon Vijay Abraham I
  0 siblings, 1 reply; 17+ messages in thread
From: Greg Kroah-Hartman @ 2021-08-24 13:06 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: Mathias Nyman, Alan Stern, linux-usb, linux-kernel, chris.chiu

On Tue, Aug 24, 2021 at 04:22:58PM +0530, Kishon Vijay Abraham I wrote:
> No functional change. Since configuration to stop HCD is invoked from
> multiple places, group all of them in usb_stop_hcd().
> 
> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
> ---
>  drivers/usb/core/hcd.c | 42 +++++++++++++++++++++++++-----------------
>  1 file changed, 25 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
> index 0f8b7c93310e..c036ba5311b3 100644
> --- a/drivers/usb/core/hcd.c
> +++ b/drivers/usb/core/hcd.c
> @@ -2760,6 +2760,29 @@ static void usb_put_invalidate_rhdev(struct usb_hcd *hcd)
>  	usb_put_dev(rhdev);
>  }
>  
> +/**
> + * usb_stop_hcd - Halt the HCD
> + * @hcd: the usb_hcd that has to be halted
> + *
> + * Stop the timer and invoke ->stop() callback on the HCD
> + */
> +static void usb_stop_hcd(struct usb_hcd *hcd)
> +{
> +	if (!hcd)
> +		return;

That's impossible to hit, so no need to check for it, right?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [RFC PATCH 2/5] usb: core: hcd: Let usb_add_hcd() indicate if roothub has to be registered
  2021-08-24 10:52 ` [RFC PATCH 2/5] usb: core: hcd: Let usb_add_hcd() indicate if roothub has to be registered Kishon Vijay Abraham I
  2021-08-24 12:17   ` kernel test robot
@ 2021-08-24 13:08   ` Greg Kroah-Hartman
  2021-08-24 13:37   ` kernel test robot
  2021-08-24 14:56   ` Alan Stern
  3 siblings, 0 replies; 17+ messages in thread
From: Greg Kroah-Hartman @ 2021-08-24 13:08 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: Mathias Nyman, Alan Stern, linux-usb, linux-kernel, chris.chiu

On Tue, Aug 24, 2021 at 04:22:59PM +0530, Kishon Vijay Abraham I wrote:
> No functional change. Add __usb_add_hcd() which takes "register_hub"
> flag that indicates if roothub has to be registered or not. This is in

"flags" like this are horrid, never do that, except at a local static
function level that might make code easier.

For this, make a usb_hcd_add_and_register() function, so that you know
instantly when seeing it be called, as to what it does.  Otherwise you
have to go look up a random boolean value and that's impossible to
remember over time.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [RFC PATCH 4/5] usb: core: hcd-pci: Let usb_hcd_pci_probe() indicate if RH has to be registered
  2021-08-24 10:53 ` [RFC PATCH 4/5] usb: core: hcd-pci: Let usb_hcd_pci_probe() indicate if RH has to be registered Kishon Vijay Abraham I
@ 2021-08-24 13:09   ` Greg Kroah-Hartman
  2021-08-24 13:34   ` kernel test robot
  2021-08-24 13:55   ` kernel test robot
  2 siblings, 0 replies; 17+ messages in thread
From: Greg Kroah-Hartman @ 2021-08-24 13:09 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: Mathias Nyman, Alan Stern, linux-usb, linux-kernel, chris.chiu

On Tue, Aug 24, 2021 at 04:23:01PM +0530, Kishon Vijay Abraham I wrote:
> No functional change. Add __usb_hcd_pci_probe() which takes "register_hub"
> flag that indicates if roothub (RH) has to be registered or not. This is in
> preparation for allowing xhci-pci to register roothub after the shared hcd
> is created. The interface for usb_hcd_pci_probe() is not modified to make
> sure there are minimal code changes.

Same "add a flag" comment here, don't do that, make the function name
obvious please.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [RFC PATCH 4/5] usb: core: hcd-pci: Let usb_hcd_pci_probe() indicate if RH has to be registered
  2021-08-24 10:53 ` [RFC PATCH 4/5] usb: core: hcd-pci: Let usb_hcd_pci_probe() indicate if RH has to be registered Kishon Vijay Abraham I
  2021-08-24 13:09   ` Greg Kroah-Hartman
@ 2021-08-24 13:34   ` kernel test robot
  2021-08-24 13:55   ` kernel test robot
  2 siblings, 0 replies; 17+ messages in thread
From: kernel test robot @ 2021-08-24 13:34 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 13922 bytes --]

Hi Kishon,

[FYI, it's a private test report for your RFC patch.]
[auto build test WARNING on usb/usb-testing]
[also build test WARNING on v5.14-rc7 next-20210824]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Kishon-Vijay-Abraham-I/Fix-cold-plugged-USB-device-on-certain-PCIe-USB-cards/20210824-185502
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
config: powerpc-akebono_defconfig (attached as .config)
compiler: powerpc-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/fd3b9b5ae10e49551c8b9635c004d54e8cf085ae
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Kishon-Vijay-Abraham-I/Fix-cold-plugged-USB-device-on-certain-PCIe-USB-cards/20210824-185502
        git checkout fd3b9b5ae10e49551c8b9635c004d54e8cf085ae
        # save the attached .config to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=powerpc SHELL=/bin/bash drivers/usb/core/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> drivers/usb/core/hcd-pci.c:177: warning: expecting prototype for usb_hcd_pci_probe(). Prototype was for __usb_hcd_pci_probe() instead


vim +177 drivers/usb/core/hcd-pci.c

^1da177e4c3f41 Linus Torvalds         2005-04-16  157  
^1da177e4c3f41 Linus Torvalds         2005-04-16  158  /**
^1da177e4c3f41 Linus Torvalds         2005-04-16  159   * usb_hcd_pci_probe - initialize PCI-based HCDs
^1da177e4c3f41 Linus Torvalds         2005-04-16  160   * @dev: USB Host Controller being probed
^1da177e4c3f41 Linus Torvalds         2005-04-16  161   * @id: pci hotplug id connecting controller to HCD framework
ff4c65ca48f08f Vinod Koul             2020-05-14  162   * @driver: USB HC driver handle
fd3b9b5ae10e49 Kishon Vijay Abraham I 2021-08-24  163   * @register_hub: Flag to indicate of roothub has to be registered or not
41631d3616c363 Ahmed S. Darwish       2020-10-19  164   *
41631d3616c363 Ahmed S. Darwish       2020-10-19  165   * Context: task context, might sleep
^1da177e4c3f41 Linus Torvalds         2005-04-16  166   *
^1da177e4c3f41 Linus Torvalds         2005-04-16  167   * Allocates basic PCI resources for this USB host controller, and
^1da177e4c3f41 Linus Torvalds         2005-04-16  168   * then invokes the start() method for the HCD associated with it
^1da177e4c3f41 Linus Torvalds         2005-04-16  169   * through the hotplug entry's driver_data.
^1da177e4c3f41 Linus Torvalds         2005-04-16  170   *
^1da177e4c3f41 Linus Torvalds         2005-04-16  171   * Store this function in the HCD's struct pci_driver as probe().
626f090c5cbbe5 Yacine Belkadi         2013-08-02  172   *
626f090c5cbbe5 Yacine Belkadi         2013-08-02  173   * Return: 0 if successful.
^1da177e4c3f41 Linus Torvalds         2005-04-16  174   */
fd3b9b5ae10e49 Kishon Vijay Abraham I 2021-08-24  175  int __usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id,
fd3b9b5ae10e49 Kishon Vijay Abraham I 2021-08-24  176  			const struct hc_driver *driver, bool register_hub)
^1da177e4c3f41 Linus Torvalds         2005-04-16 @177  {
^1da177e4c3f41 Linus Torvalds         2005-04-16  178  	struct usb_hcd		*hcd;
^1da177e4c3f41 Linus Torvalds         2005-04-16  179  	int			retval;
00eed9c814cb8f Hannes Reinecke        2013-03-04  180  	int			hcd_irq = 0;
^1da177e4c3f41 Linus Torvalds         2005-04-16  181  
^1da177e4c3f41 Linus Torvalds         2005-04-16  182  	if (usb_disabled())
^1da177e4c3f41 Linus Torvalds         2005-04-16  183  		return -ENODEV;
^1da177e4c3f41 Linus Torvalds         2005-04-16  184  
34bbe4c16ca06c Greg Kroah-Hartman     2008-01-30  185  	if (!id)
34bbe4c16ca06c Greg Kroah-Hartman     2008-01-30  186  		return -EINVAL;
ff4c65ca48f08f Vinod Koul             2020-05-14  187  
34bbe4c16ca06c Greg Kroah-Hartman     2008-01-30  188  	if (!driver)
^1da177e4c3f41 Linus Torvalds         2005-04-16  189  		return -EINVAL;
^1da177e4c3f41 Linus Torvalds         2005-04-16  190  
^1da177e4c3f41 Linus Torvalds         2005-04-16  191  	if (pci_enable_device(dev) < 0)
^1da177e4c3f41 Linus Torvalds         2005-04-16  192  		return -ENODEV;
^1da177e4c3f41 Linus Torvalds         2005-04-16  193  
00eed9c814cb8f Hannes Reinecke        2013-03-04  194  	/*
00eed9c814cb8f Hannes Reinecke        2013-03-04  195  	 * The xHCI driver has its own irq management
00eed9c814cb8f Hannes Reinecke        2013-03-04  196  	 * make sure irq setup is not touched for xhci in generic hcd code
68d07f64b8a11a Sarah Sharp            2012-02-13  197  	 */
8a1b2725a60d32 Mathias Nyman          2015-12-10  198  	if ((driver->flags & HCD_MASK) < HCD_USB3) {
306c54d0edb6ba Andy Shevchenko        2020-07-02  199  		retval = pci_alloc_irq_vectors(dev, 1, 1, PCI_IRQ_LEGACY | PCI_IRQ_MSI);
306c54d0edb6ba Andy Shevchenko        2020-07-02  200  		if (retval < 0) {
^1da177e4c3f41 Linus Torvalds         2005-04-16  201  			dev_err(&dev->dev,
^1da177e4c3f41 Linus Torvalds         2005-04-16  202  			"Found HC with no IRQ. Check BIOS/PCI %s setup!\n",
^1da177e4c3f41 Linus Torvalds         2005-04-16  203  				pci_name(dev));
^1da177e4c3f41 Linus Torvalds         2005-04-16  204  			retval = -ENODEV;
8766c815607e57 Sarah Sharp            2010-10-15  205  			goto disable_pci;
^1da177e4c3f41 Linus Torvalds         2005-04-16  206  		}
306c54d0edb6ba Andy Shevchenko        2020-07-02  207  		hcd_irq = pci_irq_vector(dev, 0);
00eed9c814cb8f Hannes Reinecke        2013-03-04  208  	}
^1da177e4c3f41 Linus Torvalds         2005-04-16  209  
^1da177e4c3f41 Linus Torvalds         2005-04-16  210  	hcd = usb_create_hcd(driver, &dev->dev, pci_name(dev));
^1da177e4c3f41 Linus Torvalds         2005-04-16  211  	if (!hcd) {
^1da177e4c3f41 Linus Torvalds         2005-04-16  212  		retval = -ENOMEM;
306c54d0edb6ba Andy Shevchenko        2020-07-02  213  		goto free_irq_vectors;
^1da177e4c3f41 Linus Torvalds         2005-04-16  214  	}
^1da177e4c3f41 Linus Torvalds         2005-04-16  215  
7868943db1668f Huang Rui              2013-09-16  216  	hcd->amd_resume_bug = (usb_hcd_amd_remote_wakeup_quirk(dev) &&
7868943db1668f Huang Rui              2013-09-16  217  			driver->flags & (HCD_USB11 | HCD_USB3)) ? 1 : 0;
7868943db1668f Huang Rui              2013-09-16  218  
34bbe4c16ca06c Greg Kroah-Hartman     2008-01-30  219  	if (driver->flags & HCD_MEMORY) {
34bbe4c16ca06c Greg Kroah-Hartman     2008-01-30  220  		/* EHCI, OHCI */
^1da177e4c3f41 Linus Torvalds         2005-04-16  221  		hcd->rsrc_start = pci_resource_start(dev, 0);
^1da177e4c3f41 Linus Torvalds         2005-04-16  222  		hcd->rsrc_len = pci_resource_len(dev, 0);
76da906ad72704 Schmid, Carsten        2019-08-23  223  		if (!devm_request_mem_region(&dev->dev, hcd->rsrc_start,
76da906ad72704 Schmid, Carsten        2019-08-23  224  				hcd->rsrc_len, driver->description)) {
^1da177e4c3f41 Linus Torvalds         2005-04-16  225  			dev_dbg(&dev->dev, "controller already in use\n");
^1da177e4c3f41 Linus Torvalds         2005-04-16  226  			retval = -EBUSY;
05768918b9a122 Alan Stern             2013-03-28  227  			goto put_hcd;
^1da177e4c3f41 Linus Torvalds         2005-04-16  228  		}
4bdc0d676a6431 Christoph Hellwig      2020-01-06  229  		hcd->regs = devm_ioremap(&dev->dev, hcd->rsrc_start,
76da906ad72704 Schmid, Carsten        2019-08-23  230  				hcd->rsrc_len);
^1da177e4c3f41 Linus Torvalds         2005-04-16  231  		if (hcd->regs == NULL) {
^1da177e4c3f41 Linus Torvalds         2005-04-16  232  			dev_dbg(&dev->dev, "error mapping memory\n");
^1da177e4c3f41 Linus Torvalds         2005-04-16  233  			retval = -EFAULT;
76da906ad72704 Schmid, Carsten        2019-08-23  234  			goto put_hcd;
^1da177e4c3f41 Linus Torvalds         2005-04-16  235  		}
^1da177e4c3f41 Linus Torvalds         2005-04-16  236  
34bbe4c16ca06c Greg Kroah-Hartman     2008-01-30  237  	} else {
34bbe4c16ca06c Greg Kroah-Hartman     2008-01-30  238  		/* UHCI */
^1da177e4c3f41 Linus Torvalds         2005-04-16  239  		int	region;
^1da177e4c3f41 Linus Torvalds         2005-04-16  240  
c9c13ba428ef90 Denis Efremov          2019-09-28  241  		for (region = 0; region < PCI_STD_NUM_BARS; region++) {
^1da177e4c3f41 Linus Torvalds         2005-04-16  242  			if (!(pci_resource_flags(dev, region) &
^1da177e4c3f41 Linus Torvalds         2005-04-16  243  					IORESOURCE_IO))
^1da177e4c3f41 Linus Torvalds         2005-04-16  244  				continue;
^1da177e4c3f41 Linus Torvalds         2005-04-16  245  
^1da177e4c3f41 Linus Torvalds         2005-04-16  246  			hcd->rsrc_start = pci_resource_start(dev, region);
^1da177e4c3f41 Linus Torvalds         2005-04-16  247  			hcd->rsrc_len = pci_resource_len(dev, region);
76da906ad72704 Schmid, Carsten        2019-08-23  248  			if (devm_request_region(&dev->dev, hcd->rsrc_start,
76da906ad72704 Schmid, Carsten        2019-08-23  249  					hcd->rsrc_len, driver->description))
^1da177e4c3f41 Linus Torvalds         2005-04-16  250  				break;
^1da177e4c3f41 Linus Torvalds         2005-04-16  251  		}
^1da177e4c3f41 Linus Torvalds         2005-04-16  252  		if (region == PCI_ROM_RESOURCE) {
^1da177e4c3f41 Linus Torvalds         2005-04-16  253  			dev_dbg(&dev->dev, "no i/o regions available\n");
^1da177e4c3f41 Linus Torvalds         2005-04-16  254  			retval = -EBUSY;
05768918b9a122 Alan Stern             2013-03-28  255  			goto put_hcd;
^1da177e4c3f41 Linus Torvalds         2005-04-16  256  		}
^1da177e4c3f41 Linus Torvalds         2005-04-16  257  	}
^1da177e4c3f41 Linus Torvalds         2005-04-16  258  
^1da177e4c3f41 Linus Torvalds         2005-04-16  259  	pci_set_master(dev);
^1da177e4c3f41 Linus Torvalds         2005-04-16  260  
05768918b9a122 Alan Stern             2013-03-28  261  	/* Note: dev_set_drvdata must be called while holding the rwsem */
05768918b9a122 Alan Stern             2013-03-28  262  	if (dev->class == CL_EHCI) {
05768918b9a122 Alan Stern             2013-03-28  263  		down_write(&companions_rwsem);
05768918b9a122 Alan Stern             2013-03-28  264  		dev_set_drvdata(&dev->dev, hcd);
05768918b9a122 Alan Stern             2013-03-28  265  		for_each_companion(dev, hcd, ehci_pre_add);
fd3b9b5ae10e49 Kishon Vijay Abraham I 2021-08-24  266  		retval = __usb_add_hcd(hcd, hcd_irq, IRQF_SHARED, register_hub);
05768918b9a122 Alan Stern             2013-03-28  267  		if (retval != 0)
05768918b9a122 Alan Stern             2013-03-28  268  			dev_set_drvdata(&dev->dev, NULL);
05768918b9a122 Alan Stern             2013-03-28  269  		for_each_companion(dev, hcd, ehci_post_add);
05768918b9a122 Alan Stern             2013-03-28  270  		up_write(&companions_rwsem);
05768918b9a122 Alan Stern             2013-03-28  271  	} else {
05768918b9a122 Alan Stern             2013-03-28  272  		down_read(&companions_rwsem);
05768918b9a122 Alan Stern             2013-03-28  273  		dev_set_drvdata(&dev->dev, hcd);
fd3b9b5ae10e49 Kishon Vijay Abraham I 2021-08-24  274  		retval = __usb_add_hcd(hcd, hcd_irq, IRQF_SHARED, register_hub);
05768918b9a122 Alan Stern             2013-03-28  275  		if (retval != 0)
05768918b9a122 Alan Stern             2013-03-28  276  			dev_set_drvdata(&dev->dev, NULL);
05768918b9a122 Alan Stern             2013-03-28  277  		else
05768918b9a122 Alan Stern             2013-03-28  278  			for_each_companion(dev, hcd, non_ehci_add);
05768918b9a122 Alan Stern             2013-03-28  279  		up_read(&companions_rwsem);
05768918b9a122 Alan Stern             2013-03-28  280  	}
05768918b9a122 Alan Stern             2013-03-28  281  
^1da177e4c3f41 Linus Torvalds         2005-04-16  282  	if (retval != 0)
76da906ad72704 Schmid, Carsten        2019-08-23  283  		goto put_hcd;
3c9740a117d40a Peter Chen             2013-11-05  284  	device_wakeup_enable(hcd->self.controller);
3da7cff4e79e4a Alan Stern             2010-06-25  285  
3da7cff4e79e4a Alan Stern             2010-06-25  286  	if (pci_dev_run_wake(dev))
3da7cff4e79e4a Alan Stern             2010-06-25  287  		pm_runtime_put_noidle(&dev->dev);
^1da177e4c3f41 Linus Torvalds         2005-04-16  288  	return retval;
^1da177e4c3f41 Linus Torvalds         2005-04-16  289  
05768918b9a122 Alan Stern             2013-03-28  290  put_hcd:
^1da177e4c3f41 Linus Torvalds         2005-04-16  291  	usb_put_hcd(hcd);
306c54d0edb6ba Andy Shevchenko        2020-07-02  292  free_irq_vectors:
306c54d0edb6ba Andy Shevchenko        2020-07-02  293  	if ((driver->flags & HCD_MASK) < HCD_USB3)
306c54d0edb6ba Andy Shevchenko        2020-07-02  294  		pci_free_irq_vectors(dev);
8766c815607e57 Sarah Sharp            2010-10-15  295  disable_pci:
^1da177e4c3f41 Linus Torvalds         2005-04-16  296  	pci_disable_device(dev);
^1da177e4c3f41 Linus Torvalds         2005-04-16  297  	dev_err(&dev->dev, "init %s fail, %d\n", pci_name(dev), retval);
^1da177e4c3f41 Linus Torvalds         2005-04-16  298  	return retval;
^1da177e4c3f41 Linus Torvalds         2005-04-16  299  }
fd3b9b5ae10e49 Kishon Vijay Abraham I 2021-08-24  300  EXPORT_SYMBOL_GPL(__usb_hcd_pci_probe);
^1da177e4c3f41 Linus Torvalds         2005-04-16  301  
^1da177e4c3f41 Linus Torvalds         2005-04-16  302  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 17763 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [RFC PATCH 2/5] usb: core: hcd: Let usb_add_hcd() indicate if roothub has to be registered
  2021-08-24 10:52 ` [RFC PATCH 2/5] usb: core: hcd: Let usb_add_hcd() indicate if roothub has to be registered Kishon Vijay Abraham I
  2021-08-24 12:17   ` kernel test robot
  2021-08-24 13:08   ` Greg Kroah-Hartman
@ 2021-08-24 13:37   ` kernel test robot
  2021-08-24 14:56   ` Alan Stern
  3 siblings, 0 replies; 17+ messages in thread
From: kernel test robot @ 2021-08-24 13:37 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 20319 bytes --]

Hi Kishon,

[FYI, it's a private test report for your RFC patch.]
[auto build test WARNING on usb/usb-testing]
[also build test WARNING on v5.14-rc7 next-20210824]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Kishon-Vijay-Abraham-I/Fix-cold-plugged-USB-device-on-certain-PCIe-USB-cards/20210824-185502
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
config: hexagon-buildonly-randconfig-r002-20210824 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project d26000e4cc2bc65e207a84fa26cb6e374d60aa12)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/fe4b8457078ee059441628dfa331b8e3e145e335
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Kishon-Vijay-Abraham-I/Fix-cold-plugged-USB-device-on-certain-PCIe-USB-cards/20210824-185502
        git checkout fe4b8457078ee059441628dfa331b8e3e145e335
        # save the attached .config to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross O=build_dir ARCH=hexagon SHELL=/bin/bash drivers/usb/core/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> drivers/usb/core/hcd.c:2799: warning: expecting prototype for usb_add_hcd(). Prototype was for __usb_add_hcd() instead


vim +2799 drivers/usb/core/hcd.c

c8195df4a79699 Kishon Vijay Abraham I    2021-08-24  2785  
^1da177e4c3f41 Linus Torvalds            2005-04-16  2786  /**
^1da177e4c3f41 Linus Torvalds            2005-04-16  2787   * usb_add_hcd - finish generic HCD structure initialization and register
^1da177e4c3f41 Linus Torvalds            2005-04-16  2788   * @hcd: the usb_hcd structure to initialize
^1da177e4c3f41 Linus Torvalds            2005-04-16  2789   * @irqnum: Interrupt line to allocate
^1da177e4c3f41 Linus Torvalds            2005-04-16  2790   * @irqflags: Interrupt type flags
fe4b8457078ee0 Kishon Vijay Abraham I    2021-08-24  2791   * @register_hub: Flag to indicate if roothub has to be registered.
^1da177e4c3f41 Linus Torvalds            2005-04-16  2792   *
^1da177e4c3f41 Linus Torvalds            2005-04-16  2793   * Finish the remaining parts of generic HCD initialization: allocate the
^1da177e4c3f41 Linus Torvalds            2005-04-16  2794   * buffers of consistent memory, register the bus, request the IRQ line,
^1da177e4c3f41 Linus Torvalds            2005-04-16  2795   * and call the driver's reset() and start() routines.
^1da177e4c3f41 Linus Torvalds            2005-04-16  2796   */
fe4b8457078ee0 Kishon Vijay Abraham I    2021-08-24  2797  int __usb_add_hcd(struct usb_hcd *hcd, unsigned int irqnum, unsigned long irqflags,
fe4b8457078ee0 Kishon Vijay Abraham I    2021-08-24  2798  		  bool register_hub)
^1da177e4c3f41 Linus Torvalds            2005-04-16 @2799  {
^1da177e4c3f41 Linus Torvalds            2005-04-16  2800  	int retval;
8ec8d20b21f00a Alan Stern                2005-04-25  2801  	struct usb_device *rhdev;
^1da177e4c3f41 Linus Torvalds            2005-04-16  2802  
29bca25e1bc474 Chunfeng Yun              2018-03-22  2803  	if (!hcd->skip_phy_initialization && usb_hcd_is_primary_hcd(hcd)) {
63cb03f5c11eef Martin Blumenstingl       2018-04-18  2804  		hcd->phy_roothub = usb_phy_roothub_alloc(hcd->self.sysdev);
bc40f53417410b Johan Hovold              2018-04-18  2805  		if (IS_ERR(hcd->phy_roothub))
bc40f53417410b Johan Hovold              2018-04-18  2806  			return PTR_ERR(hcd->phy_roothub);
178a0bce05cbc1 Martin Blumenstingl       2018-03-03  2807  
63cb03f5c11eef Martin Blumenstingl       2018-04-18  2808  		retval = usb_phy_roothub_init(hcd->phy_roothub);
63cb03f5c11eef Martin Blumenstingl       2018-04-18  2809  		if (retval)
890fa45d01eb89 Greg Kroah-Hartman        2018-04-30  2810  			return retval;
63cb03f5c11eef Martin Blumenstingl       2018-04-18  2811  
b97a31348379f7 Miquel Raynal             2019-01-29  2812  		retval = usb_phy_roothub_set_mode(hcd->phy_roothub,
b97a31348379f7 Miquel Raynal             2019-01-29  2813  						  PHY_MODE_USB_HOST_SS);
e671765e521c57 Chen-Yu Tsai              2019-03-22  2814  		if (retval)
e671765e521c57 Chen-Yu Tsai              2019-03-22  2815  			retval = usb_phy_roothub_set_mode(hcd->phy_roothub,
e671765e521c57 Chen-Yu Tsai              2019-03-22  2816  							  PHY_MODE_USB_HOST);
b97a31348379f7 Miquel Raynal             2019-01-29  2817  		if (retval)
b97a31348379f7 Miquel Raynal             2019-01-29  2818  			goto err_usb_phy_roothub_power_on;
b97a31348379f7 Miquel Raynal             2019-01-29  2819  
178a0bce05cbc1 Martin Blumenstingl       2018-03-03  2820  		retval = usb_phy_roothub_power_on(hcd->phy_roothub);
178a0bce05cbc1 Martin Blumenstingl       2018-03-03  2821  		if (retval)
178a0bce05cbc1 Martin Blumenstingl       2018-03-03  2822  			goto err_usb_phy_roothub_power_on;
178a0bce05cbc1 Martin Blumenstingl       2018-03-03  2823  	}
178a0bce05cbc1 Martin Blumenstingl       2018-03-03  2824  
^1da177e4c3f41 Linus Torvalds            2005-04-16  2825  	dev_info(hcd->self.controller, "%s\n", hcd->product_desc);
^1da177e4c3f41 Linus Torvalds            2005-04-16  2826  
7bae0432a64aa7 Dmitry Torokhov           2019-02-16  2827  	switch (authorized_default) {
7bae0432a64aa7 Dmitry Torokhov           2019-02-16  2828  	case USB_AUTHORIZE_NONE:
7bae0432a64aa7 Dmitry Torokhov           2019-02-16  2829  		hcd->dev_policy = USB_DEVICE_AUTHORIZE_NONE;
7bae0432a64aa7 Dmitry Torokhov           2019-02-16  2830  		break;
7bae0432a64aa7 Dmitry Torokhov           2019-02-16  2831  
7bae0432a64aa7 Dmitry Torokhov           2019-02-16  2832  	case USB_AUTHORIZE_ALL:
7bae0432a64aa7 Dmitry Torokhov           2019-02-16  2833  		hcd->dev_policy = USB_DEVICE_AUTHORIZE_ALL;
7bae0432a64aa7 Dmitry Torokhov           2019-02-16  2834  		break;
7bae0432a64aa7 Dmitry Torokhov           2019-02-16  2835  
7bae0432a64aa7 Dmitry Torokhov           2019-02-16  2836  	case USB_AUTHORIZE_INTERNAL:
7bae0432a64aa7 Dmitry Torokhov           2019-02-16  2837  		hcd->dev_policy = USB_DEVICE_AUTHORIZE_INTERNAL;
7bae0432a64aa7 Dmitry Torokhov           2019-02-16  2838  		break;
7bae0432a64aa7 Dmitry Torokhov           2019-02-16  2839  
7bae0432a64aa7 Dmitry Torokhov           2019-02-16  2840  	case USB_AUTHORIZE_WIRED:
7bae0432a64aa7 Dmitry Torokhov           2019-02-16  2841  	default:
7bae0432a64aa7 Dmitry Torokhov           2019-02-16  2842  		hcd->dev_policy = hcd->wireless ?
7bae0432a64aa7 Dmitry Torokhov           2019-02-16  2843  			USB_DEVICE_AUTHORIZE_NONE : USB_DEVICE_AUTHORIZE_ALL;
7bae0432a64aa7 Dmitry Torokhov           2019-02-16  2844  		break;
ff8e2c560eca32 Stefan Koch               2015-08-25  2845  	}
7bae0432a64aa7 Dmitry Torokhov           2019-02-16  2846  
8de98402652c01 Benjamin Herrenschmidt    2005-11-25  2847  	set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
8de98402652c01 Benjamin Herrenschmidt    2005-11-25  2848  
6b2bd3c8c69c48 Stefan Koch               2015-08-25  2849  	/* per default all interfaces are authorized */
6b2bd3c8c69c48 Stefan Koch               2015-08-25  2850  	set_bit(HCD_FLAG_INTF_AUTHORIZED, &hcd->flags);
6b2bd3c8c69c48 Stefan Koch               2015-08-25  2851  
b1e8f0a6a8805c David Brownell            2006-01-23  2852  	/* HC is in reset state, but accessible.  Now do the one-time init,
37ebb54915dc42 Petr Mladek               2014-09-19  2853  	 * bottom up so that hcds can customize the root hubs before hub_wq
b1e8f0a6a8805c David Brownell            2006-01-23  2854  	 * starts talking to them.  (Note, bus id is assigned early too.)
b1e8f0a6a8805c David Brownell            2006-01-23  2855  	 */
0faaad461547e2 Kris Borer                2015-07-14  2856  	retval = hcd_buffer_create(hcd);
0faaad461547e2 Kris Borer                2015-07-14  2857  	if (retval != 0) {
a8c06e407ef969 Arnd Bergmann             2017-03-13  2858  		dev_dbg(hcd->self.sysdev, "pool alloc failed\n");
00433254952221 Sergei Shtylyov           2014-09-24  2859  		goto err_create_buf;
^1da177e4c3f41 Linus Torvalds            2005-04-16  2860  	}
^1da177e4c3f41 Linus Torvalds            2005-04-16  2861  
0faaad461547e2 Kris Borer                2015-07-14  2862  	retval = usb_register_bus(&hcd->self);
0faaad461547e2 Kris Borer                2015-07-14  2863  	if (retval < 0)
8ec8d20b21f00a Alan Stern                2005-04-25  2864  		goto err_register_bus;
^1da177e4c3f41 Linus Torvalds            2005-04-16  2865  
c688d6211f57e1 Greg Kroah-Hartman        2015-04-30  2866  	rhdev = usb_alloc_dev(NULL, &hcd->self, 0);
c688d6211f57e1 Greg Kroah-Hartman        2015-04-30  2867  	if (rhdev == NULL) {
a8c06e407ef969 Arnd Bergmann             2017-03-13  2868  		dev_err(hcd->self.sysdev, "unable to allocate root hub\n");
b1e8f0a6a8805c David Brownell            2006-01-23  2869  		retval = -ENOMEM;
b1e8f0a6a8805c David Brownell            2006-01-23  2870  		goto err_allocate_root_hub;
b1e8f0a6a8805c David Brownell            2006-01-23  2871  	}
d8521afe35862f Dan Williams              2014-05-20  2872  	mutex_lock(&usb_port_peer_mutex);
6d88e679257449 Alan Stern                2010-06-09  2873  	hcd->self.root_hub = rhdev;
d8521afe35862f Dan Williams              2014-05-20  2874  	mutex_unlock(&usb_port_peer_mutex);
6b403b020c1f42 Sarah Sharp               2009-04-27  2875  
a2d49572e11ef5 Mathias Nyman             2018-04-19  2876  	rhdev->rx_lanes = 1;
a2d49572e11ef5 Mathias Nyman             2018-04-19  2877  	rhdev->tx_lanes = 1;
0299809be41556 Thinh Nguyen              2021-03-10  2878  	rhdev->ssp_rate = USB_SSP_GEN_UNKNOWN;
a2d49572e11ef5 Mathias Nyman             2018-04-19  2879  
83de4b2b90887b Sarah Sharp               2010-12-02  2880  	switch (hcd->speed) {
6b403b020c1f42 Sarah Sharp               2009-04-27  2881  	case HCD_USB11:
6b403b020c1f42 Sarah Sharp               2009-04-27  2882  		rhdev->speed = USB_SPEED_FULL;
6b403b020c1f42 Sarah Sharp               2009-04-27  2883  		break;
6b403b020c1f42 Sarah Sharp               2009-04-27  2884  	case HCD_USB2:
6b403b020c1f42 Sarah Sharp               2009-04-27  2885  		rhdev->speed = USB_SPEED_HIGH;
6b403b020c1f42 Sarah Sharp               2009-04-27  2886  		break;
1a81f8814cbc79 Thomas Pugliese           2013-05-31  2887  	case HCD_USB25:
1a81f8814cbc79 Thomas Pugliese           2013-05-31  2888  		rhdev->speed = USB_SPEED_WIRELESS;
1a81f8814cbc79 Thomas Pugliese           2013-05-31  2889  		break;
6b403b020c1f42 Sarah Sharp               2009-04-27  2890  	case HCD_USB3:
6b403b020c1f42 Sarah Sharp               2009-04-27  2891  		rhdev->speed = USB_SPEED_SUPER;
6b403b020c1f42 Sarah Sharp               2009-04-27  2892  		break;
ffe95371d2a84f Mathias Nyman             2018-04-19  2893  	case HCD_USB32:
a2d49572e11ef5 Mathias Nyman             2018-04-19  2894  		rhdev->rx_lanes = 2;
a2d49572e11ef5 Mathias Nyman             2018-04-19  2895  		rhdev->tx_lanes = 2;
0299809be41556 Thinh Nguyen              2021-03-10  2896  		rhdev->ssp_rate = USB_SSP_GEN_2x2;
0299809be41556 Thinh Nguyen              2021-03-10  2897  		rhdev->speed = USB_SPEED_SUPER_PLUS;
0299809be41556 Thinh Nguyen              2021-03-10  2898  		break;
5f9c3a668b3f75 Mathias Nyman             2015-12-10  2899  	case HCD_USB31:
0299809be41556 Thinh Nguyen              2021-03-10  2900  		rhdev->ssp_rate = USB_SSP_GEN_2x1;
5f9c3a668b3f75 Mathias Nyman             2015-12-10  2901  		rhdev->speed = USB_SPEED_SUPER_PLUS;
5f9c3a668b3f75 Mathias Nyman             2015-12-10  2902  		break;
6b403b020c1f42 Sarah Sharp               2009-04-27  2903  	default:
1d15ee4cd7c9dd Sebastian Andrzej Siewior 2011-04-14  2904  		retval = -EINVAL;
96e077ae347912 Alan Stern                2010-06-09  2905  		goto err_set_rh_speed;
6b403b020c1f42 Sarah Sharp               2009-04-27  2906  	}
b1e8f0a6a8805c David Brownell            2006-01-23  2907  
db4cefaaea4c6d David Brownell            2006-05-01  2908  	/* wakeup flag init defaults to "everything works" for root hubs,
db4cefaaea4c6d David Brownell            2006-05-01  2909  	 * but drivers can override it in reset() if needed, along with
db4cefaaea4c6d David Brownell            2006-05-01  2910  	 * recording the overall controller's system wakeup capability.
db4cefaaea4c6d David Brownell            2006-05-01  2911  	 */
a6eeeb9f45b5a4 Alan Stern                2011-09-26  2912  	device_set_wakeup_capable(&rhdev->dev, 1);
db4cefaaea4c6d David Brownell            2006-05-01  2913  
9b37596a2e8604 Alan Stern                2011-03-07  2914  	/* HCD_FLAG_RH_RUNNING doesn't matter until the root hub is
9b37596a2e8604 Alan Stern                2011-03-07  2915  	 * registered.  But since the controller can die at any time,
9b37596a2e8604 Alan Stern                2011-03-07  2916  	 * let's initialize the flag before touching the hardware.
9b37596a2e8604 Alan Stern                2011-03-07  2917  	 */
9b37596a2e8604 Alan Stern                2011-03-07  2918  	set_bit(HCD_FLAG_RH_RUNNING, &hcd->flags);
9b37596a2e8604 Alan Stern                2011-03-07  2919  
b1e8f0a6a8805c David Brownell            2006-01-23  2920  	/* "reset" is misnamed; its role is now one-time init. the controller
b1e8f0a6a8805c David Brownell            2006-01-23  2921  	 * should already have been reset (and boot firmware kicked off etc).
b1e8f0a6a8805c David Brownell            2006-01-23  2922  	 */
0faaad461547e2 Kris Borer                2015-07-14  2923  	if (hcd->driver->reset) {
0faaad461547e2 Kris Borer                2015-07-14  2924  		retval = hcd->driver->reset(hcd);
0faaad461547e2 Kris Borer                2015-07-14  2925  		if (retval < 0) {
0faaad461547e2 Kris Borer                2015-07-14  2926  			dev_err(hcd->self.controller, "can't setup: %d\n",
0faaad461547e2 Kris Borer                2015-07-14  2927  					retval);
b1e8f0a6a8805c David Brownell            2006-01-23  2928  			goto err_hcd_driver_setup;
b1e8f0a6a8805c David Brownell            2006-01-23  2929  		}
0faaad461547e2 Kris Borer                2015-07-14  2930  	}
6d88e679257449 Alan Stern                2010-06-09  2931  	hcd->rh_pollable = 1;
b1e8f0a6a8805c David Brownell            2006-01-23  2932  
34c7ed72f4f04e Marek Szyprowski          2019-08-29  2933  	retval = usb_phy_roothub_calibrate(hcd->phy_roothub);
34c7ed72f4f04e Marek Szyprowski          2019-08-29  2934  	if (retval)
34c7ed72f4f04e Marek Szyprowski          2019-08-29  2935  		goto err_hcd_driver_setup;
34c7ed72f4f04e Marek Szyprowski          2019-08-29  2936  
fb669cc01ed778 David Brownell            2006-01-24  2937  	/* NOTE: root hub and controller capabilities may not be the same */
fb669cc01ed778 David Brownell            2006-01-24  2938  	if (device_can_wakeup(hcd->self.controller)
fb669cc01ed778 David Brownell            2006-01-24  2939  			&& device_can_wakeup(&hcd->self.root_hub->dev))
b1e8f0a6a8805c David Brownell            2006-01-23  2940  		dev_dbg(hcd->self.controller, "supports USB remote wakeup\n");
b1e8f0a6a8805c David Brownell            2006-01-23  2941  
94dfd7edfd5c9b Ming Lei                  2013-07-03  2942  	/* initialize tasklets */
94dfd7edfd5c9b Ming Lei                  2013-07-03  2943  	init_giveback_urb_bh(&hcd->high_prio_bh);
94dfd7edfd5c9b Ming Lei                  2013-07-03  2944  	init_giveback_urb_bh(&hcd->low_prio_bh);
94dfd7edfd5c9b Ming Lei                  2013-07-03  2945  
68d07f64b8a11a Sarah Sharp               2012-02-13  2946  	/* enable irqs just before we start the controller,
68d07f64b8a11a Sarah Sharp               2012-02-13  2947  	 * if the BIOS provides legacy PCI irqs.
68d07f64b8a11a Sarah Sharp               2012-02-13  2948  	 */
68d07f64b8a11a Sarah Sharp               2012-02-13  2949  	if (usb_hcd_is_primary_hcd(hcd) && irqnum) {
23e0d1066f429a Sarah Sharp               2010-10-21  2950  		retval = usb_hcd_request_irqs(hcd, irqnum, irqflags);
23e0d1066f429a Sarah Sharp               2010-10-21  2951  		if (retval)
8ec8d20b21f00a Alan Stern                2005-04-25  2952  			goto err_request_irq;
c56354378426e5 Sarah Sharp               2010-10-28  2953  	}
^1da177e4c3f41 Linus Torvalds            2005-04-16  2954  
4814030ce11f08 Sarah Sharp               2011-03-11  2955  	hcd->state = HC_STATE_RUNNING;
abc4f9b099e9e7 Sarah Sharp               2010-12-01  2956  	retval = hcd->driver->start(hcd);
abc4f9b099e9e7 Sarah Sharp               2010-12-01  2957  	if (retval < 0) {
^1da177e4c3f41 Linus Torvalds            2005-04-16  2958  		dev_err(hcd->self.controller, "startup error %d\n", retval);
8ec8d20b21f00a Alan Stern                2005-04-25  2959  		goto err_hcd_driver_start;
^1da177e4c3f41 Linus Torvalds            2005-04-16  2960  	}
^1da177e4c3f41 Linus Torvalds            2005-04-16  2961  
b1e8f0a6a8805c David Brownell            2006-01-23  2962  	/* starting here, usbcore will pay attention to this root hub */
fe4b8457078ee0 Kishon Vijay Abraham I    2021-08-24  2963  	if (register_hub) {
0faaad461547e2 Kris Borer                2015-07-14  2964  		retval = register_root_hub(hcd);
0faaad461547e2 Kris Borer                2015-07-14  2965  		if (retval != 0)
8ec8d20b21f00a Alan Stern                2005-04-25  2966  			goto err_register_root_hub;
541c7d432f7677 Alan Stern                2010-06-22  2967  		if (hcd->uses_new_polling && HCD_POLL_RH(hcd))
d5926ae7a827bd Alan Stern                2005-04-21  2968  			usb_hcd_poll_rh_status(hcd);
fe4b8457078ee0 Kishon Vijay Abraham I    2021-08-24  2969  	}
a6eeeb9f45b5a4 Alan Stern                2011-09-26  2970  
^1da177e4c3f41 Linus Torvalds            2005-04-16  2971  	return retval;
^1da177e4c3f41 Linus Torvalds            2005-04-16  2972  
8ec8d20b21f00a Alan Stern                2005-04-25  2973  err_register_root_hub:
c8195df4a79699 Kishon Vijay Abraham I    2021-08-24  2974  	usb_stop_hcd(hcd);
8ec8d20b21f00a Alan Stern                2005-04-25  2975  err_hcd_driver_start:
cd70469d084fde Felipe Balbi              2012-02-29  2976  	if (usb_hcd_is_primary_hcd(hcd) && hcd->irq > 0)
^1da177e4c3f41 Linus Torvalds            2005-04-16  2977  		free_irq(irqnum, hcd);
8ec8d20b21f00a Alan Stern                2005-04-25  2978  err_request_irq:
b1e8f0a6a8805c David Brownell            2006-01-23  2979  err_hcd_driver_setup:
96e077ae347912 Alan Stern                2010-06-09  2980  err_set_rh_speed:
d8521afe35862f Dan Williams              2014-05-20  2981  	usb_put_invalidate_rhdev(hcd);
b1e8f0a6a8805c David Brownell            2006-01-23  2982  err_allocate_root_hub:
^1da177e4c3f41 Linus Torvalds            2005-04-16  2983  	usb_deregister_bus(&hcd->self);
8ec8d20b21f00a Alan Stern                2005-04-25  2984  err_register_bus:
^1da177e4c3f41 Linus Torvalds            2005-04-16  2985  	hcd_buffer_destroy(hcd);
00433254952221 Sergei Shtylyov           2014-09-24  2986  err_create_buf:
178a0bce05cbc1 Martin Blumenstingl       2018-03-03  2987  	usb_phy_roothub_power_off(hcd->phy_roothub);
178a0bce05cbc1 Martin Blumenstingl       2018-03-03  2988  err_usb_phy_roothub_power_on:
178a0bce05cbc1 Martin Blumenstingl       2018-03-03  2989  	usb_phy_roothub_exit(hcd->phy_roothub);
bc40f53417410b Johan Hovold              2018-04-18  2990  
^1da177e4c3f41 Linus Torvalds            2005-04-16  2991  	return retval;
^1da177e4c3f41 Linus Torvalds            2005-04-16  2992  }
fe4b8457078ee0 Kishon Vijay Abraham I    2021-08-24  2993  EXPORT_SYMBOL_GPL(__usb_add_hcd);
^1da177e4c3f41 Linus Torvalds            2005-04-16  2994  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 38902 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [RFC PATCH 4/5] usb: core: hcd-pci: Let usb_hcd_pci_probe() indicate if RH has to be registered
  2021-08-24 10:53 ` [RFC PATCH 4/5] usb: core: hcd-pci: Let usb_hcd_pci_probe() indicate if RH has to be registered Kishon Vijay Abraham I
  2021-08-24 13:09   ` Greg Kroah-Hartman
  2021-08-24 13:34   ` kernel test robot
@ 2021-08-24 13:55   ` kernel test robot
  2 siblings, 0 replies; 17+ messages in thread
From: kernel test robot @ 2021-08-24 13:55 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 13992 bytes --]

Hi Kishon,

[FYI, it's a private test report for your RFC patch.]
[auto build test WARNING on usb/usb-testing]
[also build test WARNING on v5.14-rc7 next-20210824]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Kishon-Vijay-Abraham-I/Fix-cold-plugged-USB-device-on-certain-PCIe-USB-cards/20210824-185502
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
config: x86_64-randconfig-a016-20210824 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project d26000e4cc2bc65e207a84fa26cb6e374d60aa12)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/fd3b9b5ae10e49551c8b9635c004d54e8cf085ae
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Kishon-Vijay-Abraham-I/Fix-cold-plugged-USB-device-on-certain-PCIe-USB-cards/20210824-185502
        git checkout fd3b9b5ae10e49551c8b9635c004d54e8cf085ae
        # save the attached .config to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/usb/core/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> drivers/usb/core/hcd-pci.c:177: warning: expecting prototype for usb_hcd_pci_probe(). Prototype was for __usb_hcd_pci_probe() instead


vim +177 drivers/usb/core/hcd-pci.c

^1da177e4c3f41 Linus Torvalds         2005-04-16  157  
^1da177e4c3f41 Linus Torvalds         2005-04-16  158  /**
^1da177e4c3f41 Linus Torvalds         2005-04-16  159   * usb_hcd_pci_probe - initialize PCI-based HCDs
^1da177e4c3f41 Linus Torvalds         2005-04-16  160   * @dev: USB Host Controller being probed
^1da177e4c3f41 Linus Torvalds         2005-04-16  161   * @id: pci hotplug id connecting controller to HCD framework
ff4c65ca48f08f Vinod Koul             2020-05-14  162   * @driver: USB HC driver handle
fd3b9b5ae10e49 Kishon Vijay Abraham I 2021-08-24  163   * @register_hub: Flag to indicate of roothub has to be registered or not
41631d3616c363 Ahmed S. Darwish       2020-10-19  164   *
41631d3616c363 Ahmed S. Darwish       2020-10-19  165   * Context: task context, might sleep
^1da177e4c3f41 Linus Torvalds         2005-04-16  166   *
^1da177e4c3f41 Linus Torvalds         2005-04-16  167   * Allocates basic PCI resources for this USB host controller, and
^1da177e4c3f41 Linus Torvalds         2005-04-16  168   * then invokes the start() method for the HCD associated with it
^1da177e4c3f41 Linus Torvalds         2005-04-16  169   * through the hotplug entry's driver_data.
^1da177e4c3f41 Linus Torvalds         2005-04-16  170   *
^1da177e4c3f41 Linus Torvalds         2005-04-16  171   * Store this function in the HCD's struct pci_driver as probe().
626f090c5cbbe5 Yacine Belkadi         2013-08-02  172   *
626f090c5cbbe5 Yacine Belkadi         2013-08-02  173   * Return: 0 if successful.
^1da177e4c3f41 Linus Torvalds         2005-04-16  174   */
fd3b9b5ae10e49 Kishon Vijay Abraham I 2021-08-24  175  int __usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id,
fd3b9b5ae10e49 Kishon Vijay Abraham I 2021-08-24  176  			const struct hc_driver *driver, bool register_hub)
^1da177e4c3f41 Linus Torvalds         2005-04-16 @177  {
^1da177e4c3f41 Linus Torvalds         2005-04-16  178  	struct usb_hcd		*hcd;
^1da177e4c3f41 Linus Torvalds         2005-04-16  179  	int			retval;
00eed9c814cb8f Hannes Reinecke        2013-03-04  180  	int			hcd_irq = 0;
^1da177e4c3f41 Linus Torvalds         2005-04-16  181  
^1da177e4c3f41 Linus Torvalds         2005-04-16  182  	if (usb_disabled())
^1da177e4c3f41 Linus Torvalds         2005-04-16  183  		return -ENODEV;
^1da177e4c3f41 Linus Torvalds         2005-04-16  184  
34bbe4c16ca06c Greg Kroah-Hartman     2008-01-30  185  	if (!id)
34bbe4c16ca06c Greg Kroah-Hartman     2008-01-30  186  		return -EINVAL;
ff4c65ca48f08f Vinod Koul             2020-05-14  187  
34bbe4c16ca06c Greg Kroah-Hartman     2008-01-30  188  	if (!driver)
^1da177e4c3f41 Linus Torvalds         2005-04-16  189  		return -EINVAL;
^1da177e4c3f41 Linus Torvalds         2005-04-16  190  
^1da177e4c3f41 Linus Torvalds         2005-04-16  191  	if (pci_enable_device(dev) < 0)
^1da177e4c3f41 Linus Torvalds         2005-04-16  192  		return -ENODEV;
^1da177e4c3f41 Linus Torvalds         2005-04-16  193  
00eed9c814cb8f Hannes Reinecke        2013-03-04  194  	/*
00eed9c814cb8f Hannes Reinecke        2013-03-04  195  	 * The xHCI driver has its own irq management
00eed9c814cb8f Hannes Reinecke        2013-03-04  196  	 * make sure irq setup is not touched for xhci in generic hcd code
68d07f64b8a11a Sarah Sharp            2012-02-13  197  	 */
8a1b2725a60d32 Mathias Nyman          2015-12-10  198  	if ((driver->flags & HCD_MASK) < HCD_USB3) {
306c54d0edb6ba Andy Shevchenko        2020-07-02  199  		retval = pci_alloc_irq_vectors(dev, 1, 1, PCI_IRQ_LEGACY | PCI_IRQ_MSI);
306c54d0edb6ba Andy Shevchenko        2020-07-02  200  		if (retval < 0) {
^1da177e4c3f41 Linus Torvalds         2005-04-16  201  			dev_err(&dev->dev,
^1da177e4c3f41 Linus Torvalds         2005-04-16  202  			"Found HC with no IRQ. Check BIOS/PCI %s setup!\n",
^1da177e4c3f41 Linus Torvalds         2005-04-16  203  				pci_name(dev));
^1da177e4c3f41 Linus Torvalds         2005-04-16  204  			retval = -ENODEV;
8766c815607e57 Sarah Sharp            2010-10-15  205  			goto disable_pci;
^1da177e4c3f41 Linus Torvalds         2005-04-16  206  		}
306c54d0edb6ba Andy Shevchenko        2020-07-02  207  		hcd_irq = pci_irq_vector(dev, 0);
00eed9c814cb8f Hannes Reinecke        2013-03-04  208  	}
^1da177e4c3f41 Linus Torvalds         2005-04-16  209  
^1da177e4c3f41 Linus Torvalds         2005-04-16  210  	hcd = usb_create_hcd(driver, &dev->dev, pci_name(dev));
^1da177e4c3f41 Linus Torvalds         2005-04-16  211  	if (!hcd) {
^1da177e4c3f41 Linus Torvalds         2005-04-16  212  		retval = -ENOMEM;
306c54d0edb6ba Andy Shevchenko        2020-07-02  213  		goto free_irq_vectors;
^1da177e4c3f41 Linus Torvalds         2005-04-16  214  	}
^1da177e4c3f41 Linus Torvalds         2005-04-16  215  
7868943db1668f Huang Rui              2013-09-16  216  	hcd->amd_resume_bug = (usb_hcd_amd_remote_wakeup_quirk(dev) &&
7868943db1668f Huang Rui              2013-09-16  217  			driver->flags & (HCD_USB11 | HCD_USB3)) ? 1 : 0;
7868943db1668f Huang Rui              2013-09-16  218  
34bbe4c16ca06c Greg Kroah-Hartman     2008-01-30  219  	if (driver->flags & HCD_MEMORY) {
34bbe4c16ca06c Greg Kroah-Hartman     2008-01-30  220  		/* EHCI, OHCI */
^1da177e4c3f41 Linus Torvalds         2005-04-16  221  		hcd->rsrc_start = pci_resource_start(dev, 0);
^1da177e4c3f41 Linus Torvalds         2005-04-16  222  		hcd->rsrc_len = pci_resource_len(dev, 0);
76da906ad72704 Schmid, Carsten        2019-08-23  223  		if (!devm_request_mem_region(&dev->dev, hcd->rsrc_start,
76da906ad72704 Schmid, Carsten        2019-08-23  224  				hcd->rsrc_len, driver->description)) {
^1da177e4c3f41 Linus Torvalds         2005-04-16  225  			dev_dbg(&dev->dev, "controller already in use\n");
^1da177e4c3f41 Linus Torvalds         2005-04-16  226  			retval = -EBUSY;
05768918b9a122 Alan Stern             2013-03-28  227  			goto put_hcd;
^1da177e4c3f41 Linus Torvalds         2005-04-16  228  		}
4bdc0d676a6431 Christoph Hellwig      2020-01-06  229  		hcd->regs = devm_ioremap(&dev->dev, hcd->rsrc_start,
76da906ad72704 Schmid, Carsten        2019-08-23  230  				hcd->rsrc_len);
^1da177e4c3f41 Linus Torvalds         2005-04-16  231  		if (hcd->regs == NULL) {
^1da177e4c3f41 Linus Torvalds         2005-04-16  232  			dev_dbg(&dev->dev, "error mapping memory\n");
^1da177e4c3f41 Linus Torvalds         2005-04-16  233  			retval = -EFAULT;
76da906ad72704 Schmid, Carsten        2019-08-23  234  			goto put_hcd;
^1da177e4c3f41 Linus Torvalds         2005-04-16  235  		}
^1da177e4c3f41 Linus Torvalds         2005-04-16  236  
34bbe4c16ca06c Greg Kroah-Hartman     2008-01-30  237  	} else {
34bbe4c16ca06c Greg Kroah-Hartman     2008-01-30  238  		/* UHCI */
^1da177e4c3f41 Linus Torvalds         2005-04-16  239  		int	region;
^1da177e4c3f41 Linus Torvalds         2005-04-16  240  
c9c13ba428ef90 Denis Efremov          2019-09-28  241  		for (region = 0; region < PCI_STD_NUM_BARS; region++) {
^1da177e4c3f41 Linus Torvalds         2005-04-16  242  			if (!(pci_resource_flags(dev, region) &
^1da177e4c3f41 Linus Torvalds         2005-04-16  243  					IORESOURCE_IO))
^1da177e4c3f41 Linus Torvalds         2005-04-16  244  				continue;
^1da177e4c3f41 Linus Torvalds         2005-04-16  245  
^1da177e4c3f41 Linus Torvalds         2005-04-16  246  			hcd->rsrc_start = pci_resource_start(dev, region);
^1da177e4c3f41 Linus Torvalds         2005-04-16  247  			hcd->rsrc_len = pci_resource_len(dev, region);
76da906ad72704 Schmid, Carsten        2019-08-23  248  			if (devm_request_region(&dev->dev, hcd->rsrc_start,
76da906ad72704 Schmid, Carsten        2019-08-23  249  					hcd->rsrc_len, driver->description))
^1da177e4c3f41 Linus Torvalds         2005-04-16  250  				break;
^1da177e4c3f41 Linus Torvalds         2005-04-16  251  		}
^1da177e4c3f41 Linus Torvalds         2005-04-16  252  		if (region == PCI_ROM_RESOURCE) {
^1da177e4c3f41 Linus Torvalds         2005-04-16  253  			dev_dbg(&dev->dev, "no i/o regions available\n");
^1da177e4c3f41 Linus Torvalds         2005-04-16  254  			retval = -EBUSY;
05768918b9a122 Alan Stern             2013-03-28  255  			goto put_hcd;
^1da177e4c3f41 Linus Torvalds         2005-04-16  256  		}
^1da177e4c3f41 Linus Torvalds         2005-04-16  257  	}
^1da177e4c3f41 Linus Torvalds         2005-04-16  258  
^1da177e4c3f41 Linus Torvalds         2005-04-16  259  	pci_set_master(dev);
^1da177e4c3f41 Linus Torvalds         2005-04-16  260  
05768918b9a122 Alan Stern             2013-03-28  261  	/* Note: dev_set_drvdata must be called while holding the rwsem */
05768918b9a122 Alan Stern             2013-03-28  262  	if (dev->class == CL_EHCI) {
05768918b9a122 Alan Stern             2013-03-28  263  		down_write(&companions_rwsem);
05768918b9a122 Alan Stern             2013-03-28  264  		dev_set_drvdata(&dev->dev, hcd);
05768918b9a122 Alan Stern             2013-03-28  265  		for_each_companion(dev, hcd, ehci_pre_add);
fd3b9b5ae10e49 Kishon Vijay Abraham I 2021-08-24  266  		retval = __usb_add_hcd(hcd, hcd_irq, IRQF_SHARED, register_hub);
05768918b9a122 Alan Stern             2013-03-28  267  		if (retval != 0)
05768918b9a122 Alan Stern             2013-03-28  268  			dev_set_drvdata(&dev->dev, NULL);
05768918b9a122 Alan Stern             2013-03-28  269  		for_each_companion(dev, hcd, ehci_post_add);
05768918b9a122 Alan Stern             2013-03-28  270  		up_write(&companions_rwsem);
05768918b9a122 Alan Stern             2013-03-28  271  	} else {
05768918b9a122 Alan Stern             2013-03-28  272  		down_read(&companions_rwsem);
05768918b9a122 Alan Stern             2013-03-28  273  		dev_set_drvdata(&dev->dev, hcd);
fd3b9b5ae10e49 Kishon Vijay Abraham I 2021-08-24  274  		retval = __usb_add_hcd(hcd, hcd_irq, IRQF_SHARED, register_hub);
05768918b9a122 Alan Stern             2013-03-28  275  		if (retval != 0)
05768918b9a122 Alan Stern             2013-03-28  276  			dev_set_drvdata(&dev->dev, NULL);
05768918b9a122 Alan Stern             2013-03-28  277  		else
05768918b9a122 Alan Stern             2013-03-28  278  			for_each_companion(dev, hcd, non_ehci_add);
05768918b9a122 Alan Stern             2013-03-28  279  		up_read(&companions_rwsem);
05768918b9a122 Alan Stern             2013-03-28  280  	}
05768918b9a122 Alan Stern             2013-03-28  281  
^1da177e4c3f41 Linus Torvalds         2005-04-16  282  	if (retval != 0)
76da906ad72704 Schmid, Carsten        2019-08-23  283  		goto put_hcd;
3c9740a117d40a Peter Chen             2013-11-05  284  	device_wakeup_enable(hcd->self.controller);
3da7cff4e79e4a Alan Stern             2010-06-25  285  
3da7cff4e79e4a Alan Stern             2010-06-25  286  	if (pci_dev_run_wake(dev))
3da7cff4e79e4a Alan Stern             2010-06-25  287  		pm_runtime_put_noidle(&dev->dev);
^1da177e4c3f41 Linus Torvalds         2005-04-16  288  	return retval;
^1da177e4c3f41 Linus Torvalds         2005-04-16  289  
05768918b9a122 Alan Stern             2013-03-28  290  put_hcd:
^1da177e4c3f41 Linus Torvalds         2005-04-16  291  	usb_put_hcd(hcd);
306c54d0edb6ba Andy Shevchenko        2020-07-02  292  free_irq_vectors:
306c54d0edb6ba Andy Shevchenko        2020-07-02  293  	if ((driver->flags & HCD_MASK) < HCD_USB3)
306c54d0edb6ba Andy Shevchenko        2020-07-02  294  		pci_free_irq_vectors(dev);
8766c815607e57 Sarah Sharp            2010-10-15  295  disable_pci:
^1da177e4c3f41 Linus Torvalds         2005-04-16  296  	pci_disable_device(dev);
^1da177e4c3f41 Linus Torvalds         2005-04-16  297  	dev_err(&dev->dev, "init %s fail, %d\n", pci_name(dev), retval);
^1da177e4c3f41 Linus Torvalds         2005-04-16  298  	return retval;
^1da177e4c3f41 Linus Torvalds         2005-04-16  299  }
fd3b9b5ae10e49 Kishon Vijay Abraham I 2021-08-24  300  EXPORT_SYMBOL_GPL(__usb_hcd_pci_probe);
^1da177e4c3f41 Linus Torvalds         2005-04-16  301  
^1da177e4c3f41 Linus Torvalds         2005-04-16  302  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 32032 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [RFC PATCH 2/5] usb: core: hcd: Let usb_add_hcd() indicate if roothub has to be registered
  2021-08-24 10:52 ` [RFC PATCH 2/5] usb: core: hcd: Let usb_add_hcd() indicate if roothub has to be registered Kishon Vijay Abraham I
                     ` (2 preceding siblings ...)
  2021-08-24 13:37   ` kernel test robot
@ 2021-08-24 14:56   ` Alan Stern
  3 siblings, 0 replies; 17+ messages in thread
From: Alan Stern @ 2021-08-24 14:56 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: Greg Kroah-Hartman, Mathias Nyman, linux-usb, linux-kernel, chris.chiu

On Tue, Aug 24, 2021 at 04:22:59PM +0530, Kishon Vijay Abraham I wrote:
> No functional change. Add __usb_add_hcd() which takes "register_hub"
> flag that indicates if roothub has to be registered or not. This is in
> preparation for allowing xhci to register roothub after the shared hcd
> is created. The interface for usb_add_hcd() is not modified to make sure
> there is no USB subsystem wide changes.
> 
> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
> ---
>  drivers/usb/core/hcd.c  | 20 +++++++++++---------
>  include/linux/usb/hcd.h |  8 ++++++--
>  2 files changed, 17 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
> index c036ba5311b3..4d7a9f0e2caa 100644
> --- a/drivers/usb/core/hcd.c
> +++ b/drivers/usb/core/hcd.c
> @@ -2788,13 +2788,14 @@ static void usb_stop_hcd(struct usb_hcd *hcd)
>   * @hcd: the usb_hcd structure to initialize
>   * @irqnum: Interrupt line to allocate
>   * @irqflags: Interrupt type flags
> + * @register_hub: Flag to indicate if roothub has to be registered.
>   *
>   * Finish the remaining parts of generic HCD initialization: allocate the
>   * buffers of consistent memory, register the bus, request the IRQ line,
>   * and call the driver's reset() and start() routines.
>   */
> -int usb_add_hcd(struct usb_hcd *hcd,
> -		unsigned int irqnum, unsigned long irqflags)
> +int __usb_add_hcd(struct usb_hcd *hcd, unsigned int irqnum, unsigned long irqflags,
> +		  bool register_hub)

For future reference: When you change the name of a function, be 
sure to update the name in the kerneldoc comment as well.

Alan Stern

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [RFC PATCH 1/5] usb: core: hcd: Modularize HCD stop configuration in usb_stop_hcd()
  2021-08-24 13:06   ` Greg Kroah-Hartman
@ 2021-08-24 15:18     ` Kishon Vijay Abraham I
  2021-08-26 11:14       ` Greg Kroah-Hartman
  0 siblings, 1 reply; 17+ messages in thread
From: Kishon Vijay Abraham I @ 2021-08-24 15:18 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Mathias Nyman, Alan Stern, linux-usb, linux-kernel, chris.chiu

Hi Greg,

On 24/08/21 6:36 pm, Greg Kroah-Hartman wrote:
> On Tue, Aug 24, 2021 at 04:22:58PM +0530, Kishon Vijay Abraham I wrote:
>> No functional change. Since configuration to stop HCD is invoked from
>> multiple places, group all of them in usb_stop_hcd().
>>
>> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
>> ---
>>  drivers/usb/core/hcd.c | 42 +++++++++++++++++++++++++-----------------
>>  1 file changed, 25 insertions(+), 17 deletions(-)
>>
>> diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
>> index 0f8b7c93310e..c036ba5311b3 100644
>> --- a/drivers/usb/core/hcd.c
>> +++ b/drivers/usb/core/hcd.c
>> @@ -2760,6 +2760,29 @@ static void usb_put_invalidate_rhdev(struct usb_hcd *hcd)
>>  	usb_put_dev(rhdev);
>>  }
>>  
>> +/**
>> + * usb_stop_hcd - Halt the HCD
>> + * @hcd: the usb_hcd that has to be halted
>> + *
>> + * Stop the timer and invoke ->stop() callback on the HCD
>> + */
>> +static void usb_stop_hcd(struct usb_hcd *hcd)
>> +{
>> +	if (!hcd)
>> +		return;
> 
> That's impossible to hit, so no need to check for it, right?

Patch 3 of this series adds support for registering roothub of shared
HCD. So after that patch there can be a case where shared_hcd is NULL.
The other option would be to check for non-null value in hcd and then
invoke usb_stop_hcd().

Thanks
Kishon

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [RFC PATCH 1/5] usb: core: hcd: Modularize HCD stop configuration in usb_stop_hcd()
  2021-08-24 15:18     ` Kishon Vijay Abraham I
@ 2021-08-26 11:14       ` Greg Kroah-Hartman
  0 siblings, 0 replies; 17+ messages in thread
From: Greg Kroah-Hartman @ 2021-08-26 11:14 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: Mathias Nyman, Alan Stern, linux-usb, linux-kernel, chris.chiu

On Tue, Aug 24, 2021 at 08:48:45PM +0530, Kishon Vijay Abraham I wrote:
> Hi Greg,
> 
> On 24/08/21 6:36 pm, Greg Kroah-Hartman wrote:
> > On Tue, Aug 24, 2021 at 04:22:58PM +0530, Kishon Vijay Abraham I wrote:
> >> No functional change. Since configuration to stop HCD is invoked from
> >> multiple places, group all of them in usb_stop_hcd().
> >>
> >> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
> >> ---
> >>  drivers/usb/core/hcd.c | 42 +++++++++++++++++++++++++-----------------
> >>  1 file changed, 25 insertions(+), 17 deletions(-)
> >>
> >> diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
> >> index 0f8b7c93310e..c036ba5311b3 100644
> >> --- a/drivers/usb/core/hcd.c
> >> +++ b/drivers/usb/core/hcd.c
> >> @@ -2760,6 +2760,29 @@ static void usb_put_invalidate_rhdev(struct usb_hcd *hcd)
> >>  	usb_put_dev(rhdev);
> >>  }
> >>  
> >> +/**
> >> + * usb_stop_hcd - Halt the HCD
> >> + * @hcd: the usb_hcd that has to be halted
> >> + *
> >> + * Stop the timer and invoke ->stop() callback on the HCD
> >> + */
> >> +static void usb_stop_hcd(struct usb_hcd *hcd)
> >> +{
> >> +	if (!hcd)
> >> +		return;
> > 
> > That's impossible to hit, so no need to check for it, right?
> 
> Patch 3 of this series adds support for registering roothub of shared
> HCD. So after that patch there can be a case where shared_hcd is NULL.
> The other option would be to check for non-null value in hcd and then
> invoke usb_stop_hcd().

Then add the check when you need it please.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2021-08-26 11:15 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-24 10:52 [RFC PATCH 0/5] Fix cold plugged USB device on certain PCIe USB cards Kishon Vijay Abraham I
2021-08-24 10:52 ` [RFC PATCH 1/5] usb: core: hcd: Modularize HCD stop configuration in usb_stop_hcd() Kishon Vijay Abraham I
2021-08-24 13:06   ` Greg Kroah-Hartman
2021-08-24 15:18     ` Kishon Vijay Abraham I
2021-08-26 11:14       ` Greg Kroah-Hartman
2021-08-24 10:52 ` [RFC PATCH 2/5] usb: core: hcd: Let usb_add_hcd() indicate if roothub has to be registered Kishon Vijay Abraham I
2021-08-24 12:17   ` kernel test robot
2021-08-24 13:08   ` Greg Kroah-Hartman
2021-08-24 13:37   ` kernel test robot
2021-08-24 14:56   ` Alan Stern
2021-08-24 10:53 ` [RFC PATCH 3/5] usb: core: hcd: Add support for registering secondary RH along with primary HCD Kishon Vijay Abraham I
2021-08-24 11:55   ` Mathias Nyman
2021-08-24 10:53 ` [RFC PATCH 4/5] usb: core: hcd-pci: Let usb_hcd_pci_probe() indicate if RH has to be registered Kishon Vijay Abraham I
2021-08-24 13:09   ` Greg Kroah-Hartman
2021-08-24 13:34   ` kernel test robot
2021-08-24 13:55   ` kernel test robot
2021-08-24 10:53 ` [RFC PATCH 5/5] xhci-pci: Use flag to not register roothub while adding primary HCD Kishon Vijay Abraham I

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.