Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Hyunjung Ko <hj351016@gmail.com>
Cc: Kevin Cernekee <cernekee@gmail.com>,
	Neill Kapron <nkapron@google.com>, Felipe Balbi <balbi@ti.com>,
	Sebastian Andrzej Siewior <sebastian@breakpoint.cc>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH] usb: gadget: bcm63xx_udc: don't sleep under spinlock in udc_stop
Date: Fri, 20 Nov 2026 15:24:35 +0100	[thread overview]
Message-ID: <2026112019-gesture-crawling-0b54@gregkh> (raw)
In-Reply-To: <20261111072310.3005580-1-hj351016@gmail.com>

On Wed, Nov 11, 2026 at 04:23:10PM +0900, Hyunjung Ko wrote:
> bcm63xx_udc_stop() clears udc->driver and then calls msleep(100) plus the
> PHY/clock teardown while still holding udc->lock, which is taken with
> spin_lock_irqsave(). Sleeping in that atomic context triggers "BUG:
> scheduling while atomic" (and a CONFIG_DEBUG_ATOMIC_SLEEP splat) when the
> gadget driver is unbound.
> 
> The lock is only needed to clear udc->driver, which serializes against the
> interrupt handler. The settle delay and the bcm63xx_select_phy_mode() /
> set_clocks() teardown only touch hardware and are already called without
> the lock during init, so drop the lock right after clearing udc->driver
> and run the sleep and teardown unlocked.
> 
> Fixes: 613065e53cb1 ("usb: gadget: bcm63xx UDC driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: Hyunjung Ko <hj351016@gmail.com>
> ---
>  drivers/usb/gadget/udc/bcm63xx_udc.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/gadget/udc/bcm63xx_udc.c b/drivers/usb/gadget/udc/bcm63xx_udc.c
> index ba91b1ebbf57..269063d19f10 100644
> --- a/drivers/usb/gadget/udc/bcm63xx_udc.c
> +++ b/drivers/usb/gadget/udc/bcm63xx_udc.c
> @@ -1847,8 +1847,8 @@ static int bcm63xx_udc_stop(struct usb_gadget *gadget)
>  	unsigned long flags;
>  
>  	spin_lock_irqsave(&udc->lock, flags);
> -
>  	udc->driver = NULL;
> +	spin_unlock_irqrestore(&udc->lock, flags);

Why is a lock needed to write a single atomic value?

thanks,

greg k-h

      reply	other threads:[~2026-11-20 14:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-11  7:23 [PATCH] usb: gadget: bcm63xx_udc: don't sleep under spinlock in udc_stop Hyunjung Ko
2026-11-20 14:24 ` Greg Kroah-Hartman [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=2026112019-gesture-crawling-0b54@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=balbi@ti.com \
    --cc=cernekee@gmail.com \
    --cc=hj351016@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=nkapron@google.com \
    --cc=sebastian@breakpoint.cc \
    --cc=stable@vger.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