imx8mm/imx8mn hang on usb stop / ehci_shutdown

Tim Harvey tharvey at gateworks.com
Thu Apr 27 19:14:40 CEST 2023


On Wed, Mar 15, 2023 at 3:01 PM Tim Harvey <tharvey at gateworks.com> wrote:
>
> Greetings,
>
> I'm seeing a hang on imx8mm-venice and imx8mn-venice boards which have
> a USB host controller in host mode when ehci_shutdown() is called
> (which is called for 'usb stop' as well as when booting a kernel once
> 'usb start' has been issued).
>
> This appears to be caused by the ehci_shutdown() function,
> specifically the write to the or_portsc register to set EHCI_PS_SUSP:
>                 for (i = 0; i < max_ports; i++) {
>                         reg = ehci_readl(&ctrl->hcor->or_portsc[i]);
>                         reg |= EHCI_PS_SUSP;
>                         ehci_writel(&ctrl->hcor->or_portsc[i], reg);
>                 }
>
> Does anyone else out there with an imx8mm/imx8mn board with usbotg1 or
> usbotg2 configured with dr_mode="host" see this as well?
>
> I'm not clear where the equivalent code would be in the Linux kernel
> to compare with. I do know that commenting out the ehcI_write above
> keeps ehci_shutdown from hanging but does cause the handshake to fail
> on the next cmd that disables CMD_RUN and thus prints "EHCI failed to
> shut down host controller.".
>
> Any ideas?
>
> Best Regards,
>
> Tim

I haven't heard any response here so I did some more digging. This
hang should be affecting all imx8mm/imx8mn devices that have USB host
controllers configured for host mode (dr_mode = "host") and would
appear for anyone that ever does a 'usb stop' (or does a 'usb start'
followed by a kernel boot for example of loading kernel from USB) in
U-Boot.

The issue is caused by the pgc_otg{1,2} and/or pgc_hsiomix power
domains getting disabled for the 'usb_hub' device (which is present
for the USB host even if you have no hub) prior to ehci_shutdown being
called.

The following patch resolves this but I'm thinking there should be a
better way to control this from ehci-mx6.c?

diff --git a/common/usb_hub.c b/common/usb_hub.c
index 85c0822d8b7b..03237deaa0be 100644
--- a/common/usb_hub.c
+++ b/common/usb_hub.c
@@ -948,7 +948,7 @@ U_BOOT_DRIVER(usb_generic_hub) = {
        .name   = "usb_hub",
        .id     = UCLASS_USB_HUB,
        .of_match = usb_hub_ids,
-       .flags  = DM_FLAG_ALLOC_PRIV_DMA,
+       .flags  = DM_FLAG_ALLOC_PRIV_DMA | DM_FLAG_LEAVE_PD_ON,
 };


Best Regards,

Tim


More information about the U-Boot mailing list