aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKory Maincent <kory.maincent@bootlin.com>2024-10-02 14:17:05 +0200
committerJakub Kicinski <kuba@kernel.org>2024-10-04 13:14:18 -0700
commitdda3529d2e84e2ee7b97158c9cdf5e10308f37bc (patch)
tree1a3870a56f742245f917929e5e669128ede292ab
parentselftests: net: no_forwarding: fix VID for $swp2 in one_bridge_two_pvids() test (diff)
downloadlinux-rng-dda3529d2e84e2ee7b97158c9cdf5e10308f37bc.tar.xz
linux-rng-dda3529d2e84e2ee7b97158c9cdf5e10308f37bc.zip
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. Fixes: d83e13761d5b ("net: pse-pd: Use regulator framework within PSE framework") Signed-off-by: Kory Maincent <kory.maincent@bootlin.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Link: https://patch.msgid.link/20241002121706.246143-1-kory.maincent@bootlin.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
-rw-r--r--drivers/net/pse-pd/pse_core.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/net/pse-pd/pse_core.c b/drivers/net/pse-pd/pse_core.c
index 4f032b16a8a0..f8e6854781e6 100644
--- a/drivers/net/pse-pd/pse_core.c
+++ b/drivers/net/pse-pd/pse_core.c
@@ -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;