Linux real-time development
 help / color / mirror / Atom feed
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: "André Draszik" <andre.draszik@linaro.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Badhri Jagan Sridharan <badhri@google.com>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Clark Williams <clrkwllms@kernel.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Peter Griffin <peter.griffin@linaro.org>,
	Tudor Ambarus <tudor.ambarus@linaro.org>,
	Juan Yescas <jyescas@google.com>,
	Amit Sunil Dhamne <amitsd@google.com>,
	kernel-team@android.com, linux-usb@vger.kernel.org,
	linux-rt-devel@lists.linux.dev
Subject: Re: [PATCH v2 4/4] usb: typec: tcpm/tcpci_maxim: only complain about vbus when sourcing
Date: Mon, 30 Nov 2026 13:38:00 +0100	[thread overview]
Message-ID: <aw1uKNpHqBP62jeF@black.igk.intel.com> (raw)
In-Reply-To: <20261125-max77759-wait-v2-4-9914b985c00b@linaro.org>

On Wed, Nov 25, 2026 at 12:16:58PM +0000, André Draszik wrote:
> get_vbus_regulator_handle() logs a spurious "Failed to get vbus
> regulator handle" error during probe and stores the ERR_PTR in
> chip->vbus_reg even when sourcing VBUS is not requested.
> 
> During tcpci_register_port(), tcpm_init_vbus() calls set_vbus(false,
> false) before the PMIC charger providing the vbus regulator has probed
> (the charger's power supply waits for the TCPM power supply), or on
> sink-only boards without a vbus regulator. Sink-only operation does not
> need the vbus regulator, and max_tcpci_set_vbus() already ignores
> regulator lookup failures when source is false.
> 
> Leave chip->vbus_reg untouched when regulator_get_exclusive() fails,
> return the error from get_vbus_regulator_handle() silently, and log an
> error in max_tcpci_set_vbus() only when sourcing is requested.
> 
> Fixes: 0c8935642cb0 ("usb: typec: tcpm/tcpci_maxim: deprecate WAR for setting charger mode")
> Signed-off-by: André Draszik <andre.draszik@linaro.org>

Not for stable?

thanks,

> ---
>  drivers/usb/typec/tcpm/tcpci_maxim_core.c | 26 ++++++++++++++++----------
>  1 file changed, 16 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/usb/typec/tcpm/tcpci_maxim_core.c b/drivers/usb/typec/tcpm/tcpci_maxim_core.c
> index 2e6a8906fb32..736d01694745 100644
> --- a/drivers/usb/typec/tcpm/tcpci_maxim_core.c
> +++ b/drivers/usb/typec/tcpm/tcpci_maxim_core.c
> @@ -208,15 +208,16 @@ static void process_rx(struct max_tcpci_chip *chip, u16 status)
>  
>  static int get_vbus_regulator_handle(struct max_tcpci_chip *chip)
>  {
> -	if (IS_ERR_OR_NULL(chip->vbus_reg)) {
> -		chip->vbus_reg = regulator_get_exclusive(chip->dev, "vbus");
> -		if (IS_ERR_OR_NULL(chip->vbus_reg)) {
> -			dev_err(chip->dev,
> -				"Failed to get vbus regulator handle\n");
> -			return -ENODEV;
> -		}
> -	}
> +	struct regulator *reg;
> +
> +	if (chip->vbus_reg)
> +		return 0;
>  
> +	reg = regulator_get_exclusive(chip->dev, "vbus");
> +	if (IS_ERR(reg))
> +		return PTR_ERR(reg);
> +
> +	chip->vbus_reg = reg;
>  	return 0;
>  }
>  
> @@ -224,7 +225,7 @@ static void max_tcpci_put_vbus_regulator(void *data)
>  {
>  	struct max_tcpci_chip *chip = data;
>  
> -	if (!IS_ERR_OR_NULL(chip->vbus_reg))
> +	if (chip->vbus_reg)
>  		regulator_put(chip->vbus_reg);
>  }
>  
> @@ -244,7 +245,12 @@ static int max_tcpci_set_vbus(struct tcpci *tcpci, struct tcpci_data *tdata, boo
>  		 * Regulator is not necessary for sink only applications. Return
>  		 * success in cases where sink mode is being modified.
>  		 */
> -		return source ? ret : 1;
> +		if (!source)
> +			return 1;
> +
> +		dev_err(chip->dev, "Failed to get vbus regulator: %pe\n",
> +			ERR_PTR(ret));
> +		return ret;
>  	}
>  
>  	if (source) {
> 
> -- 
> 2.56.1.831.g720f3f5937-goog

-- 
heikki

      reply	other threads:[~2026-11-30 12:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25 12:16 [PATCH v2 0/4] usb: typec: tcpm/tcpci_maxim: lockdep, wakeup and vbus regulator fixes André Draszik
2026-11-25 12:16 ` [PATCH v2 1/4] usb: typec: tcpm/tcpci_maxim: fix invalid wait context André Draszik
2026-11-25 12:16 ` [PATCH v2 2/4] usb: typec: tcpm/tcpci_maxim: init wakeup before irq André Draszik
2026-11-25 12:16 ` [PATCH v2 3/4] usb: typec: tcpm/tcpci_maxim: fix vbus regulator UAF on unbind André Draszik
2026-11-30 12:35   ` Heikki Krogerus
2026-11-25 12:16 ` [PATCH v2 4/4] usb: typec: tcpm/tcpci_maxim: only complain about vbus when sourcing André Draszik
2026-11-30 12:38   ` Heikki Krogerus [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=aw1uKNpHqBP62jeF@black.igk.intel.com \
    --to=heikki.krogerus@linux.intel.com \
    --cc=amitsd@google.com \
    --cc=andre.draszik@linaro.org \
    --cc=badhri@google.com \
    --cc=bigeasy@linutronix.de \
    --cc=clrkwllms@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jyescas@google.com \
    --cc=kernel-team@android.com \
    --cc=linux-rt-devel@lists.linux.dev \
    --cc=linux-usb@vger.kernel.org \
    --cc=peter.griffin@linaro.org \
    --cc=rostedt@goodmis.org \
    --cc=tudor.ambarus@linaro.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