All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: xiaoxiao_li <lxxstone@gmail.com>
Cc: hminas@synopsys.com, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] usb: dwc2: exit clock_gating when stopping udc caused deadlock
Date: Wed, 11 Mar 2026 15:17:40 +0100	[thread overview]
Message-ID: <2026031116-canine-blimp-94ae@gregkh> (raw)
In-Reply-To: <20260310080000.3164692-1-lxxstone@gmail.com>

On Tue, Mar 10, 2026 at 04:00:00PM +0800, xiaoxiao_li wrote:
> dwc2_gadget_exit_clock_gating invoke call_gadget to hold hsotg->lock,
> causing dwc2_hsotg_ep_disable_lock unable to acquire the lock,
> lead to a deadlock.
> 
> To ensure that enabling clock gating before stopping UDC does not
> cause the deadlock, we lock exit_clock_gating using
> spin_lock_irqsave and spin_unlock_irqrestore.
> 
> Signed-off-by: xiaoxiao_li <lxxstone@gmail.com>

Please use your real name for your From: and Signed-off-by: line.


> ---
>  drivers/usb/dwc2/gadget.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
> index d216e26c7..c8b02c27d 100644
> --- a/drivers/usb/dwc2/gadget.c
> +++ b/drivers/usb/dwc2/gadget.c
> @@ -4607,7 +4607,9 @@ static int dwc2_hsotg_udc_stop(struct usb_gadget *gadget)
>  	/* Exit clock gating when driver is stopped. */
>  	if (hsotg->params.power_down == DWC2_POWER_DOWN_PARAM_NONE &&
>  	    hsotg->bus_suspended && !hsotg->params.no_clock_gating) {
> +		spin_lock_irqsave(&hsotg->lock, flags);
>  		dwc2_gadget_exit_clock_gating(hsotg, 0);
> +		spin_unlock_irqrestore(&hsotg->lock, flags);

If the call to dwc2_gadget_exit_clock_gating() wants the lock, how will
calling it outside of it fix the problem?  I'm confused by your
changelog text, what am I missing here?  And what changed to cause this
to not work properly?

thanks,

greg k-h

  reply	other threads:[~2026-03-11 14:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-10  8:00 [PATCH] usb: dwc2: exit clock_gating when stopping udc caused deadlock xiaoxiao_li
2026-03-11 14:17 ` Greg KH [this message]
2026-04-10  3:36   ` xiaoxiao_li

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=2026031116-canine-blimp-94ae@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=hminas@synopsys.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=lxxstone@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.