* [PATCH net] net: stmmac: Avoid deadlock on suspend/resume
@ 2019-10-02 14:49 Thierry Reding
2019-10-03 0:22 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Thierry Reding @ 2019-10-02 14:49 UTC (permalink / raw)
To: David S . Miller
Cc: Jose Abreu, Alexandre Torgue, Giuseppe Cavallaro,
Florian Fainelli, Bitan Biswas, netdev, linux-arm-kernel,
linux-kernel
From: Thierry Reding <treding@nvidia.com>
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: 19e13cb27b99 ("net: stmmac: Hold rtnl lock in suspend/resume callbacks")
Suggested-by: Bitan Biswas <bbiswas@nvidia.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 843d53e084b7..c76a1336a451 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -4716,10 +4716,10 @@ int stmmac_suspend(struct device *dev)
if (!ndev || !netif_running(ndev))
return 0;
- mutex_lock(&priv->lock);
-
phylink_mac_change(priv->phylink, false);
+ mutex_lock(&priv->lock);
+
netif_device_detach(ndev);
stmmac_stop_all_queues(priv);
@@ -4733,9 +4733,11 @@ int stmmac_suspend(struct device *dev)
stmmac_pmt(priv, priv->hw, priv->wolopts);
priv->irq_wake = 1;
} else {
+ mutex_unlock(&priv->lock);
rtnl_lock();
phylink_stop(priv->phylink);
rtnl_unlock();
+ mutex_lock(&priv->lock);
stmmac_mac_set(priv, priv->ioaddr, false);
pinctrl_pm_select_sleep_state(priv->device);
@@ -4827,6 +4829,8 @@ int stmmac_resume(struct device *dev)
stmmac_start_all_queues(priv);
+ mutex_unlock(&priv->lock);
+
if (!device_may_wakeup(priv->device)) {
rtnl_lock();
phylink_start(priv->phylink);
@@ -4835,8 +4839,6 @@ int stmmac_resume(struct device *dev)
phylink_mac_change(priv->phylink, true);
- mutex_unlock(&priv->lock);
-
return 0;
}
EXPORT_SYMBOL_GPL(stmmac_resume);
--
2.23.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net] net: stmmac: Avoid deadlock on suspend/resume
2019-10-02 14:49 [PATCH net] net: stmmac: Avoid deadlock on suspend/resume Thierry Reding
@ 2019-10-03 0:22 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2019-10-03 0:22 UTC (permalink / raw)
To: thierry.reding
Cc: joabreu, alexandre.torgue, peppe.cavallaro, f.fainelli, bbiswas,
netdev, linux-arm-kernel, linux-kernel
From: Thierry Reding <thierry.reding@gmail.com>
Date: Wed, 2 Oct 2019 16:49:46 +0200
> From: Thierry Reding <treding@nvidia.com>
>
> 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: 19e13cb27b99 ("net: stmmac: Hold rtnl lock in suspend/resume callbacks")
> Suggested-by: Bitan Biswas <bbiswas@nvidia.com>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
Applied.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-10-03 0:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-02 14:49 [PATCH net] net: stmmac: Avoid deadlock on suspend/resume Thierry Reding
2019-10-03 0:22 ` 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).