[PATCH] usb: gadget: dwc2: reset endpoint enabled state on reinit
Patrice Chotard
patrice.chotard at foss.st.com
Tue Jun 16 14:57:56 CEST 2026
Issue found with STM32MP157C-DK2 board, first usage of "ums 0 mmc 0"
is working, but second execution doesn't. The mass storage is not visible
from host side.
Since commit 59310d1ecb9f ("usb: gadget: introduce 'enabled' flag
in struct usb_ep"), usb_ep_enable() returns early when ep->enabled is
already set.
The DWC2 UDC driver reinitializes its endpoint software state in
udc_reinit(), including descriptor, stopped state and request queues, but
it leaves the generic usb_ep.enabled flag untouched. After stopping UMS
once, endpoints can therefore still look enabled to the gadget core even
though the DWC2 endpoint state has been reset.
On the next "ums 0 mmc 0" run, usb_ep_enable() skips the controller
enable callback, so the host no longer sees a usable USB mass-storage
device.
Clear ep->ep.enabled together with the rest of the DWC2 endpoint state so
each new gadget run programs the hardware endpoints again.
Tested on STM32MP157c-dk2 board.
Fixes: 59310d1ecb9f ("usb: gadget: introduce 'enabled' flag in struct usb_ep")
Signed-off-by: Patrice Chotard <patrice.chotard at foss.st.com>
---
drivers/usb/gadget/dwc2_udc_otg.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/usb/gadget/dwc2_udc_otg.c b/drivers/usb/gadget/dwc2_udc_otg.c
index e475b14b9ac..5752bf3ca70 100644
--- a/drivers/usb/gadget/dwc2_udc_otg.c
+++ b/drivers/usb/gadget/dwc2_udc_otg.c
@@ -209,6 +209,7 @@ static void udc_reinit(struct dwc2_udc *dev)
ep->desc = 0;
ep->stopped = 0;
+ ep->ep.enabled = false;
INIT_LIST_HEAD(&ep->queue);
ep->pio_irqs = 0;
}
---
base-commit: badd97fe24dfb73b2728c26b433cabe315a27971
change-id: 20260616-ums_fix-fad8736154b6
Best regards,
--
Patrice Chotard <patrice.chotard at foss.st.com>
More information about the U-Boot
mailing list