Linux USB
 help / color / mirror / Atom feed
From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Saranya R <saranya.r@oss.qualcomm.com>
Cc: Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: Re: [PATCH v2] usb: dwc3: gadget: Fix spurious suspend event during HS link training
Date: Fri, 11 Sep 2026 23:44:31 +0000	[thread overview]
Message-ID: <aqSSVkeFkKAVcxe1@vbox> (raw)
In-Reply-To: <20260907101236.1543438-1-saranya.r@oss.qualcomm.com>

On Mon, Sep 07, 2026, Saranya R wrote:
> 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.
> 
> Signed-off-by: Saranya R <saranya.r@oss.qualcomm.com>
> ---
> 
> v2: remove Fixes tag and add cc stable
> This issue observed on 6.12 kernel.
> 
> ---
>  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 fa944856f956..a3a59d9d92ef 100644
> --- a/drivers/usb/dwc3/gadget.c
> +++ b/drivers/usb/dwc3/gadget.c
> @@ -4540,8 +4540,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
> 

Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>

Thanks,
Thinh

      reply	other threads:[~2026-09-11 23:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-03 11:09 [PATCH] usb: dwc3: gadget: Fix spurious suspend event during HS link training Saranya R
2026-09-05  0:15 ` Thinh Nguyen
2026-09-07 10:12 ` [PATCH v2] " Saranya R
2026-09-11 23:44   ` Thinh Nguyen [this message]

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=aqSSVkeFkKAVcxe1@vbox \
    --to=thinh.nguyen@synopsys.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=saranya.r@oss.qualcomm.com \
    --cc=stable@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