Re: i.MX kernel hangup caused by chipidea USB gadget driver

Xu Yang
2025-06-10T11:32:15Z

Hi Alan,

On Mon, Jun 09, 2025 at 09:54:45AM -0400, Alan Stern wrote:
> On Mon, Jun 09, 2025 at 07:53:22PM +0800, Xu Yang wrote:
> > Hi Shawn,
> >
> > Thanks for your reports!
> >
> > On Mon, Jun 09, 2025 at 01:31:06PM +0800, Shawn Guo wrote:
> > > Hi Xu, Peter,
> > >
> > > I'm seeing a kernel hangup on imx8mm-evk board. It happens when:
> > >
> > > - USB gadget is enabled as Ethernet
> > > - There is data transfer over USB Ethernet
> > > - Device is going in/out suspend
>
> > During the scp process, the usb host won't put usb device to suspend state.
> > In current design, then the ether driver doesn't know the system has
> > suspended after echo mem. The root cause is that ether driver is still tring
> > to queue usb request after usb controller has suspended where usb clock is off,
> > then the system hang.
> >
> > With the above changes, I think the ether driver will fail to eth_start_xmit()
> > at an ealier stage, so the issue can't be triggered.
> >
> > I think the ether driver needs call gether_suspend() accordingly, to do this,
> > the controller driver need explicitly call suspend() function when it's going
> > to be suspended. Could you check whether below patch fix the issue?
>
> The situation is more complicated than this.
>
> In general, a USB gadget cannot allow itself to be suspended while the
> USB bus it is connected to remains active. Not unless it can be set to
> wake up when a USB packet arrives, and even that probably won't work
> because the wakeup sequence would take too long and the USB transfer
> would time out on the host.

Agree with you. I always see such wakeup issue on some customer usecase.
Then I need to improve the system wakeup time to satisfy usb requirements.

>
> The best way to fix this problem is for the gadget to disconnect itself
> from the USB bus whenever it goes into suspend, and to reconnect when it
> resumes.

Okay, thanks for your suggestion! This should be the best solution. I will
do this when wakeup is not needed and will also take care of wakeup case
due to some user indeed need it.

Thanks,
Xu Yang

>
> Alan Stern