From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796044902; b=0i9DPRj6/oxzcO13Wq0NQPDXYaspckUCcyuBTOUBshMmAJPe0eVPW2rU60nfRYaWFOMv D+2aVc8iX4gNYu+hjEE5TefGfdSqf4rzFg/CxWvUYh38YKNfESdmhJl70MjXorBTz38Kt 77uNuN9Tk1EfqKA+R7+z+4N3nlqQATzATdn4RxhNY3ZvLJgDqnnmgqJpbPSDC1clE3XNW fL6uZw88t5JwZQAs56HQt16I8p2Lim+BRVkhxnlXrZPp07RyxPqON+CqKsTTHTgQ8HG7O 57qriAl0Vc+Q4Z198MepxwdksOj3C3AtZ0zeYxNedbILEe2wg8r5v2YbaK+0SogLN2w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796044902; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=aXI+2tRC+6LIHw7EZ90ZHQnHaiw20B7ZACHgCnhBVFU=; b=AKnLN/M0PAAzbo+VlgZTWruVnSdKcDe4BlWrlwy2bVEUV2n9ZOdp1AzQoz/yt6gvduPq xWfSYJ2qKnAV2YB51+IRo2kcQGkAl2yng5N49Nr7uNnIW6byzrzB0/6PmyQOXUAhvgIyg lqaWyJfZpxLG0UeMWP8lLmVi1bo9pUsGTR00voX0eAAiXq3thoMCSAam7PCGCEq5uHWbI FwbURi6XIEvFi2M5NzoeZQJIt4W+eY12huWv/m62/9M5qRQA9E0k1OVECm9DzaRvY5AB3 aqHFq3VEIr74I1cMJEbuPJlTeTTLZl0Bp5V6F9vmsVSzvrLdy2/Xy9fy88Ws9IuOAOw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=hztRR3bh; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BBD04606A68F; Mon, 30 Nov 2026 13:21:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=hztRR3bh Received: by smtp.kernel.org (Postfix) with ESMTPSA id 381241F00924; Mon, 30 Nov 2026 13:21:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796044902; bh=aXI+2tRC+6LIHw7EZ90ZHQnHaiw20B7ZACHgCnhBVFU=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=hztRR3bhCiKlP0bZJHPBAtErEzdLKeAsEf0ckpDGeFFZDC3M5W2mwnXvzg697sbwz hB2Y8OzRZoPVhdlLHGKEf/bmiFACyTwNiObMdE6pAEfKsPGbvQJ3tsEYXyVqrtvTTl eYtXtnoyfhq+7HrfSyI+Ua7JKGbt01ZApDb87ZKPpRANRFlw3ytPp2vuFQcYRoDgov NewlbTelfaSqq5gCk4n9feP257JL8WEmWKgJ51cKIuc1gDLxDr20tnrozcqtUeCe1p nUMv9JdGDXS5suUO6yAtQUfNj8LEurd7ZQCi3VmGneuWvTkg83es0DumOkNSEM0lp8 SgnaoswpjcyVQ== From: Jeff Layton Date: Mon, 30 Nov 2026 08:21:06 -0500 Subject: [PATCH v5 04/12] scsi: mpt3sas: Requeue topology events only for busy devices X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261130-sas-abba-v5-4-487c39d1114f@kernel.org> References: <20261130-sas-abba-v5-0-487c39d1114f@kernel.org> In-Reply-To: <20261130-sas-abba-v5-0-487c39d1114f@kernel.org> To: Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani , Ranjan Kumar , "James E.J. Bottomley" , "Martin K. Petersen" , Nagalakshmi Nandigama , James Bottomley Cc: Keith Busch , Sreekanth Reddy , MPT-FusionLinux.pdl@broadcom.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Jeff Layton X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=5181; i=jlayton@kernel.org; h=from:subject:message-id; bh=I+B7iG787mB7/7SHOSY/5/m+IU30dPgoY5tfVM47poU=; b=owEBbQKS/ZANAwAKAQAOaEEZVoIVAcsmYgBrDXhbXXrUf1dV+AP4jPU+Lzifkakgea6xK9GtI 2h4QXL7zBiJAjMEAAEKAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCaw14WwAKCRAADmhBGVaC FSnXEACP3WA4eFDINv/CLV/9fFirOcf8ZfKvXV93EA3i1T5KhJ4+1IhlOU+v+QxjxH3iedXalm8 2N1OF6rb5U6Pq9V+UqsVrcTKt5VsvxyxbLUeh9/B2QPHOp36Bp9uLdgZQK9Z1jW7zmoeakwXq4Y /4F2UhnulfvfOJT1FqEH6GjqzI7j2uOs8ij0y/CZTUH+1T/xAzvk50zjszZiyMLM0bte6Wp5iw+ eigDvdmRit59Nk1SrtMxo1t299RfWQxm/pG7oovunTEY8sol50QSzCpnNnJv3UANXCzndDwRsUO HVOF0kwfRLlIChXxgmBwlwrrwQJs3AXZqeDi8yEY1MpZEMx965RhT2TCvk1lvQBchm4mLG/lNfB 1n5h3SUlCT6XfSPOGK/yc6RtJiA4bK9aX1yF101WyPq+Ghv0dcWCMjDeJz7z9xQCXH0t6oNxunN zX+nUBZlV9+keLBarYeMM9ZLwsbOAUHgJjwyK8vOfxbl6uN+j1QuwKAmD7WwvUOd0TrsepeNPZc 2+AIr47xvqhFFCpZLafn5gYu1XNC9sVKPzZg9NRsTA+3TzdT+90ZZ04/OtiT+PD4g6ZogXtL44+ O0piVv12CCbVJjj16rIMYxA5HM56kGW01ECfw0dq1lDTgH3ZqoJZ4FeAPr4O5Vbf6fzdf59Yojc oBwllRtEwbL5bBQ== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 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 --- 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 270a26832d9c..1743c5c89230 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -8527,7 +8527,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, @@ -8543,12 +8545,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) & @@ -8556,13 +8561,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); @@ -8571,13 +8578,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, @@ -8585,7 +8592,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