net: pse-pd: Fix enabled status mismatch
Subsystems (3)
Kory Maincent
maintainerPATCH 1/1 net: pse-pd: Fix enabled status mismatch
PSE controllers like the TPS23881 can forcefully turn off their configuration state. In such cases, the is_enabled() and get_status() callbacks will report the PSE as disabled, while admin_state_enabled will show it as enabled. This mismatch can lead the user to attempt to enable it, but no action is taken as admin_state_enabled remains set.
The solution is to disable the PSE before enabling it, ensuring the actual status matches admin_state_enabled.
---
FYI: Saving the enabled state in the driver is not a viable solution, as a reboot may cause a mismatch between the real and software-saved states.
--- drivers/net/pse-pd/pse_core.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/net/pse-pd/pse_core.c +11 -0
@@ -785,6 +785,17 @@ static int pse_ethtool_c33_set_config(struct pse_control *psec,*/ switch (config->c33_admin_control) {case ETHTOOL_C33_PSE_ADMIN_STATE_ENABLED : +/* We could have mismatch between admin_state_enabled and +* state reported by regulator_is_enabled. This can occur when +* the PI is forcibly turn off by the controller. Call +* regulator_disable on that case to fix the counters state. +*/ +if (psec->pcdev->pi[psec->id].admin_state_enabled && + !regulator_is_enabled (psec->ps)) { + err =regulator_disable (psec->ps); +if (err) +break ; + }if (!psec->pcdev->pi[psec->id].admin_state_enabled) err =regulator_enable (psec->ps);break ;
Signature · 1 line
2.34.1
Quoted 9 lines · Kory Maincent
PSE controllers like the TPS23881 can forcefully turn off their configuration state. In such cases, the
is_enabled()andget_status()callbacks will report the PSE as disabled, whileadmin_state_enabledwill show it as enabled. This mismatch can lead the user to attempt to enable it, but no action is taken asadmin_state_enabledremains set.The solution is to disable the PSE before enabling it, ensuring the actual status matches
admin_state_enabled.
Quoted 6 lines
Fixes d83e13761d5b ("net: pse-pd: Use regulator framework within PSE framework")Signed-off-by Kory Maincent <[email protected]>---
FYI: Saving the enabled state in the driver is not a viable solution, as a reboot may cause a mismatch between the real and software-saved states.
This seems O.K. to me.
I'm assuming the controller has turned the configuration state to off to stop the magic smoke escaping? Is there any sort of notification of this? Does it raise an interrupt? Sometime in the future we might want to add a netlink notification about this?
Andrew
Kory Maincent
maintainerQuoted 17 lines · On Wed, 2 Oct 2024 14:38:19 +0200 Andrew Lunn <[email protected]> wrote:
Quoted 9 lines · Kory Maincent
PSE controllers like the TPS23881 can forcefully turn off their configuration state. In such cases, the
is_enabled()andget_status()callbacks will report the PSE as disabled, whileadmin_state_enabledwill show it as enabled. This mismatch can lead the user to attempt to enable it, but no action is taken asadmin_state_enabledremains set.The solution is to disable the PSE before enabling it, ensuring the actual status matches
admin_state_enabled.Quoted 6 lines
Fixes d83e13761d5b ("net: pse-pd: Use regulator framework within PSEframework") Signed-off-by: Kory Maincent <[email protected]>
---FYI: Saving the enabled state in the driver is not a viable solution, as a reboot may cause a mismatch between the real and software-saved states.
Quoted 6 lines
This seems O.K. to me.
I'm assuming the controller has turned the configuration state to off to stop the magic smoke escaping? Is there any sort of notification of this? Does it raise an interrupt? Sometime in the future we might want to add a netlink notification about this?
Thanks for your review!
Yes, in case of over-current or over-temperature, there is an interrupt. The netlink notifications support will arrive soon in the series in progress.
Regards,
Signature · 3 lines
Köry Maincent, Bootlin Embedded Linux and kernel engineering https://bootlin.com
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Wed, 2 Oct 2024 14:17:05 +0200 you wrote:
PSE controllers like the TPS23881 can forcefully turn off their configuration state. In such cases, the
is_enabled()andget_status()callbacks will report the PSE as disabled, whileadmin_state_enabledwill show it as enabled. This mismatch can lead the user to attempt to enable it, but no action is taken asadmin_state_enabledremains set.The solution is to disable the PSE before enabling it, ensuring the actual status matches
admin_state_enabled.[...]
Here is the summary with links:
- [net] net: pse-pd: Fix enabled status mismatch
https://git.kernel.org/netdev/net/c/dda3529d2e84
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html