Skip to contentSkip to conversation

net: stmmac: Fix PHY attach when custom PCS is in use

PATCH Applied Zxyan Zhu 3 participants 6 messages Jul 29 – Aug 4

Subsystems (6)
lore
Share & tools
lore

Zxyan Zhu

author
#0 lore raw

v3 cover net: stmmac: Fix PHY attach when custom PCS is in use

This series fixes the issue where stmmac platforms using a custom PCS via the pcs_init callback fail to probe when no phy-handle is specified in the device tree.

Patch 1 skips the PHY attach in stmmac when a custom PCS is already configured via priv->hw->phylink_pcs and phy_addr is invalid, avoiding the "no phy found" error for platforms that manage link state entirely through the PCS.

Patch 2 is Russell King's phylink patch that relaxes phylink_expects_phy() to allow PHYs to be attached in 802.3z inband mode.

v3:
- Move the priv->hw->phylink_pcs check inside the "addr < 0" branch to avoid skipping the phy_addr fallback for boards with both a PCS and a PHY
- Reverse patch order: stmmac fix first, phylink change second

v2:
- Include Russell's phylink patch as prerequisite
- This is now a 2-patch series targeting net-next

Zxyan Zhu (1):
net: stmmac: Skip PHY attach if custom PCS is in use

Russell King (Oracle) (1):
net: phylink: allow PHYs to be attached in 802.3z inband mode

 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 ++++
 drivers/net/phy/phylink.c                         | 8 ++------
 2 files changed, 6 insertions(+), 6 deletions(-)
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH v3 1/2 net: stmmac: Skip PHY attach if custom PCS is in use

When a platform provides a custom PCS via the pcs_init callback, the MAC's phylink_pcs is already configured. In this case, no traditional PHY device is needed.

Without this, stmmac_init_phy() falls through to the no-phy-node path and errors out with "no phy found" when the DT has no phy-handle for such interfaces.

Skip the PHY attach when priv->hw->phylink_pcs is set and phy_addr is invalid.

Fixes f0ef433fc264 ("net: stmmac: introduce pcs_init/pcs_exit stmmac operations")
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +4 -0
index 562d20830b94..575132b9cdbf 100644
@@ -1347,6 +1347,10 @@ static int stmmac_init_phy(struct net_device *dev)
 		struct phy_device *phydev;
 
 		if (addr < 0) {
+			/* If a custom PCS is in use, no PHY is needed */
+			if (priv->hw->phylink_pcs)
+				return 0;
+
 			netdev_err(priv->dev, "no phy found\n");
 			return -ENODEV;
 		}
Signature · 1 line
2.34.1
maintainer Reviewed-by on v3 1/2
#2 lore raw

Re: [PATCH net-next v3 1/2] net: stmmac: Skip PHY attach if custom PCS is in use

Hi

Quoted 8 lines · Zxyan Zhu

When a platform provides a custom PCS via the pcs_init callback, the MAC's phylink_pcs is already configured. In this case, no traditional PHY device is needed.

Without this, stmmac_init_phy() falls through to the no-phy-node path and errors out with "no phy found" when the DT has no phy-handle for such interfaces.

Quoted 5 lines

Skip the PHY attach when priv->hw->phylink_pcs is set and phy_addr is invalid.

Fixes f0ef433fc264 ("net: stmmac: introduce pcs_init/pcs_exit stmmac operations")

Maxime

Quoted 19 lines
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +4 -0
index 562d20830b94..575132b9cdbf 100644
@@ -1347,6 +1347,10 @@ static int stmmac_init_phy(struct net_device *dev)
 		struct phy_device *phydev;
 
 		if (addr < 0) {
+			/* If a custom PCS is in use, no PHY is needed */
+			if (priv->hw->phylink_pcs)
+				return 0;
+
 			netdev_err(priv->dev, "no phy found\n");
 			return -ENODEV;
 		}
author
#3 lore raw

PATCH v3 2/2 net: phylink: allow PHYs to be attached in 802.3z inband mode

In reply to Zxyan Zhu

From: "Russell King (Oracle)" <[email protected]>

Now that we have proper decision making for inband mode support which makes it a "best efforts" feature based on the capabilities of the PHY and PCS, we can relax whether we expect and permit a PHY to be attached. This is especially true for the 2500BASE-X case which some PHYs use without inband on their host side interface for 2.5G speeds, but use inband for slower speeds switching to SGMII on their host side interface.

We already have such a case for some qcom-ethqos setups, although qcom-ethqos overrides phylink's inband settings by accessing the PCS directly at the moment. This should allow qcom-ethqos to transition to defaulting to inband when 2500BASE-X or SGMII is specified in its DTS.

