Skip to contentSkip to conversation

qla2xxx: Do not consume srb greedily

PATCH Applied Daniel Wagner 4 participants 6 messages Sep 29, 2020 – Oct 13, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qla2xxx: Do not consume srb greedily

qla2xx_process_get_sp_from_handle() will clear the slot which the current srb is stored. So this function has a side effect. Therefore, we can't use it in qla24xx_process_mbx_iocb_response() to check for consistency and later again in qla24xx_mbx_iocb_entry().

Let's move the consistency check directly into qla24xx_mbx_iocb_entry() and avoid the double call or any open coding of the qla2xx_process_get_sp_from_handle() functionality.

Fixes 31a3271ff11b ("scsi: qla2xxx: Handle incorrect entry_type entries")

---
Hi,

Brown bag for me please. My test patch had an open coded version of qla2xx_process_get_sp_from_handle() which didn't consume the srb. When I prepared it for sending it out, I 'cleaned' it up by using qla2xx_process_get_sp_from_handle() twice.

Sorry,
Daniel

 drivers/scsi/qla2xxx/qla_isr.c | 42 +++++++++++++++---------------------------
 1 file changed, 15 insertions(+), 27 deletions(-)
drivers/scsi/qla2xxx/qla_isr.c +15 -27
index 96811354f78a..2baba87c4e0c 100644
@@ -1839,6 +1839,7 @@ qla24xx_mbx_iocb_entry(scsi_qla_host_t *vha, struct req_que *req,
     struct mbx_24xx_entry *pkt)
 {
 	const char func[] = "MBX-IOCB2";
+	struct qla_hw_data *ha = vha->hw;
 	srb_t *sp;
 	struct srb_iocb *si;
 	u16 sz, i;
@@ -1848,6 +1849,18 @@ qla24xx_mbx_iocb_entry(scsi_qla_host_t *vha, struct req_que *req,
 	if (!sp)
 		return;
 
+	if (sp->type == SRB_SCSI_CMD ||
+	    sp->type == SRB_NVME_CMD ||
+	    sp->type == SRB_TM_CMD) {
+		ql_log(ql_log_warn, vha, 0x509d,
+			"Inconsistent event entry type %d\n", sp->type);
+		if (IS_P3P_TYPE(ha))
+			set_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags);
+		else
+			set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
+		return;
+	}
+
 	si = &sp->u.iocb_cmd;
 	sz = min(ARRAY_SIZE(pkt->mb), ARRAY_SIZE(sp->u.iocb_cmd.u.mbx.in_mb));
 
@@ -3406,32 +3419,6 @@ void qla24xx_nvme_ls4_iocb(struct scsi_qla_host *vha,
 	sp->done(sp, comp_status);
 }
 
-static void qla24xx_process_mbx_iocb_response(struct scsi_qla_host *vha,
-	struct rsp_que *rsp, struct sts_entry_24xx *pkt)
-{
-	struct qla_hw_data *ha = vha->hw;
-	srb_t *sp;
-	static const char func[] = "MBX-IOCB2";
-
-	sp = qla2x00_get_sp_from_handle(vha, func, rsp->req, pkt);
-	if (!sp)
-		return;
-
-	if (sp->type == SRB_SCSI_CMD ||
-	    sp->type == SRB_NVME_CMD ||
-	    sp->type == SRB_TM_CMD) {
-		ql_log(ql_log_warn, vha, 0x509d,
-			"Inconsistent event entry type %d\n", sp->type);
-		if (IS_P3P_TYPE(ha))
-			set_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags);
-		else
-			set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
-		return;
-	}
-
-	qla24xx_mbx_iocb_entry(vha, rsp->req, (struct mbx_24xx_entry *)pkt);
-}
-
 /**
  * qla24xx_process_response_queue() - Process response queue entries.
  * @vha: SCSI driver HA context
@@ -3539,7 +3526,8 @@ void qla24xx_process_response_queue(struct scsi_qla_host *vha,
 			    (struct abort_entry_24xx *)pkt);
 			break;
 		case MBX_IOCB_TYPE:
-			qla24xx_process_mbx_iocb_response(vha, rsp, pkt);
+			qla24xx_mbx_iocb_entry(vha, rsp->req,
+			    (struct mbx_24xx_entry *)pkt);
 			break;
 		case VP_CTRL_IOCB_TYPE:
 			qla_ctrlvp_completed(vha, rsp->req,
Signature · 1 line
2.16.4
#1 lore raw
Quoted 11 lines · Daniel Wagner

qla2xx_process_get_sp_from_handle() will clear the slot which the current srb is stored. So this function has a side effect. Therefore, we can't use it in qla24xx_process_mbx_iocb_response() to check for consistency and later again in qla24xx_mbx_iocb_entry().

Let's move the consistency check directly into qla24xx_mbx_iocb_entry() and avoid the double call or any open coding of the qla2xx_process_get_sp_from_handle() functionality.

Fixes 31a3271ff11b ("scsi: qla2xxx: Handle incorrect entry_type entries")
Quoted 7 lines

---
Hi,

Brown bag for me please. My test patch had an open coded version of qla2xx_process_get_sp_from_handle() which didn't consume the srb. When I prepared it for sending it out, I 'cleaned' it up by using qla2xx_process_get_sp_from_handle() twice.

Ping.

Reviewed-by on v1 1/1
#2 lore raw
In reply to Daniel Wagner
Quoted 106 lines · Daniel Wagner

qla2xx_process_get_sp_from_handle() will clear the slot which the current srb is stored. So this function has a side effect. Therefore, we can't use it in qla24xx_process_mbx_iocb_response() to check for consistency and later again in qla24xx_mbx_iocb_entry().

Let's move the consistency check directly into qla24xx_mbx_iocb_entry() and avoid the double call or any open coding of the qla2xx_process_get_sp_from_handle() functionality.

Fixes 31a3271ff11b ("scsi: qla2xxx: Handle incorrect entry_type entries")

---
Hi,

Brown bag for me please. My test patch had an open coded version of qla2xx_process_get_sp_from_handle() which didn't consume the srb. When I prepared it for sending it out, I 'cleaned' it up by using qla2xx_process_get_sp_from_handle() twice.

Sorry,
Daniel

drivers/scsi/qla2xxx/qla_isr.c | 42 +++++++++++++++---------------------------

1 file changed, 15 insertions(+), 27 deletions(-)
drivers/scsi/qla2xxx/qla_isr.c +15 -27
index 96811354f78a..2baba87c4e0c 100644
@@ -1839,6 +1839,7 @@ qla24xx_mbx_iocb_entry(scsi_qla_host_t *vha, struct req_que *req,
    struct mbx_24xx_entry *pkt)
 {
 	const char func[] = "MBX-IOCB2";
+	struct qla_hw_data *ha = vha->hw;
 	srb_t *sp;
 	struct srb_iocb *si;
 	u16 sz, i;
@@ -1848,6 +1849,18 @@ qla24xx_mbx_iocb_entry(scsi_qla_host_t *vha, struct req_que *req,
 	if (!sp)
 		return;
 
+	if (sp->type == SRB_SCSI_CMD ||
+	    sp->type == SRB_NVME_CMD ||
+	    sp->type == SRB_TM_CMD) {
+		ql_log(ql_log_warn, vha, 0x509d,
+			"Inconsistent event entry type %d\n", sp->type);
+		if (IS_P3P_TYPE(ha))
+			set_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags);
+		else
+			set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
+		return;
+	}
+
 	si = &sp->u.iocb_cmd;
 	sz = min(ARRAY_SIZE(pkt->mb), ARRAY_SIZE(sp->u.iocb_cmd.u.mbx.in_mb));
 
@@ -3406,32 +3419,6 @@ void qla24xx_nvme_ls4_iocb(struct scsi_qla_host *vha,
 	sp->done(sp, comp_status);
 }
 
-static void qla24xx_process_mbx_iocb_response(struct scsi_qla_host *vha,
-	struct rsp_que *rsp, struct sts_entry_24xx *pkt)
-{
-	struct qla_hw_data *ha = vha->hw;
-	srb_t *sp;
-	static const char func[] = "MBX-IOCB2";
-
-	sp = qla2x00_get_sp_from_handle(vha, func, rsp->req, pkt);
-	if (!sp)
-		return;
-
-	if (sp->type == SRB_SCSI_CMD ||
-	    sp->type == SRB_NVME_CMD ||
-	    sp->type == SRB_TM_CMD) {
-		ql_log(ql_log_warn, vha, 0x509d,
-			"Inconsistent event entry type %d\n", sp->type);
-		if (IS_P3P_TYPE(ha))
-			set_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags);
-		else
-			set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
-		return;
-	}
-
-	qla24xx_mbx_iocb_entry(vha, rsp->req, (struct mbx_24xx_entry *)pkt);
-}
-
 /**
 * qla24xx_process_response_queue() - Process response queue entries.
 * @vha: SCSI driver HA context
@@ -3539,7 +3526,8 @@ void qla24xx_process_response_queue(struct scsi_qla_host *vha,
 			    (struct abort_entry_24xx *)pkt);
 			break;
 		case MBX_IOCB_TYPE:
-			qla24xx_process_mbx_iocb_response(vha, rsp, pkt);
+			qla24xx_mbx_iocb_entry(vha, rsp->req,
+			    (struct mbx_24xx_entry *)pkt);
 			break;
 		case VP_CTRL_IOCB_TYPE:
 			qla_ctrlvp_completed(vha, rsp->req,
Signature · 1 line
2.16.4

Makes sense :)

--
Himanshu Madhani Oracle Linux Engineering

Reviewed-by on v1 1/1
#3 lore raw
In reply to Daniel Wagner
Quoted 11 lines · Daniel Wagner

qla2xx_process_get_sp_from_handle() will clear the slot which the current srb is stored. So this function has a side effect. Therefore, we can't use it in qla24xx_process_mbx_iocb_response() to check for consistency and later again in qla24xx_mbx_iocb_entry().

Let's move the consistency check directly into qla24xx_mbx_iocb_entry() and avoid the double call or any open coding of the qla2xx_process_get_sp_from_handle() functionality.

Fixes 31a3271ff11b ("scsi: qla2xxx: Handle incorrect entry_type entries")

That was a nasty one, good that you caught it soon.

Regards,
-Arun

#4 lore raw
In reply to Daniel Wagner

Daniel,

Quoted 8 lines

qla2xx_process_get_sp_from_handle() will clear the slot which the current srb is stored. So this function has a side effect. Therefore, we can't use it in qla24xx_process_mbx_iocb_response() to check for consistency and later again in qla24xx_mbx_iocb_entry().

Let's move the consistency check directly into qla24xx_mbx_iocb_entry() and avoid the double call or any open coding of the qla2xx_process_get_sp_from_handle() functionality.

Applied to 5.10/scsi-staging, thanks!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering
#5 lore raw
In reply to Daniel Wagner
Quoted 8 lines · Daniel Wagner

qla2xx_process_get_sp_from_handle() will clear the slot which the current srb is stored. So this function has a side effect. Therefore, we can't use it in qla24xx_process_mbx_iocb_response() to check for consistency and later again in qla24xx_mbx_iocb_entry().

Let's move the consistency check directly into qla24xx_mbx_iocb_entry() and avoid the double call or any open coding of the qla2xx_process_get_sp_from_handle() functionality.

Applied to 5.10/scsi-queue, thanks!

[1/1] scsi: qla2xxx: Do not consume srb greedily

      https://git.kernel.org/mkp/scsi/c/657ed8a8a61b
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering