qla2xxx: Remove wait for online from host reset handler.
[firefly-linux-kernel-4.4.55.git] / drivers / scsi / qla2xxx / qla_os.c
index b182d27695cf4e4efc89e05d68e12ec734181217..5a430c7bc02715166a987a7aeb2b957a0795de09 100644 (file)
@@ -616,7 +616,7 @@ qla2x00_sp_free_dma(void *vha, void *ptr)
 
        if (sp->flags & SRB_CRC_CTX_DSD_VALID) {
                /* List assured to be having elements */
-               qla2x00_clean_dsd_pool(ha, sp);
+               qla2x00_clean_dsd_pool(ha, sp, NULL);
                sp->flags &= ~SRB_CRC_CTX_DSD_VALID;
        }
 
@@ -781,7 +781,7 @@ static int
 qla2x00_eh_wait_on_command(struct scsi_cmnd *cmd)
 {
 #define ABORT_POLLING_PERIOD   1000
-#define ABORT_WAIT_ITER                ((10 * 1000) / (ABORT_POLLING_PERIOD))
+#define ABORT_WAIT_ITER                ((2 * 1000) / (ABORT_POLLING_PERIOD))
        unsigned long wait_iter = ABORT_WAIT_ITER;
        scsi_qla_host_t *vha = shost_priv(cmd->device->host);
        struct qla_hw_data *ha = vha->hw;
@@ -844,11 +844,8 @@ qla2x00_wait_for_hba_online(scsi_qla_host_t *vha)
 }
 
 /*
- * qla2x00_wait_for_reset_ready
- *    Wait till the HBA is online after going through
- *    <= MAX_RETRIES_OF_ISP_ABORT  or
- *    finally HBA is disabled ie marked offline or flash
- *    operations are in progress.
+ * qla2x00_wait_for_hba_ready
+ * Wait till the HBA is ready before doing driver unload
  *
  * Input:
  *     ha - pointer to host adapter structure
@@ -857,35 +854,15 @@ qla2x00_wait_for_hba_online(scsi_qla_host_t *vha)
  *    Does context switching-Release SPIN_LOCK
  *    (if any) before calling this routine.
  *
- * Return:
- *    Success (Adapter is online/no flash ops) : 0
- *    Failed  (Adapter is offline/disabled/flash ops in progress) : 1
  */
-static int
-qla2x00_wait_for_reset_ready(scsi_qla_host_t *vha)
+static void
+qla2x00_wait_for_hba_ready(scsi_qla_host_t *vha)
 {
-       int             return_status;
-       unsigned long   wait_online;
        struct qla_hw_data *ha = vha->hw;
-       scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev);
 
-       wait_online = jiffies + (MAX_LOOP_TIMEOUT * HZ);
-       while (((test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags)) ||
-           test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags) ||
-           test_bit(ISP_ABORT_RETRY, &base_vha->dpc_flags) ||
-           ha->optrom_state != QLA_SWAITING ||
-           ha->dpc_active) && time_before(jiffies, wait_online))
+       while ((!(vha->flags.online) || ha->dpc_active ||
+           ha->flags.mbox_busy))
                msleep(1000);
-
-       if (base_vha->flags.online &&  ha->optrom_state == QLA_SWAITING)
-               return_status = QLA_SUCCESS;
-       else
-               return_status = QLA_FUNCTION_FAILED;
-
-       ql_dbg(ql_dbg_taskm, vha, 0x8019,
-           "%s return status=%d.\n", __func__, return_status);
-
-       return return_status;
 }
 
 int
@@ -945,7 +922,7 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd)
        int ret;
        unsigned int id, lun;
        unsigned long flags;
-       int wait = 0;
+       int rval, wait = 0;
        struct qla_hw_data *ha = vha->hw;
 
        if (!CMD_SP(cmd))
@@ -974,10 +951,20 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd)
        sp_get(sp);
 
        spin_unlock_irqrestore(&ha->hardware_lock, flags);
-       if (ha->isp_ops->abort_command(sp)) {
-               ret = FAILED;
+       rval = ha->isp_ops->abort_command(sp);
+       if (rval) {
+               if (rval == QLA_FUNCTION_PARAMETER_ERROR) {
+                       /*
+                        * Decrement the ref_count since we can't find the
+                        * command
+                        */
+                       atomic_dec(&sp->ref_count);
+                       ret = SUCCESS;
+               } else
+                       ret = FAILED;
+
                ql_dbg(ql_dbg_taskm, vha, 0x8003,
-                   "Abort command mbx failed cmd=%p.\n", cmd);
+                   "Abort command mbx failed cmd=%p, rval=%x.\n", cmd, rval);
        } else {
                ql_dbg(ql_dbg_taskm, vha, 0x8004,
                    "Abort command mbx success cmd=%p.\n", cmd);
@@ -985,6 +972,12 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd)
        }
 
        spin_lock_irqsave(&ha->hardware_lock, flags);
+       /*
+        * Clear the slot in the oustanding_cmds array if we can't find the
+        * command to reclaim the resources.
+        */
+       if (rval == QLA_FUNCTION_PARAMETER_ERROR)
+               vha->req->outstanding_cmds[sp->handle] = NULL;
        sp->done(ha, sp, 0);
        spin_unlock_irqrestore(&ha->hardware_lock, flags);
 
@@ -1236,7 +1229,11 @@ qla2xxx_eh_host_reset(struct scsi_cmnd *cmd)
        ql_log(ql_log_info, vha, 0x8018,
            "ADAPTER RESET ISSUED nexus=%ld:%d:%d.\n", vha->host_no, id, lun);
 
-       if (qla2x00_wait_for_reset_ready(vha) != QLA_SUCCESS)
+       /*
+        * No point in issuing another reset if one is active.  Also do not
+        * attempt a reset if we are updating flash.
+        */
+       if (qla2x00_reset_active(vha) || ha->optrom_state != QLA_SWAITING)
                goto eh_host_reset_lock;
 
        if (vha != base_vha) {
@@ -3145,6 +3142,8 @@ qla2x00_remove_one(struct pci_dev *pdev)
        base_vha = pci_get_drvdata(pdev);
        ha = base_vha->hw;
 
+       qla2x00_wait_for_hba_ready(base_vha);
+
        set_bit(UNLOADING, &base_vha->dpc_flags);
 
        if (IS_QLAFX00(ha))
@@ -5087,8 +5086,10 @@ intr_on_check:
                        ha->isp_ops->enable_intrs(ha);
 
                if (test_and_clear_bit(BEACON_BLINK_NEEDED,
-                                       &base_vha->dpc_flags))
-                       ha->isp_ops->beacon_blink(base_vha);
+                                       &base_vha->dpc_flags)) {
+                       if (ha->beacon_blink_led == 1)
+                               ha->isp_ops->beacon_blink(base_vha);
+               }
 
                if (!IS_QLAFX00(ha))
                        qla2x00_do_dpc_all_vps(base_vha);