Netdev List
 help / color / mirror / Atom feed
* [PATCH net-next] net: pse-pd: fix bogus budget evaluation strategy check in IRQ handler
@ 2026-11-26 14:30 Kory Maincent
  2026-11-27 14:30 ` netdev-bot+sashiko
  0 siblings, 1 reply; 3+ messages in thread
From: Kory Maincent @ 2026-11-26 14:30 UTC (permalink / raw)
  To: Kory Maincent (Dent Project), Oleksij Rempel, Jakub Kicinski,
	Paolo Abeni, netdev, linux-kernel
  Cc: thomas.petazzoni, Andrew Lunn, David S. Miller, Eric Dumazet

pse_set_config_isr() wrongly tested the PSE event notification bitmask
against PSE_BUDGET_EVAL_STRAT_DYNAMIC, a budget evaluation strategy
constant that has nothing to do with event notifications.

The mistake went unnoticed because ETHTOOL_C33_PSE_EVENT_DETECTION and
PSE_BUDGET_EVAL_STRAT_DYNAMIC are both BIT(2) and, when only the
detection event is reported, the function performs no action anyway.
The check does not prevent the TPS23881 from working properly, but when
a controller reports the detection event together with other events,
the whole notification handling is skipped instead of processed.

Remove this bogus check.

Fixes: ffef61d6d2737 ("net: pse-pd: Add support for budget evaluation strategies")
Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
---
Found this issue while developing the support for the TPS23861 version of
the controller.

As the TPS23881 driver (the only user of this path) works fine with this
bogus check, I am sending the fix to net-next.

If any developer of the SUIE or Sashiko passes by, I would like to point
out that all my PSE patches and fixes are registered under the DENT
company, which is wrong as I am not working for them anymore.
---
 drivers/net/pse-pd/pse_core.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/net/pse-pd/pse_core.c b/drivers/net/pse-pd/pse_core.c
index a3d4a3d7e5257..59cc0dcfa2a4b 100644
--- a/drivers/net/pse-pd/pse_core.c
+++ b/drivers/net/pse-pd/pse_core.c
@@ -1205,9 +1205,6 @@ static int pse_set_config_isr(struct pse_controller_dev *pcdev, int id,
 {
 	int ret = 0;
 
-	if (notifs & PSE_BUDGET_EVAL_STRAT_DYNAMIC)
-		return 0;
-
 	if ((notifs & ETHTOOL_C33_PSE_EVENT_DISCONNECTION) &&
 	    ((notifs & ETHTOOL_C33_PSE_EVENT_DETECTION) ||
 	     (notifs & ETHTOOL_C33_PSE_EVENT_CLASSIFICATION))) {
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] net: pse-pd: fix bogus budget evaluation strategy check in IRQ handler
  2026-11-26 14:30 [PATCH net-next] net: pse-pd: fix bogus budget evaluation strategy check in IRQ handler Kory Maincent
@ 2026-11-27 14:30 ` netdev-bot+sashiko
  2026-11-27 14:39   ` Kory Maincent
  0 siblings, 1 reply; 3+ messages in thread
From: netdev-bot+sashiko @ 2026-11-27 14:30 UTC (permalink / raw)
  To: kory.maincent
  Cc: o.rempel, kuba, pabeni, netdev, linux-kernel, thomas.petazzoni,
	andrew+netdev, davem, edumazet

Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 2 · 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).

- [Medium] The commit message says the bogus check "does not prevent the
  TPS23881 from working properly" and sends the fix to net-next for that…
- [Medium] With the early return removed, the simultaneity check at the
  top of pse_set_config_isr() (`(notifs & DISCONNECTION) && ((notifs &…

--

net: pse-pd: fix bogus budget evaluation strategy check in IRQ handler

This patch removes a check in pse_set_config_isr() that compared the PSE
event notification mask against PSE_BUDGET_EVAL_STRAT_DYNAMIC. That
constant and ETHTOOL_C33_PSE_EVENT_DETECTION are both BIT(2). As a result,
any notification that included the detection event was skipped.

> The mistake went unnoticed because ETHTOOL_C33_PSE_EVENT_DETECTION and
> PSE_BUDGET_EVAL_STRAT_DYNAMIC are both BIT(2) and, when only the
> detection event is reported, the function performs no action anyway.
> The check does not prevent the TPS23881 from working properly, but when
> a controller reports the detection event together with other events,
> the whole notification handling is skipped instead of processed.

[Severity: Medium]
Is the statement that the check does not affect the TPS23881 accurate?

The TPS23881 is the only in-tree user of devm_pse_irq_helper().
tps23881_irq_event_handler() reads TPS23881_REG_DET_EVENT once and passes
the same value to both parsers:

drivers/net/pse-pd/tps23881.c:tps23881_irq_event_handler() {
    ...
		ret = i2c_smbus_read_word_data(client, TPS23881_REG_DET_EVENT);
		...
		val = ret;
		ret = tps23881_irq_event_detection(priv, val, notifs,
						   notifs_mask);
		...
		ret = tps23881_irq_event_classification(priv, val, notifs,
							notifs_mask);
    ...
}

Both parsers OR into the same notifs[i]. The retry loop in
tps23881_irq_handler() also collects several interrupt rounds into the
same notifs[] word. A detection-done event and a class-done event for one
port can therefore arrive together as DETECTION | CLASSIFICATION. Whether
this happens depends on hardware timing.

The TPS23881 sets supp_budget_eval_strategies to
PSE_BUDGET_EVAL_STRAT_STATIC. That makes pse_pw_d_is_sw_pw_control()
true, so pse_isr() calls pse_set_config_isr().

Before this patch, that mask hit the BIT(2) early return. The
CLASSIFICATION branch never set isr_pd_detected and never called
_pse_pi_delivery_power_sw_pw_ctrl(). No SW_PW_CONTROL_ERROR was reported
either.

Under software power control nothing else powers the port. A later admin
enable cannot recover it, because pse_pi_enable() only delivers power when
isr_pd_detected is set:

drivers/net/pse-pd/pse_core.c:pse_pi_enable() {
    ...
		if (pcdev->pi[id].isr_pd_detected) {
			struct netlink_ext_ack extack;

			ret = _pse_pi_delivery_power_sw_pw_ctrl(pcdev, id, &extack);
		}
    ...
}

The note below the cut line says the fix goes to net-next because the
TPS23881 works fine with the check. Since a classified PD on an
admin-enabled TPS23881 port could be left unpowered, should this go to net
instead, so that the Fixes: tag leads to a stable backport?

> diff --git a/drivers/net/pse-pd/pse_core.c b/drivers/net/pse-pd/pse_core.c
> index 0477cf6787bd3..ae31175921a07 100644
> --- a/drivers/net/pse-pd/pse_core.c
> +++ b/drivers/net/pse-pd/pse_core.c
> @@ -1291,9 +1291,6 @@ static int pse_set_config_isr(struct pse_controller_dev *pcdev, int id,
>  {
>  	int ret = 0;
>  
> -	if (notifs & PSE_BUDGET_EVAL_STRAT_DYNAMIC)
> -		return 0;
> -
>  	if ((notifs & ETHTOOL_C33_PSE_EVENT_DISCONNECTION) &&
>  	    ((notifs & ETHTOOL_C33_PSE_EVENT_DETECTION) ||
>  	     (notifs & ETHTOOL_C33_PSE_EVENT_CLASSIFICATION))) {

[Severity: Medium]
With the early return gone, the DETECTION part of this check can now be
reached. A DETECTION | DISCONNECTION mask used to return 0. It now
returns -EINVAL, and pse_isr() reports that to user space:

drivers/net/pse-pd/pse_core.c:pse_isr() {
    ...
			ret = pse_set_config_isr(pcdev, i, notifs);
			if (ret)
				notifs |= ETHTOOL_PSE_EVENT_SW_PW_CONTROL_ERROR;
    ...
}

Is this change to the ethtool PSE netlink notifications intended? The
commit message does not mention it.

Can the TPS23881 produce this mask?

- tps23881_irq_event_over_current() ORs in OVER_CURRENT | DISCONNECTION.
- tps23881_irq_event_detection() ORs in either DETECTION or
  DISCONNECTION, depending on the signature result.
- tps23881_irq_handler() merges several interrupt rounds into one
  notifs[] word and loses their order.

An over-current shutdown followed by re-detection could be merged this
way. So could an invalid detection followed by a valid one.

In both the old and the new code, the DISCONNECTION is then not
processed:

- _pse_pi_disable() is not called.
- The PI power budget is not released.
- isr_pd_detected stays true even though the hardware has already turned
  the port off.

A later CLASSIFICATION would then allocate budget again without freeing
the old allocation.

DETECTION on its own takes no action in pse_set_config_isr(). The
c33-pse-event-detection uAPI doc also only says that a detection process
occurred on the PSE.

Should DETECTION be dropped from this conflict check so that the
DISCONNECTION gets handled? The commit message says combined events are
now processed, but this combination still is not.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261126143012.1595919-1-kory.maincent%40bootlin.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] net: pse-pd: fix bogus budget evaluation strategy check in IRQ handler
  2026-11-27 14:30 ` netdev-bot+sashiko
@ 2026-11-27 14:39   ` Kory Maincent
  0 siblings, 0 replies; 3+ messages in thread
From: Kory Maincent @ 2026-11-27 14:39 UTC (permalink / raw)
  To: netdev-bot+sashiko
  Cc: o.rempel, kuba, pabeni, netdev, linux-kernel, thomas.petazzoni,
	andrew+netdev, davem, edumazet



On 11/27/26 15:30, netdev-bot+sashiko@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential
> issue(s) to consider.
> 
> Critical: 0 · High: 0 · Medium: 2 · 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).
> 
> - [Medium] The commit message says the bogus check "does not prevent the
>    TPS23881 from working properly" and sends the fix to net-next for that…
> - [Medium] With the early return removed, the simultaneity check at the
>    top of pse_set_config_isr() (`(notifs & DISCONNECTION) && ((notifs &…
> 
> --
> 
> net: pse-pd: fix bogus budget evaluation strategy check in IRQ handler
> 
> This patch removes a check in pse_set_config_isr() that compared the PSE
> event notification mask against PSE_BUDGET_EVAL_STRAT_DYNAMIC. That
> constant and ETHTOOL_C33_PSE_EVENT_DETECTION are both BIT(2). As a result,
> any notification that included the detection event was skipped.
> 
>> The mistake went unnoticed because ETHTOOL_C33_PSE_EVENT_DETECTION and
>> PSE_BUDGET_EVAL_STRAT_DYNAMIC are both BIT(2) and, when only the
>> detection event is reported, the function performs no action anyway.
>> The check does not prevent the TPS23881 from working properly, but when
>> a controller reports the detection event together with other events,
>> the whole notification handling is skipped instead of processed.
> 
> [Severity: Medium]
> Is the statement that the check does not affect the TPS23881 accurate?

...

> The note below the cut line says the fix goes to net-next because the
> TPS23881 works fine with the check. Since a classified PD on an
> admin-enabled TPS23881 port could be left unpowered, should this go to net
> instead, so that the Fixes: tag leads to a stable backport?

I didn't face any issue with the TPS23881 driver but I am only testing 
it on my desk, so I may have miss issue with it.

>> diff --git a/drivers/net/pse-pd/pse_core.c b/drivers/net/pse-pd/pse_core.c
>> index 0477cf6787bd3..ae31175921a07 100644
>> --- a/drivers/net/pse-pd/pse_core.c
>> +++ b/drivers/net/pse-pd/pse_core.c
>> @@ -1291,9 +1291,6 @@ static int pse_set_config_isr(struct pse_controller_dev *pcdev, int id,
>>   {
>>   	int ret = 0;
>>   
>> -	if (notifs & PSE_BUDGET_EVAL_STRAT_DYNAMIC)
>> -		return 0;
>> -
>>   	if ((notifs & ETHTOOL_C33_PSE_EVENT_DISCONNECTION) &&
>>   	    ((notifs & ETHTOOL_C33_PSE_EVENT_DETECTION) ||
>>   	     (notifs & ETHTOOL_C33_PSE_EVENT_CLASSIFICATION))) {
> 
> [Severity: Medium]
> With the early return gone, the DETECTION part of this check can now be
> reached. A DETECTION | DISCONNECTION mask used to return 0. It now
> returns -EINVAL, and pse_isr() reports that to user space:
> 
> drivers/net/pse-pd/pse_core.c:pse_isr() {
>      ...
> 			ret = pse_set_config_isr(pcdev, i, notifs);
> 			if (ret)
> 				notifs |= ETHTOOL_PSE_EVENT_SW_PW_CONTROL_ERROR;
>      ...
> }
> 
> Is this change to the ethtool PSE netlink notifications intended? The
> commit message does not mention it.

Yes it is.

> Can the TPS23881 produce this mask?
> 
> - tps23881_irq_event_over_current() ORs in OVER_CURRENT | DISCONNECTION.
> - tps23881_irq_event_detection() ORs in either DETECTION or
>    DISCONNECTION, depending on the signature result.
> - tps23881_irq_handler() merges several interrupt rounds into one
>    notifs[] word and loses their order.
> 
> An over-current shutdown followed by re-detection could be merged this
> way. So could an invalid detection followed by a valid one.

This is PSE core policy an what should we do if we have detection and 
disconnection event from the driver on the same interrupt. So it is not 
related to this fix.

Anyway I think we should keep the warning in the core and maybe do 
something in the TPS23881 driver to prevent such case. IMHO this is not 
the core to decide.

Regards,
-- 
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-27 14:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-26 14:30 [PATCH net-next] net: pse-pd: fix bogus budget evaluation strategy check in IRQ handler Kory Maincent
2026-11-27 14:30 ` netdev-bot+sashiko
2026-11-27 14:39   ` Kory Maincent

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox