Skip to contentSkip to conversation

net: phy: fix too strict check in phy_start_aneg

PATCH Applied Heiner Kallweit 4 participants 4 messages Jan 9, 2019 – Jan 15, 2019

Subsystems (3)
lore
Share & tools
lore

Heiner Kallweit

author maintainer
#0 lore raw

PATCH 1/1 net: phy: fix too strict check in phy_start_aneg

When adding checks to detect wrong usage of the phylib API we added a check to phy_start_aneg() which is too strict. If the phylib state machine is in state PHY_HALTED we should allow reconfiguring and restarting aneg, and just don't touch the state.

Fixes 2b3e88ea6528 ("net: phy: improve phy state checking")
---
 drivers/net/phy/phy.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)
drivers/net/phy/phy.c +7 -12
index d33e7b3ca..189cd2048 100644
@@ -543,13 +543,6 @@ int phy_start_aneg(struct phy_device *phydev)
 
 	mutex_lock(&phydev->lock);
 
-	if (!__phy_is_started(phydev)) {
-		WARN(1, "called from state %s\n",
-		     phy_state_to_str(phydev->state));
-		err = -EBUSY;
-		goto out_unlock;
-	}
-
 	if (AUTONEG_DISABLE == phydev->autoneg)
 		phy_sanitize_settings(phydev);
 
@@ -560,11 +553,13 @@ int phy_start_aneg(struct phy_device *phydev)
 	if (err < 0)
 		goto out_unlock;
 
-	if (phydev->autoneg == AUTONEG_ENABLE) {
-		err = phy_check_link_status(phydev);
-	} else {
-		phydev->state = PHY_FORCING;
-		phydev->link_timeout = PHY_FORCE_TIMEOUT;
+	if (__phy_is_started(phydev)) {
+		if (phydev->autoneg == AUTONEG_ENABLE) {
+			err = phy_check_link_status(phydev);
+		} else {
+			phydev->state = PHY_FORCING;
+			phydev->link_timeout = PHY_FORCE_TIMEOUT;
+		}
 	}
 
 out_unlock:
Signature · 1 line
2.20.1
Tested-by on v1 1/1
#1 lore raw

Quoting Heiner Kallweit (2019-01-09 19:34:56)

Quoted 8 lines

When adding checks to detect wrong usage of the phylib API we added a check to phy_start_aneg() which is too strict. If the phylib state machine is in state PHY_HALTED we should allow reconfiguring and restarting aneg, and just don't touch the state.

Fixes 2b3e88ea6528 ("net: phy: improve phy state checking")

Courtesy of intel-gfx's CI farm,

Thanks for the fix,
-Chris

Reviewed-by on v1 1/1
#2 lore raw
In reply to Heiner Kallweit
Quoted 8 lines · Heiner Kallweit

When adding checks to detect wrong usage of the phylib API we added a check to phy_start_aneg() which is too strict. If the phylib state machine is in state PHY_HALTED we should allow reconfiguring and restarting aneg, and just don't touch the state.

Fixes 2b3e88ea6528 ("net: phy: improve phy state checking")
Signature · 1 line
Florian
maintainer Applied
#3 lore raw
In reply to Heiner Kallweit

From: Heiner Kallweit <[email protected]>
Date: Wed, 9 Jan 2019 20:34:56 +0100

Quoted 8 lines

When adding checks to detect wrong usage of the phylib API we added a check to phy_start_aneg() which is too strict. If the phylib state machine is in state PHY_HALTED we should allow reconfiguring and restarting aneg, and just don't touch the state.

Fixes 2b3e88ea6528 ("net: phy: improve phy state checking")

Applied.