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=1796046678; b=BzI0Ap5VzFVEH95Cj7Y1lBIwA6gMqanH60RT1Uvd2UZgu40C4XO4gDbGz0J4MhSt00bn bGabdfe/d9fGeSHYriq3Oefc3ueAxCQ7Gq+rrQICUTjdhaamzVK+Y9LGQF+16UXAj0y6G ArZoD86+4hVjOc57JiG0a0XPw+5SX09q0dlGJbLTAXYInCNe+CDGXSnTLG/aqPOQLwSTF AKperp/sWDBtrlQOAnIoy+d4F80XETBH1E1TwPR25/PUYWTmjZyitXfMhg88K5fFneyRJ uxQzc1fMf04CM+USnd23dnTaIwS7vdCe2OPI2t+m3wox+vy7Zv356154dzNFFY1YS4Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796046678; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=sz2RDbbQd1qJJY5cdMfHRxSfY8EAFKsbf8HYdFDKCbo=; b=2ZfMHGucgcbSGvi7/vWp2MPVnThMbxJSI7NEuIDmeaQoctMllUQoSSG/ellnzDUTUQIJ IjDH7SdFcRrZQKblt8pYc6dGuAG1V7v8cs/KfTb30SNQZI41RuN3mC9sLNULOnAnw+RDn fPKIwVcRDaYt8K68KKtrKBRmQoqmmvWgRJ4DZ12wnKQicb2j1Lf5XSsbV6FQAJ+iY8cJ4 ntSwOSZtbFMgUUz0ADjZVy1XXrlqyzzWBTT3jVEQY94Cf/kVXNJ5lWkrARRKBrGAACc6a laFV1Hm9xKswsGTHI/7OfE0fJnJ2v+uRpYSLV+qzkEzgMQM7HyXUdcYmt5UMqgKKlkg== 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=Z5VxT2vy; 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 69685606A320 for ; Mon, 30 Nov 2026 13:51:18 +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=Z5VxT2vy Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1174F1F00926; Mon, 30 Nov 2026 13:51:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796046678; bh=sz2RDbbQd1qJJY5cdMfHRxSfY8EAFKsbf8HYdFDKCbo=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=Z5VxT2vyxa3+PKKl1lvUXHbUNNh/7b3BnSuWRLjSD4yvlou3dRl2vJha7t5yFxlgv +54V8MmXcVHYLsLzk2HxUv9pmGHFinJ8OVHi3o7T8nn3yiLfH0LbPeKIwbW6i6KJdI gzR899FMPXsMGOisZqF1BU7IdZ+uU8Z1RwY6SwZrD121+8OqMFCJTtvauIM8eboHHS lkYMtnaoeHo2SSOrdiNvNVQ8vto7JN61cLYrVRoYiDL6GbeMoPWj5yxBlgXqRL3in4 gnEJh/ueqc9WVM84ugMOWVxJODmiNfCT0znidz4FSj/pn7PJsMHxPL5stHNrOAfXwq Bjb0bi2yrxH4g== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v5 07/12] scsi: mpt3sas: Stop polling devices when the unresponding scan is cancelled Reply-To: sashiko-reviews@lists.linux.dev To: "Jeff Layton" Cc: linux-scsi@vger.kernel.org In-Reply-To: <20261130-sas-abba-v5-7-487c39d1114f@kernel.org> References: <20261130-sas-abba-v5-0-487c39d1114f@kernel.org> <20261130-sas-abba-v5-7-487c39d1114f@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Mon, 30 Nov 2026 13:51:17 +0000 X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] scsi: mpt3sas: in-flight TUR failing during hard reset offlines sdev - [Medium] scsi: mpt3sas: _mpt3sas_fw_work() runs post-reset scan during hard reset -- commit cd9e963bd471db857bfd8c1a33d0a80691d1dded Author: Jeff Layton scsi: mpt3sas: Stop polling devices when the unresponding scan is cancelled This commit avoids counting device readiness polling retries in _scsih_ublock_io_all_device() while shost_recovery is set, and stops polling and skips the post-reset scan in _mpt3sas_fw_work() when remove_host or fw_events_cleanup is set. > diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/= mpt3sas_scsih.c > index 2e2e66ff01966..7d8411d1eb281 100644 > --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c > +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c > @@ -4075,6 +4075,21 @@ _scsih_internal_device_unblock(struct scsi_device = *sdev, > } > } > =20 > +/** > + * _scsih_unresponding_scan_cancelled - should polling devices stop > + * @ioc: per adapter object > + * > + * While the MPT3SAS_REMOVE_UNRESPONDING_DEVICES event polls devices, a > + * hard reset or the removal of the host waits for it to finish. > + * > + * Return: true if the event is being cancelled, false otherwise. > + */ > +static bool > +_scsih_unresponding_scan_cancelled(struct MPT3SAS_ADAPTER *ioc) > +{ > + return READ_ONCE(ioc->remove_host) || READ_ONCE(ioc->fw_events_cleanup); > +} > + > /** > * _scsih_ublock_io_all_device - unblock every device > * @ioc: per adapter object > @@ -4131,8 +4146,16 @@ _scsih_ublock_io_all_device(struct MPT3SAS_ADAPTER= *ioc, u8 no_turs) > if (pcie_device) > pcie_device_put(pcie_device); > } while ((rc =3D=3D DEVICE_RETRY || rc =3D=3D DEVICE_START_UNIT || > - rc =3D=3D DEVICE_STOP_UNIT || rc =3D=3D DEVICE_RETRY_UA) > - && count++ < command_retry_count); > + rc =3D=3D DEVICE_STOP_UNIT || rc =3D=3D DEVICE_RETRY_UA) && > + /* a reset skips the check, so it doesn't count */ > + (READ_ONCE(ioc->shost_recovery) || > + count++ < command_retry_count) && > + !_scsih_unresponding_scan_cancelled(ioc)); > + if (_scsih_unresponding_scan_cancelled(ioc)) { > + /* a reset queues a new scan, which polls the rest */ > + scsi_device_put(sdev); > + return; > + } > sas_device_priv_data->block =3D 0; > if (rc !=3D DEVICE_READY) > sas_device_priv_data->deleted =3D 1; [Severity: Medium] Can an in-flight TEST UNIT READY or START UNIT command that fails during a hard reset still mark sdev deleted and offline here? reset thread fw_event worker ------------ --------------- _scsih_ublock_io_all_device() _scsih_wait_for_device_to_become_ready() _scsih_test_unit_ready() _scsi_send_scsi_io() (shost_recovery =3D=3D 0) mpt3sas_base_hard_reset_handler() ioc->shost_recovery =3D 1 mpt3sas_wait_for_commands_to_complete() mpt3sas_base_make_ioc_ready() mpt3sas_wait_for_ioc(ioc, 10) --> -ETIME / -EFAULT --> rc =3D DEVICE_ERROR (loop exits: rc =3D=3D DEVICE_ERROR) _scsih_unresponding_scan_cancelled() --> false (fw_events_cleanup =3D=3D 0) sas_device_priv_data->block =3D 0 sas_device_priv_data->deleted =3D 1 scsi_device_set_state(sdev, SDEV_OFFLIN= E) _base_clear_outstanding_commands() ... _scsih_fw_event_cleanup_queue() ioc->fw_events_cleanup =3D 1 mpt3sas_base_hard_reset_handler() does not set ioc->fw_events_cleanup until after mpt3sas_wait_for_commands_to_complete() and mpt3sas_base_make_ioc_ready() finish. If a hard reset starts after _scsi_send_scsi_io() checks ioc->shost_recovery (or if a submitted 30s TUR times out while the reset is still in mpt3sas_base_make_ioc_ready() and mpt3sas_scsih_issue_locked_tm() fails because ioc->shost_recovery is 1), _scsih_test_unit_ready() returns DEVICE_ERROR. That exits the do-while loop while ioc->fw_events_cleanup is still 0, so _scsih_ublock_io_all_device() unblocks and offlines the device, and the new scan queued by the reset will skip it because sas_device_priv_data->block is now 0. > @@ -12124,6 +12147,14 @@ _mpt3sas_fw_work(struct MPT3SAS_ADAPTER *ioc, st= ruct fw_event_work *fw_event) > ssleep(1); > } > _scsih_remove_unresponding_devices(ioc); > + /* > + * The reset waiting for this event holds the IOC out of the > + * operational state, so the config requests below would stall > + * it, or try to reset the IOC again. The reset queues a new > + * scan, and a removal deletes the devices. > + */ > + if (_scsih_unresponding_scan_cancelled(ioc)) > + goto out; > _scsih_del_dirty_vphy(ioc); > _scsih_del_dirty_port_entries(ioc); > if (ioc->is_gen35_ioc) [Severity: Medium] Can _mpt3sas_fw_work() still run _scsih_scan_for_devices_after_reset() while a concurrent hard reset holds ioc->reset_in_progress_mutex and has the IOC non-operational, causing the same stall or ABBA deadlock? reset thread fw_event worker ------------ --------------- mpt3sas_base_hard_reset_handler() mutex_lock(&ioc->reset_in_progress_mutex) ioc->shost_recovery =3D 1 mpt3sas_wait_for_commands_to_complete() mpt3sas_base_make_ioc_ready() (IOC is non-operational, fw_events_cleanup is still 0) _mpt3sas_fw_work() _scsih_remove_unresponding_devices() _scsih_unresponding_scan_cancelled() --> false _scsih_scan_for_devices_after_reset() ... _config_request() mpt3sas_wait_for_ioc() --> -ETIME mpt3sas_base_hard_reset_handler() mutex_lock(&ioc->reset_in_progr= ess_mutex) _base_clear_outstanding_commands() ... _scsih_fw_event_cleanup_queue() cancel_work_sync(&fw_event->work) *** DEADLOCK *** Because ioc->fw_events_cleanup is only set after mpt3sas_wait_for_commands_to_complete() and mpt3sas_base_make_ioc_ready(), _scsih_unresponding_scan_cancelled(ioc) returns false throughout that window even though ioc->shost_recovery is 1 and the IOC is non-operational. If _scsih_remove_unresponding_devices() finishes during that window (for examp= le during driver load when devices are still on sas_device_init_list and no blocked scsi_device is on ioc->shost, or when the last blocked device check just completed), or if the hard reset begins after this check while _scsih_scan_for_devices_after_reset() is iterating through its config-page and device-add retry loops, _mpt3sas_fw_work() still issues config requests against the non-operational IOC while reset_in_progress_mutex is held. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261130-sas-abba-v= 5-0-487c39d1114f@kernel.org?part=3D7