* [PATCH v2 net] net: phy: Restore phy_resume() locking assumption
@ 2018-02-27 0:56 Andrew Lunn
2018-02-27 3:40 ` Florian Fainelli
2018-02-27 19:33 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Andrew Lunn @ 2018-02-27 0:56 UTC (permalink / raw)
To: David Miller
Cc: hkallweit1, Florian Fainelli, netdev, linyunsheng, Andrew Lunn
commit f5e64032a799 ("net: phy: fix resume handling") changes the
locking semantics for phy_resume() such that the caller now needs to
hold the phy mutex. Not all call sites were adopted to this new
semantic, resulting in warnings from the added
WARN_ON(!mutex_is_locked(&phydev->lock)). Rather than change the
semantics, add a __phy_resume() and restore the old behavior of
phy_resume().
Reported-by: Heiner Kallweit <hkallweit1@gmail.com>
Fixes: f5e64032a799 ("net: phy: fix resume handling")
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
v2: Fix type in phy_resume() calling itself
---
drivers/net/phy/phy.c | 2 +-
drivers/net/phy/phy_device.c | 18 +++++++++++++-----
include/linux/phy.h | 1 +
3 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index e3e29c2b028b..a6f924fee584 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -819,7 +819,7 @@ void phy_start(struct phy_device *phydev)
break;
case PHY_HALTED:
/* if phy was suspended, bring the physical link up again */
- phy_resume(phydev);
+ __phy_resume(phydev);
/* make sure interrupts are re-enabled for the PHY */
if (phy_interrupt_is_valid(phydev)) {
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index d39ae77707ef..478405e544cc 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -135,9 +135,7 @@ static int mdio_bus_phy_resume(struct device *dev)
if (!mdio_bus_phy_may_suspend(phydev))
goto no_resume;
- mutex_lock(&phydev->lock);
ret = phy_resume(phydev);
- mutex_unlock(&phydev->lock);
if (ret < 0)
return ret;
@@ -1041,9 +1039,7 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
if (err)
goto error;
- mutex_lock(&phydev->lock);
phy_resume(phydev);
- mutex_unlock(&phydev->lock);
phy_led_triggers_register(phydev);
return err;
@@ -1172,7 +1168,7 @@ int phy_suspend(struct phy_device *phydev)
}
EXPORT_SYMBOL(phy_suspend);
-int phy_resume(struct phy_device *phydev)
+int __phy_resume(struct phy_device *phydev)
{
struct phy_driver *phydrv = to_phy_driver(phydev->mdio.dev.driver);
int ret = 0;
@@ -1189,6 +1185,18 @@ int phy_resume(struct phy_device *phydev)
return ret;
}
+EXPORT_SYMBOL(__phy_resume);
+
+int phy_resume(struct phy_device *phydev)
+{
+ int ret;
+
+ mutex_lock(&phydev->lock);
+ ret = __phy_resume(phydev);
+ mutex_unlock(&phydev->lock);
+
+ return ret;
+}
EXPORT_SYMBOL(phy_resume);
int phy_loopback(struct phy_device *phydev, bool enable)
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 5a0c3e53e7c2..d7069539f351 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -924,6 +924,7 @@ void phy_device_remove(struct phy_device *phydev);
int phy_init_hw(struct phy_device *phydev);
int phy_suspend(struct phy_device *phydev);
int phy_resume(struct phy_device *phydev);
+int __phy_resume(struct phy_device *phydev);
int phy_loopback(struct phy_device *phydev, bool enable);
struct phy_device *phy_attach(struct net_device *dev, const char *bus_id,
phy_interface_t interface);
--
2.16.2
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v2 net] net: phy: Restore phy_resume() locking assumption
2018-02-27 0:56 [PATCH v2 net] net: phy: Restore phy_resume() locking assumption Andrew Lunn
@ 2018-02-27 3:40 ` Florian Fainelli
2018-02-27 19:33 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Florian Fainelli @ 2018-02-27 3:40 UTC (permalink / raw)
To: Andrew Lunn, David Miller; +Cc: hkallweit1, netdev, linyunsheng
On February 26, 2018 4:56:06 PM PST, Andrew Lunn <andrew@lunn.ch> wrote:
>commit f5e64032a799 ("net: phy: fix resume handling") changes the
>locking semantics for phy_resume() such that the caller now needs to
>hold the phy mutex. Not all call sites were adopted to this new
>semantic, resulting in warnings from the added
>WARN_ON(!mutex_is_locked(&phydev->lock)). Rather than change the
>semantics, add a __phy_resume() and restore the old behavior of
>phy_resume().
>
>Reported-by: Heiner Kallweit <hkallweit1@gmail.com>
>Fixes: f5e64032a799 ("net: phy: fix resume handling")
>Signed-off-by: Andrew Lunn <andrew@lunn.ch>
>---
>v2: Fix type in phy_resume() calling itself
>---
This version looks good thanks for taking care of that:
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
--
Florian
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v2 net] net: phy: Restore phy_resume() locking assumption
2018-02-27 0:56 [PATCH v2 net] net: phy: Restore phy_resume() locking assumption Andrew Lunn
2018-02-27 3:40 ` Florian Fainelli
@ 2018-02-27 19:33 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2018-02-27 19:33 UTC (permalink / raw)
To: andrew; +Cc: hkallweit1, f.fainelli, netdev, linyunsheng
From: Andrew Lunn <andrew@lunn.ch>
Date: Tue, 27 Feb 2018 01:56:06 +0100
> commit f5e64032a799 ("net: phy: fix resume handling") changes the
> locking semantics for phy_resume() such that the caller now needs to
> hold the phy mutex. Not all call sites were adopted to this new
> semantic, resulting in warnings from the added
> WARN_ON(!mutex_is_locked(&phydev->lock)). Rather than change the
> semantics, add a __phy_resume() and restore the old behavior of
> phy_resume().
>
> Reported-by: Heiner Kallweit <hkallweit1@gmail.com>
> Fixes: f5e64032a799 ("net: phy: fix resume handling")
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>
> ---
> v2: Fix type in phy_resume() calling itself
Applied and queued up for -stable, thanks Andrew.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-02-27 19:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-27 0:56 [PATCH v2 net] net: phy: Restore phy_resume() locking assumption Andrew Lunn
2018-02-27 3:40 ` Florian Fainelli
2018-02-27 19:33 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).