Linux USB
 help / color / mirror / Atom feed
From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Elson Serrao <elson.serrao@oss.qualcomm.com>
Cc: Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"jack.pham@oss.qualcomm.com" <jack.pham@oss.qualcomm.com>,
	"wesley.cheng@oss.qualcomm.com" <wesley.cheng@oss.qualcomm.com>
Subject: Re: [PATCH v3] usb: dwc3: avoid probe deferral when USB power supply is not available
Date: Sat, 6 Jun 2026 01:15:44 +0000	[thread overview]
Message-ID: <aiNz8jjwt_oxIILz@vbox> (raw)
In-Reply-To: <20260605181142.1925832-1-elson.serrao@oss.qualcomm.com>

On Fri, Jun 05, 2026, Elson Serrao wrote:
> The dwc3 driver currently defers probe if the USB power supply is not yet
> registered. On some platforms, even though charging and power supply
> functionality is available during normal operation, there may exist
> minimal booting modes (such as recovery or diagnostic environments) where
> the relevant USB power supply device is not registered. In such cases,
> probe deferral prevents USB gadget operation entirely.
> 
> USB data functionality for basic operation does not inherently depend on
> the power supply framework, which is only required for enforcing VBUS
> current control. The configured VBUS current limit is typically enforced
> through the charger or PMIC power path. When charging functionality is
> unavailable, applying a current limit has no practical effect, reducing
> the benefit of strict probe-time enforcement in these environments.
> 
> Instead of deferring probe, register a power supply notifier when the
> USB power supply is not yet available. Cache the requested VBUS current
> limit and apply it once the matching power supply becomes available, as
> notified through the registered callback.
> 
> Signed-off-by: Elson Serrao <elson.serrao@oss.qualcomm.com>
> ---
> Changes in v3:
>  - Introduced DWC3_CURRENT_UNSPECIFIED macro to replace UINT_MAX for
>    improved code readability.
>  - Enhanced dwc3_gadget_vbus_draw() to return success when power supply
>    is expected but not ready yet, and only return -EOPNOTSUPP when truly
>    not supported.
>  - Link to v2: https://urldefense.com/v3/__https://lore.kernel.org/all/20260526183016.3501307-1-elson.serrao@oss.qualcomm.com/__;!!A4F2R9G_pg!egKWg179wv3MYHggzavFR-zdG3Gq6GJjN6GBi2AglShH2RXQxXHLGjTHEt0gzdZjdg_cIyWWawXOKJlhFaJKUFkM6EGLbF1z$ 
> 
> Changes in v2:
>  - Removed notifier unregistration from the vbus_draw work function to
>    avoid a race with remove callback.
>  - Added an early psy registration check in the notifier callback.
>  - Moved power supply registration check after notifier registration
>    in dwc3_get_usb_power_supply() to address the race identified in v1.
>  - Link to v1: https://urldefense.com/v3/__https://lore.kernel.org/all/20260407232410.4101455-1-elson.serrao@oss.qualcomm.com/__;!!A4F2R9G_pg!egKWg179wv3MYHggzavFR-zdG3Gq6GJjN6GBi2AglShH2RXQxXHLGjTHEt0gzdZjdg_cIyWWawXOKJlhFaJKUFkM6JWOc-1o$ 
> ---
>  drivers/usb/dwc3/core.c   | 99 +++++++++++++++++++++++++++++++++------
>  drivers/usb/dwc3/core.h   |  6 +++
>  drivers/usb/dwc3/gadget.c | 15 +++++-
>  3 files changed, 104 insertions(+), 16 deletions(-)
> 

[...]

> diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
> index e0dee9d28740..d722d3f1402a 100644
> --- a/drivers/usb/dwc3/core.h
> +++ b/drivers/usb/dwc3/core.h
> @@ -677,6 +677,8 @@
>  /* Force Gen1 speed on Gen2 link */
>  #define DWC3_LLUCTL_FORCE_GEN1		BIT(10)
>  
> +#define DWC3_CURRENT_UNSPECIFIED	UINT_MAX

Would be nice if we can place this macro right under the current_limit
field of the dwc3 struct.

But I know it's minor and not a blocker for this patch, so feel free to
ignore this comment if you think it's not worth the change.

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

Thanks,
Thinh

      reply	other threads:[~2026-06-06  1:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-05 18:11 [PATCH v3] usb: dwc3: avoid probe deferral when USB power supply is not available Elson Serrao
2026-06-06  1:15 ` 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=aiNz8jjwt_oxIILz@vbox \
    --to=thinh.nguyen@synopsys.com \
    --cc=elson.serrao@oss.qualcomm.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jack.pham@oss.qualcomm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=wesley.cheng@oss.qualcomm.com \
    /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