Skip to content

Commit 983942a

Browse files
tlendackydavem330
authored andcommitted
amd-xgbe-phy: Fix initial mode when autoneg is disabled
When the ethtool command is used to set the speed of the device while the device is down, the check to set the initial mode may fail when the device is brought up, causing failure to bring the device up. Update the code to set the initial mode based on the desired speed if auto-negotiation is disabled. This patch fixes a bug introduced by: d9663c8 ("amd-xgbe-phy: Use phydev advertising field vs supported") Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent fe9066a commit 983942a

File tree

1 file changed

+42
-3
lines changed

1 file changed

+42
-3
lines changed

drivers/net/phy/amd-xgbe-phy.c

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,45 @@ static int amd_xgbe_phy_set_mode(struct phy_device *phydev,
755755
return ret;
756756
}
757757

758+
static bool amd_xgbe_phy_use_xgmii_mode(struct phy_device *phydev)
759+
{
760+
if (phydev->autoneg == AUTONEG_ENABLE) {
761+
if (phydev->advertising & ADVERTISED_10000baseKR_Full)
762+
return true;
763+
} else {
764+
if (phydev->speed == SPEED_10000)
765+
return true;
766+
}
767+
768+
return false;
769+
}
770+
771+
static bool amd_xgbe_phy_use_gmii_2500_mode(struct phy_device *phydev)
772+
{
773+
if (phydev->autoneg == AUTONEG_ENABLE) {
774+
if (phydev->advertising & ADVERTISED_2500baseX_Full)
775+
return true;
776+
} else {
777+
if (phydev->speed == SPEED_2500)
778+
return true;
779+
}
780+
781+
return false;
782+
}
783+
784+
static bool amd_xgbe_phy_use_gmii_mode(struct phy_device *phydev)
785+
{
786+
if (phydev->autoneg == AUTONEG_ENABLE) {
787+
if (phydev->advertising & ADVERTISED_1000baseKX_Full)
788+
return true;
789+
} else {
790+
if (phydev->speed == SPEED_1000)
791+
return true;
792+
}
793+
794+
return false;
795+
}
796+
758797
static int amd_xgbe_phy_set_an(struct phy_device *phydev, bool enable,
759798
bool restart)
760799
{
@@ -1235,11 +1274,11 @@ static int amd_xgbe_phy_config_init(struct phy_device *phydev)
12351274
/* Set initial mode - call the mode setting routines
12361275
* directly to insure we are properly configured
12371276
*/
1238-
if (phydev->advertising & SUPPORTED_10000baseKR_Full)
1277+
if (amd_xgbe_phy_use_xgmii_mode(phydev))
12391278
ret = amd_xgbe_phy_xgmii_mode(phydev);
1240-
else if (phydev->advertising & SUPPORTED_1000baseKX_Full)
1279+
else if (amd_xgbe_phy_use_gmii_mode(phydev))
12411280
ret = amd_xgbe_phy_gmii_mode(phydev);
1242-
else if (phydev->advertising & SUPPORTED_2500baseX_Full)
1281+
else if (amd_xgbe_phy_use_gmii_2500_mode(phydev))
12431282
ret = amd_xgbe_phy_gmii_2500_mode(phydev);
12441283
else
12451284
ret = -EINVAL;

0 commit comments

Comments
 (0)