Skip to content

Commit 9c2c2e6

Browse files
lunndavem330
authored andcommitted
net: phy: Restore phy_resume() locking assumption
commit f5e6403 ("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 <[email protected]> Fixes: f5e6403 ("net: phy: fix resume handling") Signed-off-by: Andrew Lunn <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 1b22bca commit 9c2c2e6

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

drivers/net/phy/phy.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@ void phy_start(struct phy_device *phydev)
819819
break;
820820
case PHY_HALTED:
821821
/* if phy was suspended, bring the physical link up again */
822-
phy_resume(phydev);
822+
__phy_resume(phydev);
823823

824824
/* make sure interrupts are re-enabled for the PHY */
825825
if (phy_interrupt_is_valid(phydev)) {

drivers/net/phy/phy_device.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,7 @@ static int mdio_bus_phy_resume(struct device *dev)
135135
if (!mdio_bus_phy_may_suspend(phydev))
136136
goto no_resume;
137137

138-
mutex_lock(&phydev->lock);
139138
ret = phy_resume(phydev);
140-
mutex_unlock(&phydev->lock);
141139
if (ret < 0)
142140
return ret;
143141

@@ -1041,9 +1039,7 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
10411039
if (err)
10421040
goto error;
10431041

1044-
mutex_lock(&phydev->lock);
10451042
phy_resume(phydev);
1046-
mutex_unlock(&phydev->lock);
10471043
phy_led_triggers_register(phydev);
10481044

10491045
return err;
@@ -1172,7 +1168,7 @@ int phy_suspend(struct phy_device *phydev)
11721168
}
11731169
EXPORT_SYMBOL(phy_suspend);
11741170

1175-
int phy_resume(struct phy_device *phydev)
1171+
int __phy_resume(struct phy_device *phydev)
11761172
{
11771173
struct phy_driver *phydrv = to_phy_driver(phydev->mdio.dev.driver);
11781174
int ret = 0;
@@ -1189,6 +1185,18 @@ int phy_resume(struct phy_device *phydev)
11891185

11901186
return ret;
11911187
}
1188+
EXPORT_SYMBOL(__phy_resume);
1189+
1190+
int phy_resume(struct phy_device *phydev)
1191+
{
1192+
int ret;
1193+
1194+
mutex_lock(&phydev->lock);
1195+
ret = __phy_resume(phydev);
1196+
mutex_unlock(&phydev->lock);
1197+
1198+
return ret;
1199+
}
11921200
EXPORT_SYMBOL(phy_resume);
11931201

11941202
int phy_loopback(struct phy_device *phydev, bool enable)

include/linux/phy.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -924,6 +924,7 @@ void phy_device_remove(struct phy_device *phydev);
924924
int phy_init_hw(struct phy_device *phydev);
925925
int phy_suspend(struct phy_device *phydev);
926926
int phy_resume(struct phy_device *phydev);
927+
int __phy_resume(struct phy_device *phydev);
927928
int phy_loopback(struct phy_device *phydev, bool enable);
928929
struct phy_device *phy_attach(struct net_device *dev, const char *bus_id,
929930
phy_interface_t interface);

0 commit comments

Comments
 (0)