From: sashiko-bot@kernel.org
To: "Jeff Layton" <jlayton@kernel.org>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v5 07/12] scsi: mpt3sas: Stop polling devices when the unresponding scan is cancelled
Date: Mon, 30 Nov 2026 13:51:17 +0000 [thread overview]
Message-ID: <sashiko-outbox-241318@kernel.org> (raw)
In-Reply-To: <20261130-sas-abba-v5-7-487c39d1114f@kernel.org>
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 <jlayton@kernel.org>
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,
> }
> }
>
> +/**
> + * _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 == DEVICE_RETRY || rc == DEVICE_START_UNIT ||
> - rc == DEVICE_STOP_UNIT || rc == DEVICE_RETRY_UA)
> - && count++ < command_retry_count);
> + rc == DEVICE_STOP_UNIT || rc == 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 = 0;
> if (rc != DEVICE_READY)
> sas_device_priv_data->deleted = 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 == 0)
mpt3sas_base_hard_reset_handler()
ioc->shost_recovery = 1
mpt3sas_wait_for_commands_to_complete()
mpt3sas_base_make_ioc_ready()
mpt3sas_wait_for_ioc(ioc, 10)
--> -ETIME / -EFAULT
--> rc = DEVICE_ERROR
(loop exits: rc == DEVICE_ERROR)
_scsih_unresponding_scan_cancelled()
--> false (fw_events_cleanup == 0)
sas_device_priv_data->block = 0
sas_device_priv_data->deleted = 1
scsi_device_set_state(sdev, SDEV_OFFLINE)
_base_clear_outstanding_commands()
...
_scsih_fw_event_cleanup_queue()
ioc->fw_events_cleanup = 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, struct 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 = 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_progress_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 example
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.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261130-sas-abba-v5-0-487c39d1114f@kernel.org?part=7
next prev parent reply other threads:[~2026-11-30 13:51 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 13:21 [PATCH v5 00/12] scsi: mpt3sas: Fix delayed not-responding block deadlock and related bugs Jeff Layton
2026-11-30 13:21 ` [PATCH v5 01/12] scsi: mpt3sas: Don't leave requeued firmware events pending at teardown Jeff Layton
2026-11-30 13:21 ` [PATCH v5 02/12] scsi: mpt3sas: Disarm a requeued event's timer when it leaves the event list Jeff Layton
2026-11-30 13:21 ` [PATCH v5 03/12] scsi: mpt3sas: Hold event references while cleaning up the event queue Jeff Layton
2026-11-30 13:21 ` [PATCH v5 04/12] scsi: mpt3sas: Requeue topology events only for busy devices Jeff Layton
2026-11-30 13:21 ` [PATCH v5 05/12] scsi: mpt3sas: Fix pcie_device leak in _scsih_ublock_io_device_wait() Jeff Layton
2026-11-30 13:21 ` [PATCH v5 06/12] scsi: mpt3sas: Restore unblock retry " Jeff Layton
2026-11-30 13:21 ` [PATCH v5 07/12] scsi: mpt3sas: Stop polling devices when the unresponding scan is cancelled Jeff Layton
2026-11-30 13:51 ` sashiko-bot [this message]
2026-11-30 13:21 ` [PATCH v5 08/12] scsi: mpt3sas: Reset the TUR retry count for each device Jeff Layton
2026-11-30 13:21 ` [PATCH v5 09/12] scsi: mpt3sas: Cache the missing delays the IOC actually uses Jeff Layton
2026-11-30 13:21 ` [PATCH v5 10/12] scsi: mpt3sas: Serialize interrupt-time sdev block with hostdata teardown Jeff Layton
2026-11-30 13:46 ` sashiko-bot
2026-11-30 13:21 ` [PATCH v5 11/12] scsi: mpt3sas: Don't use freed hostdata while polling devices Jeff Layton
2026-11-30 13:21 ` [PATCH v5 12/12] scsi: mpt3sas: Time out delayed not-responding device blocks Jeff Layton
2026-11-30 13:55 ` sashiko-bot
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=sashiko-outbox-241318@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=jlayton@kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.