Skip to content

Commit 2ec4808

Browse files
hkallweitnbuchwitz
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 <hkallweit1@gmail.com> Reported-by: Choong Yong Liang <yong.liang.choong@linux.intel.com> Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> Signed-off-by: David S. Miller <davem@davemloft.net> (cherry picked from commit f26a29a)
1 parent a9dfd3b commit 2ec4808

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
@@ -1728,7 +1728,7 @@ EXPORT_SYMBOL(phy_ethtool_get_eee);
17281728
* phy_ethtool_set_eee_noneg - Adjusts MAC LPI configuration without PHY
17291729
* renegotiation
17301730
* @phydev: pointer to the target PHY device structure
1731-
* @data: pointer to the ethtool_keee structure containing the new EEE settings
1731+
* @old_cfg: pointer to the eee_config structure containing the old EEE settings
17321732
*
17331733
* This function updates the Energy Efficient Ethernet (EEE) configuration
17341734
* for cases where only the MAC's Low Power Idle (LPI) configuration changes,
@@ -1739,11 +1739,10 @@ EXPORT_SYMBOL(phy_ethtool_get_eee);
17391739
* configuration.
17401740
*/
17411741
static void phy_ethtool_set_eee_noneg(struct phy_device *phydev,
1742-
struct ethtool_keee *data)
1742+
const struct eee_config *old_cfg)
17431743
{
1744-
if (phydev->eee_cfg.tx_lpi_enabled != data->tx_lpi_enabled ||
1745-
phydev->eee_cfg.tx_lpi_timer != data->tx_lpi_timer) {
1746-
eee_to_eeecfg(&phydev->eee_cfg, data);
1744+
if (phydev->eee_cfg.tx_lpi_enabled != old_cfg->tx_lpi_enabled ||
1745+
phydev->eee_cfg.tx_lpi_timer != old_cfg->tx_lpi_timer) {
17471746
phydev->enable_tx_lpi = eeecfg_mac_can_tx_lpi(&phydev->eee_cfg);
17481747
if (phydev->link) {
17491748
phydev->link = false;
@@ -1763,18 +1762,23 @@ static void phy_ethtool_set_eee_noneg(struct phy_device *phydev,
17631762
*/
17641763
int phy_ethtool_set_eee(struct phy_device *phydev, struct ethtool_keee *data)
17651764
{
1765+
struct eee_config old_cfg;
17661766
int ret;
17671767

17681768
if (!phydev->drv)
17691769
return -EIO;
17701770

17711771
mutex_lock(&phydev->lock);
1772+
1773+
old_cfg = phydev->eee_cfg;
1774+
eee_to_eeecfg(&phydev->eee_cfg, data);
1775+
17721776
ret = genphy_c45_ethtool_set_eee(phydev, data);
1773-
if (ret >= 0) {
1774-
if (ret == 0)
1775-
phy_ethtool_set_eee_noneg(phydev, data);
1776-
eee_to_eeecfg(&phydev->eee_cfg, data);
1777-
}
1777+
if (ret == 0)
1778+
phy_ethtool_set_eee_noneg(phydev, &old_cfg);
1779+
else if (ret < 0)
1780+
phydev->eee_cfg = old_cfg;
1781+
17781782
mutex_unlock(&phydev->lock);
17791783

17801784
return ret < 0 ? ret : 0;

0 commit comments

Comments
 (0)