scsi: lpfc: Fix driver release of fw-logging buffers
authorJames Smart <jsmart2021@gmail.com>
Fri, 30 Nov 2018 00:09:39 +0000 (16:09 -0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Sat, 8 Dec 2018 03:35:33 +0000 (22:35 -0500)
On driver termination, after the driver stops fw logging by writing a
register on the chip, the driver immediately unmaps and frees the logging
buffer, without confirming in any way that the chip has received the write
and terminated the logging. As termination on the chip is not immediate,
the chip may issue a dma request to the now unmapped dma buffer, resulting
in a iommu fault.

Change the driver to receive a confirmation that logging ahs been
terminated. As the driver always issues an SLI reset with the device as
part of shutdown, and as part of that is receiving confirmation that the
reset is complete - the driver was modified to perform the write to disable
fw logging prior to the SLI reset and only free the fw log buffer after the
SLI reset is complete. That guarantees use of the fw log buffer is fully
terminated when it is unmapped.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/lpfc/lpfc_bsg.c
drivers/scsi/lpfc/lpfc_crtn.h
drivers/scsi/lpfc/lpfc_init.c
drivers/scsi/lpfc/lpfc_sli.c

index b573fd00e650471f30142129de8ec0f7234f72b5..cb18dac68e281019b6e0fc543951b7436dd3cef8 100644 (file)
@@ -5380,25 +5380,6 @@ ras_job_error:
        return rc;
 }
 
-/**
- * lpfc_ras_stop_fwlog: Disable FW logging by the adapter
- * @phba: Pointer to HBA context object.
- *
- * Disable FW logging into host memory on the adapter. To
- * be done before reading logs from the host memory.
- **/
-static void
-lpfc_ras_stop_fwlog(struct lpfc_hba *phba)
-{
-       struct lpfc_ras_fwlog *ras_fwlog = &phba->ras_fwlog;
-
-       ras_fwlog->ras_active = false;
-
-       /* Disable FW logging to host memory */
-       writel(LPFC_CTL_PDEV_CTL_DDL_RAS,
-              phba->sli4_hba.conf_regs_memmap_p + LPFC_CTL_PDEV_CTL_OFFSET);
-}
-
 /**
  * lpfc_bsg_set_ras_config: Set FW logging parameters
  * @job: fc_bsg_job to handle
@@ -5519,7 +5500,8 @@ lpfc_bsg_get_ras_lwpd(struct bsg_job *job)
        if (!ras_fwlog->lwpd.virt) {
                lpfc_printf_log(phba, KERN_ERR, LOG_LIBDFC,
                                "6193 Restart FW Logging\n");
-               return -EINVAL;
+               rc = -EINVAL;
+               goto ras_job_error;
        }
 
        /* Get lwpd offset */
index 5edea80fd7f135c78ca482bf3396501f31b03d9c..6a8c5b804c2dc3f0ea5e6679f3caf4494dff680d 100644 (file)
@@ -551,6 +551,7 @@ void lpfc_sli4_ras_init(struct lpfc_hba *phba);
 void lpfc_sli4_ras_setup(struct lpfc_hba *phba);
 int  lpfc_sli4_ras_fwlog_init(struct lpfc_hba *phba, uint32_t fwlog_level,
                         uint32_t fwlog_enable);
+void lpfc_ras_stop_fwlog(struct lpfc_hba *phba);
 int lpfc_check_fwlog_support(struct lpfc_hba *phba);
 
 /* NVME interfaces. */
index 716add289397472d47145f3a488bf7c0342ac7da..c56ef73463f22bf57998d10af02878afa2256ecf 100644 (file)
@@ -10690,12 +10690,7 @@ lpfc_sli4_hba_unset(struct lpfc_hba *phba)
        kthread_stop(phba->worker_thread);
 
        /* Disable FW logging to host memory */
-       writel(LPFC_CTL_PDEV_CTL_DDL_RAS,
-              phba->sli4_hba.conf_regs_memmap_p + LPFC_CTL_PDEV_CTL_OFFSET);
-
-       /* Free RAS DMA memory */
-       if (phba->ras_fwlog.ras_enabled == true)
-               lpfc_sli4_ras_dma_free(phba);
+       lpfc_ras_stop_fwlog(phba);
 
        /* Unset the queues shared with the hardware then release all
         * allocated resources.
@@ -10706,6 +10701,10 @@ lpfc_sli4_hba_unset(struct lpfc_hba *phba)
        /* Reset SLI4 HBA FCoE function */
        lpfc_pci_function_reset(phba);
 
+       /* Free RAS DMA memory */
+       if (phba->ras_fwlog.ras_enabled)
+               lpfc_sli4_ras_dma_free(phba);
+
        /* Stop the SLI4 device port */
        phba->pport->work_port_events = 0;
 }
index 760b819f690a30f8c8bce3e72f8172b4dc24ca15..3826a32eec20bc49575fa9339b3d822182f29e51 100644 (file)
@@ -6197,6 +6197,25 @@ lpfc_set_features(struct lpfc_hba *phba, LPFC_MBOXQ_t *mbox,
        return;
 }
 
+/**
+ * lpfc_ras_stop_fwlog: Disable FW logging by the adapter
+ * @phba: Pointer to HBA context object.
+ *
+ * Disable FW logging into host memory on the adapter. To
+ * be done before reading logs from the host memory.
+ **/
+void
+lpfc_ras_stop_fwlog(struct lpfc_hba *phba)
+{
+       struct lpfc_ras_fwlog *ras_fwlog = &phba->ras_fwlog;
+
+       ras_fwlog->ras_active = false;
+
+       /* Disable FW logging to host memory */
+       writel(LPFC_CTL_PDEV_CTL_DDL_RAS,
+              phba->sli4_hba.conf_regs_memmap_p + LPFC_CTL_PDEV_CTL_OFFSET);
+}
+
 /**
  * lpfc_sli4_ras_dma_free - Free memory allocated for FW logging.
  * @phba: Pointer to HBA context object.