Skip to contentSkip to conversation

net: phy: don't reschedule state machine when PHY is halted

PATCH Superseded Heiner Kallweit 2 participants 6 messages Sep 19, 2018 – Sep 23, 2018

Subsystems (3)
lore
Share & tools
lore

Heiner Kallweit

author maintainer
#0 lore raw

PATCH 1/1 net: phy: don't reschedule state machine when PHY is halted

I think I've seen a similar or same patch before, not sure why it didn't make it yet. When being in state PHY_HALTED we don't have to reschedule the state machine, phy_start() will start it again.

---
 drivers/net/phy/phy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/phy/phy.c +1 -1
index 1ee25877c..c78203b25 100644
@@ -1123,7 +1123,7 @@ void phy_state_machine(struct work_struct *work)
 	 * PHY, if PHY_IGNORE_INTERRUPT is set, then we will be moving
 	 * between states from phy_mac_interrupt()
 	 */
-	if (phy_polling_mode(phydev))
+	if (phy_polling_mode(phydev) && old_state != PHY_HALTED)
 		queue_delayed_work(system_power_efficient_wq, &phydev->state_queue,
 				   PHY_STATE_TIME * HZ);
 }
Signature · 1 line
2.19.0
#1 lore raw
Quoted 3 lines · Heiner Kallweit

I think I've seen a similar or same patch before, not sure why it didn't make it yet. When being in state PHY_HALTED we don't have to reschedule the state machine, phy_start() will start it again.

Yes, this is conceptually the same patch as as this one:

https://patchwork.ozlabs.org/patch/830415/

I prefer your version, though the comment in the original patch explains why.

Quoted 20 lines
---
 drivers/net/phy/phy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/phy/phy.c +1 -1
index 1ee25877c..c78203b25 100644
@@ -1123,7 +1123,7 @@ void phy_state_machine(struct work_struct *work)
 	 * PHY, if PHY_IGNORE_INTERRUPT is set, then we will be moving
 	 * between states from phy_mac_interrupt()
 	 */
-	if (phy_polling_mode(phydev))
+	if (phy_polling_mode(phydev) && old_state != PHY_HALTED)
 		queue_delayed_work(system_power_efficient_wq, &phydev->state_queue,
 				   PHY_STATE_TIME * HZ);
 }
Signature · 1 line
Florian
author maintainer
#2 lore raw
Quoted 9 lines · Florian Fainelli
Quoted 3 lines · Heiner Kallweit

I think I've seen a similar or same patch before, not sure why it didn't make it yet. When being in state PHY_HALTED we don't have to reschedule the state machine, phy_start() will start it again.

Yes, this is conceptually the same patch as as this one:

https://patchwork.ozlabs.org/patch/830415/

Thanks for the link, this is what I was referring to.

Quoted 3 lines

I prefer your version, though the comment in the original patch explains why.

To be sure I understand you correctly:
You're fine with the patch as is or would you prefer to add a comment like in the original patch ?

Quoted 22 lines
Quoted 20 lines
---
 drivers/net/phy/phy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/phy/phy.c +1 -1
index 1ee25877c..c78203b25 100644
@@ -1123,7 +1123,7 @@ void phy_state_machine(struct work_struct *work)
 	 * PHY, if PHY_IGNORE_INTERRUPT is set, then we will be moving
 	 * between states from phy_mac_interrupt()
 	 */
-	if (phy_polling_mode(phydev))
+	if (phy_polling_mode(phydev) && old_state != PHY_HALTED)
 		queue_delayed_work(system_power_efficient_wq, &phydev->state_queue,
 				   PHY_STATE_TIME * HZ);
 }
#3 lore raw
Quoted 10 lines · Heiner Kallweit
Quoted 9 lines · Florian Fainelli
Quoted 3 lines · Heiner Kallweit

I think I've seen a similar or same patch before, not sure why it didn't make it yet. When being in state PHY_HALTED we don't have to reschedule the state machine, phy_start() will start it again.

Yes, this is conceptually the same patch as as this one:

https://patchwork.ozlabs.org/patch/830415/

Quoted 8 lines

Thanks for the link, this is what I was referring to.

Quoted 3 lines

I prefer your version, though the comment in the original patch explains why.

To be sure I understand you correctly:
You're fine with the patch as is or would you prefer to add a comment like in the original patch ?

Correct, unless you think this does not warrant a comment and it is clear enough as-is?

Quoted 24 lines
Quoted 23 lines
Quoted 21 lines
---
 drivers/net/phy/phy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/phy/phy.c +1 -1
index 1ee25877c..c78203b25 100644
@@ -1123,7 +1123,7 @@ void phy_state_machine(struct work_struct *work)
 	 * PHY, if PHY_IGNORE_INTERRUPT is set, then we will be moving
 	 * between states from phy_mac_interrupt()
 	 */
-	if (phy_polling_mode(phydev))
+	if (phy_polling_mode(phydev) && old_state != PHY_HALTED)
 		queue_delayed_work(system_power_efficient_wq, &phydev->state_queue,
 				   PHY_STATE_TIME * HZ);
 }
Signature · 1 line
Florian
author maintainer
#4 lore raw

PATCH v2 1/1 net: phy: don't reschedule state machine when PHY is halted

In reply to Heiner Kallweit

When being in state PHY_HALTED we don't have to reschedule the state machine, phy_start() will start it again.

---
v2:
- added comment

---
 drivers/net/phy/phy.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/phy/phy.c +6 -2
index a5e0f0721..a1f8e4816 100644
@@ -1123,9 +1123,13 @@ void phy_state_machine(struct work_struct *work)
 
 	/* Only re-schedule a PHY state machine change if we are polling the
 	 * PHY, if PHY_IGNORE_INTERRUPT is set, then we will be moving
-	 * between states from phy_mac_interrupt()
+	 * between states from phy_mac_interrupt().
+	 *
+	 * In state PHY_HALTED the PHY gets suspended, so rescheduling the
+	 * state machine would be pointless and possibly error prone when
+	 * called from phy_disconnect() synchronously.
 	 */
-	if (phy_polling_mode(phydev))
+	if (phy_polling_mode(phydev) && old_state != PHY_HALTED)
 		queue_delayed_work(system_power_efficient_wq, &phydev->state_queue,
 				   PHY_STATE_TIME * HZ);
 }
Signature · 1 line
2.19.0