[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20260124005951.fbkvd2girdqtfxe7@skbuf>
Date: Sat, 24 Jan 2026 02:59:51 +0200
From: Vladimir Oltean <olteanv@...il.com>
To: "Russell King (Oracle)" <rmk+kernel@...linux.org.uk>
Cc: Andrew Lunn <andrew@...n.ch>, Heiner Kallweit <hkallweit1@...il.com>,
Alexandre Torgue <alexandre.torgue@...s.st.com>,
Andrew Lunn <andrew+netdev@...n.ch>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
linux-arm-kernel@...ts.infradead.org, linux-arm-msm@...r.kernel.org,
linux-phy@...ts.infradead.org,
linux-stm32@...md-mailman.stormreply.com,
Maxime Chevallier <maxime.chevallier@...tlin.com>,
Maxime Coquelin <mcoquelin.stm32@...il.com>,
Mohd Ayaan Anwar <mohd.anwar@....qualcomm.com>,
Neil Armstrong <neil.armstrong@...aro.org>, netdev@...r.kernel.org,
Paolo Abeni <pabeni@...hat.com>, Vinod Koul <vkoul@...nel.org>
Subject: Re: [PATCH net-next v2 05/14] net: stmmac: add stmmac core serdes
support
On Fri, Jan 23, 2026 at 09:53:44AM +0000, Russell King (Oracle) wrote:
> Rather than having platform glue implement SerDes PHY support, add it
> to the core driver, specifically to the stmmac integrated PCS driver
> as the SerDes is connected to the integrated PCS.
>
> Platforms using external PCS can also populate plat->serdes, and the
> core driver will call phy_init() and phy_exit() when the administrative
> state of the interface changes, but the other phy methods will not be
> called.
>
> Reviewed-by: Maxime Chevallier <maxime.chevallier@...tlin.com>
> Signed-off-by: Russell King (Oracle) <rmk+kernel@...linux.org.uk>
> --
> rfc->v1: avoid calling phy_get_mode() with NULL serdes PHY
> v2: add cleanup when dwmac_serdes_set_mode() fails, because AI allegedly
> knows better than the author and phylink maintainer, even though this
> will result in dwmac_serdes_power_off() being called multiple times
> and producing a kernel warning. But if it makes AI happy, then it must
> be a good thing. It'll also make Vladimir happy.
These gratuitous passive-aggressive comments about what makes me happy,
based on twisted interpretations of conversations, are best kept to yourself.
I remember Jakub's request was only to add a note in the commit message
about the reason behind the lack of cleanup, not to add cleanup which
will be executed twice:
https://lore.kernel.org/netdev/20260120153248.0636f1e9@kernel.org/
I only expressed dissatisfaction with the phylink_pcs calling convention
as it is today, and searched for ways to make the calls balanced. I also
didn't make any suggestion to make the code worse by performing the
SerDes power down twice, just subscribed to Jakub's request to leave a
comment why your v1 is the way that it is:
https://lore.kernel.org/netdev/20260122112913.svzaie4eywk5nc32@skbuf/
Getting over that dissatisfaction and working within the framework of
the existing calling convention, but also inserting the comment that I
was looking to see, I believe that functionally correct code would look
like this (applies on top of your entire v2 patch set):
-- >8 --
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_serdes.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_serdes.c
index d46a071bc383..c4465dca6b93 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_serdes.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_serdes.c
@@ -59,12 +59,27 @@ int dwmac_serdes_power_on(struct stmmac_priv *priv)
{
int ret;
+ /* Because the dwmac_integrated_pcs_disable() call path is eventually
+ * invoked irrespective of the dwmac_integrated_pcs_enable() return
+ * code, we risk either underflowing the SerDes phy->power_count or
+ * leaving the lane powered on, depending on the cleanup choice and the
+ * point of failure. Keeping separate track of the lane power on state
+ * is a band aid until phylink offers balanced pcs_enable() and
+ * pcs_disable() calls.
+ */
+ if (priv->plat->serdes_powered_on)
+ return 0;
+
ret = phy_power_on(priv->plat->serdes);
- if (ret)
+ if (ret) {
dev_err(priv->device, "failed to power on SerDes: %pe\n",
ERR_PTR(ret));
+ return ret;
+ }
- return ret;
+ priv->plat->serdes_powered_on = true;
+
+ return 0;
}
int dwmac_serdes_init_mode(struct stmmac_priv *priv, phy_interface_t interface)
@@ -95,10 +110,17 @@ void dwmac_serdes_power_off(struct stmmac_priv *priv)
{
int ret;
+ if (!priv->plat->serdes_powered_on)
+ return;
+
ret = phy_power_off(priv->plat->serdes);
- if (ret)
+ if (ret) {
dev_err(priv->device, "failed to power off SerDes: %pe\n",
ERR_PTR(ret));
+ return;
+ }
+
+ priv->plat->serdes_powered_on = false;
}
void dwmac_serdes_exit(struct stmmac_priv *priv)
diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
index 6097f4b6dd12..e62bba38ab60 100644
--- a/include/linux/stmmac.h
+++ b/include/linux/stmmac.h
@@ -225,6 +225,7 @@ struct plat_stmmacenet_data {
*/
phy_interface_t phy_interface;
struct phy *serdes;
+ bool serdes_powered_on;
struct stmmac_mdio_bus_data *mdio_bus_data;
struct device_node *phy_node;
struct fwnode_handle *port_node;
-- >8 --
Powered by blists - more mailing lists