From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
To: Andrew Lunn <andrew@lunn.ch>
Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
linux-arm-kernel@lists.infradead.org,
linux-stm32@st-md-mailman.stormreply.com,
Mohd Ayaan Anwar <mohd.anwar@oss.qualcomm.com>,
netdev@vger.kernel.org, Paolo Abeni <pabeni@redhat.com>
Subject: [PATCH net-next 2/4] net: stmmac: add state tracking for legacy serdes power state
Date: Tue, 03 Feb 2026 10:01:19 +0000 [thread overview]
Message-ID: <E1vnDDj-00000007Xx3-2xZ0@rmk-PC.armlinux.org.uk> (raw)
In-Reply-To: <aYHHWm5UkD1JVa7D@shell.armlinux.org.uk>
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@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
next prev parent reply other threads:[~2026-02-03 10:01 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-03 10:00 [PATCH net-next 0/4] net: stmmac: fix serdes power methods Russell King (Oracle)
2026-02-03 10:01 ` [PATCH net-next 1/4] net: stmmac: add wrappers for serdes_power[up|down]() methods Russell King (Oracle)
2026-02-03 10:01 ` Russell King (Oracle) [this message]
2026-02-03 10:01 ` [PATCH net-next 3/4] net: stmmac: add missing serdes power down in error paths Russell King (Oracle)
2026-02-03 10:01 ` [PATCH net-next 4/4] net: stmmac: move serdes power methods to stmmac_[open|release]() Russell King (Oracle)
2026-02-05 5:00 ` [PATCH net-next 0/4] net: stmmac: fix serdes power methods patchwork-bot+netdevbpf
2026-02-05 10:28 ` Mohd Ayaan Anwar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1vnDDj-00000007Xx3-2xZ0@rmk-PC.armlinux.org.uk \
--to=rmk+kernel@armlinux.org.uk \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew+netdev@lunn.ch \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=mohd.anwar@oss.qualcomm.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox