From: Saranya R <saranya.r@oss.qualcomm.com>
To: Thinh.Nguyen@synopsys.com
Cc: linux-usb@vger.kernel.org, gregkh@linuxfoundation.org,
Saranya R <saranya.r@oss.qualcomm.com>
Subject: [PATCH] usb: dwc3: gadget: Fix spurious suspend event during HS link training
Date: Thu, 3 Sep 2026 16:39:47 +0530 [thread overview]
Message-ID: <20260903110947.2761354-1-saranya.r@oss.qualcomm.com> (raw)
During HS link training, a spurious DWC3_DEVICE_EVENT_SUSPEND carrying
link state U3 is fired before CONNECT_DONE completes enumeration. At
this point gadget->speed is USB_SPEED_UNKNOWN since CONNECT_DONE has
not yet run. Calling dwc3_gadget_suspend_interrupt() here triggers an
unwanted composite_suspend, causing the charger framework to drop
current to 2mA and then ramp back to 500mA on every USB connection.
Fix this by skipping suspend event processing when gadget->speed is
USB_SPEED_UNKNOWN. This precisely targets the pre-enumeration window
without affecting genuine suspend events: a real suspend at ADDRESS
state (required for BC1.2 compliance) only arrives after CONNECT_DONE
sets gadget->speed to the negotiated speed, so gadget->speed is no
longer UNKNOWN at that point.
Fixes: 4decf4060ecf ("usb: dwc3: gadget: Change condition for processing suspend event")
Signed-off-by: Saranya R <saranya.r@oss.qualcomm.com>
---
drivers/usb/dwc3/gadget.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index bfb20c3ac392..7d0d24b6c04d 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -4465,8 +4465,18 @@ static void dwc3_gadget_interrupt(struct dwc3 *dwc,
break;
case DWC3_DEVICE_EVENT_SUSPEND:
/* It changed to be suspend event for version 2.30a and above */
- if (!DWC3_VER_IS_PRIOR(DWC3, 230A))
- dwc3_gadget_suspend_interrupt(dwc, event->event_info);
+ if (!DWC3_VER_IS_PRIOR(DWC3, 230A)) {
+ /*
+ * A spurious U3 suspend event is fired during HS link
+ * training before CONNECT_DONE sets the gadget speed.
+ * Ignore it at that point to avoid triggering an unwanted
+ * composite_suspend. A genuine suspend at ADDRESS state
+ * (required for BC1.2 compliance) only arrives after
+ * CONNECT_DONE, so gadget->speed is no longer UNKNOWN then.
+ */
+ if (dwc->gadget->speed != USB_SPEED_UNKNOWN)
+ dwc3_gadget_suspend_interrupt(dwc, event->event_info);
+ }
break;
case DWC3_DEVICE_EVENT_SOF:
case DWC3_DEVICE_EVENT_ERRATIC_ERROR:
--
2.34.1
next reply other threads:[~2026-09-03 11:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-03 11:09 Saranya R [this message]
2026-09-05 0:15 ` [PATCH] usb: dwc3: gadget: Fix spurious suspend event during HS link training Thinh Nguyen
2026-09-07 10:12 ` [PATCH v2] " Saranya R
2026-09-11 23:44 ` Thinh Nguyen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260903110947.2761354-1-saranya.r@oss.qualcomm.com \
--to=saranya.r@oss.qualcomm.com \
--cc=Thinh.Nguyen@synopsys.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-usb@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox