Skip to contentSkip to conversation

qla2xxx driver update

PATCH Superseded Nilesh Javali 2 participants 11 messages Apr 27, 2023

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Nilesh Javali

author maintainer
#0 lore raw

cover qla2xxx driver update

Martin,

Please apply the qla2xxx driver enhancement and bug fixes to the scsi tree at your earliest convenience.

Thanks,
Nilesh

Nilesh Javali (1):
qla2xxx: Update version to 10.02.08.300-k

Quinn Tran (6):
qla2xxx: Multi-que support for TMF
qla2xxx: Fix task management cmd failure
qla2xxx: Fix task management cmd fail due to unavailable resource
qla2xxx: Fix hang in task management
qla2xxx: Fix mem access after free
qla2xxx: Wait for io return on terminate rport

 drivers/scsi/qla2xxx/qla_attr.c    |  13 ++
 drivers/scsi/qla2xxx/qla_def.h     |  21 +++
 drivers/scsi/qla2xxx/qla_gbl.h     |   2 +-
 drivers/scsi/qla2xxx/qla_init.c    | 254 ++++++++++++++++++++++++++---
 drivers/scsi/qla2xxx/qla_iocb.c    |  33 +++-
 drivers/scsi/qla2xxx/qla_isr.c     |  64 ++++++--
 drivers/scsi/qla2xxx/qla_os.c      | 130 ++++++++-------
 drivers/scsi/qla2xxx/qla_version.h |   4 +-
 8 files changed, 417 insertions(+), 104 deletions(-)

base-commit: c8e22b7a1694bb8d025ea636816472739d859145

Signature · 1 line
2.23.1
author maintainer
#1 lore raw

PATCH 1/7 qla2xxx: Multi-que support for TMF

From: Quinn Tran <[email protected]>

Add queue flush for task management command, before placing it on the wire.
Do IO flush for all Request Q's.

---
 drivers/scsi/qla2xxx/qla_def.h  |  8 ++++
 drivers/scsi/qla2xxx/qla_gbl.h  |  2 +-
 drivers/scsi/qla2xxx/qla_init.c | 67 ++++++++++++++++++++++++++-------
 drivers/scsi/qla2xxx/qla_iocb.c |  5 ++-
 4 files changed, 65 insertions(+), 17 deletions(-)
drivers/scsi/qla2xxx/qla_def.h +8 -0
index ec0e987b71fa..d59e94ae0db4 100644
@@ -466,6 +466,14 @@ static inline be_id_t port_id_to_be_id(port_id_t port_id)
 	return res;
 }
 
