[PATCH] usb: dwc2: fix fifo reinit in dwc2_hsotg_core_init_disconnected

From: Fabrice Gasnier

Date: Wed Oct 14 2026 - 05:01:21 EST


Currently, the fifo gets re-init, with a running DMA, e.g. when
using_desc_dma():
- dwc2_hsotg_init_fifo -> Flushes the FIFO, DMA may run in parallel
- DCFG_DESCDMA_EN gets cleared (e.g. disables dma desc)
- then DCFG_DESCDMA_EN gets set back again.

So move the dwc2_hsotg_init_fifo() call after DCFG_DESCDMA_EN gets
cleared e.g. DCFG write. Then the FIFO can be flushed safely, before
DCFG_DESCDMA_EN is set back on.

A BNA interrupt may happen on EP0, before this change. When it happens
we can't recover to a working device.

Fixes: 5b7d70c6dbf2 ("USB: Gadget driver for Samsung HS/OtG block")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Fabrice Gasnier <fabrice.gasnier@xxxxxxxxxxx>
---
drivers/usb/dwc2/gadget.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 102169b40419..3851166c9d9e 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -3422,8 +3422,6 @@ void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg *hsotg,

dwc2_phy_init(hsotg, true);

- dwc2_hsotg_init_fifo(hsotg);
-
if (!is_usb_reset) {
dwc2_set_bit(hsotg, DCTL, DCTL_SFTDISCON);
if (hsotg->params.eusb2_disc)
@@ -3451,6 +3449,8 @@ void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg *hsotg,

dwc2_writel(hsotg, dcfg, DCFG);

+ dwc2_hsotg_init_fifo(hsotg);
+
/* Clear any pending OTG interrupts */
dwc2_writel(hsotg, 0xffffffff, GOTGINT);


---
base-commit: 24a19b953e2a3d0ea5a8c4951a0ab8f32720c907
change-id: 20261014-dwc2-fix-fifo-reinit-0ebecf721d81

Best regards,
--
Fabrice Gasnier <fabrice.gasnier@xxxxxxxxxxx>