The host interrupts are re-enabled in dwc2_hcd_reinit(). So there is a race during resume between a possible hcd IRQ, and the HW accessible bit to be set. This can result in a bad_irq to be reported (nobody cared). Note dwc2_hcd_reinit() "Must be called with interrupt disabled and spinlock held." So, move dwc2_hcd_reinit() and the glocal irq enabling inside the critical section, after HCD_FLAG_HW_ACCESSIBLE has been set. Fixes: ef5e0eec4764 ("usb: dwc2: Add clock gating exiting flow by system resume") Cc: stable@vger.kernel.org Signed-off-by: Fabrice Gasnier --- Note it's been found while debugging with additional mdelay after dwc2_hcd_reinit() call. --- Changes in v4: - Address Sashiko comment "usb: dwc2: unlocked dwc2_hcd_reinit() call in _dwc2_hcd_resume()": rather move the dwc2_hcd_reinit() and irq enabling under the critical section, after HCD_FLAG_HW_ACCESSIBLE has been set. - Update commit msg. Changes in v3: - Introduce this patch since debug session (since sashiko comment on patch 1) --- drivers/usb/dwc2/hcd.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index 3f9adfa7c630..7e4202c145f2 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -4515,15 +4515,14 @@ static int _dwc2_hcd_resume(struct usb_hcd *hcd) * the global interrupts are disabled. */ 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_enable_global_interrupts(hsotg); + dwc2_hcd_reinit(hsotg); break; default: hsotg->lx_state = DWC2_L0; -- 2.43.0