Merge git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6
[safe/jmp/linux-2.6] / drivers / scsi / qla2xxx / qla_os.c
index 7c8af7e..2aed472 100644 (file)
@@ -394,10 +394,8 @@ qla2x00_queuecommand(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
        }
 
        /* Close window on fcport/rport state-transitioning. */
-       if (fcport->drport) {
-               cmd->result = DID_IMM_RETRY << 16;
-               goto qc_fail_command;
-       }
+       if (fcport->drport)
+               goto qc_target_busy;
 
        if (atomic_read(&fcport->state) != FCS_ONLINE) {
                if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD ||
@@ -405,7 +403,7 @@ qla2x00_queuecommand(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
                        cmd->result = DID_NO_CONNECT << 16;
                        goto qc_fail_command;
                }
-               goto qc_host_busy;
+               goto qc_target_busy;
        }
 
        spin_unlock_irq(ha->host->host_lock);
@@ -428,10 +426,11 @@ qc_host_busy_free_sp:
 
 qc_host_busy_lock:
        spin_lock_irq(ha->host->host_lock);
-
-qc_host_busy:
        return SCSI_MLQUEUE_HOST_BUSY;
 
+qc_target_busy:
+       return SCSI_MLQUEUE_TARGET_BUSY;
+
 qc_fail_command:
        done(cmd);
 
@@ -461,10 +460,8 @@ qla24xx_queuecommand(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
        }
 
        /* Close window on fcport/rport state-transitioning. */
-       if (fcport->drport) {
-               cmd->result = DID_IMM_RETRY << 16;
-               goto qc24_fail_command;
-       }
+       if (fcport->drport)
+               goto qc24_target_busy;
 
        if (atomic_read(&fcport->state) != FCS_ONLINE) {
                if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD ||
@@ -472,7 +469,7 @@ qla24xx_queuecommand(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
                        cmd->result = DID_NO_CONNECT << 16;
                        goto qc24_fail_command;
                }
-               goto qc24_host_busy;
+               goto qc24_target_busy;
        }
 
        spin_unlock_irq(ha->host->host_lock);
@@ -495,10 +492,11 @@ qc24_host_busy_free_sp:
 
 qc24_host_busy_lock:
        spin_lock_irq(ha->host->host_lock);
-
-qc24_host_busy:
        return SCSI_MLQUEUE_HOST_BUSY;
 
+qc24_target_busy:
+       return SCSI_MLQUEUE_TARGET_BUSY;
+
 qc24_fail_command:
        done(cmd);
 
@@ -780,7 +778,8 @@ qla2x00_eh_wait_for_pending_commands(scsi_qla_host_t *ha, unsigned int t,
                sp = pha->outstanding_cmds[cnt];
                if (!sp)
                        continue;
-               if (ha->vp_idx != sp->ha->vp_idx)
+
+               if (ha->vp_idx != sp->fcport->ha->vp_idx)
                        continue;
                match = 0;
                switch (type) {
@@ -1080,9 +1079,7 @@ qla2x00_abort_all_cmds(scsi_qla_host_t *ha, int res)
                sp = ha->outstanding_cmds[cnt];
                if (sp) {
                        ha->outstanding_cmds[cnt] = NULL;
-                       sp->flags = 0;
                        sp->cmd->result = res;
-                       sp->cmd->host_scribble = (unsigned char *)NULL;
                        qla2x00_sp_compl(ha, sp);
                }
        }
@@ -1518,6 +1515,7 @@ qla2xxx_scan_start(struct Scsi_Host *shost)
        set_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags);
        set_bit(LOCAL_LOOP_UPDATE, &ha->dpc_flags);
        set_bit(RSCN_UPDATE, &ha->dpc_flags);
+       set_bit(NPIV_CONFIG_NEEDED, &ha->dpc_flags);
 }
 
 static int
@@ -1664,8 +1662,6 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
                ha->gid_list_info_size = 8;
                ha->optrom_size = OPTROM_SIZE_25XX;
                ha->isp_ops = &qla25xx_isp_ops;
-               ha->hw_event_start = PCI_FUNC(pdev->devfn) ?
-                   FA_HW_EVENT1_ADDR: FA_HW_EVENT0_ADDR;
        }
        host->can_queue = ha->request_q_length + 128;
 
@@ -1741,6 +1737,8 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
        if (ret)
                goto probe_failed;
 
+       ha->isp_ops->enable_intrs(ha);
+
        scsi_scan_host(host);
 
        qla2x00_alloc_sysfs_attr(ha);
@@ -1776,10 +1774,15 @@ probe_out:
 static void
 qla2x00_remove_one(struct pci_dev *pdev)
 {
-       scsi_qla_host_t *ha;
+       scsi_qla_host_t *ha, *vha, *temp;
 
        ha = pci_get_drvdata(pdev);
 
+       list_for_each_entry_safe(vha, temp, &ha->vp_list, vp_list)
+               fc_vport_terminate(vha->fc_vport);
+
+       set_bit(UNLOADING, &ha->dpc_flags);
+
        qla2x00_dfs_remove(ha);
 
        qla84xx_put_chip(ha);
@@ -2427,6 +2430,12 @@ qla2x00_do_dpc(void *data)
                            ha->host_no));
                }
 
+               if (test_bit(NPIV_CONFIG_NEEDED, &ha->dpc_flags) &&
+                   atomic_read(&ha->loop_state) == LOOP_READY) {
+                       clear_bit(NPIV_CONFIG_NEEDED, &ha->dpc_flags);
+                       qla2xxx_flash_npiv_conf(ha);
+               }
+
                if (!ha->interrupts_on)
                        ha->isp_ops->enable_intrs(ha);
 
@@ -2451,8 +2460,10 @@ qla2x00_do_dpc(void *data)
 void
 qla2xxx_wake_dpc(scsi_qla_host_t *ha)
 {
-       if (ha->dpc_thread)
-               wake_up_process(ha->dpc_thread);
+       struct task_struct *t = ha->dpc_thread;
+
+       if (!test_bit(UNLOADING, &ha->dpc_flags) && t)
+               wake_up_process(t);
 }
 
 /*