Re: [RFC net 1/1] net: stmmac: skip PHY scanning when PHY already attached in DT mode

From: Marek Szyprowski
Date: Tue Apr 04 2023 - 12:55:21 EST


Hi,

On 04.04.2023 11:14, Michael Sit Wei Hong wrote:
> If PHY is successfully attached during phylink_fwnode_phy_connect()
> in DT mode. MAC should not need to scan for PHY again.
>
> Adding a logic to check if ovr_an_inband is set before scanning for
> a PHY, since phylink_fwnode_phy_connect() returns 0 when
>
> phy_fwnode = fwnode_get_phy_node(fwnode);
> if (IS_ERR(phy_fwnode)) {
> if (pl->cfg_link_an_mode == MLO_AN_PHY)
> return -ENODEV;
> return 0;
> }
>
> Fixes: fe2cfbc96803 ("net: stmmac: check if MAC needs to attach to a PHY")
> Signed-off-by: Michael Sit Wei Hong <michael.wei.hong.sit@xxxxxxxxx>

This fixes broken ethernet observed recently on various Amlogic Meson
based boards (like Khadas VIM3 or Odroid-C4). Thanks!

Tested-by: Marek Szyprowski <m.szyprowski@xxxxxxxxxxx>

> ---
> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index d41a5f92aee7..4b8d3d975678 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -1149,7 +1149,7 @@ static int stmmac_init_phy(struct net_device *dev)
> /* Some DT bindings do not set-up the PHY handle. Let's try to
> * manually parse it
> */
> - if (!fwnode || phy_needed || ret) {
> + if (!fwnode || (phy_needed && priv->phylink_config.ovr_an_inband) || ret) {
> int addr = priv->plat->phy_addr;
> struct phy_device *phydev;
>

Best regards
--
Marek Szyprowski, PhD
Samsung R&D Institute Poland