On 01.12.26 00:47, netd…@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue(s) to consider.
>
> Critical: 0 · High: 0 · Medium: 1 · 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] In drivers/net/pse-pd/realtek-pse-mcu-core.c,
> rtpse_mcu_register() now forces the MCU into mode 0x02, "dynamic, with…
>
> --
>
> net: pse-pd: realtek-pse-mcu: ensure MCU does dynamic power management
>
> This commit adds a SET_POWER_MGMT_MODE command to both dialects: 0x17
> for Gen1 and 0x10 for Gen2. rtpse_mcu_register() issues it to put the
> MCU into dynamic power management with port priority (mode 0x02). Probe
> fails if the command fails, and the mode is selected before the
> disable-ports GPIO is deasserted.
>
>> diff --git a/drivers/net/pse-pd/realtek-pse-mcu-core.c b/drivers/net/pse-pd/realtek-pse-mcu-core.c
>> index c70b09ca20122..e382045932e9e 100644
>> --- a/drivers/net/pse-pd/realtek-pse-mcu-core.c
>> +++ b/drivers/net/pse-pd/realtek-pse-mcu-core.c
> [ ... ]
>
>> @@ -369,6 +373,26 @@ static int rtpse_mcu_set_global_state(struct rtpse_mcu_ctrl *pse, bool enable)
>> return (resp.payload[0] == 0x0) ? 0 : -EIO;
>> }
>>
>> +static int rtpse_mcu_set_power_mgmt_mode(struct rtpse_mcu_ctrl *pse)
>> +{
>> + struct rtpse_mcu_msg req, resp;
>> + const struct rtpse_mcu_opcode *opc;
>> + int ret;
>> +
>> + opc = &pse->dialect->opcode[RTPSE_MCU_CMD_SET_POWER_MGMT_MODE];
>> + if (!opc->valid)
>> + return -EOPNOTSUPP;
>> +
>> + rtpse_mcu_msg_init(&req, opc->op);
>> + req.payload[0] = RTPSE_MCU_POWER_MGMT_DYNAMIC_PRIO;
> [Severity: Medium]
> Is the global power budget that this mode checks against ever set?
>
> This function writes only the mode byte. enum rtpse_mcu_cmd has no
> budget command, and neither the Gen1 nor the Gen2 opcode table maps
> one. In the Gen1 command family, 0x18 (next to 0x17) is the set global
> power budget command.
>
> The only budget reference in the driver is in rtpse_mcu_register():
>
> pse->pcdev.supp_budget_eval_strategies = PSE_BUDGET_EVAL_STRAT_DYNAMIC;
>
> pse.h says PSE_BUDGET_EVAL_STRAT_DYNAMIC compares "the current
> consumption per ports compared to the total power budget". It also
> says this mode "is managed by the PSE controller". pse_core does not do
> its own budget accounting for this strategy.
>
> If a board's firmware defaults to a non-managed mode, the MCU used to
> ignore its stored budget. With this patch, every probe makes the MCU
> enforce whatever budget the firmware holds.
>
> If that budget is below the real supply, or zero, could PDs be refused
> or shed? If it is above what the PSU can deliver, could the PSU be
> over-committed?
>
> The commit message says the driver should "ensure that the MCU performs
> dynamic power management with priorities as advertised". Should the
> budget also be programmed here, or at least read back and logged, so
> that the policy is actually established?
The concern is correct but I would reduce its importance.
The majority of switches already come with a good default configuration.
This change targets a few devices which for whatever reason ship with
IIRC mode 'None', preventing any power delivery. Still, they have a power
budget configured. So when this is set as the patch intends, the MCU will
do the dynamic budgeting with the configured budget.
I cannot exclude that there are devices which both have a power management
mode of 'None' by default and also a bad/zero budget defined. Probably it
exists but no-one has seen it so far, only either isolated case.
This was sent as a separate fix from [1] following the Sashiko suggestion.
It also seems to affect more devices than having to provide a global budget.
I plan to update the global budget on net-next too, this appears to me rather
as a new feature than a fix worth to backport.
If anyone favor having those patches together on either net or net-next,
please say so.
>> +
>> + ret = rtpse_mcu_do_xfer(pse, &req, &resp);
>> + if (ret)
>> + return ret;
>> +
>> + return (resp.payload[0] == 0x0) ? 0 : -EIO;
>> +}
> [ ... ]
>
[1] https://lore.kernel.org/all/2026…@jonasjelonek.de/
Best,
Jonas