The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Kyle Tso <kyletso@google.com>
Cc: Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"raychi@google.com" <raychi@google.com>,
	"badhri@google.com" <badhri@google.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"royluo@google.com" <royluo@google.com>,
	"bvanassche@acm.org" <bvanassche@acm.org>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: Re: [PATCH v1] usb: dwc3: core: Defer the probe until USB power supply ready
Date: Wed, 15 Jan 2025 01:23:29 +0000	[thread overview]
Message-ID: <20250115012319.td2wh6jwv6q3ujda@synopsys.com> (raw)
In-Reply-To: <20250114141607.2091154-1-kyletso@google.com>

On Tue, Jan 14, 2025, Kyle Tso wrote:
> Currently, DWC3 driver attempts to acquire the USB power supply only
> once during the probe. If the USB power supply is not ready at that
> time, the driver simply ignores the failure and continues the probe,
> leading to permanent non-functioning of the gadget vbus_draw callback.
> 
> Address this problem by delaying the dwc3 driver initialization until
> the USB power supply is registered.
> 
> Fixes: 6f0764b5adea ("usb: dwc3: add a power supply for current control")
> Cc: stable@vger.kernel.org
> Signed-off-by: Kyle Tso <kyletso@google.com>
> ---
> Note: This is a follow-up of https://urldefense.com/v3/__https://lore.kernel.org/all/20240804084612.2561230-1-kyletso@google.com/__;!!A4F2R9G_pg!ZTwcKSid-i7kN4_N622H1QDeC3jzi0uCKRqjzrTNStFGr8guMe3xY0EF30CnGGPyBK25ZCGgUc_Wg3koxwqa$ 
> ---
>  drivers/usb/dwc3/core.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index 7578c5133568..1550c39e792a 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -1669,7 +1669,7 @@ static void dwc3_get_software_properties(struct dwc3 *dwc)
>  	}
>  }
>  
> -static void dwc3_get_properties(struct dwc3 *dwc)
> +static int dwc3_get_properties(struct dwc3 *dwc)

It doesn't make sense for dwc3_get_properties() to return -EPROBE_DEFER.

>  {
>  	struct device		*dev = dwc->dev;
>  	u8			lpm_nyet_threshold;
> @@ -1724,7 +1724,7 @@ static void dwc3_get_properties(struct dwc3 *dwc)
>  	if (ret >= 0) {
>  		dwc->usb_psy = power_supply_get_by_name(usb_psy_name);
>  		if (!dwc->usb_psy)
> -			dev_err(dev, "couldn't get usb power supply\n");
> +			return dev_err_probe(dev, -EPROBE_DEFER, "couldn't get usb power supply\n");
>  	}

Move this logic (including power_supply_get_by_name()) outside of
dwc3_get_properties(). It doesn't belong here.

Thanks,
Thinh

>  
>  	dwc->has_lpm_erratum = device_property_read_bool(dev,
> @@ -1847,6 +1847,8 @@ static void dwc3_get_properties(struct dwc3 *dwc)
>  	dwc->imod_interval = 0;
>  
>  	dwc->tx_fifo_resize_max_num = tx_fifo_resize_max_num;
> +
> +	return 0;
>  }
>  
>  /* check whether the core supports IMOD */
> @@ -2181,7 +2183,9 @@ static int dwc3_probe(struct platform_device *pdev)
>  	dwc->regs	= regs;
>  	dwc->regs_size	= resource_size(&dwc_res);
>  
> -	dwc3_get_properties(dwc);
> +	ret = dwc3_get_properties(dwc);
> +	if (ret)
> +		return ret;
>  
>  	dwc3_get_software_properties(dwc);
>  
> -- 
> 2.47.1.688.g23fc6f90ad-goog
> 

      reply	other threads:[~2025-01-15  1:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-14 14:16 [PATCH v1] usb: dwc3: core: Defer the probe until USB power supply ready Kyle Tso
2025-01-15  1:23 ` 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=20250115012319.td2wh6jwv6q3ujda@synopsys.com \
    --to=thinh.nguyen@synopsys.com \
    --cc=badhri@google.com \
    --cc=bvanassche@acm.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=kyletso@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=raychi@google.com \
    --cc=royluo@google.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