Commit f0626c87 authored by Peter Dunning's avatar Peter Dunning Committed by Ben Hutchings

sfc: do not device_attach if a reset is pending

commit 9c568fd8 upstream.

efx_start_all can return without initialising queues as a reset is pending.
 This means that when netif_device_attach is called, the kernel can start
 sending traffic without having an initialised TX queue to send to.
This patch avoids this by not calling netif_device_attach if there is a
 pending reset.

Fixes: e283546c ("sfc:On MCDI timeout, issue an FLR (and mark MCDI to fail-fast)")
Signed-off-by: default avatarEdward Cree <ecree@solarflare.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
[bwh: Backported to 3.16:
 - Drop changes in ef10.c and ef10_sriov.c
 - Adjust context]
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent 8287542f
...@@ -833,7 +833,7 @@ efx_realloc_channels(struct efx_nic *efx, u32 rxq_entries, u32 txq_entries) ...@@ -833,7 +833,7 @@ efx_realloc_channels(struct efx_nic *efx, u32 rxq_entries, u32 txq_entries)
efx_schedule_reset(efx, RESET_TYPE_DISABLE); efx_schedule_reset(efx, RESET_TYPE_DISABLE);
} else { } else {
efx_start_all(efx); efx_start_all(efx);
netif_device_attach(efx->net_dev); efx_device_attach_if_not_resetting(efx);
} }
return rc; return rc;
...@@ -2036,6 +2036,8 @@ static int efx_net_open(struct net_device *net_dev) ...@@ -2036,6 +2036,8 @@ static int efx_net_open(struct net_device *net_dev)
efx_link_status_changed(efx); efx_link_status_changed(efx);
efx_start_all(efx); efx_start_all(efx);
if (efx->state == STATE_DISABLED || efx->reset_pending)
netif_device_detach(efx->net_dev);
efx_selftest_async_start(efx); efx_selftest_async_start(efx);
return 0; return 0;
} }
...@@ -2106,7 +2108,7 @@ static int efx_change_mtu(struct net_device *net_dev, int new_mtu) ...@@ -2106,7 +2108,7 @@ static int efx_change_mtu(struct net_device *net_dev, int new_mtu)
mutex_unlock(&efx->mac_lock); mutex_unlock(&efx->mac_lock);
efx_start_all(efx); efx_start_all(efx);
netif_device_attach(efx->net_dev); efx_device_attach_if_not_resetting(efx);
return 0; return 0;
} }
...@@ -2455,7 +2457,7 @@ int efx_reset(struct efx_nic *efx, enum reset_type method) ...@@ -2455,7 +2457,7 @@ int efx_reset(struct efx_nic *efx, enum reset_type method)
efx->state = STATE_DISABLED; efx->state = STATE_DISABLED;
} else { } else {
netif_dbg(efx, drv, efx->net_dev, "reset complete\n"); netif_dbg(efx, drv, efx->net_dev, "reset complete\n");
netif_device_attach(efx->net_dev); efx_device_attach_if_not_resetting(efx);
} }
return rc; return rc;
} }
...@@ -3035,7 +3037,7 @@ static int efx_pm_thaw(struct device *dev) ...@@ -3035,7 +3037,7 @@ static int efx_pm_thaw(struct device *dev)
efx_start_all(efx); efx_start_all(efx);
netif_device_attach(efx->net_dev); efx_device_attach_if_not_resetting(efx);
efx->state = STATE_READY; efx->state = STATE_READY;
......
...@@ -247,4 +247,10 @@ static inline void efx_device_detach_sync(struct efx_nic *efx) ...@@ -247,4 +247,10 @@ static inline void efx_device_detach_sync(struct efx_nic *efx)
netif_tx_unlock_bh(dev); netif_tx_unlock_bh(dev);
} }
static inline void efx_device_attach_if_not_resetting(struct efx_nic *efx)
{
if ((efx->state != STATE_DISABLED) && !efx->reset_pending)
netif_device_attach(efx->net_dev);
}
#endif /* EFX_EFX_H */ #endif /* EFX_EFX_H */
...@@ -749,7 +749,7 @@ int efx_selftest(struct efx_nic *efx, struct efx_self_tests *tests, ...@@ -749,7 +749,7 @@ int efx_selftest(struct efx_nic *efx, struct efx_self_tests *tests,
__efx_reconfigure_port(efx); __efx_reconfigure_port(efx);
mutex_unlock(&efx->mac_lock); mutex_unlock(&efx->mac_lock);
netif_device_attach(efx->net_dev); efx_device_attach_if_not_resetting(efx);
return rc_test; return rc_test;
} }
......
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