drivers: net: cpsw: abort init() on aneg timeout
PATCH 1/1 drivers: net: cpsw: abort init() on aneg timeout
Abort CPSW driver init when auto-negotiation of link times out. Currently, the code ignores return status of phy_startup(), and goes ahead with network operation (like DHCP) even though the link may be down.
Instead, abort init process if link is down or if there is another error, so phy_startup() can easily be retried again. This also helps quick fallback to next network interface (like USB RNDIS) without inordinate delay.
Tested on AM571x IDK and AM335x BeagleBone black.
--- drivers/net/cpsw.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-)
drivers/net/cpsw.c +22 -12
@@ -612,21 +612,25 @@ static void cpsw_set_slave_mac(struct cpsw_slave *slave,#endif } -static void cpsw_slave_update_link (struct cpsw_slave *slave, +static int cpsw_slave_update_link (struct cpsw_slave *slave,struct cpsw_priv *priv,int *link) {struct phy_device *phy;u32 mac_control =0 ; +int ret = -ENODEV ; phy = priv->phydev; -if (!phy) -return ; + goto out; + + ret =phy_startup (phy); +if (ret) + goto out; -phy_startup (phy); - *link = phy->link; +if (link) + *link = phy->link; -if (*link) {/* link up */ +if (phy->link) {/* link up */ mac_control = priv->data.mac_control;if (phy->speed ==1000 ) mac_control |=GIGABITEN ;
@@ -637,7 +641,7 @@ static void cpsw_slave_update_link(struct cpsw_slave *slave, }if (mac_control == slave->mac_control) -return ; + goto out;if (mac_control) { printf("link up on port %d, speed %d, %s duplex\n",
@@ -649,17 +653,20 @@ static void cpsw_slave_update_link(struct cpsw_slave *slave,__raw_writel (mac_control, &slave->sliver->mac_control); slave->mac_control = mac_control; + +out: +return ret; }static int cpsw_update_link (struct cpsw_priv *priv) { -int link =0 ; +int ret = -ENODEV ;struct cpsw_slave *slave;for_active_slave (slave, priv) -cpsw_slave_update_link (slave, priv, &link); + ret = cpsw_slave_update_link(slave, priv, NULL); -return link; +return ret; }static inline u32 cpsw_get_slave_port (struct cpsw_priv *priv,u32 slave_num)
@@ -822,7 +829,9 @@ static int _cpsw_init(struct cpsw_priv *priv, u8 *enetaddr) for_active_slave(slave, priv)cpsw_slave_init (slave, priv); -cpsw_update_link (priv); + ret =cpsw_update_link (priv); +if (ret) + goto out;/* init descriptor pool */ for (i =0 ; i <NUM_DESCS ; i++) {
@@ -897,7 +906,8 @@ static int _cpsw_init(struct cpsw_priv *priv, u8 *enetaddr) } } -return 0 ; +out: +return ret; }static void _cpsw_halt (struct cpsw_priv *priv)
Signature · 1 line
2.9.0
PATCH 1/1 drivers: net: cpsw: abort init() on aneg timeout
Quoted 5 lines · Sekhar Nori
Abort CPSW driver init when auto-negotiation of link times out. Currently, the code ignores return status of
phy_startup(), and goes ahead with network operation (like DHCP) even though the link may be down.
Quoted 8 lines
Instead, abort init process if link is down or if there is another error, so
phy_startup()can easily be retried again. This also helps quick fallback to next network interface (like USB RNDIS) without inordinate delay.Tested on AM571x IDK and AM335x BeagleBone black.
Signed-off-by Sekhar Nori <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170508/2f9ec8e9/attachment.sig>
PATCH 1/1 drivers: net: cpsw: abort init() on aneg timeout
In reply to Sekhar NoriQuoted 5 lines · Sekhar Nori
Abort CPSW driver init when auto-negotiation of link times out. Currently, the code ignores return status of
phy_startup(), and goes ahead with network operation (like DHCP) even though the link may be down.
Quoted 8 lines
Instead, abort init process if link is down or if there is another error, so
phy_startup()can easily be retried again. This also helps quick fallback to next network interface (like USB RNDIS) without inordinate delay.Tested on AM571x IDK and AM335x BeagleBone black.
Signed-off-by Sekhar Nori <[email protected]>