Skip to content

Commit f26a29a

Browse files
hkallweitdavem330
authored andcommitted
net: phy: ensure that genphy_c45_an_config_eee_aneg() sees new value of phydev->eee_cfg.eee_enabled
This is a follow-up to 41ffcd9 ("net: phy: fix phylib's dual eee_enabled") and resolves an issue with genphy_c45_an_config_eee_aneg() (called from genphy_c45_ethtool_set_eee) not seeing the new value of phydev->eee_cfg.eee_enabled. Fixes: 49168d1 ("net: phy: Add phy_support_eee() indicating MAC support EEE") Signed-off-by: Heiner Kallweit <[email protected]> Reported-by: Choong Yong Liang <[email protected]> Reviewed-by: Russell King (Oracle) <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent fcc79e1 commit f26a29a

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

drivers/net/phy/phy.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,7 +1672,7 @@ EXPORT_SYMBOL(phy_ethtool_get_eee);
16721672
* phy_ethtool_set_eee_noneg - Adjusts MAC LPI configuration without PHY
16731673
* renegotiation
16741674
* @phydev: pointer to the target PHY device structure
1675-
* @data: pointer to the ethtool_keee structure containing the new EEE settings
1675+
* @old_cfg: pointer to the eee_config structure containing the old EEE settings
16761676
*
16771677
* This function updates the Energy Efficient Ethernet (EEE) configuration
16781678
* for cases where only the MAC's Low Power Idle (LPI) configuration changes,
@@ -1683,11 +1683,10 @@ EXPORT_SYMBOL(phy_ethtool_get_eee);
16831683
* configuration.
16841684
*/
16851685
static void phy_ethtool_set_eee_noneg(struct phy_device *phydev,
1686-
struct ethtool_keee *data)
1686+
const struct eee_config *old_cfg)
16871687
{
1688-
if (phydev->eee_cfg.tx_lpi_enabled != data->tx_lpi_enabled ||
1689-
phydev->eee_cfg.tx_lpi_timer != data->tx_lpi_timer) {
1690-
eee_to_eeecfg(&phydev->eee_cfg, data);
1688+
if (phydev->eee_cfg.tx_lpi_enabled != old_cfg->tx_lpi_enabled ||
1689+
phydev->eee_cfg.tx_lpi_timer != old_cfg->tx_lpi_timer) {
16911690
phydev->enable_tx_lpi = eeecfg_mac_can_tx_lpi(&phydev->eee_cfg);
16921691
if (phydev->link) {
16931692
phydev->link = false;
@@ -1707,18 +1706,23 @@ static void phy_ethtool_set_eee_noneg(struct phy_device *phydev,
17071706
*/
17081707
int phy_ethtool_set_eee(struct phy_device *phydev, struct ethtool_keee *data)
17091708
{
1709+
struct eee_config old_cfg;
17101710
int ret;
17111711

17121712
if (!phydev->drv)
17131713
return -EIO;
17141714

17151715
mutex_lock(&phydev->lock);
1716+
1717+
old_cfg = phydev->eee_cfg;
1718+
eee_to_eeecfg(&phydev->eee_cfg, data);
1719+
17161720
ret = genphy_c45_ethtool_set_eee(phydev, data);
1717-
if (ret >= 0) {
1718-
if (ret == 0)
1719-
phy_ethtool_set_eee_noneg(phydev, data);
1720-
eee_to_eeecfg(&phydev->eee_cfg, data);
1721-
}
1721+
if (ret == 0)
1722+
phy_ethtool_set_eee_noneg(phydev, &old_cfg);
1723+
else if (ret < 0)
1724+
phydev->eee_cfg = old_cfg;
1725+
17221726
mutex_unlock(&phydev->lock);
17231727

17241728
return ret < 0 ? ret : 0;

0 commit comments

Comments
 (0)