[SCSI] qla2xxx: The ISP82XX should be online while waiting for commands completion.
[pandora-kernel.git] / drivers / scsi / qla2xxx / qla_init.c
index f948e1a..85b86b8 100644 (file)
@@ -1967,7 +1967,7 @@ qla2x00_fw_ready(scsi_qla_host_t *vha)
                } else {
                        /* Mailbox cmd failed. Timeout on min_wait. */
                        if (time_after_eq(jiffies, mtime) ||
-                           (IS_QLA82XX(ha) && ha->flags.fw_hung))
+                               ha->flags.isp82xx_fw_hung)
                                break;
                }
 
@@ -3943,8 +3943,13 @@ qla2x00_abort_isp_cleanup(scsi_qla_host_t *vha)
        struct qla_hw_data *ha = vha->hw;
        struct scsi_qla_host *vp;
        unsigned long flags;
+       fc_port_t *fcport;
 
-       vha->flags.online = 0;
+       /* For ISP82XX, driver waits for completion of the commands.
+        * online flag should be set.
+        */
+       if (!IS_QLA82XX(ha))
+               vha->flags.online = 0;
        ha->flags.chip_reset_done = 0;
        clear_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
        ha->qla_stats.total_isp_aborts++;
@@ -3952,7 +3957,10 @@ qla2x00_abort_isp_cleanup(scsi_qla_host_t *vha)
        qla_printk(KERN_INFO, ha,
            "Performing ISP error recovery - ha= %p.\n", ha);
 
-       /* Chip reset does not apply to 82XX */
+       /* For ISP82XX, reset_chip is just disabling interrupts.
+        * Driver waits for the completion of the commands.
+        * the interrupts need to be enabled.
+        */
        if (!IS_QLA82XX(ha))
                ha->isp_ops->reset_chip(vha);
 
@@ -3978,14 +3986,31 @@ qla2x00_abort_isp_cleanup(scsi_qla_host_t *vha)
                            LOOP_DOWN_TIME);
        }
 
+       /* Clear all async request states across all VPs. */
+       list_for_each_entry(fcport, &vha->vp_fcports, list)
+               fcport->flags &= ~(FCF_LOGIN_NEEDED | FCF_ASYNC_SENT);
+       spin_lock_irqsave(&ha->vport_slock, flags);
+       list_for_each_entry(vp, &ha->vp_list, list) {
+               atomic_inc(&vp->vref_count);
+               spin_unlock_irqrestore(&ha->vport_slock, flags);
+
+               list_for_each_entry(fcport, &vp->vp_fcports, list)
+                       fcport->flags &= ~(FCF_LOGIN_NEEDED | FCF_ASYNC_SENT);
+
+               spin_lock_irqsave(&ha->vport_slock, flags);
+               atomic_dec(&vp->vref_count);
+       }
+       spin_unlock_irqrestore(&ha->vport_slock, flags);
+
        if (!ha->flags.eeh_busy) {
                /* Make sure for ISP 82XX IO DMA is complete */
                if (IS_QLA82XX(ha)) {
-                       if (qla2x00_eh_wait_for_pending_commands(vha, 0, 0,
-                               WAIT_HOST) == QLA_SUCCESS) {
-                               DEBUG2(qla_printk(KERN_INFO, ha,
-                               "Done wait for pending commands\n"));
-                       }
+                       qla82xx_chip_reset_cleanup(vha);
+
+                       /* Done waiting for pending commands.
+                        * Reset the online flag.
+                        */
+                       vha->flags.online = 0;
                }
 
                /* Requeue all commands in outstanding command list. */