Linux USB
 help / color / mirror / Atom feed
* [PATCH] usb: dwc2: fix fifo reinit in dwc2_hsotg_core_init_disconnected
@ 2026-10-14  8:57 Fabrice Gasnier
  2026-10-14  9:05 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Fabrice Gasnier @ 2026-10-14  8:57 UTC (permalink / raw)
  To: Thinh Nguyen, Greg Kroah-Hartman, Ben Dooks
  Cc: linux-usb, linux-kernel, stable, Fabrice Gasnier

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@vger.kernel.org
Signed-off-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
---
 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@foss.st.com>


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] usb: dwc2: fix fifo reinit in dwc2_hsotg_core_init_disconnected
  2026-10-14  8:57 [PATCH] usb: dwc2: fix fifo reinit in dwc2_hsotg_core_init_disconnected Fabrice Gasnier
@ 2026-10-14  9:05 ` sashiko-bot
  0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-10-14  9:05 UTC (permalink / raw)
  To: Fabrice Gasnier; +Cc: linux-usb

> 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@vger.kernel.org
> Signed-off-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>

Sashiko has reviewed this patch and found no issues. It looks great!

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261014-dwc2-fix-fifo-reinit-v1-1-d918de90ee3a@foss.st.com?part=1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-10-14  9:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-14  8:57 [PATCH] usb: dwc2: fix fifo reinit in dwc2_hsotg_core_init_disconnected Fabrice Gasnier
2026-10-14  9:05 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox