Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796477507; b=gVb4BWg4jpu/6usFOcZKGcLrX/03B7XlmuylhtMK0u/q1jYEyiUt7Sj6ZkEkkV/YeXyt oqRZRx20pL6KTDDbm9qRFGIGAWzN1ThmPOnhBkEeQ71MDvrNd+nCrzXlryFiYPru0skmt Q5nkFGGzbFslNqDZ9NQj4s/hGLI4yGpECDhVNJxU4k4KIVVLG5z9TQDrZRxsq+1UzLVlm KQHaCaNRgZLBWTB+itZhJceyWVAVx/PaJ2hfB8T2H9+pfCuG5c5aJXp7cmwoBY91AS8Be LqwDmqqiFcTvSUSeNChwN15uuu4LY/d57jSEUXNZHvzrxDXV1UQMxmgI/jQOYBpmX7A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796477507; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=N1l+/WqgweJmkuUxBAyjVQeTmNP7PdxIPkBBTXC+cCE=; b=S0pdqEFVWec09e6jibfujx5wtYp/Mbe4dNSKY/U8fGt5t24SnPctSR2+KoA87/Qrc+Yf /OhT2clTRqPpWcrgaieeA2sRAm6Bfjqn1TRJN2ZuQQaey3P4dSX07H57TQhtDweDvRdnw tjJb649a7AeggpNI1CnsC827ddEvv5ZyskUd0MmjGSBkHJ/z+y9gsOp+4grB4LUuqEgDW GbdgvSglrzMYl+jNZw/Oj+ecyL5PwiU5VZwgRMXDIAc1rPWIZWOR1/yMH67zU9oE8nnig YCAuGr0St8Q/0xiO0iweKRSGDU5dCi3XgZAIDaMV3EeAmNq4FdrKo52bKTg5mm9l77Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=dACQnMXO; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0B244606A322 for ; Sat, 5 Dec 2026 13:31:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=dACQnMXO Received: by smtp.kernel.org (Postfix) with ESMTPSA id B6DBA1F0092B; Sat, 5 Dec 2026 13:31:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796477506; bh=N1l+/WqgweJmkuUxBAyjVQeTmNP7PdxIPkBBTXC+cCE=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=dACQnMXOyu3KJfqSINAId/jZjYXg0rImkt2gqExUq83LhGd3CmfB7UdDoMKHjLo6o yILMoy2JfQZ2pcuFJqrZq05EXg5wX/dOl3aFmlahcykmabuaZfs8mSeLjgNwMzzaDk zvfGuHPNKrcelXq9p2+PfvLJoCodFl+gdRmMWoFbIS5ooWbIRp++3YeEcvTTyV/nSw AGqoTyZmwbjr7QjXhhIe9Yw7+aoaZRkjsgqc6Y1Y6l6N+94YLe9c1iVThcp8lxHKhw /tx50Zx10KVEPzgWet177MHniEMHtXHthneY/TK+lwuXbxYipyRJWHWiLsOW8um9Ak DaE+Z1grtSiTQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v4 1/2] usb: dwc2: gadget: restart descriptor DMA isochronous OUT endpoints after BNA Reply-To: sashiko-reviews@lists.linux.dev To: "Vadim Yuzifovich" Cc: linux-usb@vger.kernel.org In-Reply-To: <20261205130225.341741-2-vadim@yuzi.co> References: <20261205130225.341741-1-vadim@yuzi.co> <20261205130225.341741-2-vadim@yuzi.co> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 05 Dec 2026 13:31:46 +0000 X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 12 potential issues to consider: - [High] usb: dwc2: unbounded BNA IRQ storm when queuing with isoc_out_drain_busy - [High] usb: dwc2: ep_disable() skips Rx FIFO drain before isoc_out_bna is set - [Medium] usb: dwc2: dwc2_gadget_isoc_out_drain() ignores budget when desc 0 busy - [Medium] usb: dwc2: drain budget exit leaves stopped isoc OUT endpoint unmasked - [Medium] usb: dwc2: missing EPENA check in dwc2_gadget_handle_out_token_ep_disabled() - [Medium] usb: dwc2: dwc2_gadget_start_isoc_ddma() marks desc 1..N-1 ready before DOEPDMA - [Medium] usb: dwc2: dma_wmb() does not flush posted DOEPDMA write before HREADY/udelay - [Medium] usb: dwc2: dwc2_gadget_start_isoc_ddma() exposes desc 1..N-1 before restart - [Medium] usb: dwc2: missing write barrier before polling desc->status after HREADY - [Medium] usb: dwc2: gadget: race between DXEPCTL_SNAK and in-flight ISOC OUT drain - [Medium] usb: dwc2: dwc2_gadget_isoc_out_drain() budget ignores fast DMA completions - [Low] usb: dwc2: trailing udelay(1) in dwc2_gadget_isoc_out_wait_packet() -- commit 80d6fd01c9d63259ec27d838061a3b843634e06e Author: Vadim Yuzifovich usb: dwc2: gadget: restart descriptor DMA isochronous OUT endpoints after B= NA This commit restarts descriptor DMA isochronous OUT endpoints directly from the BNA and endpoint-disabled handlers instead of flushing the Rx FIFO, waits for any held packet to land on descriptor 0, and drains held packets into a scratch buffer when no requests are queued or when the endpoint is disabled. > diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c > index 7ef704568e090..fdbc9677aef29 100644 > --- a/drivers/usb/dwc2/gadget.c > +++ b/drivers/usb/dwc2/gadget.c > @@ -218,6 +218,53 @@ static void dwc2_hsotg_ctrl_epint(struct dwc2_hsotg = *hsotg, > local_irq_restore(flags); > } > =20 > +static void dwc2_gadget_isoc_out_stop(struct dwc2_hsotg_ep *hs_ep) > +{ > + struct dwc2_hsotg *hsotg =3D hs_ep->parent; > + u32 epctl_reg =3D DOEPCTL(hs_ep->index); > + > + hs_ep->isoc_out_stopped =3D 1; > + dwc2_hsotg_ctrl_epint(hsotg, hs_ep->index, 0, 0); > + dwc2_writel(hsotg, dwc2_readl(hsotg, epctl_reg) | DXEPCTL_SNAK, > + epctl_reg); > +} [Severity: Medium] Can setting DXEPCTL_SNAK without waiting for an in-flight OUT packet to finish arriving leave a late packet stuck in the Rx FIFO? Unlike dwc2_hsotg_ep_stop_xfr(), both dwc2_gadget_isoc_out_stop() and dwc2_hsotg_ep_disable() only write DXEPCTL_SNAK and immediately call dwc2_gadget_isoc_out_drain(). Setting SNAK rejects future OUT tokens, but a packet already on the wire (up to ~17 us at High-Speed or ~682 us at Full-Speed) does not become visible in the Rx FIFO until EOP. If the 10 us probe in dwc2_gadget_isoc_out_drain() finishes first, it clears isoc_out_bna and returns with the endpoint masked. The late packet then sits stuck at the head of the shared Rx FIFO, stalling EP0 and other OUT endpoints, and dwc2_hsotg_ep_disable() will skip draining it because isoc_out_bna is already 0. Asserting DCTL_SGOUTNAK and waiting for GINTSTS_GOUTNAKEFF before draining would ensure any in-flight packet has landed first. [ ... ] > +static int dwc2_gadget_isoc_out_wait_packet(struct dwc2_hsotg_ep *hs_ep, > + unsigned int *waited) > +{ > + struct dwc2_dma_desc *desc =3D &hs_ep->desc_list[0]; > + int i; > + > + for (i =3D 0; i < 10; i++) { > + if (READ_ONCE(desc->status) >> DEV_DMA_BUFF_STS_SHIFT !=3D > + DEV_DMA_BUFF_STS_HREADY) > + break; > + udelay(1); > + } > + *waited +=3D i; > + if (i =3D=3D 10) > + return 0; > + > + for (i =3D 0; i < 100; i++) { > + if (READ_ONCE(desc->status) >> DEV_DMA_BUFF_STS_SHIFT =3D=3D > + DEV_DMA_BUFF_STS_DMADONE) > + break; > + udelay(1); > + } > + *waited +=3D i; > + if (i < 100) > + return 1; > + > + dev_warn_ratelimited(hs_ep->parent->dev, > + "%s: held packet not written in 100 us\n", > + hs_ep->ep.name); > + return -ETIMEDOUT; > +} [Severity: Low] Should both polling loops re-check desc->status after the final udelay(1)? On the last iteration each loop sleeps 1 us without checking whether desc->status changed during that microsecond. In the first loop, if the core claims descriptor 0 during that trailing delay, returning 0 causes dwc2_gadget_isoc_out_drain() to overwrite desc->status with HBUSY and clear isoc_out_bna while DMA owns it; in the second loop, a packet completing in the 100th microsecond is misreported as -ETIMEDOUT. Using read_poll_timeout_atomic() or checking desc->status once more after each loop avoids the unchecked window. [ ... ] > +static void dwc2_gadget_isoc_out_drain(struct dwc2_hsotg_ep *hs_ep, > + unsigned int budget) > +{ > + struct dwc2_hsotg *hsotg =3D hs_ep->parent; > + struct dwc2_dma_desc *desc =3D &hs_ep->desc_list[0]; > + u32 len =3D min_t(u32, hs_ep->ep.maxpacket, DWC2_ISOC_OUT_DRAIN_SIZE); > + u32 hbusy =3D DEV_DMA_BUFF_STS_HBUSY << DEV_DMA_BUFF_STS_SHIFT; > + unsigned int waited =3D 0; > + u32 mask =3D 0; > + int ret; > + > + if (!hs_ep->isoc_out_drain) > + return; > + if (!dwc2_gadget_isoc_out_drain_settled(hs_ep)) { > + dwc2_gadget_isoc_out_drain_retry(hs_ep); > + return; > + } [Severity: Medium] Does dwc2_gadget_isoc_out_drain() abandon the caller's budget too early when descriptor 0 is already busy or a packet times out? dwc2_gadget_isoc_out_drain_settled() does a single non-waiting read of desc->status, so if isoc_out_drain_busy is already set, dwc2_gadget_isoc_out_drain() returns after 0 us even when dwc2_hsotg_ep_disable() passes the 2000 us DWC2_ISOC_OUT_DRAIN_DISABLE_US budget. A single 100 us timeout from dwc2_gadget_isoc_out_wait_packet() below also returns immediately without using the remaining disable budget. During dwc2_hsotg_ep_disable(), dwc2_gadget_isoc_out_drain_retry() then needlessly unmasks DAINTMSK right before disable masks it again, and dwc2_gadget_bna_state_reset() overwrites desc_list[0].status with HBUSY while hardware DMA may still own descriptor 0 and packets remain stuck in the Rx FIFO. > + dwc2_gadget_get_desc_params(hs_ep, &mask); > + /* A packet may take 110 us: do not start one past the budget. */ > + while (waited + 110 <=3D budget) { > + desc->buf =3D hs_ep->isoc_out_drain_dma; > + WRITE_ONCE(desc->status, hbusy | DEV_DMA_L | > + ((len << DEV_DMA_NBYTES_SHIFT) & mask)); > + dwc2_writel(hsotg, hs_ep->desc_list_dma, DOEPDMA(hs_ep->index)); > + dma_wmb(); > + WRITE_ONCE(desc->status, (desc->status & ~DEV_DMA_BUFF_STS_MASK) | > + DEV_DMA_BUFF_STS_HREADY << DEV_DMA_BUFF_STS_SHIFT); [Severity: Medium] Is dma_wmb() sufficient to flush the posted write to DOEPDMA before descriptor 0 is marked HREADY and the 10 us wait begins? dma_wmb() provides no ordering guarantees for MMIO writes (for example on arm64, arm, or PCI/x86), and writeX() is not ordered before a subsequent udelay() loop. The same pattern appears in dwc2_gadget_start_isoc_ddma(). If the posted DOEPDMA write has not reached the controller before the 10 us poll runs, the core will not claim descriptor 0 in time, causing dwc2_gadget_isoc_out_drain() to clear isoc_out_bna with a packet still stuck in the Rx FIFO, or dwc2_gadget_start_isoc_ddma() to enable the chain with a held packet pending. Reading back DOEPDMA with dwc2_readl() before marking descriptor 0 HREADY flushes the posted write. > + ret =3D dwc2_gadget_isoc_out_wait_packet(hs_ep, &waited); [Severity: Medium] Can fast DMA completions allow dwc2_gadget_isoc_out_drain() to spin past its 200 us hardirq budget? dwc2_gadget_isoc_out_wait_packet() only adds its udelay(1) loop counts to *waited, so any packet that completes before the first udelay(1) adds 0 us, ignoring coherent descriptor accesses, MMIO writes, and barriers. With a default 2048-DWORD Rx FIFO able to buffer hundreds of short or zero-length packets, draining a backlog of fast-completing packets can spin with hsotg->lock held and interrupts disabled into the millisecond range. Bounding the loop with a ktime_get() deadline would enforce the intended budget. [ ... ] > + if (hs_ep->isoc_out_stopped) > + dwc2_hsotg_ctrl_epint(hsotg, hs_ep->index, 0, 1); > +} [Severity: Medium] Can unmasking the stopped endpoint on budget exit leave it permanently unmasked if the last held packet was just drained? If draining the last held packet takes more than 90 us, the loop exits with waited + 110 > budget without seeing ret =3D=3D 0, leaving isoc_out_bna set= and unmasking DAINTMSK without any retry cap. Because no held packet remains, the core raises OUTTKNEPDIS on every subsequent host ISOC OUT token instead of BNA. dwc2_gadget_handle_out_token_ep_disabled() then calls dwc2_gadget_start_isoc_ddma(), which sees an empty queue with again =3D=3D = false and returns without re-masking DAINTMSK or clearing isoc_out_bna, leaving the endpoint taking continuous OUTTKNEPDIS hardirqs until a request is queued or the endpoint is disabled. [ ... ] > static void dwc2_gadget_start_isoc_ddma(struct dwc2_hsotg_ep *hs_ep) > { > [ ... ] > + /* > + * Descriptor 0 still belongs to the core after a drain that timed > + * out. Try again on a later OUT token or BNA interrupt. > + */ > + if (!hs_ep->dir_in && !dwc2_gadget_isoc_out_drain_settled(hs_ep)) { > + hs_ep->target_frame =3D TARGET_FRAME_INITIAL; > + return; > + } [Severity: High] Can queuing a request while isoc_out_drain_busy is set trigger an unbounded BNA interrupt storm? When a drain times out and exhausts DWC2_ISOC_OUT_DRAIN_TRIES, the endpoint is left stopped with interrupts masked. If the function driver later queues a request, dwc2_hsotg_ep_queue() calls dwc2_gadget_isoc_out_unstop(), which clears isoc_out_stopped and unmasks DAINTMSK even though isoc_out_drain_busy is still set. On the next BNA, dwc2_gadget_isoc_out_bna_reset() sees a non-empty queue and calls dwc2_gadget_restart_isoc_out_ddma() -> dwc2_gadget_start_isoc_ddma(), which hits this early return without re-masking interrupts or checking isoc_out_drain_tries. Because the endpoint stays disabled and unmasked while the core holds a packet, BNA fires as fast as dwc2_hsotg_epint() clears DOEPINT, starving the CPU and bypassing the DWC2_ISOC_OUT_DRAIN_TRIES safeguard. [ ... ] > ret =3D dwc2_gadget_fill_isoc_desc(hs_ep, dma_addr, > - hs_req->req.length); > - if (ret) > + hs_req->req.length, > + !hs_ep->next_desc); > + /* > + * Stop when the chain is full and next_desc has wrapped: > + * descriptor 0 is still host busy here, so the next call > + * would not see the chain as full and would fill it again. > + */ > + if (ret || !hs_ep->next_desc) > break; > } [Severity: Medium] Can marking descriptors 1..N-1 host ready before resetting DOEPDMA let the core claim a descriptor other than descriptor 0 for the held packet? Only descriptor 0 is held HBUSY in this loop; descriptors 1..N-1 are marked HREADY before DOEPDMA is written with hs_ep->desc_list_dma. If a prior BNA stopped at descriptor k >=3D 1 (for instance after the 100 us held-packet timeout fallback where descriptor 0 has L cleared, or during the window in dwc2_gadget_fill_isoc_desc() between clearing L on descriptor k - 1 and marking descriptor k HREADY), the polling DMA engine can claim descriptor k while the next iteration clears DEV_DMA_L on it via a non-atomic read-modify-write. The held packet then lands in request k instead of request 0, races with the L-bit clear, and is missed when dwc2_gadget_isoc_out_held_packet() polls descriptor 0. Writing and flushing DOEPDMA after the HBUSY initialization loop and before filling descriptors 1..N-1 avoids this window. > hs_ep->compl_desc =3D 0; > depctl =3D hs_ep->dir_in ? DIEPCTL(index) : DOEPCTL(index); > dma_reg =3D hs_ep->dir_in ? DIEPDMA(index) : DOEPDMA(index); > =20 > /* write descriptor chain address to control register */ > dwc2_writel(hsotg, hs_ep->desc_list_dma, dma_reg); > =20 > + desc =3D &hs_ep->desc_list[0]; > + dma_wmb(); > + WRITE_ONCE(desc->status, (desc->status & ~DEV_DMA_BUFF_STS_MASK) | > + DEV_DMA_BUFF_STS_HREADY << DEV_DMA_BUFF_STS_SHIFT); [Severity: Medium] Is a write barrier needed after marking descriptor 0 HREADY before polling desc->status in dwc2_gadget_isoc_out_wait_packet()? Both here and in dwc2_gadget_isoc_out_drain(), dma_wmb() precedes the HREADY store to coherent DMA memory, but no wmb()/mb() or MMIO write follows it before the 10 us udelay(1) polling loop. On platforms with write-combining coherent DMA memory or outer cache store buffers (such as ARMv7 with PL310, arm64, RISC-V, or MIPS), the HREADY store can remain buffered while the CPU polls. If dwc2_gadget_isoc_out_wait_packet() falsely returns 0 as a result, dwc2_gadget_start_isoc_ddma() enables the chain with a held packet pending (reintroducing per-packet BNAs), and dwc2_gadget_isoc_out_drain() clears isoc_out_bna while packets remain stuck in the Rx FIFO. > + if (!hs_ep->dir_in && hs_ep->isoc_out_bna && !again) { > + unsigned int count =3D hs_ep->disable_count; > + > + if (dwc2_gadget_isoc_out_held_packet(hs_ep)) { > + /* > + * dwc2_hsotg_ep_disable() may have run while the lock > + * was dropped for the giveback, and the endpoint may > + * have been enabled again since. > + */ > + if (hs_ep->disable_count !=3D count) > + return; > + again =3D true; > + goto restart; > + } > + } [Severity: Medium] Can exposing descriptors 1..N-1 as HREADY with L cleared on descriptor 0 corrupt the chain when goto restart wipes all descriptors? With at least two queued requests and multiple packets buffered in the Rx FIFO (which a disabled ISOC OUT endpoint keeps accepting until NAKed), filling descriptor 1 clears DEV_DMA_L on descriptor 0 and marks descriptor 1 HREADY. While dwc2_gadget_isoc_out_held_packet() drops hsotg->lock to give back request 0, the core can advance into descriptor 1 for a second buffered packet. dwc2_gadget_complete_isoc_request_ddma() stops as soon as descriptor 1 is DMABUSY (or not yet DMADONE), and goto restart then unconditionally overwrites all descriptors with HBUSY and refills them. A subsequent DMA writeback to descriptor 1 can clobber the newly refilled descriptor status or silently drop the second packet. Even on a core that stops after descriptor 0, the !again guard handles only one held packet, leaving a second buffered packet to trigger BNA as soon as EPENA is set. [ ... ] > @@ -2947,6 +3477,15 @@ static void dwc2_gadget_handle_out_token_ep_disabl= ed(struct dwc2_hsotg_ep *ep) > /* Start first ISO Out */ > ep->target_frame =3D hsotg->frame_number; > dwc2_gadget_start_isoc_ddma(ep); > + } else if (!(dwc2_readl(hsotg, DOEPCTL(ep->index)) & > + DXEPCTL_EPENA)) { > + /* > + * The chain is taken for running, but the endpoint > + * is disabled: the core stopped it on a BNA that was > + * not handled as one, for example one seen with the > + * endpoint still enabled. Restart it as after a BNA. > + */ > + dwc2_gadget_isoc_out_bna_reset(ep, true); > } > return; > } [Severity: Medium] Should the TARGET_FRAME_INITIAL branch also verify that DXEPCTL_EPENA is clear before calling dwc2_gadget_start_isoc_ddma()? When dwc2_gadget_handle_isoc_bna() sees a BNA with EPENA still set and isoc_out_restarted clear, it resets target_frame to TARGET_FRAME_INITIAL with start =3D false to defer restarting until EPENA clears. If DXEPINT_OUTTKNEPDIS was latched in the same interrupt word, dwc2_gadget_handle_out_token_ep_disabled() runs immediately afterward and calls dwc2_gadget_start_isoc_ddma() without checking EPENA, overwriting desc_list with HBUSY and reprogramming DOEPDMA while the endpoint is still enabled in hardware. [ ... ] > @@ -4348,6 +4944,25 @@ static int dwc2_hsotg_ep_disable(struct usb_ep *ep) > =20 > ctrl =3D dwc2_readl(hsotg, epctrl_reg); > =20 > + /* > + * An isochronous OUT endpoint disabled by a BNA may still hold packets > + * at the head of the Rx FIFO, which EP0 shares, see > + * dwc2_gadget_isoc_out_drain(). Once the endpoint is gone no BNA comes > + * to drain on, so give the drain more time here. A Rx FIFO flush does > + * not help: the core holds the packet for a DMA write that waits for > + * a descriptor, and the flush waits for the AHB master to go idle. > + */ > + if (using_desc_dma(hsotg) && hs_ep->isochronous && !dir_in && > + hs_ep->isoc_out_bna && !(ctrl & DXEPCTL_EPENA)) { > + dwc2_writel(hsotg, ctrl | DXEPCTL_SNAK, epctrl_reg); > + dwc2_gadget_isoc_out_drain(hs_ep, > + DWC2_ISOC_OUT_DRAIN_DISABLE_US); > + if (hs_ep->isoc_out_bna) > + dev_warn(hsotg->dev, > + "%s: packets left in the Rx FIFO at disable\n", > + hs_ep->ep.name); > + } [Severity: High] Can dwc2_hsotg_ep_disable() skip draining held packets from the Rx FIFO when a BNA happens concurrently before hs_ep->isoc_out_bna is set? dwc2_gadget_isoc_out_bna_reset() calls dwc2_gadget_complete_isoc_request_ddma() before setting hs_ep->isoc_out_bna =3D 1, dropping hsotg->lock for the giveback: CPU0 CPU1 dwc2_hsotg_epint() clear DOEPINT (including BNAINTR) dwc2_gadget_isoc_out_bna_reset() dwc2_gadget_complete_isoc_request_ddma() spin_unlock(&hsotg->lock) dwc2_hsotg_ep_disable() isoc_out_bna =3D=3D 0 <-- skips drain disable_count++ spin_lock(&hsotg->lock) if (disable_count !=3D count) return; <-- never sets isoc_out_bna or drains The same gap occurs if dwc2_hsotg_ep_disable() runs during an XferCompl giveback when XferCompl and BNAINTR arrive in the same interrupt, or before dwc2_hsotg_epint() runs at all (for example when GINTSTS_USBRST calls dwc2_hsotg_core_init_disconnected() -> dwc2_hsotg_ep_disable() before GINTSTS_OEPINT is serviced). Undrained packets then stay at the head of the shared Rx FIFO after disable, stalling EP0 and other OUT endpoints and leaving GRSTCTL.AHBIDLE clear so subsequent core resets fail until reboot. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261205130225.3417= 41-1-vadim@yuzi.co?part=3D1