[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <98c1c083-2538-496f-b775-ad8c9cd340dd@cybernetics.com>
Date: Mon, 8 Sep 2025 15:11:59 -0400
From: Tony Battersby <tonyb@...ernetics.com>
To: Nilesh Javali <njavali@...vell.com>,
GR-QLogic-Storage-Upstream@...vell.com,
"James E.J. Bottomley" <James.Bottomley@...senPartnership.com>,
"Martin K. Petersen" <martin.petersen@...cle.com>
Cc: linux-scsi <linux-scsi@...r.kernel.org>, target-devel@...r.kernel.org,
scst-devel@...ts.sourceforge.net,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: [SCST PATCH 14/15] scsi: qla2xxx: add back SRR support
This patch applies to the out-of-tree SCST project, not to the Linux
kernel. Apply when importing the upstream patch with the same title.
Signed-off-by: Tony Battersby <tonyb@...ernetics.com>
---
qla2x00t-32gbit/qla2x00-target/scst_qla2xxx.c | 107 ++++++++++++++++--
1 file changed, 95 insertions(+), 12 deletions(-)
diff --git a/qla2x00t-32gbit/qla2x00-target/scst_qla2xxx.c b/qla2x00t-32gbit/qla2x00-target/scst_qla2xxx.c
index d3a978610..7f06ac6f3 100644
--- a/qla2x00t-32gbit/qla2x00-target/scst_qla2xxx.c
+++ b/qla2x00t-32gbit/qla2x00-target/scst_qla2xxx.c
@@ -72,6 +72,8 @@
#endif
#endif
+#define sense_initiator_detected_error HARDWARE_ERROR, 0x48, 0x00
+
static LIST_HEAD(sqa_tgt_glist);
/* Function definitions for callbacks from the SCST target core. */
@@ -395,6 +397,17 @@ static struct qla_tgt_cmd *sqa_qla2xxx_get_cmd(struct fc_port *sess)
return cmd;
}
+static int sqa_qla2xxx_get_cmd_ref(struct qla_tgt_cmd *cmd)
+{
+ scst_cmd_get(cmd->scst_cmd);
+ return 0;
+}
+
+static void sqa_qla2xxx_put_cmd_ref(struct qla_tgt_cmd *cmd)
+{
+ scst_cmd_put(cmd->scst_cmd);
+}
+
static DEFINE_MUTEX(sqa_mutex);
@@ -527,8 +540,12 @@ static void sqa_qla2xxx_handle_data(struct qla_tgt_cmd *cmd)
break;
case DIF_ERR_NONE:
default:
- scst_set_cmd_error(scst_cmd,
- SCST_LOAD_SENSE(scst_sense_aborted_command));
+ if (cmd->srr_failed)
+ scst_set_cmd_error(scst_cmd,
+ SCST_LOAD_SENSE(sense_initiator_detected_error));
+ else
+ scst_set_cmd_error(scst_cmd,
+ SCST_LOAD_SENSE(scst_sense_aborted_command));
break;
}
}
@@ -1546,6 +1563,11 @@ static int sqa_xmit_response(struct scst_cmd *scst_cmd)
}
}
+ if (unlikely(cmd->free_sg)) {
+ cmd->free_sg = 0;
+ qlt_free_sg(cmd);
+ }
+
cmd->bufflen = scst_cmd_get_adjusted_resp_data_len(scst_cmd);
cmd->sg = scst_cmd_get_sg(scst_cmd);
cmd->sg_cnt = scst_cmd_get_sg_cnt(scst_cmd);
@@ -1556,6 +1578,15 @@ static int sqa_xmit_response(struct scst_cmd *scst_cmd)
cmd->lba = scst_cmd_get_lba(scst_cmd);
cmd->trc_flags |= TRC_XMIT_STATUS;
+ /*
+ * se_cmd::data_length,t_data_sg,t_data_nents used by
+ * qlt_restore_orig_sg()
+ */
+ cmd->se_cmd.data_length = cmd->bufflen;
+ cmd->se_cmd.t_data_sg = cmd->sg;
+ cmd->se_cmd.t_data_nents = cmd->sg_cnt;
+ cmd->se_cmd.scsi_status = cmd->scsi_status;
+
#if QLA_ENABLE_PI
if (scst_get_tgt_dif_actions(scst_cmd->cmd_dif_actions)) {
cmd->blk_sz = scst_cmd_get_block_size(scst_cmd);
@@ -1600,7 +1631,7 @@ static int sqa_xmit_response(struct scst_cmd *scst_cmd)
cmd->bufflen, cmd->sg_cnt, cmd->dma_data_direction,
cmd->se_cmd.residual_count);
- res = qlt_xmit_response(cmd, xmit_type, scst_cmd_get_status(scst_cmd));
+ res = qlt_xmit_response(cmd, xmit_type, cmd->scsi_status);
switch (res) {
case 0:
@@ -1630,16 +1661,30 @@ static int sqa_rdy_to_xfer(struct scst_cmd *scst_cmd)
TRACE(TRACE_SCSI, "sqatgt(%ld/%d): tag=%lld", cmd->vha->host_no,
cmd->vha->vp_idx, scst_cmd_get_tag(scst_cmd));
+ if (unlikely(cmd->free_sg)) {
+ cmd->free_sg = 0;
+ qlt_free_sg(cmd);
+ }
+
cmd->bufflen = scst_cmd_get_write_fields(scst_cmd, &cmd->sg,
&cmd->sg_cnt);
+
cmd->dma_data_direction =
scst_to_tgt_dma_dir(scst_cmd_get_data_direction(scst_cmd));
+ cmd->offset = 0;
- cmd->sg = scst_cmd_get_sg(scst_cmd);
- cmd->sg_cnt = scst_cmd_get_sg_cnt(scst_cmd);
cmd->scsi_status = scst_cmd_get_status(scst_cmd);
cmd->trc_flags |= TRC_XFR_RDY;
+ /*
+ * se_cmd::data_length,t_data_sg,t_data_nents used by
+ * qlt_restore_orig_sg()
+ */
+ cmd->se_cmd.data_length = cmd->bufflen;
+ cmd->se_cmd.t_data_sg = cmd->sg;
+ cmd->se_cmd.t_data_nents = cmd->sg_cnt;
+ cmd->se_cmd.scsi_status = cmd->scsi_status;
+
#if QLA_ENABLE_PI
if (scst_get_tgt_dif_actions(scst_cmd->cmd_dif_actions)) {
cmd->blk_sz = scst_cmd_get_block_size(scst_cmd);
@@ -1866,6 +1911,7 @@ static void sqa_on_hw_pending_cmd_timeout(struct scst_cmd *scst_cmd)
struct qla_tgt_cmd *cmd = scst_cmd_get_tgt_priv(scst_cmd);
struct scsi_qla_host *vha = cmd->vha;
struct qla_qpair *qpair = cmd->qpair;
+ struct qla_tgt_srr *srr;
unsigned long flags;
bool advance_cmd = false;
@@ -1898,19 +1944,53 @@ static void sqa_on_hw_pending_cmd_timeout(struct scst_cmd *scst_cmd)
break;
}
- /* Handle race with normal CTIO completion. */
- if (!cmd->cmd_sent_to_fw) {
+ srr = cmd->srr;
+ if (srr) {
+ /* Handle race with SRR processing. */
+ if (srr->imm_ntfy_recvd && srr->ctio_recvd) {
+ TRACE_MGMT_DBG(
+ "sqatgt(%ld/%d): tag %lld: cmd should be scheduled for SRR processing",
+ vha->host_no, vha->vp_idx,
+ scst_cmd_get_tag(scst_cmd));
+ goto out_unlock;
+ }
+
TRACE_MGMT_DBG(
- "sqatgt(%ld/%d): tag %lld: cmd not sent to fw; assuming just completed",
+ "sqatgt(%ld/%d): tag %lld: timeout waiting for %s SRR",
vha->host_no, vha->vp_idx,
- scst_cmd_get_tag(scst_cmd));
- goto out_unlock;
+ scst_cmd_get_tag(scst_cmd),
+ (!srr->imm_ntfy_recvd) ? "IMM" : "CTIO");
+
+ if (srr->ctio_recvd) {
+ /*
+ * When the SRR CTIO was received, cmd processing was
+ * delayed to wait for the SRR immediate notify, which
+ * never arrived. Process the cmd now.
+ *
+ * Note that in this case cmd->cmd_sent_to_fw == 0
+ * so we avoid checking that.
+ */
+ advance_cmd = true;
+ }
+
+ qlt_srr_abort(cmd, false);
+ srr = NULL; /* srr may have been freed */
+ } else {
+ /* Handle race with normal CTIO completion. */
+ if (!cmd->cmd_sent_to_fw) {
+ TRACE_MGMT_DBG(
+ "sqatgt(%ld/%d): tag %lld: cmd not sent to fw; assuming just completed",
+ vha->host_no, vha->vp_idx,
+ scst_cmd_get_tag(scst_cmd));
+ goto out_unlock;
+ }
}
/* Check for chip reset or a timeout after sending a term exchange. */
if (!qpair->fw_started ||
cmd->reset_count != qpair->chip_reset ||
- (cmd->sent_term_exchg &&
+ (!advance_cmd &&
+ cmd->sent_term_exchg &&
time_is_before_jiffies(cmd->jiffies_at_term_exchg +
SQA_MAX_HW_PENDING_TIME * HZ / 2))) {
/*
@@ -1920,7 +2000,8 @@ static void sqa_on_hw_pending_cmd_timeout(struct scst_cmd *scst_cmd)
* mapping, so try term exchange first and see if that works.
*/
- sqa_cleanup_hw_pending_cmd(vha, cmd);
+ if (cmd->cmd_sent_to_fw)
+ sqa_cleanup_hw_pending_cmd(vha, cmd);
qlt_unmap_sg(vha, cmd);
@@ -2034,6 +2115,8 @@ static struct qla_tgt_func_tmpl sqa_qla2xxx_template = {
.handle_tmr = sqa_qla2xxx_handle_tmr,
.find_cmd_by_tag = sqa_qla2xxx_find_cmd_by_tag,
.get_cmd = sqa_qla2xxx_get_cmd,
+ .get_cmd_ref = sqa_qla2xxx_get_cmd_ref,
+ .put_cmd_ref = sqa_qla2xxx_put_cmd_ref,
.rel_cmd = sqa_qla2xxx_rel_cmd,
.free_cmd = sqa_qla2xxx_free_cmd,
.free_mcmd = sqa_qla2xxx_free_mcmd,
--
2.43.0
Powered by blists - more mailing lists