3e9631e4a313f9889000b52ec130220140a933e1
[openwrt/openwrt.git] /
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
5
6 Only read 1000Base-T link partner advertisement if autonegotiation has
7 completed and otherwise 1000Base-T link partner advertisement bits.
8
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>
15 ---
16 drivers/net/phy/realtek.c | 19 ++++++++-----------
17 1 file changed, 8 insertions(+), 11 deletions(-)
18
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
22 {
23 int ret, val;
24
25 - ret = genphy_c45_read_status(phydev);
26 - if (ret < 0)
27 - return ret;
28 -
29 - if (phydev->autoneg == AUTONEG_DISABLE ||
30 - !genphy_c45_aneg_done(phydev))
31 - mii_stat1000_mod_linkmode_lpa_t(phydev->lp_advertising, 0);
32 -
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);
38 if (val < 0)
39 return val;
40 -
41 - mii_stat1000_mod_linkmode_lpa_t(phydev->lp_advertising, val);
42 + } else {
43 + val = 0;
44 }
45 + mii_stat1000_mod_linkmode_lpa_t(phydev->lp_advertising, val);
46 +
47 + ret = genphy_c45_read_status(phydev);
48 + if (ret < 0)
49 + return ret;
50
51 if (!phydev->link)
52 return 0;