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

Alan Stern
2025-06-09T13:54:48Z

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.

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.

Alan Stern