From: sashiko-bot@kernel.org
To: "Fabrice Gasnier" <fabrice.gasnier@foss.st.com>
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH v3 2/6] usb: dwc2: fix a possible interrupt storm in hcd resume
Date: Fri, 06 Nov 2026 17:57:48 +0000 [thread overview]
Message-ID: <sashiko-outbox-201980@kernel.org> (raw)
In-Reply-To: <20261106-dwc2-low-power-fixes-stm32-v3-2-68d2a0e9bab6@foss.st.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] usb: dwc2: unlocked dwc2_hcd_reinit() call in
_dwc2_hcd_resume()
--
commit 57723fb6e396e93ffaf40174f532484ee2100bb5
Author: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
usb: dwc2: fix a possible interrupt storm in hcd resume
This commit moves set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags) before
dwc2_hcd_reinit() in _dwc2_hcd_resume() so that host interrupts enabled
during reinitialization are not rejected as unhandled.
> diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
> index d5275cd658d4c..28cde15e0cca4 100644
> --- a/drivers/usb/dwc2/hcd.c
> +++ b/drivers/usb/dwc2/hcd.c
> @@ -4469,14 +4469,14 @@ static int _dwc2_hcd_resume(struct usb_hcd *hcd)
> */
> dwc2_core_init(hsotg, false);
> dwc2_enable_global_interrupts(hsotg);
> - dwc2_hcd_reinit(hsotg);
> - spin_lock_irqsave(&hsotg->lock, flags);
>
> /*
> * Set HW accessible bit before powering on the controller
> * since an interrupt may rise.
> */
> set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
> + dwc2_hcd_reinit(hsotg);
> + spin_lock_irqsave(&hsotg->lock, flags);
> break;
[Severity: Medium]
Should spin_lock_irqsave(&hsotg->lock, flags) be acquired before setting
HCD_FLAG_HW_ACCESSIBLE and calling dwc2_hcd_reinit(hsotg)?
dwc2_hcd_reinit() requires interrupts disabled and hsotg->lock held, as
its only other caller _dwc2_hcd_start() does:
drivers/usb/dwc2/hcd.c:dwc2_hcd_reinit() {
/*
* Initializes dynamic portions of the DWC_otg HCD state
*
* Must be called with interrupt disabled and spinlock held
*/
static void dwc2_hcd_reinit(struct dwc2_hsotg *hsotg)
}
With HCD_FLAG_HW_ACCESSIBLE now set before dwc2_hcd_reinit(hsotg) while
interrupts are enabled and hsotg->lock is unlocked, a host interrupt can
enter usb_hcd_irq() -> _dwc2_hcd_irq() -> dwc2_handle_hcd_intr() (or a
concurrent caller can take hsotg->lock) while dwc2_hcd_reinit() is
modifying hsotg->flags.d32, hsotg->free_hc_list, channel states, and host
registers:
_dwc2_hcd_resume()
dwc2_enable_global_interrupts(hsotg)
set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)
dwc2_hcd_reinit(hsotg)
list_del_init(&chan->hc_list_entry)
<hardirq>
usb_hcd_irq()
_dwc2_hcd_irq()
dwc2_handle_hcd_intr() <-- races on hsotg state and lists
spin_lock_irqsave(&hsotg->lock, flags)
Neither set_bit() nor dwc2_hcd_reinit() sleeps, so acquiring hsotg->lock
before enabling global interrupts, setting HCD_FLAG_HW_ACCESSIBLE, and
calling dwc2_hcd_reinit() would avoid this race.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261106-dwc2-low-power-fixes-stm32-v3-0-68d2a0e9bab6@foss.st.com?part=2
next prev parent reply other threads:[~2026-11-06 17:57 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-06 17:38 [PATCH v3 0/6] usb: dwc2: fix low power issues found on stm32mp1 Fabrice Gasnier
2026-11-06 17:38 ` [PATCH v3 1/6] usb: dwc2: fix recovery after PM domain off Fabrice Gasnier
2026-11-06 18:16 ` sashiko-bot
2026-11-06 17:38 ` [PATCH v3 2/6] usb: dwc2: fix a possible interrupt storm in hcd resume Fabrice Gasnier
2026-11-06 17:57 ` sashiko-bot [this message]
2026-11-06 17:38 ` [PATCH v3 3/6] usb: dwc2: fix a possible interrupt storm on stm32mp1 Fabrice Gasnier
2026-11-06 17:45 ` sashiko-bot
2026-11-06 17:38 ` [PATCH v3 4/6] usb: dwc2: hcd: fix possible successive vbus supply enables Fabrice Gasnier
2026-11-06 18:08 ` sashiko-bot
2026-11-06 17:38 ` [PATCH v3 5/6] usb: dwc2: hcd: don't disable/enable external vbus by system suspend/resume Fabrice Gasnier
2026-11-06 17:57 ` sashiko-bot
2026-11-06 17:38 ` [PATCH v3 6/6] usb: dwc2: platform: fix stm32mp15 detection logic power management Fabrice Gasnier
2026-11-06 18:05 ` sashiko-bot
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=sashiko-outbox-201980@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=fabrice.gasnier@foss.st.com \
--cc=linux-usb@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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