]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
qla2xxx: Fix hang during driver unload when vport is active.
authorArun Easi <arun.easi@qlogic.com>
Tue, 10 May 2011 18:18:16 +0000 (11:18 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 3 Jun 2011 01:33:35 +0000 (10:33 +0900)
commit 43ebf16d762b082663976b679b813e1b546548d1 upstream.

Bumping ref count during fc_vport_terminate() was the cause. vport
delete would wait for ref count to drop to zero and that would never
happen.

Signed-off-by: Arun Easi <arun.easi@qlogic.com>
Signed-off-by: Madhuranath Iyengar <Madhu.Iyengar@qlogic.com>
Signed-off-by: James Bottomley <jbottomley@parallels.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/scsi/qla2xxx/qla_os.c

index f27724d76cf667ab2a95fd2e1301d02485ea4296..3010dd78159725e3a21f0a34da09c74b1828ee31 100644 (file)
@@ -2359,21 +2359,26 @@ qla2x00_remove_one(struct pci_dev *pdev)
        base_vha = pci_get_drvdata(pdev);
        ha = base_vha->hw;
 
-       spin_lock_irqsave(&ha->vport_slock, flags);
-       list_for_each_entry(vha, &ha->vp_list, list) {
-               atomic_inc(&vha->vref_count);
+       mutex_lock(&ha->vport_lock);
+       while (ha->cur_vport_count) {
+               struct Scsi_Host *scsi_host;
 
-               if (vha->fc_vport) {
-                       spin_unlock_irqrestore(&ha->vport_slock, flags);
+               spin_lock_irqsave(&ha->vport_slock, flags);
 
-                       fc_vport_terminate(vha->fc_vport);
+               BUG_ON(base_vha->list.next == &ha->vp_list);
+               /* This assumes first entry in ha->vp_list is always base vha */
+               vha = list_first_entry(&base_vha->list, scsi_qla_host_t, list);
+               scsi_host = scsi_host_get(vha->host);
 
-                       spin_lock_irqsave(&ha->vport_slock, flags);
-               }
+               spin_unlock_irqrestore(&ha->vport_slock, flags);
+               mutex_unlock(&ha->vport_lock);
+
+               fc_vport_terminate(vha->fc_vport);
+               scsi_host_put(vha->host);
 
-               atomic_dec(&vha->vref_count);
+               mutex_lock(&ha->vport_lock);
        }
-       spin_unlock_irqrestore(&ha->vport_slock, flags);
+       mutex_unlock(&ha->vport_lock);
 
        set_bit(UNLOADING, &base_vha->dpc_flags);