ice: Prevent control queue operations during reset
authorAnirudh Venkataramanan <anirudh.venkataramanan@intel.com>
Thu, 9 Aug 2018 13:29:47 +0000 (06:29 -0700)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Tue, 28 Aug 2018 17:20:00 +0000 (10:20 -0700)
Once reset is issued, the driver loses all control queue interfaces.
Exercising control queue operations during reset is incorrect and
may result in long timeouts.

This patch introduces a new field 'reset_ongoing' in the hw structure.
This is set to 1 by the core driver when it receives a reset interrupt.
ice_sq_send_cmd checks reset_ongoing before actually issuing the control
queue operation. If a reset is in progress, it returns a soft error code
(ICE_ERR_RESET_PENDING) to the caller. The caller may or may not have to
take any action based on this return. Once the driver knows that the
reset is done, it has to set reset_ongoing back to 0. This will allow
control queue operations to be posted to the hardware again.

This "bail out" logic was specifically added to ice_sq_send_cmd (which
is pretty low level function) so that we have one solution in one place
that applies to all types of control queues.

Signed-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>
Tested-by: Tony Brelinski <tonyx.brelinski@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
drivers/net/ethernet/intel/ice/ice_controlq.c
drivers/net/ethernet/intel/ice/ice_main.c
drivers/net/ethernet/intel/ice/ice_status.h
drivers/net/ethernet/intel/ice/ice_type.h

index 62be72fdc8f30c283b2385216f41ff15b87dc628..1fe026a65d752a1ac37da57d461e3957cea5ec6d 100644 (file)
@@ -806,6 +806,9 @@ ice_sq_send_cmd(struct ice_hw *hw, struct ice_ctl_q_info *cq,
        u16 retval = 0;
        u32 val = 0;
 
+       /* if reset is in progress return a soft error */
+       if (hw->reset_ongoing)
+               return ICE_ERR_RESET_ONGOING;
        mutex_lock(&cq->sq_lock);
 
        cq->sq_last_status = ICE_AQ_RC_OK;
index f1e80eed2fd6d9f94eab163acb4d178d83ba4af2..014a2f3ea76cffe2d32f5f3df7edd99b8faee539 100644 (file)
@@ -535,10 +535,13 @@ static void ice_reset_subtask(struct ice_pf *pf)
                ice_prepare_for_reset(pf);
 
                /* make sure we are ready to rebuild */
-               if (ice_check_reset(&pf->hw))
+               if (ice_check_reset(&pf->hw)) {
                        set_bit(__ICE_RESET_FAILED, pf->state);
-               else
+               } else {
+                       /* done with reset. start rebuild */
+                       pf->hw.reset_ongoing = false;
                        ice_rebuild(pf);
+               }
                clear_bit(__ICE_RESET_RECOVERY_PENDING, pf->state);
                goto unlock;
        }
@@ -1754,7 +1757,8 @@ static irqreturn_t ice_misc_intr(int __always_unused irq, void *data)
                 * We also make note of which reset happened so that peer
                 * devices/drivers can be informed.
                 */
-               if (!test_bit(__ICE_RESET_RECOVERY_PENDING, pf->state)) {
+               if (!test_and_set_bit(__ICE_RESET_RECOVERY_PENDING,
+                                     pf->state)) {
                        if (reset == ICE_RESET_CORER)
                                set_bit(__ICE_CORER_RECV, pf->state);
                        else if (reset == ICE_RESET_GLOBR)
@@ -1762,7 +1766,20 @@ static irqreturn_t ice_misc_intr(int __always_unused irq, void *data)
                        else
                                set_bit(__ICE_EMPR_RECV, pf->state);
 
-                       set_bit(__ICE_RESET_RECOVERY_PENDING, pf->state);
+                       /* There are couple of different bits at play here.
+                        * hw->reset_ongoing indicates whether the hardware is
+                        * in reset. This is set to true when a reset interrupt
+                        * is received and set back to false after the driver
+                        * has determined that the hardware is out of reset.
+                        *
+                        * __ICE_RESET_RECOVERY_PENDING in pf->state indicates
+                        * that a post reset rebuild is required before the
+                        * driver is operational again. This is set above.
+                        *
+                        * As this is the start of the reset/rebuild cycle, set
+                        * both to indicate that.
+                        */
+                       hw->reset_ongoing = true;
                }
        }
 
@@ -4185,7 +4202,14 @@ static int ice_vsi_stop_tx_rings(struct ice_vsi *vsi)
        }
        status = ice_dis_vsi_txq(vsi->port_info, vsi->num_txq, q_ids, q_teids,
                                 NULL);
-       if (status) {
+       /* if the disable queue command was exercised during an active reset
+        * flow, ICE_ERR_RESET_ONGOING is returned. This is not an error as
+        * the reset operation disables queues at the hardware level anyway.
+        */
+       if (status == ICE_ERR_RESET_ONGOING) {
+               dev_dbg(&pf->pdev->dev,
+                       "Reset in progress. LAN Tx queues already disabled\n");
+       } else if (status) {
                dev_err(&pf->pdev->dev,
                        "Failed to disable LAN Tx queues, error: %d\n",
                        status);
index 9a95c4ffd7d795b03eebea76f6953e0255c2eea2..d2dae913d81e0bac21f3b978b1cfdacf8785d0f1 100644 (file)
@@ -20,6 +20,7 @@ enum ice_status {
        ICE_ERR_ALREADY_EXISTS                  = -14,
        ICE_ERR_DOES_NOT_EXIST                  = -15,
        ICE_ERR_MAX_LIMIT                       = -17,
+       ICE_ERR_RESET_ONGOING                   = -18,
        ICE_ERR_BUF_TOO_SHORT                   = -52,
        ICE_ERR_NVM_BLANK_MODE                  = -53,
        ICE_ERR_AQ_ERROR                        = -100,
index e1a0d0e5d074e6f3d61d2ebf2cfd982171d4e9d1..adfe131bd3f3f8acf3227407f628355356e798e6 100644 (file)
@@ -295,6 +295,7 @@ struct ice_hw {
        u16 max_children[ICE_AQC_TOPO_MAX_LEVEL_NUM];
 
        u8 evb_veb;             /* true for VEB, false for VEPA */
+       u8 reset_ongoing;       /* true if hw is in reset, false otherwise */
        struct ice_bus_info bus;
        struct ice_nvm_info nvm;
        struct ice_hw_dev_caps dev_caps;        /* device capabilities */