mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] usb: dwc3: am62: handle usb2_refclk enable failures
@ 2026-02-04 14:11 Votokina Victoria
  2026-02-10  0:30 ` Thinh Nguyen
  0 siblings, 1 reply; 5+ messages in thread
From: Votokina Victoria @ 2026-02-04 14:11 UTC (permalink / raw)
  To: Thinh Nguyen
  Cc: Votokina Victoria, Greg Kroah-Hartman, Roger Quadros, linux-usb,
	linux-kernel, lvc-project

The AM62 DWC3 glue enables usb2_refclk via clk_prepare_enable(), but
the return value was ignored in the init path. If the clock cannot be
enabled (including -EPROBE_DEFER), the driver continues and may access
the controller/PHY in an undefined state.

Also check dwc3_ti_init() return value on resume when power/context was
lost.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 31d500c2d0d4 ("usb: dwc3: dwc3-am62: Re-initialize controller if lost power in PM suspend")
Signed-off-by: Votokina Victoria <Victoria.Votokina@kaspersky.com>
---
 drivers/usb/dwc3/dwc3-am62.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/dwc3/dwc3-am62.c b/drivers/usb/dwc3/dwc3-am62.c
index e11d7643f966..d8b35098e921 100644
--- a/drivers/usb/dwc3/dwc3-am62.c
+++ b/drivers/usb/dwc3/dwc3-am62.c
@@ -205,7 +205,9 @@ static int dwc3_ti_init(struct dwc3_am62 *am62)
 
 	dwc3_ti_writel(am62, USBSS_PHY_CONFIG, reg);
 
-	clk_prepare_enable(am62->usb2_refclk);
+	ret = clk_prepare_enable(am62->usb2_refclk);
+	if (ret)
+		return dev_err_probe(am62->dev, ret, "failed to enable usb2_refclk\n");
 
 	/* Set mode valid bit to indicate role is valid */
 	reg = dwc3_ti_readl(am62, USBSS_MODE_CONTROL);
@@ -361,14 +363,17 @@ static int dwc3_ti_resume_common(struct device *dev)
 {
 	struct dwc3_am62 *am62 = dev_get_drvdata(dev);
 	u32 reg;
+	int ret;
 
 	reg = dwc3_ti_readl(am62, USBSS_DEBUG_CFG);
 	if (reg != USBSS_DEBUG_CFG_DISABLED) {
 		/* lost power/context */
-		dwc3_ti_init(am62);
+		return dwc3_ti_init(am62);
 	} else {
+		ret = clk_prepare_enable(am62->usb2_refclk);
+		if (ret)
+			return ret;
 		dwc3_ti_writel(am62, USBSS_DEBUG_CFG, USBSS_DEBUG_CFG_OFF);
-		clk_prepare_enable(am62->usb2_refclk);
 	}
 
 	if (device_may_wakeup(dev)) {
-- 
2.43.0


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

end of thread, other threads:[~2026-02-14  0:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-04 14:11 [PATCH] usb: dwc3: am62: handle usb2_refclk enable failures Votokina Victoria
2026-02-10  0:30 ` Thinh Nguyen
2026-02-10  9:36   ` Votokina Victoria
2026-02-10 10:15     ` Greg KH
2026-02-14  0:07     ` Thinh Nguyen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®