Commit 29c69a48 authored by Ben Hutchings's avatar Ben Hutchings

sfc: Detach net device when stopping queues for reconfiguration

We must only ever stop TX queues when they are full or the net device
is not 'ready' so far as the net core, and specifically the watchdog,
is concerned.  Otherwise, the watchdog may fire *immediately* if no
packets have been added to the queue in the last 5 seconds.

The device is ready if all the following are true:

(a) It has a qdisc
(b) It is marked present
(c) It is running
(d) The link is reported up

(a) and (c) are normally true, and must not be changed by a driver.
(d) is under our control, but fake link changes may disturb userland.
This leaves (b).  We already mark the device absent during reset
and self-test, but we need to do the same during MTU changes and ring
reallocation.  We don't need to do this when the device is brought
down because then (c) is already false.
Signed-off-by: default avatarBen Hutchings <bhutchings@solarflare.com>
parent b590ace0
...@@ -779,6 +779,7 @@ efx_realloc_channels(struct efx_nic *efx, u32 rxq_entries, u32 txq_entries) ...@@ -779,6 +779,7 @@ efx_realloc_channels(struct efx_nic *efx, u32 rxq_entries, u32 txq_entries)
tx_queue->txd.entries); tx_queue->txd.entries);
} }
efx_device_detach_sync(efx);
efx_stop_all(efx); efx_stop_all(efx);
efx_stop_interrupts(efx, true); efx_stop_interrupts(efx, true);
...@@ -832,6 +833,7 @@ efx_realloc_channels(struct efx_nic *efx, u32 rxq_entries, u32 txq_entries) ...@@ -832,6 +833,7 @@ efx_realloc_channels(struct efx_nic *efx, u32 rxq_entries, u32 txq_entries)
efx_start_interrupts(efx, true); efx_start_interrupts(efx, true);
efx_start_all(efx); efx_start_all(efx);
netif_device_attach(efx->net_dev);
return rc; return rc;
rollback: rollback:
...@@ -1641,8 +1643,12 @@ static void efx_stop_all(struct efx_nic *efx) ...@@ -1641,8 +1643,12 @@ static void efx_stop_all(struct efx_nic *efx)
/* Flush efx_mac_work(), refill_workqueue, monitor_work */ /* Flush efx_mac_work(), refill_workqueue, monitor_work */
efx_flush_all(efx); efx_flush_all(efx);
/* Stop the kernel transmit interface late, so the watchdog /* Stop the kernel transmit interface. This is only valid if
* timer isn't ticking over the flush */ * the device is stopped or detached; otherwise the watchdog
* may fire immediately.
*/
WARN_ON(netif_running(efx->net_dev) &&
netif_device_present(efx->net_dev));
netif_tx_disable(efx->net_dev); netif_tx_disable(efx->net_dev);
efx_stop_datapath(efx); efx_stop_datapath(efx);
...@@ -1963,16 +1969,18 @@ static int efx_change_mtu(struct net_device *net_dev, int new_mtu) ...@@ -1963,16 +1969,18 @@ static int efx_change_mtu(struct net_device *net_dev, int new_mtu)
if (new_mtu > EFX_MAX_MTU) if (new_mtu > EFX_MAX_MTU)
return -EINVAL; return -EINVAL;
efx_stop_all(efx);
netif_dbg(efx, drv, efx->net_dev, "changing MTU to %d\n", new_mtu); netif_dbg(efx, drv, efx->net_dev, "changing MTU to %d\n", new_mtu);
efx_device_detach_sync(efx);
efx_stop_all(efx);
mutex_lock(&efx->mac_lock); mutex_lock(&efx->mac_lock);
net_dev->mtu = new_mtu; net_dev->mtu = new_mtu;
efx->type->reconfigure_mac(efx); efx->type->reconfigure_mac(efx);
mutex_unlock(&efx->mac_lock); mutex_unlock(&efx->mac_lock);
efx_start_all(efx); efx_start_all(efx);
netif_device_attach(efx->net_dev);
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