]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
sfc: lock TX queues when calling netif_device_detach()
authorDaniel Pieczko <dpieczko@solarflare.com>
Wed, 17 Oct 2012 12:21:23 +0000 (13:21 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 28 Mar 2013 19:11:55 +0000 (12:11 -0700)
[ Upstream commit c2f3b8e3a44b6fe9e36704e30157ebe1a88c08b1 ]

The assertion of netif_device_present() at the top of
efx_hard_start_xmit() may fail if we don't do this.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
[bwh: Backported to 3.4: adjust context]
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ethernet/sfc/efx.c
drivers/net/ethernet/sfc/efx.h
drivers/net/ethernet/sfc/selftest.c

index e7ac397d2778c05b14de9b3fe4557ae1ca3b6a1e..8c81d1c6519af38a04ac04a35d0fecafd7ea9e15 100644 (file)
@@ -2224,7 +2224,7 @@ int efx_reset(struct efx_nic *efx, enum reset_type method)
        netif_info(efx, drv, efx->net_dev, "resetting (%s)\n",
                   RESET_TYPE(method));
 
-       netif_device_detach(efx->net_dev);
+       efx_device_detach_sync(efx);
        efx_reset_down(efx, method);
 
        rc = efx->type->reset(efx, method);
@@ -2718,7 +2718,7 @@ static int efx_pm_freeze(struct device *dev)
 
        efx->state = STATE_FINI;
 
-       netif_device_detach(efx->net_dev);
+       efx_device_detach_sync(efx);
 
        efx_stop_all(efx);
        efx_stop_interrupts(efx, false);
index 70755c97251aaab4e9cafe969b0a8b95821a1cbb..320cf7bfc7f9b13aae6e21f25178e0e52e579019 100644 (file)
@@ -162,4 +162,17 @@ extern void efx_link_status_changed(struct efx_nic *efx);
 extern void efx_link_set_advertising(struct efx_nic *efx, u32);
 extern void efx_link_set_wanted_fc(struct efx_nic *efx, u8);
 
+static inline void efx_device_detach_sync(struct efx_nic *efx)
+{
+       struct net_device *dev = efx->net_dev;
+
+       /* Lock/freeze all TX queues so that we can be sure the
+        * TX scheduler is stopped when we're done and before
+        * netif_device_present() becomes false.
+        */
+       netif_tx_lock(dev);
+       netif_device_detach(dev);
+       netif_tx_unlock(dev);
+}
+
 #endif /* EFX_EFX_H */
index de4c0069f5b2ef658f9badf314672685bc21cf13..06867916c0200b73f3ddd86df7d4a3b27a4f2016 100644 (file)
@@ -735,7 +735,7 @@ int efx_selftest(struct efx_nic *efx, struct efx_self_tests *tests,
        /* Detach the device so the kernel doesn't transmit during the
         * loopback test and the watchdog timeout doesn't fire.
         */
-       netif_device_detach(efx->net_dev);
+       efx_device_detach_sync(efx);
 
        mutex_lock(&efx->mac_lock);
        if (efx->loopback_modes) {