Skip to content

Commit 134cc4c

Browse files
thierryredingdavem330
authored andcommitted
net: stmmac: Avoid deadlock on suspend/resume
The stmmac driver will try to acquire its private mutex during suspend via phylink_resolve() -> stmmac_mac_link_down() -> stmmac_eee_init(). However, the phylink configuration is updated with the private mutex held already, which causes a deadlock during suspend. Fix this by moving the phylink configuration updates out of the region of code protected by the private mutex. Fixes: 19e13cb ("net: stmmac: Hold rtnl lock in suspend/resume callbacks") Suggested-by: Bitan Biswas <bbiswas@nvidia.com> Signed-off-by: Thierry Reding <treding@nvidia.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 53de429 commit 134cc4c

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4716,10 +4716,10 @@ int stmmac_suspend(struct device *dev)
47164716
if (!ndev || !netif_running(ndev))
47174717
return 0;
47184718

4719-
mutex_lock(&priv->lock);
4720-
47214719
phylink_mac_change(priv->phylink, false);
47224720

4721+
mutex_lock(&priv->lock);
4722+
47234723
netif_device_detach(ndev);
47244724
stmmac_stop_all_queues(priv);
47254725

@@ -4733,9 +4733,11 @@ int stmmac_suspend(struct device *dev)
47334733
stmmac_pmt(priv, priv->hw, priv->wolopts);
47344734
priv->irq_wake = 1;
47354735
} else {
4736+
mutex_unlock(&priv->lock);
47364737
rtnl_lock();
47374738
phylink_stop(priv->phylink);
47384739
rtnl_unlock();
4740+
mutex_lock(&priv->lock);
47394741

47404742
stmmac_mac_set(priv, priv->ioaddr, false);
47414743
pinctrl_pm_select_sleep_state(priv->device);
@@ -4827,6 +4829,8 @@ int stmmac_resume(struct device *dev)
48274829

48284830
stmmac_start_all_queues(priv);
48294831

4832+
mutex_unlock(&priv->lock);
4833+
48304834
if (!device_may_wakeup(priv->device)) {
48314835
rtnl_lock();
48324836
phylink_start(priv->phylink);
@@ -4835,8 +4839,6 @@ int stmmac_resume(struct device *dev)
48354839

48364840
phylink_mac_change(priv->phylink, true);
48374841

4838-
mutex_unlock(&priv->lock);
4839-
48404842
return 0;
48414843
}
48424844
EXPORT_SYMBOL_GPL(stmmac_resume);

0 commit comments

Comments
 (0)