linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: dwc3: don't reset device side if dwc3 was configured as host-only
@ 2023-06-27 16:20 Jisheng Zhang
  2023-06-30 22:23 ` Thinh Nguyen
  2023-09-30  7:43 ` Lu jicong
  0 siblings, 2 replies; 14+ messages in thread
From: Jisheng Zhang @ 2023-06-27 16:20 UTC (permalink / raw)
  To: Thinh Nguyen, Greg Kroah-Hartman; +Cc: linux-usb, linux-kernel

Commit c4a5153e87fd ("usb: dwc3: core: Power-off core/PHYs on
system_suspend in host mode") replaces check for HOST only dr_mode with
current_dr_role. But during booting, the current_dr_role isn't
initialized, thus the device side reset is always issued even if dwc3
was configured as host-only. What's more, on some platforms with host
only dwc3, aways issuing device side reset by accessing device register
block can cause kernel panic.

Fixes: c4a5153e87fd ("usb: dwc3: core: Power-off core/PHYs on system_suspend in host mode")
Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
---
 drivers/usb/dwc3/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 7b2ce013cc5b..16d7a1d1cbfa 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -277,9 +277,9 @@ int dwc3_core_soft_reset(struct dwc3 *dwc)
 	/*
 	 * We're resetting only the device side because, if we're in host mode,
 	 * XHCI driver will reset the host block. If dwc3 was configured for
-	 * host-only mode, then we can return early.
+	 * host-only mode or current role is host, then we can return early.
 	 */
-	if (dwc->current_dr_role == DWC3_GCTL_PRTCAP_HOST)
+	if (dwc->dr_mode == USB_DR_MODE_HOST || dwc->current_dr_role == DWC3_GCTL_PRTCAP_HOST)
 		return 0;
 
 	reg = dwc3_readl(dwc->regs, DWC3_DCTL);
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread
* Re: [PATCH] usb: dwc3: don't reset device side if dwc3 was configured as host-only
@ 2023-11-16 16:42 Köry Maincent
  2023-11-16 16:59 ` Köry Maincent
  0 siblings, 1 reply; 14+ messages in thread
From: Köry Maincent @ 2023-11-16 16:42 UTC (permalink / raw)
  To: Jisheng Zhang, Thinh Nguyen, Greg Kroah-Hartman, Lu jicong
  Cc: linux-usb, linux-kernel, Thomas Petazzoni

Hello,

Similar issue with ZynqMP board related to that patch:

xilinx-psgtr fd400000.phy: lane 3 (type 1, protocol 3): PLL lock timeout
phy phy-fd400000.phy.3: phy poweron failed --> -110
dwc3 fe300000.usb: error -ETIMEDOUT: failed to initialize core

With CONFIG_USB_DWC3_DUAL_ROLE and dr_mode = "host";

It may not be the correct fix.

-- 
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com

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

end of thread, other threads:[~2023-12-05 14:20 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-27 16:20 [PATCH] usb: dwc3: don't reset device side if dwc3 was configured as host-only Jisheng Zhang
2023-06-30 22:23 ` Thinh Nguyen
2023-09-30  7:43 ` Lu jicong
  -- strict thread matches above, loose matches on Subject: below --
2023-11-16 16:42 Köry Maincent
2023-11-16 16:59 ` Köry Maincent
2023-11-17  1:40   ` Thinh Nguyen
2023-11-17  1:55     ` Thinh Nguyen
2023-11-17  9:22       ` Köry Maincent
2023-11-21  9:49       ` Köry Maincent
2023-12-01  9:09         ` Köry Maincent
2023-12-02  0:26           ` Thinh Nguyen
2023-12-05  1:27             ` Thinh Nguyen
2023-12-05 13:56               ` Jisheng Zhang
2023-12-05 14:19             ` Köry Maincent

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).