[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20171025232124.14120-4-f.fainelli@gmail.com>
Date: Wed, 25 Oct 2017 16:21:23 -0700
From: Florian Fainelli <f.fainelli@...il.com>
To: netdev@...r.kernel.org
Cc: Florian Fainelli <f.fainelli@...il.com>, davem@...emloft.net,
andrew@...n.ch, opendmb@...il.com,
Marc Gonzalez <marc_gonzalez@...madesigns.com>,
slash.tmp@...e.fr, david.daney@...ium.com, geert+renesas@...der.be
Subject: [RFC net-next 3/4] net: phy: Force PHY_HALTED during phy_disconnect()
While debugging a crash reported by David Daney, we discovered that the
offending driver was calling phy_disconnect() without a prior call to
phy_stop() although it should have.
Add a WARN_ON() to catch such drivers, in order to invite their
maintainers to fix them, and also force the PHY state machine to
PHY_HALTED since we are about to disconnect anyway, there is nothing we
will be doing.
Signed-off-by: Florian Fainelli <f.fainelli@...il.com>
---
drivers/net/phy/phy_device.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 67f25ac29025..69eb985c26fe 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -797,6 +797,11 @@ void phy_disconnect(struct phy_device *phydev)
if (phydev->irq > 0)
phy_stop_interrupts(phydev);
+ mutex_lock(&phydev->lock);
+ WARN_ON(phydev->state != PHY_HALTED);
+ phydev->state = PHY_HALTED;
+ mutex_unlock(&phydev->lock);
+
phy_stop_machine(phydev);
phydev->adjust_link = NULL;
--
2.9.3
Powered by blists - more mailing lists