[lvc-project] [PATCH] usb: dwc3: am62: handle usb2_refclk enable failures

Thinh Nguyen Thinh.Nguyen at synopsys.com
Tue Feb 10 03:30:36 MSK 2026


On Wed, Feb 04, 2026, Votokina Victoria wrote:
> 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.

What's the actual error here that you encountered? Or is this a
hypothesis/static check?

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

This changes the current logic. This is wrong. How did you test this.

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

This does more than what's described in the commit. Please explain.

BR,
Thinh

>  	}
>  
>  	if (device_may_wakeup(dev)) {
> -- 
> 2.43.0
> 


More information about the lvc-project mailing list