From: netdev-bot+sashiko@kernel.org
To: github@szelinsky.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, horms@kernel.org,
broonie@kernel.org, lgirdwood@gmail.com,
maxime.chevallier@bootlin.com, kyle.swenson@est.tech,
ross@r-sc.ca, netdev-bot+sashiko@kernel.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net v5 06/14] net: pse-pd: check the PI state under the lock when setting a power limit
Date: Fri, 20 Nov 2026 06:41:50 +0000 [thread overview]
Message-ID: <179515691045.3136.13671979747174463292@kernel.org> (raw)
In-Reply-To: <20261118183957.2031311-7-github@szelinsky.de>
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 0 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [High] The patch moves the PI-state check into
pse_pi_update_pw_budget(), under pcdev->lock, but the predicate is…
--
net: pse-pd: check the PI state under the lock when setting a power limit
This patch moves the "PI is enabled and has a PD detected" check from
pse_ethtool_set_pw_limit() into pse_pi_update_pw_budget(), so it runs
under pcdev->lock. It also adds an updated flag, so the rollback after a
failed regulator_set_current_limit() only runs when the budget was
actually changed.
> diff --git a/drivers/net/pse-pd/pse_core.c b/drivers/net/pse-pd/pse_core.c
> index b8cba6f86a7fd..342fb27e38319 100644
> --- a/drivers/net/pse-pd/pse_core.c
> +++ b/drivers/net/pse-pd/pse_core.c
[ ... ]
> /* We don't want pw_allocated_mW value change in the middle of an
> * power budget update
> */
> mutex_lock(&pcdev->lock);
> + /* Only a PI under software power control that is enabled and has a
> + * PD detected gets a budget. Check this here, as pse_isr() changes
> + * it under the same lock.
> + */
> + if (!pse_pw_d_is_sw_pw_control(pcdev, pi->pw_d) ||
> + !pi->admin_state_enabled || !pi->isr_pd_detected)
> + goto out;
> +
[Severity: High]
The check now runs under the lock. Is admin_state_enabled &&
isr_pd_detected enough to show that the PI is powered and has a budget?
pse_pi_is_admin_enable_pending() describes a state where both flags are
set but the PI is off in hardware and pw_allocated_mW is 0:
pse_pi_is_admin_enable_pending() {
if (!pcdev->pi[id].admin_state_enabled ||
!pcdev->pi[id].isr_pd_detected)
return false;
ret = pse_pi_is_hw_enabled(pcdev, id);
if (ret == 1)
return false;
return true;
}
It looks like this state can be reached without any race:
- On classification, pse_set_config_isr() sets isr_pd_detected = true.
If the static allocation then fails, it turns -ERANGE into 0.
pse_pi_enable() also sets admin_state_enabled = 1 on -ERANGE.
- pse_disable_pi_pol()->_pse_pi_disable() sheds a lower priority PI and
frees its budget, but leaves both flags set.
- If ops->pi_enable() fails after the budget was allocated, the budget
is freed but the flags stay set.
In that state, pse_ethtool_set_pw_limit()->pse_pi_update_pw_budget()
passes the new check. pw_diff = pw_limit - 0 is positive, so
regulator_request_power_budget() is called and pi->pw_allocated_mW =
pw_limit is recorded for a port that is not powered.
The voltage == 0 early return in pse_ethtool_set_pw_limit() doesn't
seem to stop this on tps23881, because tps23881_pi_get_voltage() reads
the controller input voltage.
Later, pse_ethtool_set_prio() calls pse_pw_d_retry_power_delivery(), as
does the disable or disconnect of another PI in the same domain. That
function picks exactly these admin enable pending PIs:
pse_pw_d_retry_power_delivery()
_pse_pi_delivery_power_sw_pw_ctrl()
pse_pi_allocate_pw_budget_static_prio()
pse_pi_allocate_pw_budget_static_prio() then requests pw_req again and
does:
pi->pw_allocated_mW = pw_req;
return 0;
It does not free the reservation made by set_pw_limit first. Doesn't
this leak the power budget on the supply until the controller is bound
again? That is the same leak the commit message describes.
Until that retry runs, shedding can't reclaim the reservation either:
pse_disable_pi_prio() skips PIs where pse_pi_is_hw_enabled() <= 0. As a
result, powered ports could be shed or refused power.
The later patches in the series, such as "use each PI's own supply
handle for the power budget", only change the supply handle in these
functions. The predicate and the overwrite still appear to be there at
the end of the series.
Would it work to check under the lock that the PI is actually powered
or budgeted, for example pse_pi_is_hw_enabled(pcdev, id) == 1 or
pw_allocated_mW != 0? Another option is for
pse_pi_allocate_pw_budget_static_prio() to free an existing
pw_allocated_mW before overwriting it.
> previous_pw_allocated = pi->pw_allocated_mW;
> pw_diff = pw_req - previous_pw_allocated;
> if (!pw_diff) {
[ ... ]
> @@ -1846,6 +1859,7 @@ static int pse_pi_update_pw_budget(struct pse_controller_dev *pcdev, int id,
> regulator_free_power_budget(pi->pw_d->supply, -pw_diff);
> }
> pi->pw_allocated_mW = pw_req;
> + *updated = true;
> ret = previous_pw_allocated;
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261118183957.2031311-1-github%40szelinsky.de
next prev parent reply other threads:[~2026-11-20 6:41 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 18:39 [PATCH net v5 00/14] net: pse-pd: assorted lifetime and error-path fixes Carlo Szelinsky
2026-11-18 18:39 ` [PATCH net v5 01/14] net: pse-pd: size the notification kfifo after defaulting nr_lines Carlo Szelinsky
2026-11-18 18:39 ` [PATCH net v5 02/14] net: pse-pd: remove dead pi_get_admin_state() checks Carlo Szelinsky
2026-11-18 18:39 ` [PATCH net v5 03/14] net: pse-pd: fix module refcount leak in pse_control_get_internal() Carlo Szelinsky
2026-11-18 18:39 ` [PATCH net v5 04/14] net: pse-pd: do not keep a failed IRQ in pcdev->irq Carlo Szelinsky
2026-11-20 6:41 ` netdev-bot+sashiko
2026-11-20 8:32 ` Carlo Szelinsky
2026-11-18 18:39 ` [PATCH net v5 05/14] net: pse-pd: do not reach a freed PHY from the notification worker Carlo Szelinsky
2026-11-20 6:41 ` netdev-bot+sashiko
2026-11-20 8:33 ` Carlo Szelinsky
2026-11-18 18:39 ` [PATCH net v5 06/14] net: pse-pd: check the PI state under the lock when setting a power limit Carlo Szelinsky
2026-11-20 6:41 ` netdev-bot+sashiko [this message]
2026-11-20 8:33 ` Carlo Szelinsky
2026-11-20 9:32 ` Kory Maincent
2026-11-20 10:08 ` Carlo Szelinsky
2026-11-18 18:39 ` [PATCH net v5 07/14] net: pse-pd: do not tie a shared power domain to its creator's devres Carlo Szelinsky
2026-11-20 6:41 ` netdev-bot+sashiko
2026-11-20 8:33 ` Carlo Szelinsky
2026-11-18 18:39 ` [PATCH net v5 08/14] net: pse-pd: stop async event sources before freeing PI data in unregister Carlo Szelinsky
2026-11-20 6:41 ` netdev-bot+sashiko
2026-11-20 8:33 ` Carlo Szelinsky
2026-11-18 18:39 ` [PATCH net v5 09/14] net: pse-pd: unregister from the controller list before freeing PI data Carlo Szelinsky
2026-11-18 18:39 ` [PATCH net v5 10/14] net: pse-pd: keep the PI data until the PI regulators are gone Carlo Szelinsky
2026-11-18 18:39 ` [PATCH net v5 11/14] net: pse-pd: free the notification kfifo when registration fails Carlo Szelinsky
2026-11-18 18:39 ` [PATCH net v5 12/14] net: pse-pd: use each PI's own supply handle for the power budget Carlo Szelinsky
2026-11-18 18:39 ` [PATCH net v5 13/14] net: pse-pd: pd692x0: release the manager power budget through devres Carlo Szelinsky
2026-11-18 18:39 ` [PATCH net v5 14/14] net: pse-pd: pd692x0: defer probe while a manager supply is unresolved Carlo Szelinsky
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=179515691045.3136.13671979747174463292@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=broonie@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=github@szelinsky.de \
--cc=horms@kernel.org \
--cc=kory.maincent@bootlin.com \
--cc=kuba@kernel.org \
--cc=kyle.swenson@est.tech \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maxime.chevallier@bootlin.com \
--cc=netdev@vger.kernel.org \
--cc=o.rempel@pengutronix.de \
--cc=pabeni@redhat.com \
--cc=ross@r-sc.ca \
/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.