Skip to content

Commit 9634bb0

Browse files
Ranjan Kumarmartinkpetersen
authored andcommitted
scsi: mpi3mr: Enhance the Enable Controller retry logic
When enabling the IOC request and polling for controller ready status, poll for controller fault and reset history bit. If the controller is faulted or the reset history bit is set, retry the initialization a maximum of three times (2 retries) or if the cumulative time taken for all retries exceeds 510 seconds. Signed-off-by: Prayas Patel <[email protected]> Signed-off-by: Ranjan Kumar <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Martin K. Petersen <[email protected]>
1 parent cff06a7 commit 9634bb0

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

drivers/scsi/mpi3mr/mpi3mr_fw.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1362,6 +1362,10 @@ static int mpi3mr_bring_ioc_ready(struct mpi3mr_ioc *mrioc)
13621362
int retval = 0;
13631363
enum mpi3mr_iocstate ioc_state;
13641364
u64 base_info;
1365+
u8 retry = 0;
1366+
u64 start_time, elapsed_time_sec;
1367+
1368+
retry_bring_ioc_ready:
13651369

13661370
ioc_status = readl(&mrioc->sysif_regs->ioc_status);
13671371
ioc_config = readl(&mrioc->sysif_regs->ioc_configuration);
@@ -1460,6 +1464,9 @@ static int mpi3mr_bring_ioc_ready(struct mpi3mr_ioc *mrioc)
14601464
ioc_config |= MPI3_SYSIF_IOC_CONFIG_ENABLE_IOC;
14611465
writel(ioc_config, &mrioc->sysif_regs->ioc_configuration);
14621466

1467+
if (retry == 0)
1468+
start_time = jiffies;
1469+
14631470
timeout = mrioc->ready_timeout * 10;
14641471
do {
14651472
ioc_state = mpi3mr_get_iocstate(mrioc);
@@ -1469,6 +1476,12 @@ static int mpi3mr_bring_ioc_ready(struct mpi3mr_ioc *mrioc)
14691476
mpi3mr_iocstate_name(ioc_state));
14701477
return 0;
14711478
}
1479+
ioc_status = readl(&mrioc->sysif_regs->ioc_status);
1480+
if ((ioc_status & MPI3_SYSIF_IOC_STATUS_RESET_HISTORY) ||
1481+
(ioc_status & MPI3_SYSIF_IOC_STATUS_FAULT)) {
1482+
mpi3mr_print_fault_info(mrioc);
1483+
goto out_failed;
1484+
}
14721485
if (!pci_device_is_present(mrioc->pdev)) {
14731486
mrioc->unrecoverable = 1;
14741487
ioc_err(mrioc,
@@ -1477,9 +1490,19 @@ static int mpi3mr_bring_ioc_ready(struct mpi3mr_ioc *mrioc)
14771490
goto out_device_not_present;
14781491
}
14791492
msleep(100);
1480-
} while (--timeout);
1493+
elapsed_time_sec = jiffies_to_msecs(jiffies - start_time)/1000;
1494+
} while (elapsed_time_sec < mrioc->ready_timeout);
14811495

14821496
out_failed:
1497+
elapsed_time_sec = jiffies_to_msecs(jiffies - start_time)/1000;
1498+
if ((retry < 2) && (elapsed_time_sec < (mrioc->ready_timeout - 60))) {
1499+
retry++;
1500+
1501+
ioc_warn(mrioc, "retrying to bring IOC ready, retry_count:%d\n"
1502+
" elapsed time =%llu\n", retry, elapsed_time_sec);
1503+
1504+
goto retry_bring_ioc_ready;
1505+
}
14831506
ioc_state = mpi3mr_get_iocstate(mrioc);
14841507
ioc_err(mrioc,
14851508
"failed to bring to ready state, current state: %s\n",

0 commit comments

Comments
 (0)