Skip to content

Commit 3b8b11f

Browse files
hkallweitdavem330
authored andcommitted
net: phy: improve link partner capability detection
genphy_read_status() so far checks phydev->supported, not the actual PHY capabilities. This can make a difference if the supported speeds have been limited by of_set_phy_supported() or phy_set_max_speed(). It seems that this issue only affects the link partner advertisements as displayed by ethtool. Also this patch wouldn't apply to older kernels because linkmode bitmaps have been introduced recently. Therefore net-next. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 8bb309e commit 3b8b11f

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

drivers/net/phy/phy_device.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1756,10 +1756,7 @@ int genphy_read_status(struct phy_device *phydev)
17561756
linkmode_zero(phydev->lp_advertising);
17571757

17581758
if (phydev->autoneg == AUTONEG_ENABLE && phydev->autoneg_complete) {
1759-
if (linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseT_Half_BIT,
1760-
phydev->supported) ||
1761-
linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT,
1762-
phydev->supported)) {
1759+
if (phydev->is_gigabit_capable) {
17631760
lpagb = phy_read(phydev, MII_STAT1000);
17641761
if (lpagb < 0)
17651762
return lpagb;
@@ -2154,6 +2151,13 @@ static int phy_probe(struct device *dev)
21542151
if (err)
21552152
goto out;
21562153

2154+
if (linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseT_Half_BIT,
2155+
phydev->supported))
2156+
phydev->is_gigabit_capable = 1;
2157+
if (linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT,
2158+
phydev->supported))
2159+
phydev->is_gigabit_capable = 1;
2160+
21572161
of_set_phy_supported(phydev);
21582162
linkmode_copy(phydev->advertising, phydev->supported);
21592163

include/linux/phy.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ struct phy_c45_device_ids {
345345
* is_c45: Set to true if this phy uses clause 45 addressing.
346346
* is_internal: Set to true if this phy is internal to a MAC.
347347
* is_pseudo_fixed_link: Set to true if this phy is an Ethernet switch, etc.
348+
* is_gigabit_capable: Set to true if PHY supports 1000Mbps
348349
* has_fixups: Set to true if this phy has fixups/quirks.
349350
* suspended: Set to true if this phy has been suspended successfully.
350351
* sysfs_links: Internal boolean tracking sysfs symbolic links setup/removal.
@@ -382,6 +383,7 @@ struct phy_device {
382383
unsigned is_c45:1;
383384
unsigned is_internal:1;
384385
unsigned is_pseudo_fixed_link:1;
386+
unsigned is_gigabit_capable:1;
385387
unsigned has_fixups:1;
386388
unsigned suspended:1;
387389
unsigned sysfs_links:1;

0 commit comments

Comments
 (0)