net: stmmac: Fix PHY attach when custom PCS is in use
Subsystems (6)
v2 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 is Russell King's phylink patch that relaxes phylink_expects_phy() to allow PHYs to be attached in 802.3z inband mode.
Patch 2 skips the PHY attach in stmmac when a custom PCS is already configured via priv->hw->phylink_pcs, avoiding the "no phy found" error for platforms that manage link state entirely through the PCS.
v2:
- Include Russell's phylink patch as prerequisite (Patch 1)
- This is now a 2-patch series targeting net-next
Russell King (Oracle) (1):
net: phylink: allow PHYs to be attached in 802.3z inband mode
Zxyan Zhu (1):
net: stmmac: Skip PHY attach if custom PCS is in use
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 ++++ drivers/net/phy/phylink.c | 8 ++------ 2 files changed, 6 insertions(+), 6 deletions(-)
--
2.34.1
PATCH v2 1/2 net: phylink: allow PHYs to be attached in 802.3z inband mode
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
@@ -1983,9 +1983,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; }
@@ -2224,9 +2222,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
PATCH v2 2/2 net: stmmac: Skip PHY attach if custom PCS is in use
In reply to Zxyan ZhuWhen a platform provides a custom PCS via the pcs_init callback, the MAC's phylink_pcs is already configured. In this case, phylink validates against the PCS's supported interfaces and manages link state through the PCS, so 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 already set and no phy-handle is specified in the device tree.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +4 -0
@@ -1346,6 +1346,10 @@ static int stmmac_init_phy(struct net_device *dev)int addr = priv->plat->phy_addr;struct phy_device *phydev; +/* If a custom PCS is in use, no PHY is needed */ +if (priv->hw->phylink_pcs) +return 0 ; +if (addr <0 ) {netdev_err (priv->dev,"no phy found\n" );return -ENODEV ;
Signature · 1 line
2.34.1
Maxime Chevallier
maintainerRe: [PATCH net-next v2 2/2] net: stmmac: Skip PHY attach if custom PCS is in use
Hi,
I think sashiko's are correct that we can err on the safe side and move the check inside the "if (addr < 0)" check (even though I don't think we have platforms with a PCS but no fwnode-described PHYs, but just to be safe).
Also, sashiko reports an issue on patch 1 that this exact patch is solving, so you may want to re-send but with patches in the reverse order.
Maxime
Quoted 33 lines · Zxyan Zhu
When a platform provides a custom PCS via the
pcs_initcallback, the MAC'sphylink_pcsis already configured. In this case, phylink validates against the PCS's supported interfaces and manages link state through the PCS, so 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_pcsis already set and no phy-handle is specified in the device tree.Fixes f0ef433fc264 ("net: stmmac: introduce pcs_init/pcs_exit stmmac operations")Signed-off-by Zxyan Zhu <[email protected]>--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +4
-0@@ -1346,6 +1346,10 @@ static int stmmac_init_phy(struct net_device *dev)int addr = priv->plat->phy_addr;struct phy_device *phydev; +/* If a custom PCS is in use, no PHY is needed */ +if (priv->hw->phylink_pcs) +return 0 ; +if (addr <0 ) {netdev_err (priv->dev,"no phy found\n" );return -ENODEV ;
Hi,
Quoted 10 lines · Zxyan Zhu
This series fixes the issue where stmmac platforms using a custom PCS via the
pcs_initcallback fail to probe when no phy-handle is specified in the device tree.Patch 1 is Russell King's phylink patch that relaxes
phylink_expects_phy()to allow PHYs to be attached in 802.3z inband mode.Patch 2 skips the PHY attach in stmmac when a custom PCS is already configured via
priv->hw->phylink_pcs, avoiding the "no phy found" error for platforms that manage link state entirely through the PCS.
I've tested this series on the board that saw the regression from Russell's first attempt, and now with the associated stmmac patch, it works :)
Thanks for that, for the series :
Maxime
Jakub Kicinski
maintainerQuoted 8 lines · On Mon, 27 Jul 2026 08:49:11 +0200 Maxime Chevallier wrote:
Quoted 7 lines · Zxyan Zhu
This series fixes the issue where stmmac platforms using a custom PCS via the
pcs_initcallback fail to probe when no phy-handle is specified in the device tree.Patch 1 is Russell King's phylink patch that relaxes
phylink_expects_phy()to allow PHYs to be attached in 802.3z inband mode.
Quoted 6 lines
Quoted 3 lines
Patch 2 skips the PHY attach in stmmac when a custom PCS is already configured via
priv->hw->phylink_pcs, avoiding the "no phy found" error for platforms that manage link state entirely through the PCS.I've tested this series on the board that saw the regression from Russell's first attempt, and now with the associated stmmac patch, it works :)
Both Sashikos see a risk of regression here, could you TAL and confirm it's not real / unlikely?