net/cxgb4: Don't retrieve stats during recovery
authorGavin Shan <shangw@linux.vnet.ibm.com>
Thu, 23 Jan 2014 04:27:35 +0000 (12:27 +0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 23 Jan 2014 21:21:03 +0000 (13:21 -0800)
We possibly retrieve the adapter's statistics during EEH recovery
and that should be disallowed. Otherwise, it would possibly incur
replicate EEH error and EEH recovery is going to fail eventually.

The patch reuses statistics lock and checks net_device is attached
before going to retrieve statistics, so that the problem can be
avoided.

Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c

index c8eafbf1f51d26c56659f940987f05078f8acb5d..139a70405582c1fa094f7147c32928dd8b880190 100644 (file)
@@ -4288,7 +4288,15 @@ static struct rtnl_link_stats64 *cxgb_get_stats(struct net_device *dev,
        struct port_info *p = netdev_priv(dev);
        struct adapter *adapter = p->adapter;
 
+       /* Block retrieving statistics during EEH error
+        * recovery. Otherwise, the recovery might fail
+        * and the PCI device will be removed permanently
+        */
        spin_lock(&adapter->stats_lock);
+       if (!netif_device_present(dev)) {
+               spin_unlock(&adapter->stats_lock);
+               return ns;
+       }
        t4_get_port_stats(adapter, p->tx_chan, &stats);
        spin_unlock(&adapter->stats_lock);
 
@@ -5496,12 +5504,14 @@ static pci_ers_result_t eeh_err_detected(struct pci_dev *pdev,
        rtnl_lock();
        adap->flags &= ~FW_OK;
        notify_ulds(adap, CXGB4_STATE_START_RECOVERY);
+       spin_lock(&adap->stats_lock);
        for_each_port(adap, i) {
                struct net_device *dev = adap->port[i];
 
                netif_device_detach(dev);
                netif_carrier_off(dev);
        }
+       spin_unlock(&adap->stats_lock);
        if (adap->flags & FULL_INIT_DONE)
                cxgb_down(adap);
        rtnl_unlock();