diff options
author | James Smart <james.smart@broadcom.com> | 2020-11-15 11:26:32 -0800 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2020-11-17 00:43:54 -0500 |
commit | 95f0ef8a8368b2195ca9b8b4eca9a3ec8d132a75 (patch) | |
tree | d6e62807961ab2efcc1376d10f39dc0b76fbc0e6 /drivers/scsi/lpfc/lpfc_init.c | |
parent | scsi: lpfc: Rework locations of ndlp reference taking (diff) | |
download | linux-dev-95f0ef8a8368b2195ca9b8b4eca9a3ec8d132a75.tar.xz linux-dev-95f0ef8a8368b2195ca9b8b4eca9a3ec8d132a75.zip |
scsi: lpfc: Fix removal of SCSI transport device get and put on dev structure
The lpfc driver is calling get_device and put_device on scsi_fc_transport
device structure. When this code was removed, the driver triggered an oops
in "scsi_is_host_dev" when the first SCSI target was unregistered from the
transport.
The reason the calls were necessary is that the driver is calling
scsi_remove_host too early, before the target rports are unregistered and
the scsi devices disconnected from the scsi_host. The fc_host was torn
down during fc_remove_host.
Fix by moving the lpfc_pci_remove_one_s3/s4 calls to scsi_remove_host to
after the nodes are cleaned up. Remove the get_device and put_device calls
and the supporting code.
Link: https://lore.kernel.org/r/20201115192646.12977-4-james.smart@broadcom.com
Co-developed-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/scsi/lpfc/lpfc_init.c')
-rw-r--r-- | drivers/scsi/lpfc/lpfc_init.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index add2eb0d729b..72448287a3d1 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -12499,12 +12499,15 @@ lpfc_pci_remove_one_s3(struct pci_dev *pdev) } lpfc_destroy_vport_work_array(phba, vports); - /* Remove FC host and then SCSI host with the physical port */ + /* Remove FC host with the physical port */ fc_remove_host(shost); - scsi_remove_host(shost); + /* Clean up all nodes, mailboxes and IOs. */ lpfc_cleanup(vport); + /* Remove the shost now that the devices connections are lost. */ + scsi_remove_host(shost); + /* * Bring down the SLI Layer. This step disable all interrupts, * clears the rings, discards all mailbox commands, and resets @@ -13342,7 +13345,6 @@ lpfc_pci_remove_one_s4(struct pci_dev *pdev) vport->load_flag |= FC_UNLOADING; spin_unlock_irq(&phba->hbalock); - /* Free the HBA sysfs attributes */ lpfc_free_sysfs_attr(vport); /* Release all the vports against this physical port */ @@ -13355,9 +13357,8 @@ lpfc_pci_remove_one_s4(struct pci_dev *pdev) } lpfc_destroy_vport_work_array(phba, vports); - /* Remove FC host and then SCSI host with the physical port */ + /* Remove FC host with the physical port */ fc_remove_host(shost); - scsi_remove_host(shost); /* Perform ndlp cleanup on the physical port. The nvme and nvmet * localports are destroyed after to cleanup all transport memory. @@ -13370,6 +13371,9 @@ lpfc_pci_remove_one_s4(struct pci_dev *pdev) if (phba->cfg_xri_rebalancing) lpfc_destroy_multixri_pools(phba); + /* Remove the shost now that the devices connections are lost. */ + scsi_remove_host(shost); + /* * Bring down the SLI Layer. This step disables all interrupts, * clears the rings, discards all mailbox commands, and resets |