Merge branch 'x86-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[pandora-kernel.git] / drivers / scsi / qla2xxx / qla_os.c
index 9c3a57f..26afe44 100644 (file)
@@ -449,7 +449,7 @@ qla24xx_queuecommand(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
        int rval;
        scsi_qla_host_t *pha = to_qla_parent(ha);
 
-       if (unlikely(pci_channel_offline(ha->pdev))) {
+       if (unlikely(pci_channel_offline(pha->pdev))) {
                cmd->result = DID_REQUEUE << 16;
                goto qc24_fail_command;
        }
@@ -780,7 +780,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 +1081,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);
                }
        }
@@ -1776,10 +1775,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);
@@ -1849,6 +1853,7 @@ qla2x00_schedule_rport_del(struct scsi_qla_host *ha, fc_port_t *fcport,
     int defer)
 {
        struct fc_rport *rport;
+       scsi_qla_host_t *pha = to_qla_parent(ha);
 
        if (!fcport->rport)
                return;
@@ -1858,8 +1863,8 @@ qla2x00_schedule_rport_del(struct scsi_qla_host *ha, fc_port_t *fcport,
                spin_lock_irq(ha->host->host_lock);
                fcport->drport = rport;
                spin_unlock_irq(ha->host->host_lock);
-               set_bit(FCPORT_UPDATE_NEEDED, &ha->dpc_flags);
-               qla2xxx_wake_dpc(ha);
+               set_bit(FCPORT_UPDATE_NEEDED, &pha->dpc_flags);
+               qla2xxx_wake_dpc(pha);
        } else
                fc_remote_port_delete(rport);
 }
@@ -1931,7 +1936,7 @@ qla2x00_mark_all_devices_lost(scsi_qla_host_t *ha, int defer)
        scsi_qla_host_t *pha = to_qla_parent(ha);
 
        list_for_each_entry(fcport, &pha->fcports, list) {
-               if (ha->vp_idx != 0 && ha->vp_idx != fcport->vp_idx)
+               if (ha->vp_idx != fcport->vp_idx)
                        continue;
                /*
                 * No point in marking the device as lost, if the device is
@@ -1939,17 +1944,10 @@ qla2x00_mark_all_devices_lost(scsi_qla_host_t *ha, int defer)
                 */
                if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD)
                        continue;
-               if (atomic_read(&fcport->state) == FCS_ONLINE) {
-                       if (defer)
-                               qla2x00_schedule_rport_del(ha, fcport, defer);
-                       else if (ha->vp_idx == fcport->vp_idx)
-                               qla2x00_schedule_rport_del(ha, fcport, defer);
-               }
+               if (atomic_read(&fcport->state) == FCS_ONLINE)
+                       qla2x00_schedule_rport_del(ha, fcport, defer);
                atomic_set(&fcport->state, FCS_DEVICE_LOST);
        }
-
-       if (defer)
-               qla2xxx_wake_dpc(ha);
 }
 
 /*
@@ -2184,7 +2182,7 @@ qla2x00_alloc_work(struct scsi_qla_host *ha, enum qla_work_type type,
 static int
 qla2x00_post_work(struct scsi_qla_host *ha, struct qla_work_evt *e, int locked)
 {
-       unsigned long flags;
+       unsigned long uninitialized_var(flags);
        scsi_qla_host_t *pha = to_qla_parent(ha);
 
        if (!locked)
@@ -2341,8 +2339,10 @@ qla2x00_do_dpc(void *data)
                            ha->host_no));
                }
 
-               if (test_and_clear_bit(FCPORT_UPDATE_NEEDED, &ha->dpc_flags))
+               if (test_bit(FCPORT_UPDATE_NEEDED, &ha->dpc_flags)) {
                        qla2x00_update_fcports(ha);
+                       clear_bit(FCPORT_UPDATE_NEEDED, &ha->dpc_flags);
+               }
 
                if (test_and_clear_bit(RESET_MARKER_NEEDED, &ha->dpc_flags) &&
                    (!(test_and_set_bit(RESET_ACTIVE, &ha->dpc_flags)))) {
@@ -2455,8 +2455,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);
 }
 
 /*