mirror of
https://github.com/torvalds/linux.git
synced 2024-11-25 05:32:00 +00:00
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:
d9663c8c21
("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>
This commit is contained in:
parent
fe9066ade6
commit
983942a5ea
@ -755,6 +755,45 @@ static int amd_xgbe_phy_set_mode(struct phy_device *phydev,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static bool amd_xgbe_phy_use_xgmii_mode(struct phy_device *phydev)
|
||||
{
|
||||
if (phydev->autoneg == AUTONEG_ENABLE) {
|
||||
if (phydev->advertising & ADVERTISED_10000baseKR_Full)
|
||||
return true;
|
||||
} else {
|
||||
if (phydev->speed == SPEED_10000)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool amd_xgbe_phy_use_gmii_2500_mode(struct phy_device *phydev)
|
||||
{
|
||||
if (phydev->autoneg == AUTONEG_ENABLE) {
|
||||
if (phydev->advertising & ADVERTISED_2500baseX_Full)
|
||||
return true;
|
||||
} else {
|
||||
if (phydev->speed == SPEED_2500)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool amd_xgbe_phy_use_gmii_mode(struct phy_device *phydev)
|
||||
{
|
||||
if (phydev->autoneg == AUTONEG_ENABLE) {
|
||||
if (phydev->advertising & ADVERTISED_1000baseKX_Full)
|
||||
return true;
|
||||
} else {
|
||||
if (phydev->speed == SPEED_1000)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static int amd_xgbe_phy_set_an(struct phy_device *phydev, bool enable,
|
||||
bool restart)
|
||||
{
|
||||
@ -1235,11 +1274,11 @@ static int amd_xgbe_phy_config_init(struct phy_device *phydev)
|
||||
/* Set initial mode - call the mode setting routines
|
||||
* directly to insure we are properly configured
|
||||
*/
|
||||
if (phydev->advertising & SUPPORTED_10000baseKR_Full)
|
||||
if (amd_xgbe_phy_use_xgmii_mode(phydev))
|
||||
ret = amd_xgbe_phy_xgmii_mode(phydev);
|
||||
else if (phydev->advertising & SUPPORTED_1000baseKX_Full)
|
||||
else if (amd_xgbe_phy_use_gmii_mode(phydev))
|
||||
ret = amd_xgbe_phy_gmii_mode(phydev);
|
||||
else if (phydev->advertising & SUPPORTED_2500baseX_Full)
|
||||
else if (amd_xgbe_phy_use_gmii_2500_mode(phydev))
|
||||
ret = amd_xgbe_phy_gmii_2500_mode(phydev);
|
||||
else
|
||||
ret = -EINVAL;
|
||||
|
Loading…
Reference in New Issue
Block a user