All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jeff Layton" <jlayton@kernel.org>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v3 06/11] scsi: mpt3sas: Stop polling devices when the unresponding scan is cancelled
Date: Wed, 18 Nov 2026 23:27:57 +0000	[thread overview]
Message-ID: <sashiko-outbox-222179@kernel.org> (raw)
In-Reply-To: <20261118-sas-abba-v3-6-5562d690cf61@kernel.org>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] scsi: mpt3sas: _mpt3sas_fw_work() continues scan after
  cancellation
- [High] scsi: mpt3sas: _scsih_unresponding_scan_cancelled() ignores
  shost_recovery
--

commit 35d95180d221b7f75fd9660f0fc687ebab407910
Author: Jeff Layton <jlayton@kernel.org>

scsi: mpt3sas: Stop polling devices when the unresponding scan is cancelled

This commit stops the device readiness polling loop in
_scsih_ublock_io_all_device() and returns early when ioc->remove_host or
ioc->fw_events_cleanup is set.

> diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
> index 5d494ad12c542..5657bda241f77 100644
> --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
> +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
> @@ -4057,6 +4057,22 @@ _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, and the
> + * readiness check doesn't test devices during a reset.
> + *
> + * 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);
> +}

[Severity: High]
Can a device still exhaust its retries and be offlined untested while
ioc->shost_recovery is set before ioc->fw_events_cleanup is set?

mpt3sas_base_hard_reset_handler() sets ioc->shost_recovery = 1 before
running mpt3sas_wait_for_commands_to_complete() (up to 10 seconds) and
mpt3sas_base_make_ioc_ready() (15 to 45+ seconds), whereas
ioc->fw_events_cleanup is only set later inside
_base_clear_outstanding_commands() -> ... ->
_scsih_fw_event_cleanup_queue().  During that initial reset window,
_scsih_wait_for_device_to_become_ready() immediately returns DEVICE_RETRY
without testing the device, while _scsih_unresponding_scan_cancelled()
still returns false.  If count reaches command_retry_count before
_scsih_fw_event_cleanup_queue() runs (or if mpt3sas_base_make_ioc_ready()
fails and skips _base_clear_outstanding_commands()), the loop still marks
the untested device deleted and SDEV_OFFLINE.

>  /**
>   * _scsih_ublock_io_all_device - unblock every device
>   * @ioc: per adapter object
> @@ -4114,7 +4130,13 @@ _scsih_ublock_io_all_device(struct MPT3SAS_ADAPTER *ioc, u8 no_turs)
>  				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);
> +			&& 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;
> +		}

[Severity: High]
When this returns early, doesn't _mpt3sas_fw_work() continue running the
rest of the MPT3SAS_REMOVE_UNRESPONDING_DEVICES handler while the reset or
removal is waiting in cancel_work_sync()?

drivers/scsi/mpt3sas/mpt3sas_scsih.c:_mpt3sas_fw_work() {
	...
	case MPT3SAS_REMOVE_UNRESPONDING_DEVICES:
		...
		_scsih_remove_unresponding_devices(ioc);
		_scsih_del_dirty_vphy(ioc);
		_scsih_del_dirty_port_entries(ioc);
		if (ioc->is_gen35_ioc)
			_scsih_update_device_qdepth(ioc);
		_scsih_scan_for_devices_after_reset(ioc);
		...
		if (ioc->is_driver_loading)
			_scsih_complete_devices_scanning(ioc);
		_scsih_set_nvme_max_shutdown_latency(ioc);
		break;
}

When cancelled by a hard reset, the reset thread holds
ioc->reset_in_progress_mutex with the controller in MPI2_IOC_STATE_READY
and blocks in _scsih_fw_event_cleanup_queue() -> cancel_work_sync() before
_base_make_ioc_operational() is reached.  _scsih_scan_for_devices_after_reset()
then issues config requests that wait for MPI2_IOC_STATE_OPERATIONAL in
mpt3sas_wait_for_ioc(): if ioc->is_driver_loading is set,
mpt3sas_wait_for_ioc() returns -ETIME and _config_request() calls
mpt3sas_base_hard_reset_handler(), deadlocking on
ioc->reset_in_progress_mutex; otherwise each config request stalls the
reset for its 15-second timeout.  Should _mpt3sas_fw_work() also bail out
to out after _scsih_remove_unresponding_devices() when
_scsih_unresponding_scan_cancelled(ioc) is true?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261118-sas-abba-v3-0-5562d690cf61@kernel.org?part=6

  reply	other threads:[~2026-11-18 23:27 UTC|newest]

Thread overview: 17+ 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:33   ` sashiko-bot
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 ` [PATCH v3 03/11] scsi: mpt3sas: Requeue topology events only for busy devices Jeff Layton
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:27   ` sashiko-bot [this message]
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:23   ` sashiko-bot
2026-11-18 23:10 ` [PATCH v3 11/11] scsi: mpt3sas: Time out delayed not-responding device blocks Jeff Layton
2026-11-18 23:33   ` sashiko-bot
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=sashiko-outbox-222179@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.