All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Oleksij Rempel" <o.rempel@pengutronix.de>
Cc: devicetree@vger.kernel.org, conor+dt@kernel.org, robh@kernel.org
Subject: Re: [PATCH net-next v1 2/2] net: dsa: realtek: rtl83xx: add support for enabling supplies
Date: Fri, 07 Aug 2026 14:02:52 +0000	[thread overview]
Message-ID: <20260807140253.628601F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260806140239.3518906-3-o.rempel@pengutronix.de>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Potential back-powering of unpowered chip during device removal or probe failure.
--

--- Patch [2]: [PATCH net-next v1 2/2] net: dsa: realtek: rtl83xx: add support for enabling supplies ---
commit bb86fcef91dead11293d5508eb30d8736c1afc82
Author: Ahmad Fatoum <a.fatoum@pengutronix.de>

net: dsa: realtek: rtl83xx: add support for enabling supplies

This commit extends the Realtek DSA driver to optionally enable power
supplies specified in the device tree. The supplies are enabled before
the reset line is driven to prevent forcing current into unpowered pins.

> diff --git a/drivers/net/dsa/realtek/rtl83xx.c b/drivers/net/dsa/realtek/rtl83xx.c
> index 35df809a59518..fb6aaaa60aa35 100644
> --- a/drivers/net/dsa/realtek/rtl83xx.c
> +++ b/drivers/net/dsa/realtek/rtl83xx.c

[ ... ]

> @@ -195,17 +215,22 @@ rtl83xx_probe(struct device *dev,
>  	priv->leds_disabled = of_property_read_bool(dev->of_node,
>  						    "realtek,disable-leds");
>  
> -	/* TODO: if power is software controlled, set up any regulators here */
> +	/* Enable the supplies before the RESET line is requested and driven,
> +	 * so the chip is powered before current is forced into its pins.
> +	 */
> +	num_supplies = rtl83xx_enable_supplies(dev, var->supplies);
> +	if (num_supplies < 0)
> +		return ERR_PTR(num_supplies);
> +
>  	priv->reset_ctl = devm_reset_control_get_optional(dev, NULL);
>  	if (IS_ERR(priv->reset_ctl))
>  		return dev_err_cast_probe(dev, priv->reset_ctl,
>  					  "failed to get reset control\n");
>  
>  	priv->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);

[Severity: High]
Does this allocation order cause the unpowered chip to be back-powered
by the SoC during driver unbind or probe failure?

Because the devm regulators are enabled before the devm reset controls are
allocated, devres will clean them up in the reverse order. The reset
control and GPIO will be released first, followed by the regulators being
disabled.

Releasing a GPIO via gpiod_put() or a reset control doesn't automatically
assert it or change it to a high-impedance input state; they remain driven
to their last active value (deasserted). Then devres disables the
regulators, leaving the switch unpowered while the SoC continues to actively
drive the reset pin.

> -	if (IS_ERR(priv->reset)) {
> -		dev_err(dev, "failed to get RESET GPIO\n");
> -		return ERR_CAST(priv->reset);
> -	}
> +	if (IS_ERR(priv->reset))
> +		return dev_err_cast_probe(dev, priv->reset,
> +					  "failed to get RESET GPIO\n");
>  
>  	dev_set_drvdata(dev, priv);
>  
> @@ -214,10 +239,13 @@ rtl83xx_probe(struct device *dev,
>  		dev_dbg(dev, "asserted RESET\n");
>  		msleep(REALTEK_HW_STOP_DELAY);
>  		rtl83xx_reset_deassert(priv);
> -		msleep(REALTEK_HW_START_DELAY);
>  		dev_dbg(dev, "deasserted RESET\n");
>  	}

Is a custom devm action (like devm_add_action_or_reset) needed here to
safely assert the reset line before the regulators are disabled on teardown?

>  
> +	/* Wait for the chip to come up only if we powered and/or reset it. */
> +	if (priv->reset_ctl || priv->reset || num_supplies)
> +		msleep(REALTEK_HW_START_DELAY);
> +
>  	return priv;
>  }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260806140239.3518906-1-o.rempel@pengutronix.de?part=2

      parent reply	other threads:[~2026-08-07 14:02 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-06 14:02 [PATCH net-next v1 0/2] net: dsa: realtek: enable RTL8365MB power supplies Oleksij Rempel
2026-08-06 14:02 ` [PATCH net-next v1 1/2] dt-bindings: net: dsa: realtek: add " Oleksij Rempel
2026-08-06 14:02 ` [PATCH net-next v1 2/2] net: dsa: realtek: rtl83xx: add support for enabling supplies Oleksij Rempel
2026-08-06 14:12   ` Andrew Lunn
2026-08-06 15:10     ` Oleksij Rempel
2026-08-06 15:35       ` Andrew Lunn
2026-08-06 15:56         ` Ahmad Fatoum
2026-08-06 17:40           ` Linus Walleij
2026-08-07  4:26             ` Oleksij Rempel
2026-08-07  6:51               ` Linus Walleij
2026-08-07  7:10                 ` Oleksij Rempel
2026-08-07  7:49                   ` Ahmad Fatoum
2026-08-07  8:20                     ` Linus Walleij
2026-08-07  8:27                       ` Ahmad Fatoum
2026-08-07 12:19                         ` Mark Brown
2026-08-07 14:05                           ` Ahmad Fatoum
2026-08-07 14:02   ` sashiko-bot [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=20260807140253.628601F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=o.rempel@pengutronix.de \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.