linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* i.MX kernel hangup caused by chipidea USB gadget driver
@ 2025-06-09  5:31 Shawn Guo
  2025-06-09 11:53 ` Xu Yang
  0 siblings, 1 reply; 18+ messages in thread
From: Shawn Guo @ 2025-06-09  5:31 UTC (permalink / raw)
  To: Xu Yang, Peter Chen
  Cc: Shawn Guo, imx, linux-usb, linux-kernel, linux-arm-kernel

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

A simple way to reproduce the issue could be:

 1. Copy a big file (like 500MB) from host PC to device with scp

 2. While the file copy is ongoing, suspend & resume the device like:

    $ echo +3 > /sys/class/rtc/rtc0/wakealarm; echo mem > /sys/power/state

 3. The device will hang up there

I reproduced on the following kernels:

 - Mainline kernel
 - NXP kernel lf-6.6.y
 - NXP kernel lf-6.12.y

But NXP kernel lf-6.1.y doesn't have this problem.  I tracked it down to
Peter's commit [1] on lf-6.1.y, and found that the gadget disconnect &
connect calls got lost from suspend & resume hooks, when the commit were
split and pushed upstream.  I confirm that adding the calls back fixes
the hangup.

---8<--------------------

diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index 8a9b31fd5c89..72329a7eac4d 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -2374,6 +2374,9 @@ static void udc_suspend(struct ci_hdrc *ci)
         */
        if (hw_read(ci, OP_ENDPTLISTADDR, ~0) == 0)
                hw_write(ci, OP_ENDPTLISTADDR, ~0, ~0);
+
+       if (ci->driver && ci->vbus_active && (ci->gadget.state != USB_STATE_SUSPENDED))
+               usb_gadget_disconnect(&ci->gadget);
 }
 
 static void udc_resume(struct ci_hdrc *ci, bool power_lost)
@@ -2384,6 +2387,9 @@ static void udc_resume(struct ci_hdrc *ci, bool power_lost)
                                        OTGSC_BSVIS | OTGSC_BSVIE);
                if (ci->vbus_active)
                        usb_gadget_vbus_disconnect(&ci->gadget);
+       } else {
+               if (ci->driver && ci->vbus_active)
+                       usb_gadget_connect(&ci->gadget);
        }
 
        /* Restore value 0 if it was set for power lost check */

---->8------------------

But it's unclear to me why the hangup happens and how the change above
fix the problem.  Do you guys have any insight here?

Shawn

[1] https://github.com/reMarkable/linux-imx/commit/0791d25578cb0e46fd93ae7a3c36ff7a424f3547


^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2025-06-13  3:18 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-09  5:31 i.MX kernel hangup caused by chipidea USB gadget driver Shawn Guo
2025-06-09 11:53 ` Xu Yang
2025-06-09 13:54   ` Alan Stern
2025-06-10 10:08     ` Shawn Guo
2025-06-10 11:27     ` Xu Yang
2025-06-09 14:17   ` John Ernberg
2025-06-10  2:12     ` Peter Chen (CIX)
2025-06-10 10:17       ` Shawn Guo
2025-06-10 11:33       ` Xu Yang
2025-06-10  3:04     ` Shawn Guo
2025-06-10 15:03       ` John Ernberg
2025-06-10 11:30     ` Xu Yang
2025-06-10 15:05       ` John Ernberg
2025-06-12 13:23       ` John Ernberg
2025-06-13  3:13         ` Xu Yang
2025-06-10  9:50   ` Shawn Guo
2025-06-10 11:54     ` Xu Yang
2025-06-11  2:59       ` Shawn Guo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).