Re: [PATCH net-next v3 1/2] net: stmmac: Skip PHY attach if custom PCS is in use
From: Maxime Chevallier
Date: Wed Jul 29 2026 - 04:40:02 EST
Hi
On 7/29/26 09:42, Zxyan Zhu wrote:
> 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")
> Signed-off-by: Zxyan Zhu <zxyan0222@xxxxxxxxx>
Reviewed-by: Maxime Chevallier <maxime.chevallier@xxxxxxxxxxx>
Maxime
> ---
> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index 562d20830b94..575132b9cdbf 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -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;
> }