[PATCH v3 08/11] scsi: mpt3sas: Cache the missing delays the IOC actually uses

From: Jeff Layton

Date: Wed Nov 18 2026 - 18:10:45 EST


When the missing_delay module parameter is set,
mpt3sas_base_update_missing_delay() writes the new delays to SAS IO
Unit Page 1. If the write succeeds, the function caches the requested
values in ioc->device_missing_delay and ioc->io_missing_delay.

mpt3sas_config_set_sas_iounit_pg1() ignores the result of the
WRITE_CURRENT request. It returns the result of the subsequent
WRITE_NVRAM request. If the WRITE_CURRENT request fails and the
WRITE_NVRAM request succeeds, the cached delays do not match the delays
that the IOC uses. The device_delay sysfs attribute then reports the
wrong value.

After the write, read the page again and cache the delays that it
reports. If this read fails, cache the requested delays if the NVRAM
update succeeded, as before.

Fixes: f92363d12359 ("[SCSI] mpt3sas: add new driver supporting 12GB SAS")
Signed-off-by: Jeff Layton <jlayton@xxxxxxxxxx>
---
drivers/scsi/mpt3sas/mpt3sas_base.c | 46 +++++++++++++++++++++++++------------
1 file changed, 31 insertions(+), 15 deletions(-)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c
index 5c957044eded..07e16acc8abc 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
@@ -4923,6 +4923,7 @@ mpt3sas_base_update_missing_delay(struct MPT3SAS_ADAPTER *ioc,
Mpi2ConfigReply_t mpi_reply;
u8 num_phys = 0;
u16 ioc_status;
+ int rc;

mpt3sas_config_get_number_hba_phys(ioc, &num_phys);
if (!num_phys)
@@ -4969,23 +4970,38 @@ mpt3sas_base_update_missing_delay(struct MPT3SAS_ADAPTER *ioc,
io_missing_delay_original = sas_iounit_pg1->IODeviceMissingDelay;
sas_iounit_pg1->IODeviceMissingDelay = io_missing_delay;

- if (!mpt3sas_config_set_sas_iounit_pg1(ioc, &mpi_reply, sas_iounit_pg1,
- sz)) {
- if (dmd & MPI2_SASIOUNIT1_REPORT_MISSING_UNIT_16)
- dmd_new = (dmd &
- MPI2_SASIOUNIT1_REPORT_MISSING_TIMEOUT_MASK) * 16;
- else
- dmd_new =
- dmd & MPI2_SASIOUNIT1_REPORT_MISSING_TIMEOUT_MASK;
- ioc_info(ioc, "device_missing_delay: old(%d), new(%d)\n",
- dmd_orignal, dmd_new);
- ioc_info(ioc, "ioc_missing_delay: old(%d), new(%d)\n",
- io_missing_delay_original,
- io_missing_delay);
- ioc->device_missing_delay = dmd_new;
- ioc->io_missing_delay = io_missing_delay;
+ /*
+ * This returns the result of the NVRAM update, not of the update
+ * to the current page, so read back the delays the IOC now uses.
+ * If that fails, assume the requested delays are used if the NVRAM
+ * update succeeded.
+ */
+ rc = mpt3sas_config_set_sas_iounit_pg1(ioc, &mpi_reply,
+ sas_iounit_pg1, sz);
+ if (!mpt3sas_config_get_sas_iounit_pg1(ioc, &mpi_reply,
+ sas_iounit_pg1, sz) &&
+ (le16_to_cpu(mpi_reply.IOCStatus) & MPI2_IOCSTATUS_MASK) ==
+ MPI2_IOCSTATUS_SUCCESS) {
+ dmd = sas_iounit_pg1->ReportDeviceMissingDelay;
+ io_missing_delay = sas_iounit_pg1->IODeviceMissingDelay;
+ } else {
+ ioc_warn(ioc, "failed to read back the missing delays\n");
+ if (rc)
+ goto out;
}

+ if (dmd & MPI2_SASIOUNIT1_REPORT_MISSING_UNIT_16)
+ dmd_new = (dmd & MPI2_SASIOUNIT1_REPORT_MISSING_TIMEOUT_MASK) * 16;
+ else
+ dmd_new = dmd & MPI2_SASIOUNIT1_REPORT_MISSING_TIMEOUT_MASK;
+ ioc_info(ioc, "device_missing_delay: old(%d), new(%d)\n",
+ dmd_orignal, dmd_new);
+ ioc_info(ioc, "ioc_missing_delay: old(%d), new(%d)\n",
+ io_missing_delay_original,
+ io_missing_delay);
+ ioc->device_missing_delay = dmd_new;
+ ioc->io_missing_delay = io_missing_delay;
+
out:
kfree(sas_iounit_pg1);
}

--
2.56.1