Commit da1774e5 authored by Russell King's avatar Russell King Committed by David S. Miller

net: fec: improve safety of suspend/resume/transmit timeout paths

We should hold the rtnl lock while suspending, resuming or processing
the transmit timeout to ensure that nothing will interfere while we
bring up, take down or restart the hardware.  The transmit timeout
could run if we're preempted during suspend.
Acked-by: default avatarFugang Duan <B38611@freescale.com>
Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2167cefc
...@@ -1068,8 +1068,10 @@ static void fec_enet_work(struct work_struct *work) ...@@ -1068,8 +1068,10 @@ static void fec_enet_work(struct work_struct *work)
if (fep->delay_work.timeout) { if (fep->delay_work.timeout) {
fep->delay_work.timeout = false; fep->delay_work.timeout = false;
rtnl_lock();
fec_restart(fep->netdev, fep->full_duplex); fec_restart(fep->netdev, fep->full_duplex);
netif_wake_queue(fep->netdev); netif_wake_queue(fep->netdev);
rtnl_unlock();
} }
if (fep->delay_work.trig_tx) { if (fep->delay_work.trig_tx) {
...@@ -2680,11 +2682,14 @@ fec_suspend(struct device *dev) ...@@ -2680,11 +2682,14 @@ fec_suspend(struct device *dev)
struct net_device *ndev = dev_get_drvdata(dev); struct net_device *ndev = dev_get_drvdata(dev);
struct fec_enet_private *fep = netdev_priv(ndev); struct fec_enet_private *fep = netdev_priv(ndev);
rtnl_lock();
if (netif_running(ndev)) { if (netif_running(ndev)) {
phy_stop(fep->phy_dev); phy_stop(fep->phy_dev);
fec_stop(ndev); fec_stop(ndev);
netif_device_detach(ndev); netif_device_detach(ndev);
} }
rtnl_unlock();
fec_enet_clk_enable(ndev, false); fec_enet_clk_enable(ndev, false);
pinctrl_pm_select_sleep_state(&fep->pdev->dev); pinctrl_pm_select_sleep_state(&fep->pdev->dev);
...@@ -2712,11 +2717,13 @@ fec_resume(struct device *dev) ...@@ -2712,11 +2717,13 @@ fec_resume(struct device *dev)
if (ret) if (ret)
goto failed_clk; goto failed_clk;
rtnl_lock();
if (netif_running(ndev)) { if (netif_running(ndev)) {
fec_restart(ndev, fep->full_duplex); fec_restart(ndev, fep->full_duplex);
netif_device_attach(ndev); netif_device_attach(ndev);
phy_start(fep->phy_dev); phy_start(fep->phy_dev);
} }
rtnl_unlock();
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment