Skip to content

Commit c804002

Browse files
Luke LuDa Xue
authored andcommitted
stmmac: meson: retry phy connnection
we need to wait mdio-mux node ready in stmmac probe, so try to iterate phy connections several times. this will fix following error when in system bootup: 541:[ 12.377795] meson8b-dwmac ff3f0000.ethernet eth0: Register MEM_TYPE_PAGE_POOL RxQ-0 542:[ 12.380991] meson8b-dwmac ff3f0000.ethernet eth0: __stmmac_open: Cannot attach to PHY (error: -19) Signed-off-by: Luke Lu <luke.lu@libre.computer>
1 parent 4cd541a commit c804002

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1136,6 +1136,23 @@ static void stmmac_check_pcs_mode(struct stmmac_priv *priv)
11361136
}
11371137
}
11381138

1139+
static int stmmac_try_connect_phy(struct phylink *phylink, struct fwnode_handle *fwnode)
1140+
{
1141+
#define WAIT_TIMES 40
1142+
int ret = 0, i;
1143+
for (i = 0; i < WAIT_TIMES; i++) {
1144+
ret = phylink_fwnode_phy_connect(phylink, fwnode, 0);
1145+
if (!ret || ret != -ENODEV)
1146+
break;
1147+
msleep_interruptible(50);
1148+
}
1149+
1150+
if (ret)
1151+
pr_err("%s: fail to wait %d times, ret = %d\n", __func__, i, ret);
1152+
1153+
return ret;
1154+
}
1155+
11391156
/**
11401157
* stmmac_init_phy - PHY initialization
11411158
* @dev: net device structure
@@ -1184,7 +1201,8 @@ static int stmmac_init_phy(struct net_device *dev)
11841201
ret = phylink_connect_phy(priv->phylink, phydev);
11851202
} else {
11861203
fwnode_handle_put(phy_fwnode);
1187-
ret = phylink_fwnode_phy_connect(priv->phylink, fwnode, 0);
1204+
1205+
ret = stmmac_try_connect_phy(priv->phylink, fwnode);
11881206
}
11891207

11901208
if (!priv->plat->pmt) {

0 commit comments

Comments
 (0)