All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] usb: dwc2: Postponed gadget registration to the udc class driver
@ 2020-05-31 14:42 Minas Harutyunyan
  2020-06-05 14:10 ` Sasha Levin
  0 siblings, 1 reply; 2+ messages in thread
From: Minas Harutyunyan @ 2020-05-31 14:42 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Minas Harutyunyan, linux-usb,
	Dinh Nguyen
  Cc: John Youn, stable, Marek Vasut

During dwc2 driver probe, after gadget registration to the udc class
driver, if exist any builtin function driver it immediately bound to
dwc2 and after init host side (dwc2_hcd_init()) stucked in host mode.
Patch postpone gadget registration after host side initialization done.

Cc: stable@vger.kernel.org
Fixes: 117777b2c3bb9 ("usb: dwc2: Move gadget probe function into
platform code")
Tested-by: Marek Vasut <marex@denx.de>

Signed-off-by: Minas Harutyunyan <hminas@synopsys.com>
---

Changes in V2:
- add module configuration check

 drivers/usb/dwc2/gadget.c   |  6 ------
 drivers/usb/dwc2/platform.c | 11 +++++++++++
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 12b98b466287..7faf5f8c056d 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -4920,12 +4920,6 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg)
 					  epnum, 0);
 	}
 
-	ret = usb_add_gadget_udc(dev, &hsotg->gadget);
-	if (ret) {
-		dwc2_hsotg_ep_free_request(&hsotg->eps_out[0]->ep,
-					   hsotg->ctrl_req);
-		return ret;
-	}
 	dwc2_hsotg_dump(hsotg);
 
 	return 0;
diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index e571c8ae65ec..c347d93eae64 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -575,6 +575,17 @@ static int dwc2_driver_probe(struct platform_device *dev)
 	if (hsotg->dr_mode == USB_DR_MODE_PERIPHERAL)
 		dwc2_lowlevel_hw_disable(hsotg);
 
+#if IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL) || \
+	IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
+	/* Postponed adding a new gadget to the udc class driver list */
+	if (hsotg->gadget_enabled) {
+		retval = usb_add_gadget_udc(hsotg->dev, &hsotg->gadget);
+		if (retval) {
+			dwc2_hsotg_remove(hsotg);
+			goto error_init;
+		}
+	}
+#endif /* CONFIG_USB_DWC2_PERIPHERAL || CONFIG_USB_DWC2_DUAL_ROLE */
 	return 0;
 
 error_init:
-- 
2.11.0


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

* Re: [PATCH v2] usb: dwc2: Postponed gadget registration to the udc class driver
  2020-05-31 14:42 [PATCH v2] usb: dwc2: Postponed gadget registration to the udc class driver Minas Harutyunyan
@ 2020-06-05 14:10 ` Sasha Levin
  0 siblings, 0 replies; 2+ messages in thread
From: Sasha Levin @ 2020-06-05 14:10 UTC (permalink / raw)
  To: Sasha Levin, Minas Harutyunyan, Felipe Balbi
  Cc: John Youn, stable, stable, stable

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1162 bytes --]

Hi

[This is an automated email]

This commit has been processed because it contains a "Fixes:" tag
fixing commit: 117777b2c3bb ("usb: dwc2: Move gadget probe function into platform code").

The bot has tested the following trees: v5.6.15, v5.4.43, v4.19.125, v4.14.182, v4.9.225, v4.4.225.

v5.6.15: Build failed! Errors:
    drivers/usb/dwc2/platform.c:517:4: error: label ‘error_init’ used but not defined

v5.4.43: Build failed! Errors:
    drivers/usb/dwc2/platform.c:517:4: error: label ‘error_init’ used but not defined

v4.19.125: Build failed! Errors:
    drivers/usb/dwc2/platform.c:502:4: error: label ‘error_init’ used but not defined

v4.14.182: Build failed! Errors:
    drivers/usb/dwc2/platform.c:462:4: error: label ‘error_init’ used but not defined

v4.9.225: Build failed! Errors:
    drivers/usb/dwc2/platform.c:671:4: error: label ‘error_init’ used but not defined

v4.4.225: Build failed! Errors:
    drivers/usb/dwc2/platform.c:462:4: error: label ‘error_init’ used but not defined


NOTE: The patch will not be queued to stable trees until it is upstream.

How should we proceed with this patch?

-- 
Thanks
Sasha

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

end of thread, other threads:[~2020-06-05 14:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-31 14:42 [PATCH v2] usb: dwc2: Postponed gadget registration to the udc class driver Minas Harutyunyan
2020-06-05 14:10 ` Sasha Levin

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.