Allow PHYs to be attached when inband mode has been specified, which will be necessary to allow inband mode to be used on qcom-ethqos.

---
 drivers/net/phy/phylink.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/net/phy/phylink.c +2 -6
index 59dfe35afa54..fd4e80eeeda7 100644
@@ -1964,9 +1964,7 @@ EXPORT_SYMBOL_GPL(phylink_destroy);
  */
 bool phylink_expects_phy(struct phylink *pl)
 {
-	if (pl->cfg_link_an_mode == MLO_AN_FIXED ||
-	    (pl->cfg_link_an_mode == MLO_AN_INBAND &&
-	     phy_interface_mode_is_8023z(pl->link_interface)))
+	if (pl->cfg_link_an_mode == MLO_AN_FIXED)
 		return false;
 	return true;
 }
@@ -2205,9 +2203,7 @@ static int phylink_attach_phy(struct phylink *pl, struct phy_device *phy,
 {
 	u32 flags = 0;
 
-	if (WARN_ON(pl->cfg_link_an_mode == MLO_AN_FIXED ||
-		    (pl->cfg_link_an_mode == MLO_AN_INBAND &&
-		     phy_interface_mode_is_8023z(interface) && !pl->sfp_bus)))
+	if (WARN_ON(pl->cfg_link_an_mode == MLO_AN_FIXED))
 		return -EINVAL;
 
 	if (pl->phydev)
Signature · 1 line
2.34.1
maintainer Reviewed-by on v3 2/2
#4 lore raw

Re: [PATCH net-next v3 2/2] net: phylink: allow PHYs to be attached in 802.3z inband mode

Hi

Quoted 15 lines · Zxyan Zhu

From: "Russell King (Oracle)" <[email protected]>

Now that we have proper decision making for inband mode support which makes it a "best efforts" feature based on the capabilities of the PHY and PCS, we can relax whether we expect and permit a PHY to be attached. This is especially true for the 2500BASE-X case which some PHYs use without inband on their host side interface for 2.5G speeds, but use inband for slower speeds switching to SGMII on their host side interface.

We already have such a case for some qcom-ethqos setups, although qcom-ethqos overrides phylink's inband settings by accessing the PCS directly at the moment. This should allow qcom-ethqos to transition to defaulting to inband when 2500BASE-X or SGMII is specified in its DTS.

Quoted 5 lines

Allow PHYs to be attached when inband mode has been specified, which will be necessary to allow inband mode to be used on qcom-ethqos.

Maxime

Quoted 30 lines
---
 drivers/net/phy/phylink.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/net/phy/phylink.c +2 -6
index 59dfe35afa54..fd4e80eeeda7 100644
@@ -1964,9 +1964,7 @@ EXPORT_SYMBOL_GPL(phylink_destroy);
  */
 bool phylink_expects_phy(struct phylink *pl)
 {
-	if (pl->cfg_link_an_mode == MLO_AN_FIXED ||
-	    (pl->cfg_link_an_mode == MLO_AN_INBAND &&
-	     phy_interface_mode_is_8023z(pl->link_interface)))
+	if (pl->cfg_link_an_mode == MLO_AN_FIXED)
 		return false;
 	return true;
 }
@@ -2205,9 +2203,7 @@ static int phylink_attach_phy(struct phylink *pl, struct phy_device *phy,
 {
 	u32 flags = 0;
 
-	if (WARN_ON(pl->cfg_link_an_mode == MLO_AN_FIXED ||
-		    (pl->cfg_link_an_mode == MLO_AN_INBAND &&
-		     phy_interface_mode_is_8023z(interface) && !pl->sfp_bus)))
+	if (WARN_ON(pl->cfg_link_an_mode == MLO_AN_FIXED))
 		return -EINVAL;
 
 	if (pl->phydev)
#5 lore raw
In reply to Zxyan Zhu
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 10 lines · On Wed, 29 Jul 2026 15:42:35 +0800 you wrote:

This series fixes the issue where stmmac platforms using a custom PCS via the pcs_init callback fail to probe when no phy-handle is specified in the device tree.

Patch 1 skips the PHY attach in stmmac when a custom PCS is already configured via priv->hw->phylink_pcs and phy_addr is invalid, avoiding the "no phy found" error for platforms that manage link state entirely through the PCS.

[...]

Here is the summary with links:
- [net-next,v3,1/2] net: stmmac: Skip PHY attach if custom PCS is in use

    https://git.kernel.org/netdev/net-next/c/af4d93416445
  - [net-next,v3,2/2] net: phylink: allow PHYs to be attached in 802.3z inband mode
    https://git.kernel.org/netdev/net-next/c/e5db987f5d7f

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html