Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ranjan Kumar" <ranjan.kumar@broadcom.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v2 04/10] mpi3mr: Fix NVMe page size caching for non-operational devices
Date: Wed, 08 Jul 2026 19:18:23 +0000	[thread overview]
Message-ID: <20260708191824.5C5AC1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260708183305.244485-5-ranjan.kumar@broadcom.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] The `reset_to` and `abort_to` fields are left uninitialized for PCIe devices in error states, causing task management commands to time out instantly and trigger unintended full controller resets.
--

--- Patch [4]: [PATCH v2 04/10] mpi3mr: Fix NVMe page size caching for non-operational devices ---
commit a648ff0d4d5627aa485822e3033940c480028902
Author: Ranjan Kumar <ranjan.kumar@broadcom.com>

mpi3mr: Fix NVMe page size caching for non-operational devices

This patch populates the PCIe page size attribute for NVMe devices regardless
of their access status, ensuring management IOCTLs can reach the firmware.
It also adds bounds checking for the firmware-provided page size to prevent
undefined shift behavior, falling back to a default size if invalid.

Closes: https://sashiko.dev/#/patchset/20260626114109.43685-1-ranjan.kumar@broadcom.com?part=4

> diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c
> index d2a20f2721dbf..df7365d19b44a 100644
> --- a/drivers/scsi/mpi3mr/mpi3mr_os.c
> +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c
> @@ -1354,12 +1354,14 @@ static void mpi3mr_update_tgtdev(struct mpi3mr_ioc *mrioc,
>  		tgtdev->dev_spec.pcie_inf.capb =
>  		    le32_to_cpu(pcieinf->capabilities);
>  		tgtdev->dev_spec.pcie_inf.mdts = MPI3MR_DEFAULT_MDTS;
> -		/* 2^12 = 4096 */
> -		tgtdev->dev_spec.pcie_inf.pgsz = 12;
> +		/* Validate firmware page size to prevent undefined shift behavior */
> +		if (pcieinf->page_size > 0 && pcieinf->page_size < 31)
> +			tgtdev->dev_spec.pcie_inf.pgsz = pcieinf->page_size;
> +		else
> +			tgtdev->dev_spec.pcie_inf.pgsz = 12; /* Default to 4096 (2^12) */
>  		if (dev_pg0->access_status == MPI3_DEVICE0_ASTATUS_NO_ERRORS) {
>  			tgtdev->dev_spec.pcie_inf.mdts =
>  			    le32_to_cpu(pcieinf->maximum_data_transfer_size);
> -			tgtdev->dev_spec.pcie_inf.pgsz = pcieinf->page_size;
>  			tgtdev->dev_spec.pcie_inf.reset_to =
>  			    max_t(u8, pcieinf->controller_reset_to,
>  			     MPI3MR_INTADMCMD_TIMEOUT);

[Severity: High]
This is a pre-existing issue, but does exposing the device to IOCTLs by
setting the page size here unintentionally turn a device error into a full
controller reset?

When an NVMe device is in an error state (e.g., NEEDS_INITIALIZATION),
access_status != NO_ERRORS, so reset_to and abort_to are left uninitialized (0).

With this patch populating pgsz for these devices, management IOCTLs can pass
the driver's PRP validation and reach the firmware. If the IOCTL times out
because the device is in an error state, the driver attempts recovery:

drivers/scsi/mpi3mr/mpi3mr_os.c:mpi3mr_issue_tm() {
    ...
	if (tgtdev) {
		if (tgtdev->dev_type == MPI3_DEVICE_DEVFORM_PCIE)
			timeout = cmd_priv ? tgtdev->dev_spec.pcie_inf.abort_to
					   : tgtdev->dev_spec.pcie_inf.reset_to;
    ...
}

Since reset_to and abort_to are 0, wait_for_completion_timeout() fails
instantly, causing the driver to falsely detect a TM timeout and
unconditionally execute mpi3mr_soft_reset_handler(), resetting the entire
controller.

Should reset_to and abort_to also be initialized with defaults even when the
device is in an error state to prevent routine monitoring tools from triggering
an HBA reset?

>  			tgtdev->dev_spec.pcie_inf.abort_to =
>  			    max_t(u8, pcieinf->nvme_abort_to,
>  			    MPI3MR_INTADMCMD_TIMEOUT);
>  		}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260708183305.244485-1-ranjan.kumar@broadcom.com?part=4

  reply	other threads:[~2026-07-08 19:18 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-08 18:32 [PATCH v2 00/10] mpi3mr: Few Enhancements and minor fixes Ranjan Kumar
2026-07-08 18:32 ` [PATCH v2 01/10] mpi3mr: Skip device shutdown during unload per controller configuration Ranjan Kumar
2026-07-08 18:53   ` sashiko-bot
2026-07-08 18:32 ` [PATCH v2 02/10] mpi3mr: Update MPI Headers to revision 41 Ranjan Kumar
2026-07-08 18:32 ` [PATCH v2 03/10] mpi3mr: Add early timestamp synchronization after driver load Ranjan Kumar
2026-07-08 18:32 ` [PATCH v2 04/10] mpi3mr: Fix NVMe page size caching for non-operational devices Ranjan Kumar
2026-07-08 19:18   ` sashiko-bot [this message]
2026-07-08 18:33 ` [PATCH v2 05/10] mpi3mr: Fix performance regression caused by extended IRQ poll sleep Ranjan Kumar
2026-07-08 19:30   ` sashiko-bot
2026-07-08 18:33 ` [PATCH v2 06/10] mpi3mr: Fix memory leak on operational queue creation failure Ranjan Kumar
2026-07-08 19:48   ` sashiko-bot
2026-07-08 18:33 ` [PATCH v2 07/10] mpi3mr: Fix firmware event reference leak during cleanup Ranjan Kumar
2026-07-08 19:59   ` sashiko-bot
2026-07-08 18:33 ` [PATCH v2 08/10] mpi3mr: Fix SAS port allocation and registration error handling Ranjan Kumar
2026-07-08 20:12   ` sashiko-bot
2026-07-08 18:33 ` [PATCH v2 09/10] mpi3mr: Fix SAS PHY cleanup in host addition error paths Ranjan Kumar
2026-07-08 18:33 ` [PATCH v2 10/10] mpi3mr: Driver version update to 8.18.0.8.50 Ranjan Kumar

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=20260708191824.5C5AC1F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=ranjan.kumar@broadcom.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox