瀏覽代碼

[SCSI] fnic: Allocate OS interrupt resources just before enabling interrupts

The OS interrupt vectors were getting allocated before the interrupt
resources were mapped from hardware. For Legacy interrupts, since
they are shared with other devices, as soon as an interrupt is
registered with the OS, it can fire while the fnic isr resource is
still unmapped. This can cause crash because of access to unmapped resources.
For MSIX and MSI, since interrupts are not shared with other devices,
this problem didnt happen, because the interrupt is enabled as the last
step before returning from _probe. For Legacy however, since the
interrupt is shared, the handler can be called as soon as it is registered.

Solution is to register interrupt handlers with OS as last step before
enabling device interrupts.

Signed-off-by: Abhijeet Joglekar <abjoglek@cisco.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Abhijeet Joglekar 15 年之前
父節點
當前提交
2e76f7670b
共有 1 個文件被更改,包括 10 次插入11 次删除
  1. 10 11
      drivers/scsi/fnic/fnic_main.c

+ 10 - 11
drivers/scsi/fnic/fnic_main.c

@@ -572,19 +572,12 @@ static int __devinit fnic_probe(struct pci_dev *pdev,
 		goto err_out_dev_close;
 		goto err_out_dev_close;
 	}
 	}
 
 
-	err = fnic_request_intr(fnic);
-	if (err) {
-		shost_printk(KERN_ERR, fnic->lport->host,
-			     "Unable to request irq.\n");
-		goto err_out_clear_intr;
-	}
-
 	err = fnic_alloc_vnic_resources(fnic);
 	err = fnic_alloc_vnic_resources(fnic);
 	if (err) {
 	if (err) {
 		shost_printk(KERN_ERR, fnic->lport->host,
 		shost_printk(KERN_ERR, fnic->lport->host,
 			     "Failed to alloc vNIC resources, "
 			     "Failed to alloc vNIC resources, "
 			     "aborting.\n");
 			     "aborting.\n");
-		goto err_out_free_intr;
+		goto err_out_clear_intr;
 	}
 	}
 
 
 
 
@@ -729,6 +722,14 @@ static int __devinit fnic_probe(struct pci_dev *pdev,
 	fc_fabric_login(lp);
 	fc_fabric_login(lp);
 
 
 	vnic_dev_enable(fnic->vdev);
 	vnic_dev_enable(fnic->vdev);
+
+	err = fnic_request_intr(fnic);
+	if (err) {
+		shost_printk(KERN_ERR, fnic->lport->host,
+			     "Unable to request irq.\n");
+		goto err_out_free_exch_mgr;
+	}
+
 	for (i = 0; i < fnic->intr_count; i++)
 	for (i = 0; i < fnic->intr_count; i++)
 		vnic_intr_unmask(&fnic->intr[i]);
 		vnic_intr_unmask(&fnic->intr[i]);
 
 
@@ -753,8 +754,6 @@ err_out_free_ioreq_pool:
 	mempool_destroy(fnic->io_req_pool);
 	mempool_destroy(fnic->io_req_pool);
 err_out_free_resources:
 err_out_free_resources:
 	fnic_free_vnic_resources(fnic);
 	fnic_free_vnic_resources(fnic);
-err_out_free_intr:
-	fnic_free_intr(fnic);
 err_out_clear_intr:
 err_out_clear_intr:
 	fnic_clear_intr_mode(fnic);
 	fnic_clear_intr_mode(fnic);
 err_out_dev_close:
 err_out_dev_close:
@@ -828,8 +827,8 @@ static void __devexit fnic_remove(struct pci_dev *pdev)
 	scsi_remove_host(fnic->lport->host);
 	scsi_remove_host(fnic->lport->host);
 	fc_exch_mgr_free(fnic->lport);
 	fc_exch_mgr_free(fnic->lport);
 	vnic_dev_notify_unset(fnic->vdev);
 	vnic_dev_notify_unset(fnic->vdev);
-	fnic_free_vnic_resources(fnic);
 	fnic_free_intr(fnic);
 	fnic_free_intr(fnic);
+	fnic_free_vnic_resources(fnic);
 	fnic_clear_intr_mode(fnic);
 	fnic_clear_intr_mode(fnic);
 	vnic_dev_close(fnic->vdev);
 	vnic_dev_close(fnic->vdev);
 	vnic_dev_unregister(fnic->vdev);
 	vnic_dev_unregister(fnic->vdev);