i40e: add a comment on barrier and fix panic on reset
authorGreg Rose <gregory.v.rose@intel.com>
Wed, 18 Dec 2013 13:45:53 +0000 (13:45 +0000)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Thu, 9 Jan 2014 10:19:36 +0000 (02:19 -0800)
The memory barrier used in maybe_stop_tx can use a comment.

Also add checks to VSI->rx_rings to ensure a kernel panic is not induced.

Change-ID: I48cc1bf1d6cf301818155b737edeef77c0d790c7
Change-ID: I1363a8445fbf521a26267849966296ed55f43ad8
Signed-off-by: Greg Rose <gregory.v.rose@intel.com>
Signed-off-by: Mitch Williams <mitch.a.williams@intel.com>
Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
Tested-by: Kavindya Deegala <kavindya.s.deegala@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
drivers/net/ethernet/intel/i40e/i40e_main.c
drivers/net/ethernet/intel/i40e/i40e_txrx.c

index ea761347b9f7cc1b7ffd278a181966f34934c040..5cdc67c31a3191f7caff5b8f7993842b3c8a99ec 100644 (file)
@@ -422,7 +422,7 @@ void i40e_vsi_reset_stats(struct i40e_vsi *vsi)
        memset(&vsi->net_stats_offsets, 0, sizeof(vsi->net_stats_offsets));
        memset(&vsi->eth_stats, 0, sizeof(vsi->eth_stats));
        memset(&vsi->eth_stats_offsets, 0, sizeof(vsi->eth_stats_offsets));
-       if (vsi->rx_rings)
+       if (vsi->rx_rings && vsi->rx_rings[0]) {
                for (i = 0; i < vsi->num_queue_pairs; i++) {
                        memset(&vsi->rx_rings[i]->stats, 0 ,
                               sizeof(vsi->rx_rings[i]->stats));
@@ -433,6 +433,7 @@ void i40e_vsi_reset_stats(struct i40e_vsi *vsi)
                        memset(&vsi->tx_rings[i]->tx_stats, 0,
                               sizeof(vsi->tx_rings[i]->tx_stats));
                }
+       }
        vsi->stat_offsets_loaded = false;
 }
 
@@ -2067,8 +2068,11 @@ static void i40e_vsi_free_tx_resources(struct i40e_vsi *vsi)
 {
        int i;
 
+       if (!vsi->tx_rings)
+               return;
+
        for (i = 0; i < vsi->num_queue_pairs; i++)
-               if (vsi->tx_rings[i]->desc)
+               if (vsi->tx_rings[i] && vsi->tx_rings[i]->desc)
                        i40e_free_tx_resources(vsi->tx_rings[i]);
 }
 
@@ -2101,8 +2105,11 @@ static void i40e_vsi_free_rx_resources(struct i40e_vsi *vsi)
 {
        int i;
 
+       if (!vsi->rx_rings)
+               return;
+
        for (i = 0; i < vsi->num_queue_pairs; i++)
-               if (vsi->rx_rings[i]->desc)
+               if (vsi->rx_rings[i] && vsi->rx_rings[i]->desc)
                        i40e_free_rx_resources(vsi->rx_rings[i]);
 }
 
@@ -5349,7 +5356,7 @@ static void i40e_vsi_clear_rings(struct i40e_vsi *vsi)
 {
        int i;
 
-       if (vsi->tx_rings[0]) {
+       if (vsi->tx_rings && vsi->tx_rings[0]) {
                for (i = 0; i < vsi->alloc_queue_pairs; i++) {
                        kfree_rcu(vsi->tx_rings[i], rcu);
                        vsi->tx_rings[i] = NULL;
index e81e5bf1742e814f942fdcd5a2c5eba0d10b9d14..bc72f4efd6d6527374aa159653dec9f6f797d79f 100644 (file)
@@ -1715,6 +1715,7 @@ dma_error:
 static inline int __i40e_maybe_stop_tx(struct i40e_ring *tx_ring, int size)
 {
        netif_stop_subqueue(tx_ring->netdev, tx_ring->queue_index);
+       /* Memory barrier before checking head and tail */
        smp_mb();
 
        /* Check again in a case another CPU has just made room available. */