From: Vladimir Oltean <olteanv@gmail.com>
To: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
Cc: Andrew Lunn <andrew@lunn.ch>,
Heiner Kallweit <hkallweit1@gmail.com>,
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-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org,
linux-stm32@st-md-mailman.stormreply.com,
Maxime Chevallier <maxime.chevallier@bootlin.com>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Mohd Ayaan Anwar <mohd.anwar@oss.qualcomm.com>,
Neil Armstrong <neil.armstrong@linaro.org>,
netdev@vger.kernel.org, Paolo Abeni <pabeni@redhat.com>,
Vinod Koul <vkoul@kernel.org>
Subject: Re: [PATCH net-next v2 05/14] net: stmmac: add stmmac core serdes support
Date: Sat, 24 Jan 2026 02:59:51 +0200 [thread overview]
Message-ID: <20260124005951.fbkvd2girdqtfxe7@skbuf> (raw)
In-Reply-To: <E1vjDrM-00000005fQR-0rmB@rmk-PC.armlinux.org.uk>
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@bootlin.com>
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.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 --
next prev parent reply other threads:[~2026-01-24 0:59 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-23 9:52 [PATCH net-next v2 00/14] net: stmmac: SerDes, PCS, BASE-X, and inband goodies Russell King (Oracle)
2026-01-23 9:53 ` [PATCH net-next v2 01/14] net: stmmac: qcom-ethqos: remove mac_base Russell King (Oracle)
2026-01-27 12:06 ` Mohd Ayaan Anwar
2026-01-23 9:53 ` [PATCH net-next v2 02/14] net: stmmac: qcom-ethqos: convert to set_clk_tx_rate() method Russell King (Oracle)
2026-02-17 18:51 ` Mohd Ayaan Anwar
2026-01-23 9:53 ` [PATCH net-next v2 03/14] phy: qcom-sgmii-eth: add .set_mode() and .validate() methods Russell King (Oracle)
2026-01-23 9:53 ` [PATCH net-next v2 04/14] net: stmmac: wrap phylink's rx_clk_stop functions Russell King (Oracle)
2026-01-23 9:53 ` [PATCH net-next v2 05/14] net: stmmac: add stmmac core serdes support Russell King (Oracle)
2026-01-24 0:59 ` Vladimir Oltean [this message]
2026-01-23 9:53 ` [PATCH net-next v2 06/14] net: stmmac: qcom-ethqos: convert to dwmac generic SerDes support Russell King (Oracle)
2026-01-23 9:53 ` [PATCH net-next v2 07/14] net: stmmac: move most PCS register definitions to stmmac_pcs.c Russell King (Oracle)
2026-01-23 9:53 ` [PATCH net-next v2 08/14] net: stmmac: handle integrated PCS phy_intf_sel separately Russell King (Oracle)
2026-01-23 9:54 ` [PATCH net-next v2 09/14] net: stmmac: add BASE-X support to integrated PCS Russell King (Oracle)
2026-01-23 9:54 ` [PATCH net-next v2 10/14] net: stmmac: use integrated PCS for BASE-X modes Russell King (Oracle)
2026-01-23 9:54 ` [PATCH net-next v2 11/14] net: stmmac: add struct stmmac_pcs_info Russell King (Oracle)
2026-01-23 9:54 ` [PATCH net-next v2 12/14] net: stmmac: add support for reading inband SGMII status Russell King (Oracle)
2026-01-23 9:54 ` [PATCH net-next v2 13/14] net: stmmac: configure SGMII AN control according to phylink Russell King (Oracle)
2026-01-23 9:54 ` [PATCH net-next v2 14/14] net: stmmac: report PCS configuration changes Russell King (Oracle)
2026-01-23 9:56 ` [PATCH net-next v2 00/14] net: stmmac: SerDes, PCS, BASE-X, and inband goodies Russell King (Oracle)
2026-01-23 11:13 ` Russell King (Oracle)
2026-01-24 0:04 ` Vladimir Oltean
2026-01-24 0:16 ` Russell King (Oracle)
2026-01-23 13:35 ` Mohd Ayaan Anwar
2026-01-23 17:26 ` Russell King (Oracle)
2026-01-27 13:45 ` Mohd Ayaan Anwar
2026-01-23 21:32 ` Russell King (Oracle)
2026-01-27 14:57 ` Mohd Ayaan Anwar
2026-01-27 15:17 ` Andrew Lunn
2026-01-27 15:42 ` Russell King (Oracle)
2026-01-29 7:27 ` Mohd Ayaan Anwar
2026-01-29 22:00 ` Russell King (Oracle)
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=20260124005951.fbkvd2girdqtfxe7@skbuf \
--to=olteanv@gmail.com \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew+netdev@lunn.ch \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-phy@lists.infradead.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=maxime.chevallier@bootlin.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=mohd.anwar@oss.qualcomm.com \
--cc=neil.armstrong@linaro.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rmk+kernel@armlinux.org.uk \
--cc=vkoul@kernel.org \
/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