[PATCH net-next 2/4] net: stmmac: add state tracking for legacy serdes power state

Russell King (Oracle) rmk+kernel at armlinux.org.uk
Tue Feb 3 02:01:19 PST 2026


Avoid calling the serdes_powerdown() method if we have not had a
preceeding successful call to the serdes_powerup() method. This
avoids unbalancing refcounted resources that may be used in the
these platform glue serdes methods.

Signed-off-by: Russell King (Oracle) <rmk+kernel at armlinux.org.uk>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac.h      | 1 +
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 +++++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
index 012b0a477255..5bd97aaaba86 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
@@ -303,6 +303,7 @@ struct stmmac_priv {
 	bool eee_enabled;
 	bool eee_active;
 	bool eee_sw_timer_en;
+	bool legacy_serdes_is_powered;
 	unsigned int mode;
 	unsigned int chain_mode;
 	int extend_desc;
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 93d18709bc13..9efdde915229 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -884,8 +884,10 @@ static void stmmac_release_ptp(struct stmmac_priv *priv)
 
 static void stmmac_legacy_serdes_power_down(struct stmmac_priv *priv)
 {
-	if (priv->plat->serdes_powerdown)
+	if (priv->plat->serdes_powerdown && priv->legacy_serdes_is_powered)
 		priv->plat->serdes_powerdown(priv->dev, priv->plat->bsp_priv);
+
+	priv->legacy_serdes_is_powered = false;
 }
 
 static int stmmac_legacy_serdes_power_up(struct stmmac_priv *priv)
@@ -898,6 +900,8 @@ static int stmmac_legacy_serdes_power_up(struct stmmac_priv *priv)
 	ret = priv->plat->serdes_powerup(priv->dev, priv->plat->bsp_priv);
 	if (ret < 0)
 		netdev_err(priv->dev, "SerDes powerup failed\n");
+	else
+		priv->legacy_serdes_is_powered = true;
 
 	return ret;
 }
-- 
2.47.3




More information about the linux-arm-kernel mailing list