Skip to content

Commit 5d6a361

Browse files
committed
Merge branch 'realtek-link-down'
Daniel Golle says: ==================== net: phy: realtek: fix status when link is down The .read_status method for RealTek RTL822x PHYs (both C22 and C45) has multilpe issues which result in reporting bogus link partner advertised modes as well as speed and duplex while the link is down and no cable is plugged in. Example: ethtool after disconnecting a 1000M/Full capable link partner, now with no wire plugged: Settings for lan1: Supported ports: [ TP ] Supported link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full 1000baseT/Full 2500baseT/Full Supported pause frame use: Symmetric Receive-only Supports auto-negotiation: Yes Supported FEC modes: Not reported Advertised link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full 1000baseT/Full 2500baseT/Full Advertised pause frame use: Symmetric Receive-only Advertised auto-negotiation: Yes Advertised FEC modes: Not reported Link partner advertised link modes: 1000baseT/Full Link partner advertised pause frame use: No Link partner advertised auto-negotiation: No Link partner advertised FEC modes: Not reported Speed: 1000Mb/s Duplex: Full Auto-negotiation: on Port: Twisted Pair PHYAD: 7 Transceiver: external MDI-X: Unknown Supports Wake-on: d Wake-on: d Link detected: no Fix this by making sure all of the fields populated by rtl822x_c45_read_status() or rtl822x_read_status() get reset, also in case the link is down. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents ce69b40 + d3eb585 commit 5d6a361

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

drivers/net/phy/realtek.c

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -952,15 +952,15 @@ static int rtl822x_read_status(struct phy_device *phydev)
952952
{
953953
int lpadv, ret;
954954

955+
mii_10gbt_stat_mod_linkmode_lpa_t(phydev->lp_advertising, 0);
956+
955957
ret = rtlgen_read_status(phydev);
956958
if (ret < 0)
957959
return ret;
958960

959961
if (phydev->autoneg == AUTONEG_DISABLE ||
960-
!phydev->autoneg_complete) {
961-
mii_10gbt_stat_mod_linkmode_lpa_t(phydev->lp_advertising, 0);
962+
!phydev->autoneg_complete)
962963
return 0;
963-
}
964964

965965
lpadv = phy_read_paged(phydev, 0xa5d, 0x13);
966966
if (lpadv < 0)
@@ -1023,26 +1023,25 @@ static int rtl822x_c45_read_status(struct phy_device *phydev)
10231023
{
10241024
int ret, val;
10251025

1026-
ret = genphy_c45_read_status(phydev);
1027-
if (ret < 0)
1028-
return ret;
1029-
1030-
if (phydev->autoneg == AUTONEG_DISABLE ||
1031-
!genphy_c45_aneg_done(phydev))
1032-
mii_stat1000_mod_linkmode_lpa_t(phydev->lp_advertising, 0);
1033-
10341026
/* Vendor register as C45 has no standardized support for 1000BaseT */
1035-
if (phydev->autoneg == AUTONEG_ENABLE) {
1027+
if (phydev->autoneg == AUTONEG_ENABLE && genphy_c45_aneg_done(phydev)) {
10361028
val = phy_read_mmd(phydev, MDIO_MMD_VEND2,
10371029
RTL822X_VND2_GANLPAR);
10381030
if (val < 0)
10391031
return val;
1040-
1041-
mii_stat1000_mod_linkmode_lpa_t(phydev->lp_advertising, val);
1032+
} else {
1033+
val = 0;
10421034
}
1035+
mii_stat1000_mod_linkmode_lpa_t(phydev->lp_advertising, val);
10431036

1044-
if (!phydev->link)
1037+
ret = genphy_c45_read_status(phydev);
1038+
if (ret < 0)
1039+
return ret;
1040+
1041+
if (!phydev->link) {
1042+
phydev->master_slave_state = MASTER_SLAVE_STATE_UNKNOWN;
10451043
return 0;
1044+
}
10461045

10471046
/* Read actual speed from vendor register. */
10481047
val = phy_read_mmd(phydev, MDIO_MMD_VEND2, RTL_VND2_PHYSR);

0 commit comments

Comments
 (0)