diff mbox series

[08/10] qla2xxx: Fix TMF leak through

Message ID 20230712090535.34894-9-njavali@marvell.com
State Superseded
Headers show
Series qla2xxx driver bug fixes | expand

Commit Message

Nilesh Javali July 12, 2023, 9:05 a.m. UTC
From: Quinn Tran <qutran@marvell.com>

Task management can retry up to 5 times when FW resource
becomes bottle neck. Between the retry, there is a short sleep.
Current code assumes the chip has not reset or session has
not change.

Check for chip reset or session change before sending Task management.

Cc: stable@vger.kernel.org
Fixes: 9803fb5d2759 (“scsi: qla2xxx: Fix task management cmd failure”)
Signed-off-by: Quinn Tran <qutran@marvell.com>
Signed-off-by: Nilesh Javali <njavali@marvell.com>
---
 drivers/scsi/qla2xxx/qla_init.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

Comments

Himanshu Madhani July 13, 2023, 7:34 p.m. UTC | #1
> On Jul 12, 2023, at 2:05 AM, Nilesh Javali <njavali@marvell.com> wrote:
> 
> From: Quinn Tran <qutran@marvell.com>
> 
> Task management can retry up to 5 times when FW resource
> becomes bottle neck. Between the retry, there is a short sleep.
> Current code assumes the chip has not reset or session has
> not change.
> 
> Check for chip reset or session change before sending Task management.
> 
> Cc: stable@vger.kernel.org
> Fixes: 9803fb5d2759 (“scsi: qla2xxx: Fix task management cmd failure”)
> Signed-off-by: Quinn Tran <qutran@marvell.com>
> Signed-off-by: Nilesh Javali <njavali@marvell.com>
> ---
> drivers/scsi/qla2xxx/qla_init.c | 20 ++++++++++++++------
> 1 file changed, 14 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
> index 06c4e5215789..40897d0958c4 100644
> --- a/drivers/scsi/qla2xxx/qla_init.c
> +++ b/drivers/scsi/qla2xxx/qla_init.c
> @@ -2038,10 +2038,14 @@ static void qla_marker_sp_done(srb_t *sp, int res)
> complete(&tmf->u.tmf.comp);
> }
> 
> -#define  START_SP_W_RETRIES(_sp, _rval) \
> +#define  START_SP_W_RETRIES(_sp, _rval, _chip_gen, _login_gen) \
> {\
> int cnt = 5; \
> do { \
> + if (_chip_gen != sp->vha->hw->chip_reset || _login_gen != sp->fcport->login_gen) {\
> + _rval = EINVAL; \
> + break; \
> + } \
> _rval = qla2x00_start_sp(_sp); \
> if (_rval == EAGAIN) \
> msleep(1); \
> @@ -2064,6 +2068,7 @@ qla26xx_marker(struct tmf_arg *arg)
> srb_t *sp;
> int rval = QLA_FUNCTION_FAILED;
> fc_port_t *fcport = arg->fcport;
> + u32 chip_gen, login_gen;
> 
> if (TMF_NOT_READY(arg->fcport)) {
> ql_dbg(ql_dbg_taskm, vha, 0x8039,
> @@ -2073,6 +2078,9 @@ qla26xx_marker(struct tmf_arg *arg)
> return QLA_SUSPENDED;
> }
> 
> + chip_gen = vha->hw->chip_reset;
> + login_gen = fcport->login_gen;
> +
> /* ref: INIT */
> sp = qla2xxx_get_qpair_sp(vha, arg->qpair, fcport, GFP_KERNEL);
> if (!sp)
> @@ -2090,7 +2098,7 @@ qla26xx_marker(struct tmf_arg *arg)
> tm_iocb->u.tmf.loop_id = fcport->loop_id;
> tm_iocb->u.tmf.vp_index = vha->vp_idx;
> 
> - START_SP_W_RETRIES(sp, rval);
> + START_SP_W_RETRIES(sp, rval, chip_gen, login_gen);
> 
> ql_dbg(ql_dbg_taskm, vha, 0x8006,
>    "Async-marker hdl=%x loop-id=%x portid=%06x modifier=%x lun=%lld qp=%d rval %d.\n",
> @@ -2159,6 +2167,9 @@ __qla2x00_async_tm_cmd(struct tmf_arg *arg)
> return QLA_SUSPENDED;
> }
> 
> + chip_gen = vha->hw->chip_reset;
> + login_gen = fcport->login_gen;
> +
> /* ref: INIT */
> sp = qla2xxx_get_qpair_sp(vha, arg->qpair, fcport, GFP_KERNEL);
> if (!sp)
> @@ -2176,7 +2187,7 @@ __qla2x00_async_tm_cmd(struct tmf_arg *arg)
> tm_iocb->u.tmf.flags = arg->flags;
> tm_iocb->u.tmf.lun = arg->lun;
> 
> - START_SP_W_RETRIES(sp, rval);
> + START_SP_W_RETRIES(sp, rval, chip_gen, login_gen);
> 
> ql_dbg(ql_dbg_taskm, vha, 0x802f,
>    "Async-tmf hdl=%x loop-id=%x portid=%06x ctrl=%x lun=%lld qp=%d rval=%x.\n",
> @@ -2195,9 +2206,6 @@ __qla2x00_async_tm_cmd(struct tmf_arg *arg)
> }
> 
> if (!test_bit(UNLOADING, &vha->dpc_flags) && !IS_QLAFX00(vha->hw)) {
> - chip_gen = vha->hw->chip_reset;
> - login_gen = fcport->login_gen;
> -
> jif = jiffies;
> if (qla_tmf_wait(arg)) {
> ql_log(ql_log_info, vha, 0x803e,
> -- 
> 2.23.1
> 

Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
diff mbox series

Patch

diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 06c4e5215789..40897d0958c4 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -2038,10 +2038,14 @@  static void qla_marker_sp_done(srb_t *sp, int res)
 	complete(&tmf->u.tmf.comp);
 }
 
-#define  START_SP_W_RETRIES(_sp, _rval) \
+#define  START_SP_W_RETRIES(_sp, _rval, _chip_gen, _login_gen) \
 {\
 	int cnt = 5; \
 	do { \
+		if (_chip_gen != sp->vha->hw->chip_reset || _login_gen != sp->fcport->login_gen) {\
+			_rval = EINVAL; \
+			break; \
+		} \
 		_rval = qla2x00_start_sp(_sp); \
 		if (_rval == EAGAIN) \
 			msleep(1); \
@@ -2064,6 +2068,7 @@  qla26xx_marker(struct tmf_arg *arg)
 	srb_t *sp;
 	int rval = QLA_FUNCTION_FAILED;
 	fc_port_t *fcport = arg->fcport;
+	u32 chip_gen, login_gen;
 
 	if (TMF_NOT_READY(arg->fcport)) {
 		ql_dbg(ql_dbg_taskm, vha, 0x8039,
@@ -2073,6 +2078,9 @@  qla26xx_marker(struct tmf_arg *arg)
 		return QLA_SUSPENDED;
 	}
 
+	chip_gen = vha->hw->chip_reset;
+	login_gen = fcport->login_gen;
+
 	/* ref: INIT */
 	sp = qla2xxx_get_qpair_sp(vha, arg->qpair, fcport, GFP_KERNEL);
 	if (!sp)
@@ -2090,7 +2098,7 @@  qla26xx_marker(struct tmf_arg *arg)
 	tm_iocb->u.tmf.loop_id = fcport->loop_id;
 	tm_iocb->u.tmf.vp_index = vha->vp_idx;
 
-	START_SP_W_RETRIES(sp, rval);
+	START_SP_W_RETRIES(sp, rval, chip_gen, login_gen);
 
 	ql_dbg(ql_dbg_taskm, vha, 0x8006,
 	    "Async-marker hdl=%x loop-id=%x portid=%06x modifier=%x lun=%lld qp=%d rval %d.\n",
@@ -2159,6 +2167,9 @@  __qla2x00_async_tm_cmd(struct tmf_arg *arg)
 		return QLA_SUSPENDED;
 	}
 
+	chip_gen = vha->hw->chip_reset;
+	login_gen = fcport->login_gen;
+
 	/* ref: INIT */
 	sp = qla2xxx_get_qpair_sp(vha, arg->qpair, fcport, GFP_KERNEL);
 	if (!sp)
@@ -2176,7 +2187,7 @@  __qla2x00_async_tm_cmd(struct tmf_arg *arg)
 	tm_iocb->u.tmf.flags = arg->flags;
 	tm_iocb->u.tmf.lun = arg->lun;
 
-	START_SP_W_RETRIES(sp, rval);
+	START_SP_W_RETRIES(sp, rval, chip_gen, login_gen);
 
 	ql_dbg(ql_dbg_taskm, vha, 0x802f,
 	    "Async-tmf hdl=%x loop-id=%x portid=%06x ctrl=%x lun=%lld qp=%d rval=%x.\n",
@@ -2195,9 +2206,6 @@  __qla2x00_async_tm_cmd(struct tmf_arg *arg)
 	}
 
 	if (!test_bit(UNLOADING, &vha->dpc_flags) && !IS_QLAFX00(vha->hw)) {
-		chip_gen = vha->hw->chip_reset;
-		login_gen = fcport->login_gen;
-
 		jif = jiffies;
 		if (qla_tmf_wait(arg)) {
 			ql_log(ql_log_info, vha, 0x803e,