+struct tmf_arg {
+	struct qla_qpair *qpair;
+	struct fc_port *fcport;
+	struct scsi_qla_host *vha;
+	u64 lun;
+	u32 flags;
+};
+
 struct els_logo_payload {
 	uint8_t opcode;
 	uint8_t rsvd[3];
drivers/scsi/qla2xxx/qla_gbl.h +1 -1
index 9aba07c7bde4..ef11ce46381d 100644
@@ -69,7 +69,7 @@ extern int qla2x00_async_logout(struct scsi_qla_host *, fc_port_t *);
 extern int qla2x00_async_prlo(struct scsi_qla_host *, fc_port_t *);
 extern int qla2x00_async_adisc(struct scsi_qla_host *, fc_port_t *,
     uint16_t *);
-extern int qla2x00_async_tm_cmd(fc_port_t *, uint32_t, uint32_t, uint32_t);
+extern int qla2x00_async_tm_cmd(fc_port_t *, uint32_t, uint64_t, uint32_t);
 struct qla_work_evt *qla2x00_alloc_work(struct scsi_qla_host *,
     enum qla_work_type);
 extern int qla24xx_async_gnl(struct scsi_qla_host *, fc_port_t *);
drivers/scsi/qla2xxx/qla_init.c +53 -14

102 lines not on this page · raw message

drivers/scsi/qla2xxx/qla_iocb.c +3 -2
index b9b3e6f80ea9..b02039601cc0 100644
@@ -2541,7 +2541,7 @@ qla24xx_tm_iocb(srb_t *sp, struct tsk_mgmt_entry *tsk)
 	scsi_qla_host_t *vha = fcport->vha;
 	struct qla_hw_data *ha = vha->hw;
 	struct srb_iocb *iocb = &sp->u.iocb_cmd;
-	struct req_que *req = vha->req;
+	struct req_que *req = sp->qpair->req;
 
 	flags = iocb->u.tmf.flags;
 	lun = iocb->u.tmf.lun;
@@ -2557,7 +2557,8 @@ qla24xx_tm_iocb(srb_t *sp, struct tsk_mgmt_entry *tsk)
 	tsk->port_id[2] = fcport->d_id.b.domain;
 	tsk->vp_index = fcport->vha->vp_idx;
 
-	if (flags == TCF_LUN_RESET) {
+	if (flags & (TCF_LUN_RESET | TCF_ABORT_TASK_SET|
+	    TCF_CLEAR_TASK_SET|TCF_CLEAR_ACA)) {
 		int_to_scsilun(lun, &tsk->lun);
 		host_to_fcp_swap((uint8_t *)&tsk->lun,
 			sizeof(tsk->lun));
Signature · 1 line
2.23.1
#2 lore raw

Re: [PATCH 1/7] qla2xxx: Multi-que support for TMF

kernel test robot noticed the following build warnings:

Hi Nilesh,

kernel test robot noticed the following build warnings:

[auto build test WARNING on c8e22b7a1694bb8d025ea636816472739d859145]

url:    https://github.com/intel-lab-lkp/linux/commits/Nilesh-Javali/qla2xxx-Multi-que-support-for-TMF/20230427-160555
base:   c8e22b7a1694bb8d025ea636816472739d859145
patch link:    https://lore.kernel.org/r/20230427080351.9889-2-njavali%40marvell.com
patch subject: [PATCH 1/7] qla2xxx: Multi-que support for TMF
config: ia64-allyesconfig (https://download.01.org/0day-ci/archive/20230427/[email protected]/config)
compiler: ia64-linux-gcc (GCC) 12.1.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/b9e8bdc4cd77acae5886c7c447d34d898bd1d821
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Nilesh-Javali/qla2xxx-Multi-que-support-for-TMF/20230427-160555
git checkout b9e8bdc4cd77acae5886c7c447d34d898bd1d821
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=ia64 olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=ia64 SHELL=/bin/bash drivers/scsi/qla2xxx/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

>> drivers/scsi/qla2xxx/qla_init.c:2024:1: warning: no previous prototype for '__qla2x00_async_tm_cmd' [-Wmissing-prototypes]
    2024 | __qla2x00_async_tm_cmd(struct tmf_arg *arg)
         | ^~~~~~~~~~~~~~~~~~~~~~

vim +/__qla2x00_async_tm_cmd +2024 drivers/scsi/qla2xxx/qla_init.c

2022
2023 int

> 2024	__qla2x00_async_tm_cmd(struct tmf_arg *arg)
  2025	{
  2026		struct scsi_qla_host *vha = arg->vha;
  2027		struct srb_iocb *tm_iocb;
  2028		srb_t *sp;
  2029		unsigned long flags;
  2030		int rval = QLA_FUNCTION_FAILED;
  2031	
  2032		fc_port_t *fcport = arg->fcport;
  2033	
  2034		/* ref: INIT */
  2035		sp = qla2xxx_get_qpair_sp(vha, arg->qpair, fcport, GFP_KERNEL);
  2036		if (!sp)
  2037			goto done;
  2038	
  2039		qla_vha_mark_busy(vha);
  2040		sp->type = SRB_TM_CMD;
  2041		sp->name = "tmf";
  2042		qla2x00_init_async_sp(sp, qla2x00_get_async_timeout(vha),
  2043				      qla2x00_tmf_sp_done);
  2044		sp->u.iocb_cmd.timeout = qla2x00_tmf_iocb_timeout;
  2045	
  2046		tm_iocb = &sp->u.iocb_cmd;
  2047		init_completion(&tm_iocb->u.tmf.comp);
  2048		tm_iocb->u.tmf.flags = arg->flags;
  2049		tm_iocb->u.tmf.lun = arg->lun;
  2050	
  2051		rval = qla2x00_start_sp(sp);
  2052		ql_dbg(ql_dbg_taskm, vha, 0x802f,
  2053		    "Async-tmf hdl=%x loop-id=%x portid=%02x%02x%02x ctrl=%x.\n",
  2054		    sp->handle, fcport->loop_id, fcport->d_id.b.domain,
  2055		    fcport->d_id.b.area, fcport->d_id.b.al_pa, arg->flags);

2056
2057 if (rval != QLA_SUCCESS)
2058 goto done_free_sp;
2059 wait_for_completion(&tm_iocb->u.tmf.comp);
2060
2061 rval = tm_iocb->u.tmf.data;
2062
2063 if (rval != QLA_SUCCESS) {
2064 ql_log(ql_log_warn, vha, 0x8030,
2065 "TM IOCB failed (%x).\n", rval);
2066 }
2067
2068 if (!test_bit(UNLOADING, &vha->dpc_flags) && !IS_QLAFX00(vha->hw)) {
2069 flags = tm_iocb->u.tmf.flags;
2070 if (flags & (TCF_LUN_RESET|TCF_ABORT_TASK_SET|
2071 TCF_CLEAR_TASK_SET|TCF_CLEAR_ACA))
2072 flags = MK_SYNC_ID_LUN;
2073 else
2074 flags = MK_SYNC_ID;
2075
2076 qla2x00_marker(vha, sp->qpair,
2077 sp->fcport->loop_id, arg->lun, flags);
2078 }
2079
2080 done_free_sp:
2081 /* ref: INIT */
2082 kref_put(&sp->cmd_kref, qla2x00_sp_release);
2083 done:
2084 return rval;
2085 }
2086

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
author maintainer
#3 lore raw

PATCH 2/7 qla2xxx: Fix task management cmd failure

In reply to Nilesh Javali

From: Quinn Tran <[email protected]>

Task management cmd failed with status 30h which means FW is not able to finish processing one task management before another task management for the same lun. Hence add wait for completion of marker to space it out.

---
 drivers/scsi/qla2xxx/qla_def.h  |   6 ++
 drivers/scsi/qla2xxx/qla_init.c | 102 +++++++++++++++++++++++++++-----
 drivers/scsi/qla2xxx/qla_iocb.c |  28 +++++++--
 drivers/scsi/qla2xxx/qla_isr.c  |  26 +++++++-
 4 files changed, 139 insertions(+), 23 deletions(-)
drivers/scsi/qla2xxx/qla_def.h +6 -0
index d59e94ae0db4..0437e0150a50 100644
@@ -472,6 +472,7 @@ struct tmf_arg {
 	struct scsi_qla_host *vha;
 	u64 lun;
 	u32 flags;
+	uint8_t modifier;
 };
 
 struct els_logo_payload {
@@ -553,6 +554,10 @@ struct srb_iocb {
 			uint32_t data;
 			struct completion comp;
 			__le16 comp_status;
+
+			uint8_t modifier;
+			uint8_t vp_index;
+			uint16_t loop_id;
 		} tmf;
 		struct {
 #define SRB_FXDISC_REQ_DMA_VALID	BIT_0
@@ -656,6 +661,7 @@ struct srb_iocb {
 #define SRB_SA_UPDATE	25
 #define SRB_ELS_CMD_HST_NOLOGIN 26
 #define SRB_SA_REPLACE	27
+#define SRB_MARKER	28
 
 struct qla_els_pt_arg {
 	u8 els_opcode;
drivers/scsi/qla2xxx/qla_init.c +86 -16

133 lines not on this page · raw message

drivers/scsi/qla2xxx/qla_iocb.c +24 -4
index b02039601cc0..6acfdcc48b16 100644
@@ -522,21 +522,25 @@ __qla2x00_marker(struct scsi_qla_host *vha, struct qla_qpair *qpair,
 		return (QLA_FUNCTION_FAILED);
 	}
 
+	mrk24 = (struct mrk_entry_24xx *)mrk;
+
 	mrk->entry_type = MARKER_TYPE;
 	mrk->modifier = type;
 	if (type != MK_SYNC_ALL) {
 		if (IS_FWI2_CAPABLE(ha)) {
-			mrk24 = (struct mrk_entry_24xx *) mrk;
 			mrk24->nport_handle = cpu_to_le16(loop_id);
 			int_to_scsilun(lun, (struct scsi_lun *)&mrk24->lun);
 			host_to_fcp_swap(mrk24->lun, sizeof(mrk24->lun));
 			mrk24->vp_index = vha->vp_idx;
-			mrk24->handle = make_handle(req->id, mrk24->handle);
 		} else {
 			SET_TARGET_ID(ha, mrk->target, loop_id);
 			mrk->lun = cpu_to_le16((uint16_t)lun);
 		}
 	}
+
+	if (IS_FWI2_CAPABLE(ha))
+		mrk24->handle = QLA_SKIP_HANDLE;
+
 	wmb();
 
 	qla2x00_start_iocbs(vha, req);
@@ -3853,9 +3857,9 @@ static int qla_get_iocbs_resource(struct srb *sp)
 	case SRB_NACK_LOGO:
 	case SRB_LOGOUT_CMD:
 	case SRB_CTRL_VP:
-		push_it_through = true;
-		fallthrough;
+	case SRB_MARKER:
 	default:
+		push_it_through = true;
 		get_exch = false;
 	}
 
@@ -3871,6 +3875,19 @@ static int qla_get_iocbs_resource(struct srb *sp)
 	return qla_get_fw_resources(sp->qpair, &sp->iores);
 }
 
+static void
+qla_marker_iocb(srb_t *sp, struct mrk_entry_24xx *mrk)
+{
+	mrk->entry_type = MARKER_TYPE;
+	mrk->modifier = sp->u.iocb_cmd.u.tmf.modifier;
+	if (sp->u.iocb_cmd.u.tmf.modifier != MK_SYNC_ALL) {
+		mrk->nport_handle = cpu_to_le16(sp->u.iocb_cmd.u.tmf.loop_id);
+		int_to_scsilun(sp->u.iocb_cmd.u.tmf.lun, (struct scsi_lun *)&mrk->lun);
+		host_to_fcp_swap(mrk->lun, sizeof(mrk->lun));
+		mrk->vp_index = sp->u.iocb_cmd.u.tmf.vp_index;
+	}
+}
+
 int
 qla2x00_start_sp(srb_t *sp)
 {
@@ -3974,6 +3991,9 @@ qla2x00_start_sp(srb_t *sp)
 	case SRB_SA_REPLACE:
 		qla24xx_sa_replace_iocb(sp, pkt);
 		break;
+	case SRB_MARKER:
+		qla_marker_iocb(sp, pkt);
+		break;
 	default:
 		break;
 	}
drivers/scsi/qla2xxx/qla_isr.c +23 -3
index 71feda2cdb63..f3107508cf12 100644
@@ -3750,6 +3750,28 @@ static int qla_chk_cont_iocb_avail(struct scsi_qla_host *vha,
 	return rc;
 }
 
+static void qla_marker_iocb_entry(scsi_qla_host_t *vha, struct req_que *req,
+	struct mrk_entry_24xx *pkt)
+{
+	const char func[] = "MRK-IOCB";
+	srb_t *sp;
+	int res = QLA_SUCCESS;
+
+	if (!IS_FWI2_CAPABLE(vha->hw))
+		return;
+
+	sp = qla2x00_get_sp_from_handle(vha, func, req, pkt);
+	if (!sp)
+		return;
+
+	if (pkt->entry_status) {
+		ql_dbg(ql_dbg_taskm, vha, 0x8025, "marker failure.\n");
+		res = QLA_COMMAND_ERROR;
+	}
+	sp->u.iocb_cmd.u.tmf.data = res;
+	sp->done(sp, res);
+}
+
 /**
  * qla24xx_process_response_queue() - Process response queue entries.
  * @vha: SCSI driver HA context
@@ -3863,9 +3885,7 @@ void qla24xx_process_response_queue(struct scsi_qla_host *vha,
 					(struct nack_to_isp *)pkt);
 			break;
 		case MARKER_TYPE:
-			/* Do nothing in this case, this check is to prevent it
-			 * from falling into default case
-			 */
+			qla_marker_iocb_entry(vha, rsp->req, (struct mrk_entry_24xx *)pkt);
 			break;
 		case ABORT_IOCB_TYPE:
 			qla24xx_abort_iocb_entry(vha, rsp->req,
Signature · 1 line
2.23.1
#4 lore raw

Re: [PATCH 2/7] qla2xxx: Fix task management cmd failure

kernel test robot noticed the following build warnings:

Hi Nilesh,

kernel test robot noticed the following build warnings:

[auto build test WARNING on c8e22b7a1694bb8d025ea636816472739d859145]

url:    https://github.com/intel-lab-lkp/linux/commits/Nilesh-Javali/qla2xxx-Multi-que-support-for-TMF/20230427-160555
base:   c8e22b7a1694bb8d025ea636816472739d859145
patch link:    https://lore.kernel.org/r/20230427080351.9889-3-njavali%40marvell.com
patch subject: [PATCH 2/7] qla2xxx: Fix task management cmd failure
config: ia64-allyesconfig (https://download.01.org/0day-ci/archive/20230427/[email protected]/config)
compiler: ia64-linux-gcc (GCC) 12.1.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/c6708965eb88a81ea9d42ed583d9abe09e3a4251
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Nilesh-Javali/qla2xxx-Multi-que-support-for-TMF/20230427-160555
git checkout c6708965eb88a81ea9d42ed583d9abe09e3a4251
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=ia64 olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=ia64 SHELL=/bin/bash drivers/scsi/qla2xxx/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

>> drivers/scsi/qla2xxx/qla_init.c:2043:1: warning: no previous prototype for 'qla26xx_marker' [-Wmissing-prototypes]
    2043 | qla26xx_marker(struct tmf_arg *arg)
         | ^~~~~~~~~~~~~~
   drivers/scsi/qla2xxx/qla_init.c:2098:1: warning: no previous prototype for '__qla2x00_async_tm_cmd' [-Wmissing-prototypes]
    2098 | __qla2x00_async_tm_cmd(struct tmf_arg *arg)
         | ^~~~~~~~~~~~~~~~~~~~~~

vim +/qla26xx_marker +2043 drivers/scsi/qla2xxx/qla_init.c

2041
2042 int

> 2043	qla26xx_marker(struct tmf_arg *arg)
  2044	{
  2045		struct scsi_qla_host *vha = arg->vha;
  2046		struct srb_iocb *tm_iocb;
  2047		srb_t *sp;
  2048		int rval = QLA_FUNCTION_FAILED;
  2049		fc_port_t *fcport = arg->fcport;
  2050	
  2051		/* ref: INIT */
  2052		sp = qla2xxx_get_qpair_sp(vha, arg->qpair, fcport, GFP_KERNEL);
  2053		if (!sp)
  2054			goto done;
  2055	
  2056		sp->type = SRB_MARKER;
  2057		sp->name = "marker";
  2058		qla2x00_init_async_sp(sp, qla2x00_get_async_timeout(vha), qla_marker_sp_done);
  2059		sp->u.iocb_cmd.timeout = qla2x00_tmf_iocb_timeout;
  2060	
  2061		tm_iocb = &sp->u.iocb_cmd;
  2062		init_completion(&tm_iocb->u.tmf.comp);
  2063		tm_iocb->u.tmf.modifier = arg->modifier;
  2064		tm_iocb->u.tmf.lun = arg->lun;
  2065		tm_iocb->u.tmf.loop_id = fcport->loop_id;
  2066		tm_iocb->u.tmf.vp_index = vha->vp_idx;
  2067	
  2068		START_SP_W_RETRIES(sp, rval);
  2069	
  2070		ql_dbg(ql_dbg_taskm, vha, 0x8006,
  2071		    "Async-marker hdl=%x loop-id=%x portid=%06x modifier=%x lun=%lld qp=%d rval %d.\n",
  2072		    sp->handle, fcport->loop_id, fcport->d_id.b24,
  2073		    arg->modifier, arg->lun, sp->qpair->id, rval);

2074
2075 if (rval != QLA_SUCCESS) {
2076 ql_log(ql_log_warn, vha, 0x8031,
2077 "Marker IOCB failed (%x).\n", rval);
2078 goto done_free_sp;
2079 }
2080
2081 wait_for_completion(&tm_iocb->u.tmf.comp);
2082
2083 done_free_sp:
2084 /* ref: INIT */
2085 kref_put(&sp->cmd_kref, qla2x00_sp_release);
2086 done:
2087 return rval;
2088 }
2089

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
author maintainer
#5 lore raw

PATCH 3/7 qla2xxx: Fix task management cmd fail due to unavailable resource

In reply to Nilesh Javali

From: Quinn Tran <[email protected]>

Task management command failed with status 2Ch which is a result of too many task management commands sent to the same target. Hence limit task management commands to 8 per target.

---
 drivers/scsi/qla2xxx/qla_def.h  |  3 ++
 drivers/scsi/qla2xxx/qla_init.c | 63 ++++++++++++++++++++++++++++++---
 2 files changed, 61 insertions(+), 5 deletions(-)
drivers/scsi/qla2xxx/qla_def.h +3 -0
index 0437e0150a50..0971150953a9 100644
@@ -2543,6 +2543,7 @@ enum rscn_addr_format {
 typedef struct fc_port {
 	struct list_head list;
 	struct scsi_qla_host *vha;
+	struct list_head tmf_pending;
 
 	unsigned int conf_compl_supported:1;
 	unsigned int deleted:2;
@@ -2563,6 +2564,8 @@ typedef struct fc_port {
 	unsigned int do_prli_nvme:1;
 
 	uint8_t nvme_flag;
+	uint8_t active_tmf;
+#define MAX_ACTIVE_TMF 8
 
 	uint8_t node_name[WWN_SIZE];
 	uint8_t port_name[WWN_SIZE];
drivers/scsi/qla2xxx/qla_init.c +58 -5

94 lines not on this page · raw message

Signature · 1 line
2.23.1
#6 lore raw

Re: [PATCH 3/7] qla2xxx: Fix task management cmd fail due to unavailable resource

kernel test robot noticed the following build warnings:

Hi Nilesh,

kernel test robot noticed the following build warnings:

[auto build test WARNING on c8e22b7a1694bb8d025ea636816472739d859145]

url:    https://github.com/intel-lab-lkp/linux/commits/Nilesh-Javali/qla2xxx-Multi-que-support-for-TMF/20230427-160555
base:   c8e22b7a1694bb8d025ea636816472739d859145
patch link:    https://lore.kernel.org/r/20230427080351.9889-4-njavali%40marvell.com
patch subject: [PATCH 3/7] qla2xxx: Fix task management cmd fail due to unavailable resource
config: ia64-allyesconfig (https://download.01.org/0day-ci/archive/20230427/[email protected]/config)
compiler: ia64-linux-gcc (GCC) 12.1.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/ea97bb99e7ceb449ede36ec249341061982a7f11
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Nilesh-Javali/qla2xxx-Multi-que-support-for-TMF/20230427-160555 git checkout ea97bb99e7ceb449ede36ec249341061982a7f11
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=ia64 olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=ia64 SHELL=/bin/bash drivers/scsi/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

drivers/scsi/qla2xxx/qla_init.c:2043:1: warning: no previous prototype for 'qla26xx_marker' [-Wmissing-prototypes]

    2043 | qla26xx_marker(struct tmf_arg *arg)
         | ^~~~~~~~~~~~~~
   drivers/scsi/qla2xxx/qla_init.c:2098:1: warning: no previous prototype for '__qla2x00_async_tm_cmd' [-Wmissing-prototypes]
    2098 | __qla2x00_async_tm_cmd(struct tmf_arg *arg)
         | ^~~~~~~~~~~~~~~~~~~~~~
>> drivers/scsi/qla2xxx/qla_init.c:2152:6: warning: no previous prototype for 'qla_put_tmf' [-Wmissing-prototypes]
    2152 | void qla_put_tmf(fc_port_t *fcport)
         |      ^~~~~~~~~~~

vim +/qla_put_tmf +2152 drivers/scsi/qla2xxx/qla_init.c

2041
2042 int

> 2043	qla26xx_marker(struct tmf_arg *arg)
  2044	{
  2045		struct scsi_qla_host *vha = arg->vha;
  2046		struct srb_iocb *tm_iocb;
  2047		srb_t *sp;
  2048		int rval = QLA_FUNCTION_FAILED;
  2049		fc_port_t *fcport = arg->fcport;
  2050	
  2051		/* ref: INIT */
  2052		sp = qla2xxx_get_qpair_sp(vha, arg->qpair, fcport, GFP_KERNEL);
  2053		if (!sp)
  2054			goto done;
  2055	
  2056		sp->type = SRB_MARKER;
  2057		sp->name = "marker";
  2058		qla2x00_init_async_sp(sp, qla2x00_get_async_timeout(vha), qla_marker_sp_done);
  2059		sp->u.iocb_cmd.timeout = qla2x00_tmf_iocb_timeout;
  2060	
  2061		tm_iocb = &sp->u.iocb_cmd;
  2062		init_completion(&tm_iocb->u.tmf.comp);
  2063		tm_iocb->u.tmf.modifier = arg->modifier;
  2064		tm_iocb->u.tmf.lun = arg->lun;
  2065		tm_iocb->u.tmf.loop_id = fcport->loop_id;
  2066		tm_iocb->u.tmf.vp_index = vha->vp_idx;
  2067	
  2068		START_SP_W_RETRIES(sp, rval);
  2069	
  2070		ql_dbg(ql_dbg_taskm, vha, 0x8006,
  2071		    "Async-marker hdl=%x loop-id=%x portid=%06x modifier=%x lun=%lld qp=%d rval %d.\n",
  2072		    sp->handle, fcport->loop_id, fcport->d_id.b24,
  2073		    arg->modifier, arg->lun, sp->qpair->id, rval);
  2074	
  2075		if (rval != QLA_SUCCESS) {
  2076			ql_log(ql_log_warn, vha, 0x8031,
  2077			    "Marker IOCB failed (%x).\n", rval);
  2078			goto done_free_sp;
  2079		}
  2080	
  2081		wait_for_completion(&tm_iocb->u.tmf.comp);
  2082	
  2083	done_free_sp:
  2084		/* ref: INIT */
  2085		kref_put(&sp->cmd_kref, qla2x00_sp_release);
  2086	done:
  2087		return rval;
  2088	}
  2089	
  2090	static void qla2x00_tmf_sp_done(srb_t *sp, int res)
  2091	{
  2092		struct srb_iocb *tmf = &sp->u.iocb_cmd;
  2093	
  2094		complete(&tmf->u.tmf.comp);
  2095	}
  2096	
  2097	int
  2098	__qla2x00_async_tm_cmd(struct tmf_arg *arg)
  2099	{
  2100		struct scsi_qla_host *vha = arg->vha;
  2101		struct srb_iocb *tm_iocb;
  2102		srb_t *sp;
  2103		int rval = QLA_FUNCTION_FAILED;
  2104	
  2105		fc_port_t *fcport = arg->fcport;
  2106	
  2107		/* ref: INIT */
  2108		sp = qla2xxx_get_qpair_sp(vha, arg->qpair, fcport, GFP_KERNEL);
  2109		if (!sp)
  2110			goto done;
  2111	
  2112		qla_vha_mark_busy(vha);
  2113		sp->type = SRB_TM_CMD;
  2114		sp->name = "tmf";
  2115		qla2x00_init_async_sp(sp, qla2x00_get_async_timeout(vha),
  2116				      qla2x00_tmf_sp_done);
  2117		sp->u.iocb_cmd.timeout = qla2x00_tmf_iocb_timeout;
  2118	
  2119		tm_iocb = &sp->u.iocb_cmd;
  2120		init_completion(&tm_iocb->u.tmf.comp);
  2121		tm_iocb->u.tmf.flags = arg->flags;
  2122		tm_iocb->u.tmf.lun = arg->lun;
  2123	
  2124		START_SP_W_RETRIES(sp, rval);
  2125	
  2126		ql_dbg(ql_dbg_taskm, vha, 0x802f,
  2127		    "Async-tmf hdl=%x loop-id=%x portid=%06x ctrl=%x lun=%lld qp=%d rval=%x.\n",
  2128		    sp->handle, fcport->loop_id, fcport->d_id.b24,
  2129		    arg->flags, arg->lun, sp->qpair->id, rval);
  2130	
  2131		if (rval != QLA_SUCCESS)
  2132			goto done_free_sp;
  2133		wait_for_completion(&tm_iocb->u.tmf.comp);
  2134	
  2135		rval = tm_iocb->u.tmf.data;
  2136	
  2137		if (rval != QLA_SUCCESS) {
  2138			ql_log(ql_log_warn, vha, 0x8030,
  2139			    "TM IOCB failed (%x).\n", rval);
  2140		}
  2141	
  2142		if (!test_bit(UNLOADING, &vha->dpc_flags) && !IS_QLAFX00(vha->hw))
  2143			rval = qla26xx_marker(arg);
  2144	
  2145	done_free_sp:
  2146		/* ref: INIT */
  2147		kref_put(&sp->cmd_kref, qla2x00_sp_release);
  2148	done:
  2149		return rval;
  2150	}
  2151	
> 2152	void qla_put_tmf(fc_port_t *fcport)

2153 {
2154 struct scsi_qla_host *vha = fcport->vha;
2155 struct qla_hw_data *ha = vha->hw;
2156 unsigned long flags;
2157
2158 spin_lock_irqsave(&ha->tgt.sess_lock, flags);
2159 fcport->active_tmf--;
2160 spin_unlock_irqrestore(&ha->tgt.sess_lock, flags);
2161 }
2162

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
author maintainer
#7 lore raw

PATCH 4/7 qla2xxx: Fix hang in task management

In reply to Nilesh Javali

From: Quinn Tran <[email protected]>

Task management command hangs where a side band chip reset failed to nudge the TMF from it's current send path.

Add additional error check to block TMF from entering during chip reset and along the TMF path to cause it to bail out, skip over abort of marker.

---
 drivers/scsi/qla2xxx/qla_def.h  |  4 +++
 drivers/scsi/qla2xxx/qla_init.c | 60 +++++++++++++++++++++++++++++++--
 2 files changed, 61 insertions(+), 3 deletions(-)
drivers/scsi/qla2xxx/qla_def.h +4 -0
index 0971150953a9..3e0be0136cad 100644
@@ -5516,4 +5516,8 @@ struct ql_vnd_tgt_stats_resp {
 	_fp->disc_state, _fp->scan_state, _fp->loop_id, _fp->deleted, \
 	_fp->flags
 
+#define TMF_NOT_READY(_fcport) \
+	(!_fcport || IS_SESSION_DELETED(_fcport) || atomic_read(&_fcport->state) != FCS_ONLINE || \
+	!_fcport->vha->hw->flags.fw_started)
+
 #endif
drivers/scsi/qla2xxx/qla_init.c +57 -3

134 lines not on this page · raw message

Signature · 1 line
2.23.1
author maintainer
#8 lore raw

PATCH 5/7 qla2xxx: Fix mem access after free

In reply to Nilesh Javali

From: Quinn Tran <[email protected]>

System crash, where driver is accessing scsi layer's memory (scsi_cmnd->device->host) to search for a well known internal pointer (vha). The scsi_cmnd was released back to upper layer which could be freed, but the driver is still accessing it.

7 [ffffa8e8d2c3f8d0] page_fault at ffffffff86c010fe
[exception RIP: __qla2x00_eh_wait_for_pending_commands+240]

  RIP: ffffffffc0642350  RSP: ffffa8e8d2c3f988  RFLAGS: 00010286
  RAX: 0000000000000165  RBX: 0000000000000002  RCX: 00000000000036d8
  RDX: 0000000000000000  RSI: ffff9c5c56535188  RDI: 0000000000000286
  RBP: ffff9c5bf7aa4a58   R8: ffff9c589aecdb70   R9: 00000000000003d1
  R10: 0000000000000001  R11: 0000000000380000 R12: ffff9c5c5392bc78
  R13: ffff9c57044ff5c0 R14: ffff9c56b5a3aa00  R15: 00000000000006db
  ORIG_RAX: ffffffffffffffff  CS: 0010  SS: 0018

8 [ffffa8e8d2c3f9c8] qla2x00_eh_wait_for_pending_commands at ffffffffc0646dd5 [qla2xxx] 9 [ffffa8e8d2c3fa00] __qla2x00_async_tm_cmd at ffffffffc0658094 [qla2xxx]

Remove access of freed memory. Currently the driver was checking to see if scsi_done was called by seeing if the sp->type has changed. Instead, check to see if the command has left the oustanding_cmds[] array as sign of scsi_done was called.

---
 drivers/scsi/qla2xxx/qla_isr.c |  38 ++++++++--
 drivers/scsi/qla2xxx/qla_os.c  | 130 ++++++++++++++++-----------------
 2 files changed, 95 insertions(+), 73 deletions(-)
drivers/scsi/qla2xxx/qla_isr.c +31 -7
index f3107508cf12..a07c010b0843 100644
@@ -1862,9 +1862,9 @@ qla2x00_process_completed_request(struct scsi_qla_host *vha,
 	}
 }
 
-srb_t *
-qla2x00_get_sp_from_handle(scsi_qla_host_t *vha, const char *func,
-    struct req_que *req, void *iocb)
+static srb_t *
+qla_get_sp_from_handle(scsi_qla_host_t *vha, const char *func,
+		       struct req_que *req, void *iocb, u16 *ret_index)
 {
 	struct qla_hw_data *ha = vha->hw;
 	sts_entry_t *pkt = iocb;
@@ -1899,12 +1899,25 @@ qla2x00_get_sp_from_handle(scsi_qla_host_t *vha, const char *func,
 		return NULL;
 	}
 
-	req->outstanding_cmds[index] = NULL;
-
+	*ret_index = index;
 	qla_put_fw_resources(sp->qpair, &sp->iores);
 	return sp;
 }
 
+srb_t *
+qla2x00_get_sp_from_handle(scsi_qla_host_t *vha, const char *func,
+			   struct req_que *req, void *iocb)
+{
+	uint16_t index;
+	srb_t *sp;
+
+	sp = qla_get_sp_from_handle(vha, func, req, iocb, &index);
+	if (sp)
+		req->outstanding_cmds[index] = NULL;
+
+	return sp;
+}
+
 static void
 qla2x00_mbx_iocb_entry(scsi_qla_host_t *vha, struct req_que *req,
     struct mbx_entry *mbx)
@@ -3237,13 +3250,13 @@ qla2x00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt)
 		return;
 	}
 
-	req->outstanding_cmds[handle] = NULL;
 	cp = GET_CMD_SP(sp);
 	if (cp == NULL) {
 		ql_dbg(ql_dbg_io, vha, 0x3018,
 		    "Command already returned (0x%x/%p).\n",
 		    sts->handle, sp);
 
+		req->outstanding_cmds[handle] = NULL;
 		return;
 	}
 
@@ -3514,6 +3527,9 @@ qla2x00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt)
 
 	if (rsp->status_srb == NULL)
 		sp->done(sp, res);
+
+	/* for io's, clearing of outstanding_cmds[handle] means scsi_done was called */
+	req->outstanding_cmds[handle] = NULL;
 }
 
 /**
@@ -3590,6 +3606,7 @@ qla2x00_error_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, sts_entry_t *pkt)
 	uint16_t que = MSW(pkt->handle);
 	struct req_que *req = NULL;
 	int res = DID_ERROR << 16;
+	u16 index;
 
 	ql_dbg(ql_dbg_async, vha, 0x502a,
 	    "iocb type %xh with error status %xh, handle %xh, rspq id %d\n",
@@ -3608,7 +3625,6 @@ qla2x00_error_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, sts_entry_t *pkt)
 
 	switch (pkt->entry_type) {
 	case NOTIFY_ACK_TYPE:
-	case STATUS_TYPE:
 	case STATUS_CONT_TYPE:
 	case LOGINOUT_PORT_IOCB_TYPE:
 	case CT_IOCB_TYPE:
@@ -3628,6 +3644,14 @@ qla2x00_error_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, sts_entry_t *pkt)
 	case CTIO_TYPE7:
 	case CTIO_CRC2:
 		return 1;
+	case STATUS_TYPE:
+		sp = qla_get_sp_from_handle(vha, func, req, pkt, &index);
+		if (sp) {
+			sp->done(sp, res);
+			req->outstanding_cmds[index] = NULL;
+			return 0;
+		}
+		break;
 	}
 fatal:
 	ql_log(ql_log_warn, vha, 0x5030,
drivers/scsi/qla2xxx/qla_os.c +64 -66

154 lines not on this page · raw message

Signature · 1 line
2.23.1
author maintainer
#9 lore raw

PATCH 6/7 qla2xxx: Wait for io return on terminate rport

In reply to Nilesh Javali

From: Quinn Tran <[email protected]>

System crash due to use after free.
Current code allows terminate_rport_io to exit before making sure all IOs has returned. For FCP-2 device, IO's can hang on in HW because driver has not tear down the session in FW at first sign of cable pull. When dev_loss_tmo timer pops, terminate_rport_io is called and upper layer is about to free various resources. Terminate_rport_io trigger qla to do the final cleanup, but the cleanup might not be fast enough where it leave qla still holding on to the same resource.

Wait for IO's to return to upper layer before resources are freed.

---
 drivers/scsi/qla2xxx/qla_attr.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/scsi/qla2xxx/qla_attr.c +13 -0
index 70cfc94c3d43..b00222459607 100644
@@ -2750,6 +2750,7 @@ static void
 qla2x00_terminate_rport_io(struct fc_rport *rport)
 {
 	fc_port_t *fcport = *(fc_port_t **)rport->dd_data;
+	scsi_qla_host_t *vha;
 
 	if (!fcport)
 		return;
@@ -2759,9 +2760,12 @@ qla2x00_terminate_rport_io(struct fc_rport *rport)
 
 	if (test_bit(ABORT_ISP_ACTIVE, &fcport->vha->dpc_flags))
 		return;
+	vha = fcport->vha;
 
 	if (unlikely(pci_channel_offline(fcport->vha->hw->pdev))) {
 		qla2x00_abort_all_cmds(fcport->vha, DID_NO_CONNECT << 16);
+		qla2x00_eh_wait_for_pending_commands(fcport->vha, fcport->d_id.b24,
+			0, WAIT_TARGET);
 		return;
 	}
 	/*
@@ -2786,6 +2790,15 @@ qla2x00_terminate_rport_io(struct fc_rport *rport)
 			qla2x00_port_logout(fcport->vha, fcport);
 		}
 	}
+
+	/* check for any straggling io left behind */
+	if (qla2x00_eh_wait_for_pending_commands(fcport->vha, fcport->d_id.b24, 0, WAIT_TARGET)) {
+		ql_log(ql_log_warn, vha, 0x300b,
+		       "IO not return.  Resetting. \n");
+		set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
+		qla2xxx_wake_dpc(vha);
+		qla2x00_wait_for_chip_reset(vha);
+	}
 }
 
 static int
Signature · 1 line
2.23.1
author maintainer
#10 lore raw

PATCH 7/7 qla2xxx: Update version to 10.02.08.300-k

In reply to Nilesh Javali
---
 drivers/scsi/qla2xxx/qla_version.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/qla2xxx/qla_version.h +2 -2
index 42d69d89834f..4d6f06fb156b 100644
@@ -6,9 +6,9 @@
 /*
  * Driver version
  */
-#define QLA2XXX_VERSION      "10.02.08.200-k"
+#define QLA2XXX_VERSION      "10.02.08.300-k"
 
 #define QLA_DRIVER_MAJOR_VER	10
 #define QLA_DRIVER_MINOR_VER	2
 #define QLA_DRIVER_PATCH_VER	8
-#define QLA_DRIVER_BETA_VER	200
+#define QLA_DRIVER_BETA_VER	300
Signature · 1 line
2.23.1