All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Strahan <david.strahan@microchip.com>
To: <linux-scsi@vger.kernel.org>
Cc: David Strahan <David.Strahan@microchip.com>,
	Mike McGowen <mike.mcgowen@microchip.com>,
	Don Brace <don.brace@microchip.com>,
	"David Strahan" <david.strahan@microchip.com>
Subject: [PATCH v1 1/4] smartpqi: Fix AIO retry marker cleared by SCSI core between dispatches.
Date: Wed, 22 Jul 2026 17:03:58 -0500	[thread overview]
Message-ID: <20260722220401.6357-2-david.strahan@microchip.com> (raw)
In-Reply-To: <20260722220401.6357-1-david.strahan@microchip.com>

From: David Strahan <David.Strahan@microchip.com>

On recent Linux kernels the driver can enter a retry loop on the
AIO fast path when a request is retried, looping until timeout.
A diagnostic path that takes a physical drive offline on AIO-bypass
failure is also never entered on affected kernels.

Register a per-command initialization callback with the SCSI
core. Its presence causes the core to skip the per-dispatch
clear, so the retry marker now survives across the requeue and
the AIO-to-RAID fallback proceeds as intended. The driver takes
over the marker's lifetime: it is zeroed at tag allocation,
preserved across the retry requeue so the error path can act on
it, and cleared on terminal completion so the tag starts clean on
its next use.

Fixes: dce5c4afd035 ("scsi: core: Clear driver private data when retrying request")
Signed-off-by: Mike McGowen <mike.mcgowen@microchip.com>
Acked-by: Don Brace <don.brace@microchip.com>
Signed-off-by: David Strahan <david.strahan@microchip.com>
---
 drivers/scsi/smartpqi/smartpqi_init.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c
index 5ec583d..3a75b9f 100644
--- a/drivers/scsi/smartpqi/smartpqi_init.c
+++ b/drivers/scsi/smartpqi/smartpqi_init.c
@@ -66,6 +66,12 @@ static struct pqi_cmd_priv *pqi_cmd_priv(struct scsi_cmnd *cmd)
 	return scsi_cmd_priv(cmd);
 }
 
+static int pqi_init_cmd_priv(struct Scsi_Host *shost, struct scsi_cmnd *cmd)
+{
+	memset(pqi_cmd_priv(cmd), 0, sizeof(struct pqi_cmd_priv));
+	return 0;
+}
+
 static void pqi_verify_structures(void);
 static void pqi_take_ctrl_offline(struct pqi_ctrl_info *ctrl_info,
 	enum pqi_ctrl_shutdown_reason ctrl_shutdown_reason);
@@ -5958,6 +5964,17 @@ void pqi_prep_for_scsi_done(struct scsi_cmnd *scmd)
 	struct pqi_scsi_dev *device;
 	struct completion *wait;
 
+	/*
+	 * Clear the AIO-retry marker on final completion so the tag
+	 * starts clean on its next dispatch.  On DID_IMM_RETRY leave
+	 * it intact: pqi_aio_io_complete() sets DID_IMM_RETRY and
+	 * bumps the marker to steer the requeue onto the RAID path,
+	 * and pqi_process_raid_io_error() consumes the non-zero
+	 * marker to offline a misbehaving drive.
+	 */
+	if (host_byte(scmd->result) != DID_IMM_RETRY)
+		pqi_cmd_priv(scmd)->this_residual = 0;
+
 	if (!scmd->device) {
 		set_host_byte(scmd, DID_NO_CONNECT);
 		return;
@@ -7612,6 +7629,7 @@ static const struct scsi_host_template pqi_driver_template = {
 	.sdev_groups = pqi_sdev_groups,
 	.shost_groups = pqi_shost_groups,
 	.cmd_size = sizeof(struct pqi_cmd_priv),
+	.init_cmd_priv = pqi_init_cmd_priv,
 };
 
 static int pqi_register_scsi(struct pqi_ctrl_info *ctrl_info)
-- 
2.52.0


  reply	other threads:[~2026-07-22 22:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-22 22:03 [PATCH v1 0/4] smartpqi: fixes and updates for 2.1.42-011 David Strahan
2026-07-22 22:03 ` David Strahan [this message]
2026-07-22 22:36   ` [PATCH v1 1/4] smartpqi: Fix AIO retry marker cleared by SCSI core between dispatches sashiko-bot
2026-07-22 22:03 ` [PATCH v1 2/4] smartpqi: add support for CCISS_BIG_PASSTHRU ioctl David Strahan
2026-07-22 22:32   ` sashiko-bot
2026-07-22 22:04 ` [PATCH v1 3/4] smartpqi: add new pci device-ids David Strahan
2026-07-22 22:04 ` [PATCH v1 4/4] smartpqi: update version to 2.1.42-011 David Strahan

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=20260722220401.6357-2-david.strahan@microchip.com \
    --to=david.strahan@microchip.com \
    --cc=don.brace@microchip.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=mike.mcgowen@microchip.com \
    /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.