mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Myeonghun Pak <mhun512@gmail.com>
Cc: Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Roger Quadros <rogerq@kernel.org>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Ijae Kim <ae878000@gmail.com>
Subject: Re: [PATCH] usb: dwc3-am62: shut down refclk on remove
Date: Wed, 23 Sep 2026 00:21:55 +0000	[thread overview]
Message-ID: <arMa4Y1_iTQJg3FA@vbox> (raw)
In-Reply-To: <20260913012620.13593-1-mhun512@gmail.com>

On Sat, Sep 12, 2026, Myeonghun Pak wrote:
> dwc3_ti_remove() relies on pm_runtime_put_sync() to invoke the
> runtime-suspend callback and disable the USB2 reference clock.  The
> callback is not guaranteed to run: autosuspend may defer it, and a
> reference held by pm_runtime_forbid() keeps the usage count above zero.
> The following pm_runtime_disable() then cancels pending work while the
> clock remains enabled.
> 
> Balance only the reference acquired by remove without requesting a suspend,
> then disable runtime PM to drain any operation in progress.  Disable the
> clock explicitly when the stable runtime status shows that the device was
> not already suspended.  This also handles CONFIG_PM=n, where the runtime-PM
> calls are stubs, without double-disabling the clock after a failed resume.
> 
> This issue was identified during our ongoing static-analysis research while
> reviewing kernel code.
> 
> Fixes: 6661befe4100 ("usb: dwc3-am62: fix module unload/reload behavior")
> Assisted-by: OpenAI:GPT-5.6
> Co-developed-by: Ijae Kim <ae878000@gmail.com>
> Signed-off-by: Ijae Kim <ae878000@gmail.com>
> Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
> ---
>  drivers/usb/dwc3/dwc3-am62.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/dwc3/dwc3-am62.c b/drivers/usb/dwc3/dwc3-am62.c
> index 632634d6e..2fb9e088f 100644
> --- a/drivers/usb/dwc3/dwc3-am62.c
> +++ b/drivers/usb/dwc3/dwc3-am62.c
> @@ -319,9 +319,11 @@ static void dwc3_ti_remove(struct platform_device *pdev)
>  	reg &= ~USBSS_MODE_VALID;
>  	dwc3_ti_writel(am62, USBSS_MODE_CONTROL, reg);
>  
> -	pm_runtime_put_sync(dev);
> +	pm_runtime_put_noidle(dev);
>  	pm_runtime_disable(dev);
>  	pm_runtime_dont_use_autosuspend(dev);
> +	if (!pm_runtime_status_suspended(dev))
> +		clk_disable_unprepare(am62->usb2_refclk);
>  	pm_runtime_set_suspended(dev);
>  }
>  
> -- 
> 2.47.1
> 

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

Please also add Cc stable.

Thanks,
Thinh

      reply	other threads:[~2026-09-23  0:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-13  1:26 Myeonghun Pak
2026-09-23  0:21 ` Thinh Nguyen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=arMa4Y1_iTQJg3FA@vbox \
    --to=thinh.nguyen@synopsys.com \
    --cc=ae878000@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mhun512@gmail.com \
    --cc=rogerq@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®