1 From 34d5a86ff7bbe225fba3ad91f9b4dc85fb408e18 Mon Sep 17 00:00:00 2001
2 From: Daniel Golle <daniel@makrotopia.org>
3 Date: Wed, 15 Jan 2025 14:43:35 +0000
4 Subject: [PATCH] net: phy: realtek: clear 1000Base-T lpa if link is down
6 Only read 1000Base-T link partner advertisement if autonegotiation has
7 completed and otherwise 1000Base-T link partner advertisement bits.
9 This fixes bogus 1000Base-T link partner advertisement after link goes
10 down (eg. by disconnecting the wire).
11 Fixes: 5cb409b3960e ("net: phy: realtek: clear 1000Base-T link partner advertisement")
12 Signed-off-by: Daniel Golle <daniel@makrotopia.org>
13 Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
14 Signed-off-by: David S. Miller <davem@davemloft.net>
16 drivers/net/phy/realtek.c | 19 ++++++++-----------
17 1 file changed, 8 insertions(+), 11 deletions(-)
19 --- a/drivers/net/phy/realtek.c
20 +++ b/drivers/net/phy/realtek.c
21 @@ -1023,23 +1023,20 @@ static int rtl822x_c45_read_status(struc
25 - ret = genphy_c45_read_status(phydev);
29 - if (phydev->autoneg == AUTONEG_DISABLE ||
30 - !genphy_c45_aneg_done(phydev))
31 - mii_stat1000_mod_linkmode_lpa_t(phydev->lp_advertising, 0);
33 /* Vendor register as C45 has no standardized support for 1000BaseT */
34 - if (phydev->autoneg == AUTONEG_ENABLE) {
35 + if (phydev->autoneg == AUTONEG_ENABLE && genphy_c45_aneg_done(phydev)) {
36 val = phy_read_mmd(phydev, MDIO_MMD_VEND2,
37 RTL822X_VND2_GANLPAR);
41 - mii_stat1000_mod_linkmode_lpa_t(phydev->lp_advertising, val);
45 + mii_stat1000_mod_linkmode_lpa_t(phydev->lp_advertising, val);
47 + ret = genphy_c45_read_status(phydev);