回复: [EXT] Re: [PATCH 5/6] usb: dwc3: gadget: Add delay after software writes DCTL in dwc3_gadget_run_stop()
    Alice Guo 
    alice.guo at nxp.com
       
    Thu Oct  9 12:23:41 CEST 2025
    
    
  
> -----邮件原件-----
> 发件人: Mattijs Korpershoek <mkorpershoek at kernel.org>
> 发送时间: 2025年9月29日 16:47
> 收件人: Alice Guo (OSS) <alice.guo at oss.nxp.com>; Stefano Babic
> <sbabic at nabladev.com>; Fabio Estevam <festevam at gmail.com>; dl-uboot-imx
> <uboot-imx at nxp.com>; Tom Rini <trini at konsulko.com>; Peng Fan
> <peng.fan at nxp.com>; Troy Kisky <troy.kisky at boundarydevices.com>; Adrian
> Alonso <adrian.alonso at nxp.com>; Lukasz Majewski <lukma at denx.de>; Mattijs
> Korpershoek <mkorpershoek at kernel.org>; Marek Vasut <marex at denx.de>;
> tharvey at gateworks.com; Alice Guo <alice.guo at nxp.com>
> 抄送: u-boot at lists.denx.de
> 主题: [EXT] Re: [PATCH 5/6] usb: dwc3: gadget: Add delay after software writes
> DCTL in dwc3_gadget_run_stop()
>
> [Some people who received this message don't often get email from
> mkorpershoek at kernel.org. Learn why this is important at
> https://aka.ms/LearnAboutSenderIdentification ]
>
> Caution: This is an external email. Please take care when clicking links or
> opening attachments. When in doubt, report the message using the 'Report this
> email' button
>
>
> Hi Alice,
>
> Thank you for the patch.
>
> On Sun, Jul 20, 2025 at 06:13, "Alice Guo (OSS)" <alice.guo at oss.nxp.com>
> wrote:
>
> > From: Alice Guo <alice.guo at nxp.com>
> >
> > When using NXP UUU to download flash.bin to i.MX95 19x19 evk board, it
> > will get stuck in a loop at sdp_init() without this change.
> >
> > Signed-off-by: Alice Guo <alice.guo at nxp.com>
>
> I see that a similar change exist in the Linux kernel:
> https://lore.kern/
> el.org%2Fall%2F20220901193625.8727-4-quic_wcheng%40quicinc.com%2F&da
> ta=05%7C02%7Calice.guo%40nxp.com%7Cde74c5250f024fa4c9ec08ddff34c0a
> d%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C6389473242115893
> 33%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAu
> MDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C
> %7C&sdata=8Ao4tOmcMSKHtoniiVTwP40Jwg54lz342KP0JHUKwA8%3D&reserv
> ed=0
>
> Please mention this change in the commit message for v2.
> See the following example:
> https://lore.kern/
> el.org%2Fall%2F20250110-dwc2-dev-v4-7-987f4fd6f8b2%40pigmoral.tech%2F&
> data=05%7C02%7Calice.guo%40nxp.com%7Cde74c5250f024fa4c9ec08ddff34c
> 0ad%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C63894732421162
> 6416%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjA
> uMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7
> C%7C&sdata=MtXqSueNAZ6GfiOxdnt%2BH6IUWabL3JDe01m8IKJpMy0%3D&r
> eserved=0
>
> > ---
> >  drivers/usb/dwc3/gadget.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> > index 2b01113d54c..6b2b25c7aa5 100644
> > --- a/drivers/usb/dwc3/gadget.c
> > +++ b/drivers/usb/dwc3/gadget.c
> > @@ -1423,6 +1423,7 @@ static int dwc3_gadget_run_stop(struct dwc3 *dwc,
> int is_on, int suspend)
> >       }
> >
> >       dwc3_writel(dwc->regs, DWC3_DCTL, reg);
> > +     mdelay(2);
>
> Can you elaborate on why 1ms is not enough?
>
Hi Mattijs,
This patch I submitted was indeed inspired by the change you mentioned in the Linux kernel. The mdelay(2) value was determined empirically during testing on our development board.
However, after a deeper understanding of the driver, I believe the real root cause is that the USB3 PHY was not properly initialized. When DWC3 is configured to DWC3_DSTS_SUPERSPEED in dwc3_gadget_start(), enumeration fails because the PHY is not ready and cannot complete the electrical and protocol-level handshake required by USB 3.0. The delay acts as a workaround to compensate for the missing hardware initialization or timing issues. Once the PHY driver (phy-imx8mq-usb.c) is added and properly initializes the USB3 PHY, the delay is no longer needed.
The updated changes are included in the patchset titled "Enable USB and ENETC on i.MX943 EVK", specifically in patch 6 and patch 7:
https://patchwork.ozlabs.org/project/uboot/patch/20250923-usbnetc-v1-6-507cddbe7214@oss.nxp.com/
https://patchwork.ozlabs.org/project/uboot/patch/20250923-usbnetc-v1-7-507cddbe7214@oss.nxp.com/
Thanks for the feedback!
Best regards,
Alice Guo
    
    
More information about the U-Boot
mailing list