Skip to contentSkip to conversation

net: phy: fix waiting for link

PATCH In review Sascha Hauer 2 participants 3 messages Mar 12, 2021 – Mar 15, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: phy: fix waiting for link

phydev->adjust_link() is called only from phy_update_status() when the link status changes during that function. phydev->link is also updated in genphy_update_link() called from phy_wait_aneg_done(), so it can happen that phydev->link changes outside of phy_update_status(), thus phydev->adjust_link is never called and no link change notice is printed.

Instead of calling genphy_update_link() from phy_wait_aneg_done(), call phy_update_status(). This makes sure that a link change is properly noticed.

---
 drivers/net/phy/phy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/phy/phy.c +1 -1
index 622acbe40d..e8e8dad5bd 100644
@@ -571,7 +571,7 @@ int phy_wait_aneg_done(struct phy_device *phydev)
 	}
 
 	do {
-		genphy_update_link(phydev);
+		phy_update_status(phydev);
 		if (phydev->link == 1)
 			return 0;
 	} while (!is_timeout(start, PHY_AN_TIMEOUT * SECOND));
Signature · 7 lines
2.29.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw
Quoted 11 lines · Sascha Hauer

phydev->adjust_link() is called only from phy_update_status() when the link status changes during that function. phydev->link is also updated in genphy_update_link() called from phy_wait_aneg_done(), so it can happen that phydev->link changes outside of phy_update_status(), thus phydev->adjust_link is never called and no link change notice is printed.

Instead of calling genphy_update_link() from phy_wait_aneg_done(), call phy_update_status(). This makes sure that a link change is properly noticed.

Fixes 8f75aa496dcb ("net: reply to ping requests")

Isn't it?

Quoted 19 lines
---
 drivers/net/phy/phy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/phy/phy.c +1 -1
index 622acbe40d..e8e8dad5bd 100644
@@ -571,7 +571,7 @@ int phy_wait_aneg_done(struct phy_device *phydev)
 	}
 
 	do {
-		genphy_update_link(phydev);
+		phy_update_status(phydev);
 		if (phydev->link == 1)
 			return 0;
 	} while (!is_timeout(start, PHY_AN_TIMEOUT * SECOND));
Signature · 9 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw
Quoted 10 lines · Ahmad Fatoum
Quoted 7 lines · Sascha Hauer

phydev->adjust_link() is called only from phy_update_status() when the link status changes during that function. phydev->link is also updated in genphy_update_link() called from phy_wait_aneg_done(), so it can happen that phydev->link changes outside of phy_update_status(), thus phydev->adjust_link is never called and no link change notice is printed.

Quoted 8 lines
Quoted 4 lines

Instead of calling genphy_update_link() from phy_wait_aneg_done(), call phy_update_status(). This makes sure that a link change is properly noticed.

Fixes 8f75aa496dcb ("net: reply to ping requests")

Isn't it?

8f75aa496dcb Isn't exactly broken, it just triggers a problem on this particular board. It might be confusing to add a fixes tag here.

Sascha

Quoted 27 lines
Quoted 20 lines
---
 drivers/net/phy/phy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/phy/phy.c +1 -1
index 622acbe40d..e8e8dad5bd 100644
@@ -571,7 +571,7 @@ int phy_wait_aneg_done(struct phy_device *phydev)
 	}
 
 	do {
-		genphy_update_link(phydev);
+		phy_update_status(phydev);
 		if (phydev->link == 1)
 			return 0;
 	} while (!is_timeout(start, PHY_AN_TIMEOUT * SECOND));
Signature · 4 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
Signature · 9 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox