aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2015-02-09 17:17:19 -0500
committerDavid S. Miller <davem@davemloft.net>2015-02-09 17:17:19 -0500
commit60cd0854de687103125e2aa62b5f6ab3ee0213ea (patch)
treeb057159c9dcb4765498b9fc74ea219f40f5f6364
parent1d966d03a37f7f58abf12e87203d03f96950cfd0 (diff)
parent638702bd59a336f48f39a58ed8bdf199c08afeda (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/net-next
Jeff Kirsher says: ==================== Intel Wired LAN Driver Updates 2015-02-09 This series contains updates to i40e and i40evf only. Rickard Strandqvist removes an unused function for i40e. John Linville reorders a piece of code so that y_budget does not get used by the FCoE code before it gets initialized. Mitch adds a delay after VF reset with a minimum of 10ms to allow the hardware internal FIFOs to flush. Bumps up the ARQ descriptors, since we can easily overrun the PF's admin receive queue. Added locking around the VF reset code, since during VF deallocation, we cannot depend on simply masking the interrupt since this does not lock out the service task, which can still call the reset routine. Fix a potential multi-minute delay on driver unload, VF disable or system shutdown. When the module is being unloaded, waiting for the PF to politely handle all of our admin queue requests might take forever with a lot of VFs enabled, so just stop everything and request a VF reset. Also stops the watchdog during shutdown to prevent a log full of admin queue errors and the occasional hang when the system is shut down. Anjali forces Tx descriptor writebacks on ITR by kicking off the SWINT interrupt since we noticed that there are non-cache-aligned Tx descriptors waiting in the ring while interrupts are disabled under NAPI. Enables loopback for the FCoE VSI, so that VSIs can directly talk to each other without going out on the wire. Matthew fixes an LED blink issue by making sure to clear the GPIO blink field, instead of OR'ing against zero if the field is already '1'. Greg cleans up a function header comment. Vasu helps biosdevname user tool to differentiate dev_port for PCoE netdev and PF netdev, by setting different dev_port value for FCoE netdev. Carolyn adds a call to u64_stats_init to the receive setup in order to avoid lockdep errors with seqcount on newer kernels. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e.h5
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_common.c6
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_fcoe.c16
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_main.c14
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_txrx.c6
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c25
-rw-r--r--drivers/net/ethernet/intel/i40evf/i40e_txrx.c40
-rw-r--r--drivers/net/ethernet/intel/i40evf/i40e_txrx.h1
-rw-r--r--drivers/net/ethernet/intel/i40evf/i40evf_main.c23
9 files changed, 95 insertions, 41 deletions
diff --git a/drivers/net/ethernet/intel/i40e/i40e.h b/drivers/net/ethernet/intel/i40e/i40e.h
index fadf8fa3cb75..2b65cdcad6ba 100644
--- a/drivers/net/ethernet/intel/i40e/i40e.h
+++ b/drivers/net/ethernet/intel/i40e/i40e.h
@@ -87,8 +87,8 @@
87#define I40E_MINIMUM_FCOE 1 /* minimum number of QPs for FCoE */ 87#define I40E_MINIMUM_FCOE 1 /* minimum number of QPs for FCoE */
88#endif /* I40E_FCOE */ 88#endif /* I40E_FCOE */
89#define I40E_MAX_AQ_BUF_SIZE 4096 89#define I40E_MAX_AQ_BUF_SIZE 4096
90#define I40E_AQ_LEN 128 90#define I40E_AQ_LEN 256
91#define I40E_AQ_WORK_LIMIT 16 91#define I40E_AQ_WORK_LIMIT 32
92#define I40E_MAX_USER_PRIORITY 8 92#define I40E_MAX_USER_PRIORITY 8
93#define I40E_DEFAULT_MSG_ENABLE 4 93#define I40E_DEFAULT_MSG_ENABLE 4
94#define I40E_QUEUE_WAIT_RETRY_LIMIT 10 94#define I40E_QUEUE_WAIT_RETRY_LIMIT 10
@@ -148,6 +148,7 @@ enum i40e_state_t {
148 __I40E_FD_FLUSH_REQUESTED, 148 __I40E_FD_FLUSH_REQUESTED,
149 __I40E_RESET_FAILED, 149 __I40E_RESET_FAILED,
150 __I40E_PORT_TX_SUSPENDED, 150 __I40E_PORT_TX_SUSPENDED,
151 __I40E_VF_DISABLE,
151}; 152};
152 153
153enum i40e_interrupt_policy { 154enum i40e_interrupt_policy {
diff --git a/drivers/net/ethernet/intel/i40e/i40e_common.c b/drivers/net/ethernet/intel/i40e/i40e_common.c
index 5669bfa39f14..11a9ffebf8d8 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_common.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_common.c
@@ -1142,8 +1142,10 @@ void i40e_led_set(struct i40e_hw *hw, u32 mode, bool blink)
1142 if (mode == I40E_LINK_ACTIVITY) 1142 if (mode == I40E_LINK_ACTIVITY)
1143 blink = false; 1143 blink = false;
1144 1144
1145 gpio_val |= (blink ? 1 : 0) << 1145 if (blink)
1146 I40E_GLGEN_GPIO_CTL_LED_BLINK_SHIFT; 1146 gpio_val |= (1 << I40E_GLGEN_GPIO_CTL_LED_BLINK_SHIFT);
1147 else
1148 gpio_val &= ~(1 << I40E_GLGEN_GPIO_CTL_LED_BLINK_SHIFT);
1147 1149
1148 wr32(hw, I40E_GLGEN_GPIO_CTL(i), gpio_val); 1150 wr32(hw, I40E_GLGEN_GPIO_CTL(i), gpio_val);
1149 break; 1151 break;
diff --git a/drivers/net/ethernet/intel/i40e/i40e_fcoe.c b/drivers/net/ethernet/intel/i40e/i40e_fcoe.c
index 2cd841b29059..27c206e62da7 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_fcoe.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_fcoe.c
@@ -39,15 +39,6 @@
39#include "i40e_fcoe.h" 39#include "i40e_fcoe.h"
40 40
41/** 41/**
42 * i40e_rx_is_fip - returns true if the rx packet type is FIP
43 * @ptype: the packet type field from rx descriptor write-back
44 **/
45static inline bool i40e_rx_is_fip(u16 ptype)
46{
47 return ptype == I40E_RX_PTYPE_L2_FIP_PAY2;
48}
49
50/**
51 * i40e_rx_is_fcoe - returns true if the rx packet type is FCoE 42 * i40e_rx_is_fcoe - returns true if the rx packet type is FCoE
52 * @ptype: the packet type field from rx descriptor write-back 43 * @ptype: the packet type field from rx descriptor write-back
53 **/ 44 **/
@@ -404,6 +395,7 @@ int i40e_fcoe_vsi_init(struct i40e_vsi *vsi, struct i40e_vsi_context *ctxt)
404 I40E_AQ_VSI_PROP_INGRESS_UP_VALID | 395 I40E_AQ_VSI_PROP_INGRESS_UP_VALID |
405 I40E_AQ_VSI_PROP_EGRESS_UP_VALID)); 396 I40E_AQ_VSI_PROP_EGRESS_UP_VALID));
406 397
398 info->switch_id = cpu_to_le16(I40E_AQ_VSI_SW_ID_FLAG_ALLOW_LB);
407 enabled_tc = i40e_get_fcoe_tc_map(pf); 399 enabled_tc = i40e_get_fcoe_tc_map(pf);
408 i40e_vsi_setup_queue_map(vsi, ctxt, enabled_tc, true); 400 i40e_vsi_setup_queue_map(vsi, ctxt, enabled_tc, true);
409 401
@@ -1511,6 +1503,12 @@ void i40e_fcoe_config_netdev(struct net_device *netdev, struct i40e_vsi *vsi)
1511 strlcpy(netdev->name, "fcoe%d", IFNAMSIZ-1); 1503 strlcpy(netdev->name, "fcoe%d", IFNAMSIZ-1);
1512 netdev->mtu = FCOE_MTU; 1504 netdev->mtu = FCOE_MTU;
1513 SET_NETDEV_DEV(netdev, &pf->pdev->dev); 1505 SET_NETDEV_DEV(netdev, &pf->pdev->dev);
1506 /* set different dev_port value 1 for FCoE netdev than the default
1507 * zero dev_port value for PF netdev, this helps biosdevname user
1508 * tool to differentiate them correctly while both attached to the
1509 * same PCI function.
1510 */
1511 netdev->dev_port = 1;
1514 i40e_add_filter(vsi, hw->mac.san_addr, 0, false, false); 1512 i40e_add_filter(vsi, hw->mac.san_addr, 0, false, false);
1515 i40e_add_filter(vsi, (u8[6]) FC_FCOE_FLOGI_MAC, 0, false, false); 1513 i40e_add_filter(vsi, (u8[6]) FC_FCOE_FLOGI_MAC, 0, false, false);
1516 i40e_add_filter(vsi, FIP_ALL_FCOE_MACS, 0, false, false); 1514 i40e_add_filter(vsi, FIP_ALL_FCOE_MACS, 0, false, false);
diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index e774a23901f9..cbe281be1c9f 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -2940,7 +2940,7 @@ void i40e_irq_dynamic_enable(struct i40e_vsi *vsi, int vector)
2940/** 2940/**
2941 * i40e_irq_dynamic_disable - Disable default interrupt generation settings 2941 * i40e_irq_dynamic_disable - Disable default interrupt generation settings
2942 * @vsi: pointer to a vsi 2942 * @vsi: pointer to a vsi
2943 * @vector: enable a particular Hw Interrupt vector 2943 * @vector: disable a particular Hw Interrupt vector
2944 **/ 2944 **/
2945void i40e_irq_dynamic_disable(struct i40e_vsi *vsi, int vector) 2945void i40e_irq_dynamic_disable(struct i40e_vsi *vsi, int vector)
2946{ 2946{
@@ -6933,17 +6933,17 @@ static int i40e_init_msix(struct i40e_pf *pf)
6933 if (pf->flags & I40E_FLAG_FD_SB_ENABLED) 6933 if (pf->flags & I40E_FLAG_FD_SB_ENABLED)
6934 other_vecs++; 6934 other_vecs++;
6935 6935
6936 /* Scale down if necessary, and the rings will share vectors */
6937 pf->num_lan_msix = min_t(int, pf->num_lan_msix,
6938 (hw->func_caps.num_msix_vectors - other_vecs));
6939 v_budget = pf->num_lan_msix + other_vecs;
6940
6936#ifdef I40E_FCOE 6941#ifdef I40E_FCOE
6937 if (pf->flags & I40E_FLAG_FCOE_ENABLED) { 6942 if (pf->flags & I40E_FLAG_FCOE_ENABLED) {
6938 pf->num_fcoe_msix = pf->num_fcoe_qps; 6943 pf->num_fcoe_msix = pf->num_fcoe_qps;
6939 v_budget += pf->num_fcoe_msix; 6944 v_budget += pf->num_fcoe_msix;
6940 } 6945 }
6941
6942#endif 6946#endif
6943 /* Scale down if necessary, and the rings will share vectors */
6944 pf->num_lan_msix = min_t(int, pf->num_lan_msix,
6945 (hw->func_caps.num_msix_vectors - other_vecs));
6946 v_budget = pf->num_lan_msix + other_vecs;
6947 6947
6948 pf->msix_entries = kcalloc(v_budget, sizeof(struct msix_entry), 6948 pf->msix_entries = kcalloc(v_budget, sizeof(struct msix_entry),
6949 GFP_KERNEL); 6949 GFP_KERNEL);
@@ -9736,6 +9736,8 @@ static int i40e_suspend(struct pci_dev *pdev, pm_message_t state)
9736 9736
9737 set_bit(__I40E_SUSPENDED, &pf->state); 9737 set_bit(__I40E_SUSPENDED, &pf->state);
9738 set_bit(__I40E_DOWN, &pf->state); 9738 set_bit(__I40E_DOWN, &pf->state);
9739 del_timer_sync(&pf->service_timer);
9740 cancel_work_sync(&pf->service_task);
9739 rtnl_lock(); 9741 rtnl_lock();
9740 i40e_prep_for_reset(pf); 9742 i40e_prep_for_reset(pf);
9741 rtnl_unlock(); 9743 rtnl_unlock();
diff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.c b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
index 420d66274d69..f4d6d90572d1 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_txrx.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
@@ -836,8 +836,8 @@ static void i40e_force_wb(struct i40e_vsi *vsi, struct i40e_q_vector *q_vector)
836{ 836{
837 u32 val = I40E_PFINT_DYN_CTLN_INTENA_MASK | 837 u32 val = I40E_PFINT_DYN_CTLN_INTENA_MASK |
838 I40E_PFINT_DYN_CTLN_SWINT_TRIG_MASK | 838 I40E_PFINT_DYN_CTLN_SWINT_TRIG_MASK |
839 I40E_PFINT_DYN_CTLN_SW_ITR_INDX_ENA_MASK 839 I40E_PFINT_DYN_CTLN_SW_ITR_INDX_ENA_MASK;
840 /* allow 00 to be written to the index */; 840 /* allow 00 to be written to the index */
841 841
842 wr32(&vsi->back->hw, 842 wr32(&vsi->back->hw,
843 I40E_PFINT_DYN_CTLN(q_vector->v_idx + vsi->base_vector - 1), 843 I40E_PFINT_DYN_CTLN(q_vector->v_idx + vsi->base_vector - 1),
@@ -1098,6 +1098,8 @@ int i40e_setup_rx_descriptors(struct i40e_ring *rx_ring)
1098 if (!rx_ring->rx_bi) 1098 if (!rx_ring->rx_bi)
1099 goto err; 1099 goto err;
1100 1100
1101 u64_stats_init(rx_ring->syncp);
1102
1101 /* Round up to nearest 4K */ 1103 /* Round up to nearest 4K */
1102 rx_ring->size = ring_is_16byte_desc_enabled(rx_ring) 1104 rx_ring->size = ring_is_16byte_desc_enabled(rx_ring)
1103 ? rx_ring->count * sizeof(union i40e_16byte_rx_desc) 1105 ? rx_ring->count * sizeof(union i40e_16byte_rx_desc)
diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
index 044019b9d406..40f042af4131 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
@@ -647,6 +647,9 @@ void i40e_reset_vf(struct i40e_vf *vf, bool flr)
647 int i; 647 int i;
648 u32 reg; 648 u32 reg;
649 649
650 if (test_and_set_bit(__I40E_VF_DISABLE, &pf->state))
651 return;
652
650 /* warn the VF */ 653 /* warn the VF */
651 clear_bit(I40E_VF_STAT_ACTIVE, &vf->vf_states); 654 clear_bit(I40E_VF_STAT_ACTIVE, &vf->vf_states);
652 655
@@ -668,13 +671,13 @@ void i40e_reset_vf(struct i40e_vf *vf, bool flr)
668 /* poll VPGEN_VFRSTAT reg to make sure 671 /* poll VPGEN_VFRSTAT reg to make sure
669 * that reset is complete 672 * that reset is complete
670 */ 673 */
671 for (i = 0; i < 100; i++) { 674 for (i = 0; i < 10; i++) {
672 /* vf reset requires driver to first reset the 675 /* VF reset requires driver to first reset the VF and then
673 * vf and then poll the status register to make sure 676 * poll the status register to make sure that the reset
674 * that the requested op was completed 677 * completed successfully. Due to internal HW FIFO flushes,
675 * successfully 678 * we must wait 10ms before the register will be valid.
676 */ 679 */
677 usleep_range(10, 20); 680 usleep_range(10000, 20000);
678 reg = rd32(hw, I40E_VPGEN_VFRSTAT(vf->vf_id)); 681 reg = rd32(hw, I40E_VPGEN_VFRSTAT(vf->vf_id));
679 if (reg & I40E_VPGEN_VFRSTAT_VFRD_MASK) { 682 if (reg & I40E_VPGEN_VFRSTAT_VFRD_MASK) {
680 rsd = true; 683 rsd = true;
@@ -706,6 +709,7 @@ complete_reset:
706 /* tell the VF the reset is done */ 709 /* tell the VF the reset is done */
707 wr32(hw, I40E_VFGEN_RSTAT1(vf->vf_id), I40E_VFR_VFACTIVE); 710 wr32(hw, I40E_VFGEN_RSTAT1(vf->vf_id), I40E_VFR_VFACTIVE);
708 i40e_flush(hw); 711 i40e_flush(hw);
712 clear_bit(__I40E_VF_DISABLE, &pf->state);
709} 713}
710 714
711/** 715/**
@@ -790,6 +794,8 @@ void i40e_free_vfs(struct i40e_pf *pf)
790 794
791 if (!pf->vf) 795 if (!pf->vf)
792 return; 796 return;
797 while (test_and_set_bit(__I40E_VF_DISABLE, &pf->state))
798 usleep_range(1000, 2000);
793 799
794 /* Disable IOV before freeing resources. This lets any VF drivers 800 /* Disable IOV before freeing resources. This lets any VF drivers
795 * running in the host get themselves cleaned up before we yank 801 * running in the host get themselves cleaned up before we yank
@@ -800,9 +806,6 @@ void i40e_free_vfs(struct i40e_pf *pf)
800 806
801 msleep(20); /* let any messages in transit get finished up */ 807 msleep(20); /* let any messages in transit get finished up */
802 808
803 /* Disable interrupt 0 so we don't try to handle the VFLR. */
804 i40e_irq_dynamic_disable_icr0(pf);
805
806 /* free up vf resources */ 809 /* free up vf resources */
807 tmp = pf->num_alloc_vfs; 810 tmp = pf->num_alloc_vfs;
808 pf->num_alloc_vfs = 0; 811 pf->num_alloc_vfs = 0;
@@ -834,9 +837,7 @@ void i40e_free_vfs(struct i40e_pf *pf)
834 dev_warn(&pf->pdev->dev, 837 dev_warn(&pf->pdev->dev,
835 "unable to disable SR-IOV because VFs are assigned.\n"); 838 "unable to disable SR-IOV because VFs are assigned.\n");
836 } 839 }
837 840 clear_bit(__I40E_VF_DISABLE, &pf->state);
838 /* Re-enable interrupt 0. */
839 i40e_irq_dynamic_enable_icr0(pf);
840} 841}
841 842
842#ifdef CONFIG_PCI_IOV 843#ifdef CONFIG_PCI_IOV
diff --git a/drivers/net/ethernet/intel/i40evf/i40e_txrx.c b/drivers/net/ethernet/intel/i40evf/i40e_txrx.c
index 82c3798fdd36..459499a47ca3 100644
--- a/drivers/net/ethernet/intel/i40evf/i40e_txrx.c
+++ b/drivers/net/ethernet/intel/i40evf/i40e_txrx.c
@@ -192,6 +192,8 @@ static inline u32 i40e_get_head(struct i40e_ring *tx_ring)
192 return le32_to_cpu(*(volatile __le32 *)head); 192 return le32_to_cpu(*(volatile __le32 *)head);
193} 193}
194 194
195#define WB_STRIDE 0x3
196
195/** 197/**
196 * i40e_clean_tx_irq - Reclaim resources after transmit completes 198 * i40e_clean_tx_irq - Reclaim resources after transmit completes
197 * @tx_ring: tx ring to clean 199 * @tx_ring: tx ring to clean
@@ -293,6 +295,14 @@ static bool i40e_clean_tx_irq(struct i40e_ring *tx_ring, int budget)
293 tx_ring->q_vector->tx.total_bytes += total_bytes; 295 tx_ring->q_vector->tx.total_bytes += total_bytes;
294 tx_ring->q_vector->tx.total_packets += total_packets; 296 tx_ring->q_vector->tx.total_packets += total_packets;
295 297
298 if (budget &&
299 !((i & WB_STRIDE) == WB_STRIDE) &&
300 !test_bit(__I40E_DOWN, &tx_ring->vsi->state) &&
301 (I40E_DESC_UNUSED(tx_ring) != tx_ring->count))
302 tx_ring->arm_wb = true;
303 else
304 tx_ring->arm_wb = false;
305
296 if (check_for_tx_hang(tx_ring) && i40e_check_tx_hang(tx_ring)) { 306 if (check_for_tx_hang(tx_ring) && i40e_check_tx_hang(tx_ring)) {
297 /* schedule immediate reset if we believe we hung */ 307 /* schedule immediate reset if we believe we hung */
298 dev_info(tx_ring->dev, "Detected Tx Unit Hang\n" 308 dev_info(tx_ring->dev, "Detected Tx Unit Hang\n"
@@ -344,6 +354,24 @@ static bool i40e_clean_tx_irq(struct i40e_ring *tx_ring, int budget)
344} 354}
345 355
346/** 356/**
357 * i40e_force_wb -Arm hardware to do a wb on noncache aligned descriptors
358 * @vsi: the VSI we care about
359 * @q_vector: the vector on which to force writeback
360 *
361 **/
362static void i40e_force_wb(struct i40e_vsi *vsi, struct i40e_q_vector *q_vector)
363{
364 u32 val = I40E_VFINT_DYN_CTLN_INTENA_MASK |
365 I40E_VFINT_DYN_CTLN_SWINT_TRIG_MASK |
366 I40E_VFINT_DYN_CTLN_SW_ITR_INDX_ENA_MASK;
367 /* allow 00 to be written to the index */
368
369 wr32(&vsi->back->hw,
370 I40E_VFINT_DYN_CTLN1(q_vector->v_idx + vsi->base_vector - 1),
371 val);
372}
373
374/**
347 * i40e_set_new_dynamic_itr - Find new ITR level 375 * i40e_set_new_dynamic_itr - Find new ITR level
348 * @rc: structure containing ring performance data 376 * @rc: structure containing ring performance data
349 * 377 *
@@ -568,6 +596,8 @@ int i40evf_setup_rx_descriptors(struct i40e_ring *rx_ring)
568 if (!rx_ring->rx_bi) 596 if (!rx_ring->rx_bi)
569 goto err; 597 goto err;
570 598
599 u64_stats_init(rx_ring->syncp);
600
571 /* Round up to nearest 4K */ 601 /* Round up to nearest 4K */
572 rx_ring->size = ring_is_16byte_desc_enabled(rx_ring) 602 rx_ring->size = ring_is_16byte_desc_enabled(rx_ring)
573 ? rx_ring->count * sizeof(union i40e_16byte_rx_desc) 603 ? rx_ring->count * sizeof(union i40e_16byte_rx_desc)
@@ -1065,6 +1095,7 @@ int i40evf_napi_poll(struct napi_struct *napi, int budget)
1065 struct i40e_vsi *vsi = q_vector->vsi; 1095 struct i40e_vsi *vsi = q_vector->vsi;
1066 struct i40e_ring *ring; 1096 struct i40e_ring *ring;
1067 bool clean_complete = true; 1097 bool clean_complete = true;
1098 bool arm_wb = false;
1068 int budget_per_ring; 1099 int budget_per_ring;
1069 1100
1070 if (test_bit(__I40E_DOWN, &vsi->state)) { 1101 if (test_bit(__I40E_DOWN, &vsi->state)) {
@@ -1075,8 +1106,10 @@ int i40evf_napi_poll(struct napi_struct *napi, int budget)
1075 /* Since the actual Tx work is minimal, we can give the Tx a larger 1106 /* Since the actual Tx work is minimal, we can give the Tx a larger
1076 * budget and be more aggressive about cleaning up the Tx descriptors. 1107 * budget and be more aggressive about cleaning up the Tx descriptors.
1077 */ 1108 */
1078 i40e_for_each_ring(ring, q_vector->tx) 1109 i40e_for_each_ring(ring, q_vector->tx) {
1079 clean_complete &= i40e_clean_tx_irq(ring, vsi->work_limit); 1110 clean_complete &= i40e_clean_tx_irq(ring, vsi->work_limit);
1111 arm_wb |= ring->arm_wb;
1112 }
1080 1113
1081 /* We attempt to distribute budget to each Rx queue fairly, but don't 1114 /* We attempt to distribute budget to each Rx queue fairly, but don't
1082 * allow the budget to go below 1 because that would exit polling early. 1115 * allow the budget to go below 1 because that would exit polling early.
@@ -1087,8 +1120,11 @@ int i40evf_napi_poll(struct napi_struct *napi, int budget)
1087 clean_complete &= i40e_clean_rx_irq(ring, budget_per_ring); 1120 clean_complete &= i40e_clean_rx_irq(ring, budget_per_ring);
1088 1121
1089 /* If work not completed, return budget and polling will return */ 1122 /* If work not completed, return budget and polling will return */
1090 if (!clean_complete) 1123 if (!clean_complete) {
1124 if (arm_wb)
1125 i40e_force_wb(vsi, q_vector);
1091 return budget; 1126 return budget;
1127 }
1092 1128
1093 /* Work is done so exit the polling mode and re-enable the interrupt */ 1129 /* Work is done so exit the polling mode and re-enable the interrupt */
1094 napi_complete(napi); 1130 napi_complete(napi);
diff --git a/drivers/net/ethernet/intel/i40evf/i40e_txrx.h b/drivers/net/ethernet/intel/i40evf/i40e_txrx.h
index c7f29626eada..4e15903b2b6d 100644
--- a/drivers/net/ethernet/intel/i40evf/i40e_txrx.h
+++ b/drivers/net/ethernet/intel/i40evf/i40e_txrx.h
@@ -238,6 +238,7 @@ struct i40e_ring {
238 u8 atr_count; 238 u8 atr_count;
239 239
240 bool ring_active; /* is ring online or not */ 240 bool ring_active; /* is ring online or not */
241 bool arm_wb; /* do something to arm write back */
241 242
242 /* stats structs */ 243 /* stats structs */
243 struct i40e_queue_stats stats; 244 struct i40e_queue_stats stats;
diff --git a/drivers/net/ethernet/intel/i40evf/i40evf_main.c b/drivers/net/ethernet/intel/i40evf/i40evf_main.c
index f946aac1df71..8d8c201c63c1 100644
--- a/drivers/net/ethernet/intel/i40evf/i40evf_main.c
+++ b/drivers/net/ethernet/intel/i40evf/i40evf_main.c
@@ -1631,7 +1631,7 @@ static void i40evf_adminq_task(struct work_struct *work)
1631 v_msg = (struct i40e_virtchnl_msg *)&event.desc; 1631 v_msg = (struct i40e_virtchnl_msg *)&event.desc;
1632 do { 1632 do {
1633 ret = i40evf_clean_arq_element(hw, &event, &pending); 1633 ret = i40evf_clean_arq_element(hw, &event, &pending);
1634 if (ret) 1634 if (ret || !v_msg->v_opcode)
1635 break; /* No event to process or error cleaning ARQ */ 1635 break; /* No event to process or error cleaning ARQ */
1636 1636
1637 i40evf_virtchnl_completion(adapter, v_msg->v_opcode, 1637 i40evf_virtchnl_completion(adapter, v_msg->v_opcode,
@@ -2213,12 +2213,18 @@ err:
2213static void i40evf_shutdown(struct pci_dev *pdev) 2213static void i40evf_shutdown(struct pci_dev *pdev)
2214{ 2214{
2215 struct net_device *netdev = pci_get_drvdata(pdev); 2215 struct net_device *netdev = pci_get_drvdata(pdev);
2216 struct i40evf_adapter *adapter = netdev_priv(netdev);
2216 2217
2217 netif_device_detach(netdev); 2218 netif_device_detach(netdev);
2218 2219
2219 if (netif_running(netdev)) 2220 if (netif_running(netdev))
2220 i40evf_close(netdev); 2221 i40evf_close(netdev);
2221 2222
2223 /* Prevent the watchdog from running. */
2224 adapter->state = __I40EVF_REMOVE;
2225 adapter->aq_required = 0;
2226 adapter->aq_pending = 0;
2227
2222#ifdef CONFIG_PM 2228#ifdef CONFIG_PM
2223 pci_save_state(pdev); 2229 pci_save_state(pdev);
2224 2230
@@ -2423,7 +2429,6 @@ static void i40evf_remove(struct pci_dev *pdev)
2423 struct i40evf_adapter *adapter = netdev_priv(netdev); 2429 struct i40evf_adapter *adapter = netdev_priv(netdev);
2424 struct i40evf_mac_filter *f, *ftmp; 2430 struct i40evf_mac_filter *f, *ftmp;
2425 struct i40e_hw *hw = &adapter->hw; 2431 struct i40e_hw *hw = &adapter->hw;
2426 int count = 50;
2427 2432
2428 cancel_delayed_work_sync(&adapter->init_task); 2433 cancel_delayed_work_sync(&adapter->init_task);
2429 cancel_work_sync(&adapter->reset_task); 2434 cancel_work_sync(&adapter->reset_task);
@@ -2432,12 +2437,18 @@ static void i40evf_remove(struct pci_dev *pdev)
2432 unregister_netdev(netdev); 2437 unregister_netdev(netdev);
2433 adapter->netdev_registered = false; 2438 adapter->netdev_registered = false;
2434 } 2439 }
2435 while (count-- && adapter->aq_required)
2436 msleep(50);
2437 2440
2438 if (count < 0) 2441 /* Shut down all the garbage mashers on the detention level */
2439 dev_err(&pdev->dev, "Timed out waiting for PF driver.\n");
2440 adapter->state = __I40EVF_REMOVE; 2442 adapter->state = __I40EVF_REMOVE;
2443 adapter->aq_required = 0;
2444 adapter->aq_pending = 0;
2445 i40evf_request_reset(adapter);
2446 msleep(20);
2447 /* If the FW isn't responding, kick it once, but only once. */
2448 if (!i40evf_asq_done(hw)) {
2449 i40evf_request_reset(adapter);
2450 msleep(20);
2451 }
2441 2452
2442 if (adapter->msix_entries) { 2453 if (adapter->msix_entries) {
2443 i40evf_misc_irq_disable(adapter); 2454 i40evf_misc_irq_disable(adapter);