From: Jeff Layton <jlayton@kernel.org>
To: Sathya Prakash <sathya.prakash@broadcom.com>,
Sreekanth Reddy <sreekanth.reddy@broadcom.com>,
Suganath Prabu Subramani <suganath-prabu.subramani@broadcom.com>,
Ranjan Kumar <ranjan.kumar@broadcom.com>,
"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
"Martin K. Petersen" <mkp@kernel.org>,
Nagalakshmi Nandigama <Nagalakshmi.Nandigama@lsi.com>,
James Bottomley <JBottomley@Parallels.com>
Cc: Keith Busch <kbusch@kernel.org>,
Sreekanth Reddy <Sreekanth.Reddy@lsi.com>,
MPT-FusionLinux.pdl@broadcom.com, linux-scsi@vger.kernel.org,
linux-kernel@vger.kernel.org, Jeff Layton <jlayton@kernel.org>
Subject: [PATCH v3 03/11] scsi: mpt3sas: Requeue topology events only for busy devices
Date: Wed, 18 Nov 2026 15:10:00 -0800 [thread overview]
Message-ID: <20261118-sas-abba-v3-3-5562d690cf61@kernel.org> (raw)
In-Reply-To: <20261118-sas-abba-v3-0-5562d690cf61@kernel.org>
Since commit ad5957193107 ("scsi: mpt3sas: Add firmware event requeue
support for busy devices"), _scsih_sas_topology_change_event() requeues
the event whenever _scsih_add_device() returns non-zero. It retries the
event every second. But _scsih_add_device() returns 1 only for a busy
device. It returns -1 when it cannot add the device at all. This occurs
when:
- the driver cannot read the SAS Device Page 0 of the device
- the device is not an end device, or is not present
- discovery reported an access problem
- the device is already added
None of these conditions clear with time, and nothing limits the
number of retries. In a stress test, the driver retried the add of a
device that was not present 249 times.
A requeued event keeps the handle and phy number from its original
report. Meanwhile, the handle may go to another device, because a host
reset assigns all handles again. In one stress run, a requeued add
first ran after a host reset. At that time, its handle was not in use.
Thus the read of SAS Device Page 0 failed, and the driver requeued the
event. One second later, at the retry, a device that was returning on
another phy had that handle.
The retry then makes mpt3sas_transport_update_links() record the SAS
address of that device on the phy of the event. The add of the device
then makes _transport_sanity_check() delete the port of the drive on
that phy. Thus the driver removed the drive, although the drive never
disappeared.
When _scsih_add_device() cannot add the device, return 0, as
_scsih_pcie_add_device() does. Then the driver retries only a busy
device. Some failures of the page read do clear with time:
- -EAGAIN, when no internal command is free or after a reset
- an IOC status of BUSY or INSUFFICIENT_RESOURCES
Continue to retry these failures, up to command_retry_count times, as
for a busy device. This change also prevents a spin on such a device
in the loops that call _scsih_add_device() after a host reset.
Fixes: ad5957193107 ("scsi: mpt3sas: Add firmware event requeue support for busy devices")
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
drivers/scsi/mpt3sas/mpt3sas_scsih.c | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
index b455b7e5d8f3..2d98fcb8e135 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
@@ -8509,7 +8509,9 @@ _scsih_check_device(struct MPT3SAS_ADAPTER *ioc,
*
* Creating end device object, stored in ioc->sas_device_list.
*
- * Return: 0 for success, non-zero for failure.
+ * Return: 1 if adding the device should be retried: it is busy, or
+ * reading its SAS Device Page 0 failed in a way that can clear with time.
+ * 0 otherwise.
*/
static int
_scsih_add_device(struct MPT3SAS_ADAPTER *ioc, u16 handle, u8 retry_count,
@@ -8525,12 +8527,15 @@ _scsih_add_device(struct MPT3SAS_ADAPTER *ioc, u16 handle, u8 retry_count,
u32 device_info;
u8 connector_name[5];
u8 port_id;
+ int r;
- if ((mpt3sas_config_get_sas_device_pg0(ioc, &mpi_reply, &sas_device_pg0,
- MPI2_SAS_DEVICE_PGAD_FORM_HANDLE, handle))) {
+ r = mpt3sas_config_get_sas_device_pg0(ioc, &mpi_reply, &sas_device_pg0,
+ MPI2_SAS_DEVICE_PGAD_FORM_HANDLE, handle);
+ if (r) {
ioc_err(ioc, "failure at %s:%d/%s()!\n",
__FILE__, __LINE__, __func__);
- return -1;
+ /* e.g. no free internal command, or a reset intervened */
+ return r == -EAGAIN && retry_count < command_retry_count;
}
ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
@@ -8538,13 +8543,15 @@ _scsih_add_device(struct MPT3SAS_ADAPTER *ioc, u16 handle, u8 retry_count,
if (ioc_status != MPI2_IOCSTATUS_SUCCESS) {
ioc_err(ioc, "failure at %s:%d/%s()!\n",
__FILE__, __LINE__, __func__);
- return -1;
+ return (ioc_status == MPI2_IOCSTATUS_BUSY ||
+ ioc_status == MPI2_IOCSTATUS_INSUFFICIENT_RESOURCES) &&
+ retry_count < command_retry_count;
}
/* check if this is end device */
device_info = le32_to_cpu(sas_device_pg0.DeviceInfo);
if (!(_scsih_is_end_device(device_info)))
- return -1;
+ return 0;
set_bit(handle, ioc->pend_os_device_add);
sas_address = le64_to_cpu(sas_device_pg0.SASAddress);
@@ -8553,13 +8560,13 @@ _scsih_add_device(struct MPT3SAS_ADAPTER *ioc, u16 handle, u8 retry_count,
MPI2_SAS_DEVICE0_FLAGS_DEVICE_PRESENT)) {
ioc_err(ioc, "device is not present handle(0x04%x)!!!\n",
handle);
- return -1;
+ return 0;
}
/* check if there were any issues with discovery */
if (_scsih_check_access_status(ioc, sas_address, handle,
sas_device_pg0.AccessStatus))
- return -1;
+ return 0;
port_id = sas_device_pg0.PhysicalPort;
sas_device = mpt3sas_get_sdev_by_addr(ioc,
@@ -8567,7 +8574,7 @@ _scsih_add_device(struct MPT3SAS_ADAPTER *ioc, u16 handle, u8 retry_count,
if (sas_device) {
clear_bit(handle, ioc->pend_os_device_add);
sas_device_put(sas_device);
- return -1;
+ return 0;
}
if (sas_device_pg0.EnclosureHandle) {
--
2.56.1
next prev parent reply other threads:[~2026-11-18 23:10 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 23:09 [PATCH v3 00/11] scsi: mpt3sas: Fix delayed not-responding block deadlock and related bugs Jeff Layton
2026-11-18 23:09 ` [PATCH v3 01/11] scsi: mpt3sas: Don't leave requeued firmware events pending at teardown Jeff Layton
2026-11-18 23:09 ` [PATCH v3 02/11] scsi: mpt3sas: Hold event references while cleaning up the event queue Jeff Layton
2026-11-18 23:10 ` Jeff Layton [this message]
2026-11-18 23:10 ` [PATCH v3 04/11] scsi: mpt3sas: Fix pcie_device leak in _scsih_ublock_io_device_wait() Jeff Layton
2026-11-18 23:10 ` [PATCH v3 05/11] scsi: mpt3sas: Restore unblock retry " Jeff Layton
2026-11-18 23:10 ` [PATCH v3 06/11] scsi: mpt3sas: Stop polling devices when the unresponding scan is cancelled Jeff Layton
2026-11-18 23:10 ` [PATCH v3 07/11] scsi: mpt3sas: Reset the TUR retry count for each device Jeff Layton
2026-11-18 23:10 ` [PATCH v3 08/11] scsi: mpt3sas: Cache the missing delays the IOC actually uses Jeff Layton
2026-11-18 23:10 ` [PATCH v3 09/11] scsi: mpt3sas: Serialize interrupt-time sdev block with hostdata teardown Jeff Layton
2026-11-18 23:10 ` [PATCH v3 10/11] scsi: mpt3sas: Don't use freed hostdata while polling devices Jeff Layton
2026-11-18 23:10 ` [PATCH v3 11/11] scsi: mpt3sas: Time out delayed not-responding device blocks Jeff Layton
2026-11-18 23:13 ` [PATCH v3 00/11] scsi: mpt3sas: Fix delayed not-responding block deadlock and related bugs Jeff Layton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261118-sas-abba-v3-3-5562d690cf61@kernel.org \
--to=jlayton@kernel.org \
--cc=JBottomley@Parallels.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=MPT-FusionLinux.pdl@broadcom.com \
--cc=Nagalakshmi.Nandigama@lsi.com \
--cc=Sreekanth.Reddy@lsi.com \
--cc=kbusch@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=mkp@kernel.org \
--cc=ranjan.kumar@broadcom.com \
--cc=sathya.prakash@broadcom.com \
--cc=sreekanth.reddy@broadcom.com \
--cc=suganath-prabu.subramani@broadcom.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®