mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: jonas@jonasjelonek.de
Cc: o.rempel@pengutronix.de, kory.maincent@bootlin.com,
	andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
	kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org,
	robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org,
	linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
	sander@svanheule.net, russell@personaltelco.net
Subject: Re: [PATCH net-next v2 3/3] net: pse-pd: realtek-pse-mcu: configure global power budget
Date: Thu, 19 Nov 2026 05:54:04 +0000	[thread overview]
Message-ID: <179506764491.3136.18101194586618488763@kernel.org> (raw)
In-Reply-To: <20261116115224.1454885-4-jonas@jonasjelonek.de>

Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] rtpse_mcu_register() (drivers/net/pse-pd/realtek-pse-mcu-
  core.c:933) gets the optional 'vmain' supply with…
- [Low] rtpse_mcu_get_global_budget_idx() (drivers/net/pse-pd/realtek-
  pse-mcu-core.c:402-422) reads the MCU's current budget/power-bank…

--

net: pse-pd: realtek-pse-mcu: configure global power budget

This patch takes the power budget of the optional vmain supply and uses
it to program the MCU's aggregate PoE limit, in 100 mW units, at the
MCU's current budget index. The budget is reserved through the regulator
core and released by a devm action. The driver uses the regulator only
for budget accounting and never enables it.

> diff --git a/drivers/net/pse-pd/realtek-pse-mcu-core.c b/drivers/net/pse-pd/realtek-pse-mcu-core.c
> index d8b6e05039397..ae58581a0dad8 100644
> --- a/drivers/net/pse-pd/realtek-pse-mcu-core.c
> +++ b/drivers/net/pse-pd/realtek-pse-mcu-core.c

[ ... ]

> @@ -393,6 +399,84 @@ static int rtpse_mcu_set_power_mgmt_mode(struct rtpse_mcu_ctrl *pse)
>  	return (resp.payload[0] == 0x0) ? 0 : -EIO;
>  }
>  
> +static int rtpse_mcu_get_global_budget_idx(struct rtpse_mcu_ctrl *pse, u8 *budget_idx)
> +{

[ ... ]

> +	if (resp.payload[4] > 0x7)
> +		return -ERANGE;
> +
> +	*budget_idx = resp.payload[4];
> +	return 0;
> +}
> +

[ ... ]

> +static int rtpse_mcu_apply_global_budget(struct rtpse_mcu_ctrl *pse,
> +					 struct regulator *vmain)
> +{

[ ... ]

> +	ret = regulator_request_power_budget(vmain, budget);
> +	if (ret)
> +		return ret;
> +	pse->requested_budget_mW = budget;
> +
> +	ret = rtpse_mcu_get_global_budget_idx(pse, &budget_idx);
> +	if (ret)
> +		return ret;
> +
> +	/* Retain the programmed MCU limit even if later probe steps fail. */
> +	return rtpse_mcu_set_global_budget(pse, budget_idx, budget_raw);
> +}

[Severity: Low]
rtpse_mcu_get_global_budget_idx() accepts payload[4] values from 0 to 7,
which suggests the MCU has up to eight budget banks. The limit is written
only to the bank that is active at probe time, and the index is never
read again. The other banks keep their firmware or EEPROM limits.

What happens if the MCU firmware switches its active bank after probe?
For example, PSU presence inputs could change on a board with redundant
or hot-plug PSUs. Would the MCU then enforce a firmware default limit
that has nothing to do with requested_budget_mW? The reservation in the
regulator core and the limit enforced in hardware would then disagree.

It isn't clear that any of the supported boards switch banks at runtime.
Programming every bank with the same static value would not obviously be
correct either. Should this limitation at least be documented?

[ ... ]

> @@ -837,6 +930,20 @@ int rtpse_mcu_register(struct rtpse_mcu_ctrl *pse)
>  		return dev_err_probe(pse->dev, -EINVAL,
>  				     "dialect for chip is incomplete\n");
>  
> +	vmain = devm_regulator_get_optional(pse->dev, "vmain");
> +	if (PTR_ERR(vmain) == -ENODEV)
> +		vmain = NULL;
> +	else if (IS_ERR(vmain))
> +		return dev_err_probe(pse->dev, PTR_ERR(vmain),
> +				     "failed to get vmain supply\n");
> +

[Severity: Low]
Here vmain is used only for budget accounting. Nothing takes an enable
reference on it. There is no regulator_enable(), and no
regulator_is_enabled() check runs before the MCU budget is programmed,
the ports are ungated and the PSE controller is registered.

The PI regulators that pse_core registers take their supply from each
PI's vpwr, not from vmain, so vmain's use_count stays at zero.

Suppose a board describes vmain-supply as a switchable regulator without
regulator-always-on, such as a regulator-fixed with an enable GPIO, or
one marked only regulator-boot-on. Would regulator_late_cleanup() then
switch the PoE rail off after boot?

drivers/regulator/core.c:regulator_late_cleanup() {
    ...
	if (rdev->use_count)
		goto unlock;
    ...
	if (have_full_constraints()) {
		...
		ret = _regulator_do_disable(rdev);
    ...
}

In that case the MCU would still believe the programmed budget is
available, and the driver would not report an error.

The commit message says:

    Use the regulator only for budget accounting, leaving the rail
    externally controlled or marked with regulator-always-on.

The binding also says the supply is used for power-budget accounting
only, so such a DT would go against the documented expectation.

Would it be worth enforcing that requirement instead of assuming it?
That could be a regulator_is_enabled() check at probe, or a
regulator_enable() call, which would be a no-op on a truly fixed rail.

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261116115224.1454885-1-jonas%40jonasjelonek.de

      reply	other threads:[~2026-11-19  5:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 11:52 [PATCH net-next v2 0/3] net: pse-pd: realtek-pse-mcu: establish power management configuration Jonas Jelonek
2026-11-16 11:52 ` [PATCH net-next v2 1/3] dt-bindings: net: pse-pd: realtek,pse-mcu: add VMAIN supply Jonas Jelonek
2026-11-16 11:52 ` [PATCH net-next v2 2/3] net: pse-pd: realtek-pse-mcu: ensure MCU does dynamic power management Jonas Jelonek
2026-11-19  5:54   ` netdev-bot+sashiko
2026-11-16 11:52 ` [PATCH net-next v2 3/3] net: pse-pd: realtek-pse-mcu: configure global power budget Jonas Jelonek
2026-11-19  5:54   ` netdev-bot+sashiko [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=179506764491.3136.18101194586618488763@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=conor+dt@kernel.org \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=edumazet@kernel.org \
    --cc=jonas@jonasjelonek.de \
    --cc=kory.maincent@bootlin.com \
    --cc=krzk+dt@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=o.rempel@pengutronix.de \
    --cc=pabeni@redhat.com \
    --cc=robh@kernel.org \
    --cc=russell@personaltelco.net \
    --cc=sander@svanheule.net \
    /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

all inboxes | Powered by JetHome®