Blame SOURCES/0056-scsi-scsi-qla2xxx-Fix-driver-unload-when-FC-NVMe-LUN.patch

3c6e85
From 970619c33d827965004346d7d3bb145d2a0cd664 Mon Sep 17 00:00:00 2001
3c6e85
From: Himanshu Madhani <hmadhani@redhat.com>
3c6e85
Date: Thu, 1 Aug 2019 15:55:16 -0400
3c6e85
Subject: [PATCH 056/124] [scsi] scsi: qla2xxx: Fix driver unload when FC-NVMe
3c6e85
 LUNs are connected
3c6e85
3c6e85
Message-id: <20190801155618.12650-57-hmadhani@redhat.com>
3c6e85
Patchwork-id: 267837
3c6e85
O-Subject: [RHEL 7.8 e-stor PATCH 056/118] scsi: qla2xxx: Fix driver unload when FC-NVMe LUNs are connected
3c6e85
Bugzilla: 1729270
3c6e85
RH-Acked-by: Jarod Wilson <jarod@redhat.com>
3c6e85
RH-Acked-by: Tony Camuso <tcamuso@redhat.com>
3c6e85
3c6e85
From: Giridhar Malavali <gmalavali@marvell.com>
3c6e85
3c6e85
Bugzilla 1729270
3c6e85
3c6e85
This patch allows driver to unload using "modprobe -r" when FC-NVMe LUNs
3c6e85
are connected.
3c6e85
3c6e85
Signed-off-by: Giridhar Malavali <gmalavali@marvell.com>
3c6e85
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
3c6e85
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3c6e85
(cherry picked from commit b2d1453a45aa8477b1d33ee94a7694146bb8b340)
3c6e85
Signed-off-by: Himanshu Madhani <hmadhani@redhat.com>
3c6e85
Signed-off-by: Jan Stancek <jstancek@redhat.com>
3c6e85
---
3c6e85
 drivers/scsi/qla2xxx/qla_nvme.c | 29 +++++++++++++++++++++++------
3c6e85
 drivers/scsi/qla2xxx/qla_os.c   |  6 ++++--
3c6e85
 2 files changed, 27 insertions(+), 8 deletions(-)
3c6e85
3c6e85
diff --git a/drivers/scsi/qla2xxx/qla_nvme.c b/drivers/scsi/qla2xxx/qla_nvme.c
3c6e85
index 8d4624c9f75b..ae1aae52f59e 100644
3c6e85
--- a/drivers/scsi/qla2xxx/qla_nvme.c
3c6e85
+++ b/drivers/scsi/qla2xxx/qla_nvme.c
3c6e85
@@ -164,12 +164,13 @@ static void qla_nvme_sp_done(void *ptr, int res)
3c6e85
 	if (!atomic_dec_and_test(&sp->ref_count))
3c6e85
 		return;
3c6e85
 
3c6e85
-	if (res == QLA_SUCCESS)
3c6e85
-		fd->status = 0;
3c6e85
-	else
3c6e85
-		fd->status = NVME_SC_INTERNAL;
3c6e85
-
3c6e85
-	fd->rcv_rsplen = nvme->u.nvme.rsp_pyld_len;
3c6e85
+	if (res == QLA_SUCCESS) {
3c6e85
+		fd->rcv_rsplen = nvme->u.nvme.rsp_pyld_len;
3c6e85
+	} else {
3c6e85
+		fd->rcv_rsplen = 0;
3c6e85
+		fd->transferred_length = 0;
3c6e85
+	}
3c6e85
+	fd->status = 0;
3c6e85
 	fd->done(fd);
3c6e85
 	qla2xxx_rel_qpair_sp(sp->qpair, sp);
3c6e85
 
3c6e85
@@ -193,6 +194,22 @@ static void qla_nvme_abort_work(struct work_struct *work)
3c6e85
 	if (!ha->flags.fw_started && (fcport && fcport->deleted))
3c6e85
 		return;
3c6e85
 
3c6e85
+	if (ha->flags.host_shutting_down) {
3c6e85
+		ql_log(ql_log_info, sp->fcport->vha, 0xffff,
3c6e85
+		    "%s Calling done on sp: %p, type: 0x%x, sp->ref_count: 0x%x\n",
3c6e85
+		    __func__, sp, sp->type, atomic_read(&sp->ref_count));
3c6e85
+		sp->done(sp, 0);
3c6e85
+		return;
3c6e85
+	}
3c6e85
+
3c6e85
+	if (atomic_read(&sp->ref_count) == 0) {
3c6e85
+		WARN_ON(1);
3c6e85
+		ql_log(ql_log_info, fcport->vha, 0xffff,
3c6e85
+			"%s: command alredy aborted on sp: %p\n",
3c6e85
+			__func__, sp);
3c6e85
+		return;
3c6e85
+	}
3c6e85
+
3c6e85
 	rval = ha->isp_ops->abort_command(sp);
3c6e85
 
3c6e85
 	ql_dbg(ql_dbg_io, fcport->vha, 0x212b,
3c6e85
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
3c6e85
index c440d5bffefe..1cf427cf1ffe 100644
3c6e85
--- a/drivers/scsi/qla2xxx/qla_os.c
3c6e85
+++ b/drivers/scsi/qla2xxx/qla_os.c
3c6e85
@@ -6835,8 +6835,10 @@ qla2x00_timer(scsi_qla_host_t *vha)
3c6e85
 	 * FC-NVME
3c6e85
 	 * see if the active AEN count has changed from what was last reported.
3c6e85
 	 */
3c6e85
-	if (!vha->vp_idx && (atomic_read(&ha->nvme_active_aen_cnt) !=
3c6e85
-	    ha->nvme_last_rptd_aen) && ha->zio_mode == QLA_ZIO_MODE_6) {
3c6e85
+	if (!vha->vp_idx &&
3c6e85
+	    (atomic_read(&ha->nvme_active_aen_cnt) != ha->nvme_last_rptd_aen) &&
3c6e85
+	    ha->zio_mode == QLA_ZIO_MODE_6 &&
3c6e85
+	    !ha->flags.host_shutting_down) {
3c6e85
 		ql_log(ql_log_info, vha, 0x3002,
3c6e85
 		    "nvme: Sched: Set ZIO exchange threshold to %d.\n",
3c6e85
 		    ha->nvme_last_rptd_aen);
3c6e85
-- 
3c6e85
2.13.6
3c6e85