The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] usb: dwc3: am62: Propagate USB2 refclk enable failures
@ 2026-06-24  5:56 Pengpeng Hou
  2026-06-26 22:16 ` Thinh Nguyen
  0 siblings, 1 reply; 2+ messages in thread
From: Pengpeng Hou @ 2026-06-24  5:56 UTC (permalink / raw)
  To: Thinh Nguyen, Greg Kroah-Hartman; +Cc: linux-usb, linux-kernel, Pengpeng Hou

The AM62 wrapper requires the USB2 ref clock, but dwc3_ti_init() ignores
clk_prepare_enable() failures before marking the mode valid.  Probe can
then populate the child DWC3 device even though the wrapper clock
transition failed.

Resume has the same issue after context loss or direct refclk re-enable.
Check and propagate the refclk enable errors so the wrapper does not
publish or resume a child provider without parent readiness.

Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
---
 drivers/usb/dwc3/dwc3-am62.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/dwc3/dwc3-am62.c b/drivers/usb/dwc3/dwc3-am62.c
index e11d7643f966..632634d6e81e 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 ret;
 
 	/* Set mode valid bit to indicate role is valid */
 	reg = dwc3_ti_readl(am62, USBSS_MODE_CONTROL);
@@ -361,14 +363,19 @@ 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);
+		ret = dwc3_ti_init(am62);
+		if (ret)
+			return ret;
 	} else {
 		dwc3_ti_writel(am62, USBSS_DEBUG_CFG, USBSS_DEBUG_CFG_OFF);
-		clk_prepare_enable(am62->usb2_refclk);
+		ret = clk_prepare_enable(am62->usb2_refclk);
+		if (ret)
+			return ret;
 	}
 
 	if (device_may_wakeup(dev)) {
-- 
2.50.1 (Apple Git-155)


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

* Re: [PATCH] usb: dwc3: am62: Propagate USB2 refclk enable failures
  2026-06-24  5:56 [PATCH] usb: dwc3: am62: Propagate USB2 refclk enable failures Pengpeng Hou
@ 2026-06-26 22:16 ` Thinh Nguyen
  0 siblings, 0 replies; 2+ messages in thread
From: Thinh Nguyen @ 2026-06-26 22:16 UTC (permalink / raw)
  To: Pengpeng Hou
  Cc: Thinh Nguyen, Greg Kroah-Hartman, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org

On Wed, Jun 24, 2026, Pengpeng Hou wrote:
> The AM62 wrapper requires the USB2 ref clock, but dwc3_ti_init() ignores
> clk_prepare_enable() failures before marking the mode valid.  Probe can
> then populate the child DWC3 device even though the wrapper clock
> transition failed.
> 
> Resume has the same issue after context loss or direct refclk re-enable.
> Check and propagate the refclk enable errors so the wrapper does not
> publish or resume a child provider without parent readiness.
> 
> Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
> ---
>  drivers/usb/dwc3/dwc3-am62.c | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/dwc3/dwc3-am62.c b/drivers/usb/dwc3/dwc3-am62.c
> index e11d7643f966..632634d6e81e 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 ret;
>  
>  	/* Set mode valid bit to indicate role is valid */
>  	reg = dwc3_ti_readl(am62, USBSS_MODE_CONTROL);
> @@ -361,14 +363,19 @@ 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);
> +		ret = dwc3_ti_init(am62);
> +		if (ret)
> +			return ret;
>  	} else {
>  		dwc3_ti_writel(am62, USBSS_DEBUG_CFG, USBSS_DEBUG_CFG_OFF);
> -		clk_prepare_enable(am62->usb2_refclk);
> +		ret = clk_prepare_enable(am62->usb2_refclk);
> +		if (ret)
> +			return ret;
>  	}
>  
>  	if (device_may_wakeup(dev)) {
> -- 
> 2.50.1 (Apple Git-155)
> 

Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>

Thanks,
Thinh

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

end of thread, other threads:[~2026-06-26 22:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-24  5:56 [PATCH] usb: dwc3: am62: Propagate USB2 refclk enable failures Pengpeng Hou
2026-06-26 22:16 ` Thinh Nguyen

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