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

net: fec: only restart or stop the device if it is present and running

Avoid calling fec_restart() or fec_stop() while the device is down
or not present (iow suspended.)

Although the ndo_timeout method will only be called if the device is
present and running, we defer this to a work queue.  The work queue
can run independently, and so needs to repeat these checks to ensure
that a restart doesn't occur after the device has been taken down or
detached for suspend.  In this case, we call fec_restart() in the
resume path, so nothing is lost.

For fec_set_features, we add a call to fec_restart() in fec_enet_open()
to ensure that the hardware is appropriate programmed when the interface
is opened.  fec_set_features() call should not occur while we're
suspended, so we don't have to worry about that case.

The adjust_link needs similar treatment - this also is called from a
work queue, which may be run independently after we have taken the
device down and detached it.  In this case, we just mark the link
down and take no further action.  We will reset things appropriately
once the device is up and running again, at which point we will receive
another adjust_link callback.
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 8bbbd3c1
...@@ -1065,12 +1065,15 @@ static void fec_enet_work(struct work_struct *work) ...@@ -1065,12 +1065,15 @@ static void fec_enet_work(struct work_struct *work)
container_of(work, container_of(work,
struct fec_enet_private, struct fec_enet_private,
delay_work.delay_work.work); delay_work.delay_work.work);
struct net_device *ndev = fep->netdev;
if (fep->delay_work.timeout) { if (fep->delay_work.timeout) {
fep->delay_work.timeout = false; fep->delay_work.timeout = false;
rtnl_lock(); rtnl_lock();
fec_restart(fep->netdev, fep->full_duplex); if (netif_device_present(ndev) || netif_running(ndev)) {
netif_wake_queue(fep->netdev); fec_restart(ndev, fep->full_duplex);
netif_wake_queue(ndev);
}
rtnl_unlock(); rtnl_unlock();
} }
...@@ -1504,7 +1507,14 @@ static void fec_enet_adjust_link(struct net_device *ndev) ...@@ -1504,7 +1507,14 @@ static void fec_enet_adjust_link(struct net_device *ndev)
return; return;
} }
if (phy_dev->link) { /*
* If the netdev is down, or is going down, we're not interested
* in link state events, so just mark our idea of the link as down
* and ignore the event.
*/
if (!netif_running(ndev) || !netif_device_present(ndev)) {
fep->link = 0;
} else if (phy_dev->link) {
if (!fep->link) { if (!fep->link) {
fep->link = phy_dev->link; fep->link = phy_dev->link;
status_change = 1; status_change = 1;
...@@ -2184,6 +2194,7 @@ fec_enet_open(struct net_device *ndev) ...@@ -2184,6 +2194,7 @@ fec_enet_open(struct net_device *ndev)
return ret; return ret;
} }
fec_restart(ndev, fep->full_duplex);
napi_enable(&fep->napi); napi_enable(&fep->napi);
phy_start(fep->phy_dev); phy_start(fep->phy_dev);
netif_start_queue(ndev); netif_start_queue(ndev);
...@@ -2350,8 +2361,6 @@ static int fec_set_features(struct net_device *netdev, ...@@ -2350,8 +2361,6 @@ static int fec_set_features(struct net_device *netdev,
fec_stop(netdev); fec_stop(netdev);
fec_restart(netdev, fep->phy_dev->duplex); fec_restart(netdev, fep->phy_dev->duplex);
netif_wake_queue(netdev); netif_wake_queue(netdev);
} else {
fec_restart(netdev, fep->phy_dev->duplex);
} }
} }
......
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