scsi: mpi3mr: Wait for diagnostic save during controller init
authorRanjan Kumar <ranjan.kumar@broadcom.com>
Tue, 28 Feb 2023 14:08:32 +0000 (06:08 -0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Mon, 6 Mar 2023 23:33:12 +0000 (18:33 -0500)
If a controller reset operation is triggered to recover the controller from
a fault state, then wait for the snapdump to be saved in the firmware
region before proceeding to reset the controller.

Signed-off-by: Ranjan Kumar <ranjan.kumar@broadcom.com>
Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Link: https://lore.kernel.org/r/20230228140835.4075-4-ranjan.kumar@broadcom.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/mpi3mr/mpi3mr_fw.c

index 4254e46a20f1a679d829bb737c5a32896f8a27ba..fa903a70baac8984bf6b49b768cbe9c95fe8d8c3 100644 (file)
@@ -1198,7 +1198,7 @@ mpi3mr_revalidate_factsdata(struct mpi3mr_ioc *mrioc)
  */
 static int mpi3mr_bring_ioc_ready(struct mpi3mr_ioc *mrioc)
 {
-       u32 ioc_config, ioc_status, timeout;
+       u32 ioc_config, ioc_status, timeout, host_diagnostic;
        int retval = 0;
        enum mpi3mr_iocstate ioc_state;
        u64 base_info;
@@ -1252,6 +1252,23 @@ static int mpi3mr_bring_ioc_ready(struct mpi3mr_ioc *mrioc)
                            retval, mpi3mr_iocstate_name(ioc_state));
        }
        if (ioc_state != MRIOC_STATE_RESET) {
+               if (ioc_state == MRIOC_STATE_FAULT) {
+                       timeout = MPI3_SYSIF_DIAG_SAVE_TIMEOUT * 10;
+                       mpi3mr_print_fault_info(mrioc);
+                       do {
+                               host_diagnostic =
+                                       readl(&mrioc->sysif_regs->host_diagnostic);
+                               if (!(host_diagnostic &
+                                     MPI3_SYSIF_HOST_DIAG_SAVE_IN_PROGRESS))
+                                       break;
+                               if (!pci_device_is_present(mrioc->pdev)) {
+                                       mrioc->unrecoverable = 1;
+                                       ioc_err(mrioc, "controller is not present at the bringup\n");
+                                       goto out_device_not_present;
+                               }
+                               msleep(100);
+                       } while (--timeout);
+               }
                mpi3mr_print_fault_info(mrioc);
                ioc_info(mrioc, "issuing soft reset to bring to reset state\n");
                retval = mpi3mr_issue_reset(mrioc,