All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net v2] net: phy: Correctly process PHY_HALTED in phy_stop_machine()
@ 2017-07-28 18:58 Florian Fainelli
  2017-07-28 19:53 ` Marc Gonzalez
  2017-08-01  0:28 ` David Miller
  0 siblings, 2 replies; 7+ messages in thread
From: Florian Fainelli @ 2017-07-28 18:58 UTC (permalink / raw)
  To: netdev
  Cc: davem, andrew, slash.tmp, marc_gonzalez, rmk+kernel, Florian Fainelli

Marc reported that he was not getting the PHY library adjust_link()
callback function to run when calling phy_stop() + phy_disconnect()
which does not indeed happen because we set the state machine to
PHY_HALTED but we don't get to run it to process this state past that
point.

Fix this with a synchronous call to phy_state_machine() in order to have
the state machine actually act on PHY_HALTED, set the PHY device's link
down, turn the network device's carrier off and finally call the
adjust_link() function.

Reported-by: Marc Gonzalez <marc_gonzalez@sigmadesigns.com>
Fixes: a390d1f379cf ("phylib: convert state_queue work to delayed_work")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
Changes in v2:

- reword subject and commit message based on changes
- dropped flush_scheduled_work() since it is redundant

 drivers/net/phy/phy.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index d0626bf5c540..5068c582d502 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -749,6 +749,9 @@ void phy_stop_machine(struct phy_device *phydev)
 	if (phydev->state > PHY_UP && phydev->state != PHY_HALTED)
 		phydev->state = PHY_UP;
 	mutex_unlock(&phydev->lock);
+
+	/* Now we can run the state machine synchronously */
+	phy_state_machine(&phydev->state_queue.work);
 }
 
 /**
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-08-31  0:52 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-28 18:58 [PATCH net v2] net: phy: Correctly process PHY_HALTED in phy_stop_machine() Florian Fainelli
2017-07-28 19:53 ` Marc Gonzalez
2017-08-01  0:28 ` David Miller
2017-08-31  0:13   ` David Daney
2017-08-31  0:16     ` Florian Fainelli
2017-08-31  0:16     ` David Daney
2017-08-31  0:52     ` Florian Fainelli

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.