netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net: phy: realtek: clear status if link is down
@ 2025-01-15  0:46 Daniel Golle
  2025-01-15  2:50 ` Andrew Lunn
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Golle @ 2025-01-15  0:46 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit, Russell King, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Daniel Golle, netdev,
	linux-kernel

Clear speed, duplex and master/slave status in case the link is down
to avoid reporting bogus link(-partner) properties.

Fixes: 5cb409b3960e ("net: phy: realtek: clear 1000Base-T link partner advertisement")
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
 drivers/net/phy/realtek.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
index f65d7f1f348e..3f0e03e2abce 100644
--- a/drivers/net/phy/realtek.c
+++ b/drivers/net/phy/realtek.c
@@ -720,8 +720,12 @@ static int rtlgen_read_status(struct phy_device *phydev)
 	if (ret < 0)
 		return ret;
 
-	if (!phydev->link)
+	if (!phydev->link) {
+		phydev->duplex = DUPLEX_UNKNOWN;
+		phydev->master_slave_state = MASTER_SLAVE_STATE_UNKNOWN;
+		phydev->speed = SPEED_UNKNOWN;
 		return 0;
+	}
 
 	val = phy_read_paged(phydev, 0xa43, 0x12);
 	if (val < 0)
@@ -1028,11 +1032,11 @@ static int rtl822x_c45_read_status(struct phy_device *phydev)
 		return ret;
 
 	if (phydev->autoneg == AUTONEG_DISABLE ||
-	    !genphy_c45_aneg_done(phydev))
+	    !genphy_c45_aneg_done(phydev) ||
+	    !phydev->link) {
 		mii_stat1000_mod_linkmode_lpa_t(phydev->lp_advertising, 0);
-
-	/* Vendor register as C45 has no standardized support for 1000BaseT */
-	if (phydev->autoneg == AUTONEG_ENABLE) {
+	} else {
+		/* Vendor register as C45 has no standardized support for 1000BaseT */
 		val = phy_read_mmd(phydev, MDIO_MMD_VEND2,
 				   RTL822X_VND2_GANLPAR);
 		if (val < 0)
@@ -1041,8 +1045,12 @@ static int rtl822x_c45_read_status(struct phy_device *phydev)
 		mii_stat1000_mod_linkmode_lpa_t(phydev->lp_advertising, val);
 	}
 
-	if (!phydev->link)
+	if (!phydev->link) {
+		phydev->duplex = DUPLEX_UNKNOWN;
+		phydev->master_slave_state = MASTER_SLAVE_STATE_UNKNOWN;
+		phydev->speed = SPEED_UNKNOWN;
 		return 0;
+	}
 
 	/* Read actual speed from vendor register. */
 	val = phy_read_mmd(phydev, MDIO_MMD_VEND2, RTL_VND2_PHYSR);
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-01-15  9:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-15  0:46 [PATCH net] net: phy: realtek: clear status if link is down Daniel Golle
2025-01-15  2:50 ` Andrew Lunn
2025-01-15  5:07   ` Daniel Golle
2025-01-15  9:24     ` Russell King (Oracle)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).