stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Quinn Tran <qutran@marvell.com>,
	Himanshu Madhani <hmadhani@marvell.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH 5.4 08/73] scsi: qla2xxx: Fix fabric scan hang
Date: Mon, 19 Apr 2021 15:05:59 +0200	[thread overview]
Message-ID: <20210419130524.085206558@linuxfoundation.org> (raw)
In-Reply-To: <20210419130523.802169214@linuxfoundation.org>

From: Quinn Tran <qutran@marvell.com>

[ Upstream commit f57a0107359605b29f4ea9afb8ee2e03473b1448 ]

On timeout, SRB pointer was cleared from outstanding command array and
dropped.  It was not allowed to go through the done process and cleanup.
This patch will abort the SRB where FW will return it with an error status
and resume the normal cleanup.

Link: https://lore.kernel.org/r/20191217220617.28084-3-hmadhani@marvell.com
Signed-off-by: Quinn Tran <qutran@marvell.com>
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/scsi/qla2xxx/qla_gbl.h  |  1 +
 drivers/scsi/qla2xxx/qla_init.c | 34 +++++++++++++++------------
 drivers/scsi/qla2xxx/qla_iocb.c | 41 ++++++++++++++++++++++++++-------
 3 files changed, 53 insertions(+), 23 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
index 5a3c47eed645..7aa233771ec8 100644
--- a/drivers/scsi/qla2xxx/qla_gbl.h
+++ b/drivers/scsi/qla2xxx/qla_gbl.h
@@ -256,6 +256,7 @@ extern char *qla2x00_get_fw_version_str(struct scsi_qla_host *, char *);
 
 extern void qla2x00_mark_device_lost(scsi_qla_host_t *, fc_port_t *, int, int);
 extern void qla2x00_mark_all_devices_lost(scsi_qla_host_t *, int);
+extern int qla24xx_async_abort_cmd(srb_t *, bool);
 
 extern struct fw_blob *qla2x00_request_firmware(scsi_qla_host_t *);
 
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index b4f0c2c8414e..643b8ae36cbe 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -50,16 +50,9 @@ qla2x00_sp_timeout(struct timer_list *t)
 {
 	srb_t *sp = from_timer(sp, t, u.iocb_cmd.timer);
 	struct srb_iocb *iocb;
-	struct req_que *req;
-	unsigned long flags;
-	struct qla_hw_data *ha = sp->vha->hw;
 
-	WARN_ON_ONCE(irqs_disabled());
-	spin_lock_irqsave(&ha->hardware_lock, flags);
-	req = sp->qpair->req;
-	req->outstanding_cmds[sp->handle] = NULL;
+	WARN_ON(irqs_disabled());
 	iocb = &sp->u.iocb_cmd;
-	spin_unlock_irqrestore(&ha->hardware_lock, flags);
 	iocb->timeout(sp);
 }
 
@@ -153,7 +146,7 @@ static void qla24xx_abort_sp_done(srb_t *sp, int res)
 		sp->free(sp);
 }
 
-static int qla24xx_async_abort_cmd(srb_t *cmd_sp, bool wait)
+int qla24xx_async_abort_cmd(srb_t *cmd_sp, bool wait)
 {
 	scsi_qla_host_t *vha = cmd_sp->vha;
 	struct srb_iocb *abt_iocb;
@@ -253,6 +246,7 @@ qla2x00_async_iocb_timeout(void *data)
 	case SRB_NACK_PRLI:
 	case SRB_NACK_LOGO:
 	case SRB_CTRL_VP:
+	default:
 		rc = qla24xx_async_abort_cmd(sp, false);
 		if (rc) {
 			spin_lock_irqsave(sp->qpair->qp_lock_ptr, flags);
@@ -269,10 +263,6 @@ qla2x00_async_iocb_timeout(void *data)
 			sp->done(sp, QLA_FUNCTION_TIMEOUT);
 		}
 		break;
-	default:
-		WARN_ON_ONCE(true);
-		sp->done(sp, QLA_FUNCTION_TIMEOUT);
-		break;
 	}
 }
 
@@ -1794,9 +1784,23 @@ qla2x00_tmf_iocb_timeout(void *data)
 {
 	srb_t *sp = data;
 	struct srb_iocb *tmf = &sp->u.iocb_cmd;
+	int rc, h;
+	unsigned long flags;
 
-	tmf->u.tmf.comp_status = CS_TIMEOUT;
-	complete(&tmf->u.tmf.comp);
+	rc = qla24xx_async_abort_cmd(sp, false);
+	if (rc) {
+		spin_lock_irqsave(sp->qpair->qp_lock_ptr, flags);
+		for (h = 1; h < sp->qpair->req->num_outstanding_cmds; h++) {
+			if (sp->qpair->req->outstanding_cmds[h] == sp) {
+				sp->qpair->req->outstanding_cmds[h] = NULL;
+				break;
+			}
+		}
+		spin_unlock_irqrestore(sp->qpair->qp_lock_ptr, flags);
+		tmf->u.tmf.comp_status = CS_TIMEOUT;
+		tmf->u.tmf.data = QLA_FUNCTION_FAILED;
+		complete(&tmf->u.tmf.comp);
+	}
 }
 
 static void qla2x00_tmf_sp_done(srb_t *sp, int res)
diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c
index 3f43410fab9d..936103604d02 100644
--- a/drivers/scsi/qla2xxx/qla_iocb.c
+++ b/drivers/scsi/qla2xxx/qla_iocb.c
@@ -2537,13 +2537,32 @@ qla2x00_els_dcmd_iocb_timeout(void *data)
 	fc_port_t *fcport = sp->fcport;
 	struct scsi_qla_host *vha = sp->vha;
 	struct srb_iocb *lio = &sp->u.iocb_cmd;
+	unsigned long flags = 0;
+	int res, h;
 
 	ql_dbg(ql_dbg_io, vha, 0x3069,
 	    "%s Timeout, hdl=%x, portid=%02x%02x%02x\n",
 	    sp->name, sp->handle, fcport->d_id.b.domain, fcport->d_id.b.area,
 	    fcport->d_id.b.al_pa);
 
-	complete(&lio->u.els_logo.comp);
+	/* Abort the exchange */
+	res = qla24xx_async_abort_cmd(sp, false);
+	if (res) {
+		ql_dbg(ql_dbg_io, vha, 0x3070,
+		    "mbx abort_command failed.\n");
+		spin_lock_irqsave(sp->qpair->qp_lock_ptr, flags);
+		for (h = 1; h < sp->qpair->req->num_outstanding_cmds; h++) {
+			if (sp->qpair->req->outstanding_cmds[h] == sp) {
+				sp->qpair->req->outstanding_cmds[h] = NULL;
+				break;
+			}
+		}
+		spin_unlock_irqrestore(sp->qpair->qp_lock_ptr, flags);
+		complete(&lio->u.els_logo.comp);
+	} else {
+		ql_dbg(ql_dbg_io, vha, 0x3071,
+		    "mbx abort_command success.\n");
+	}
 }
 
 static void qla2x00_els_dcmd_sp_done(srb_t *sp, int res)
@@ -2708,23 +2727,29 @@ qla2x00_els_dcmd2_iocb_timeout(void *data)
 	srb_t *sp = data;
 	fc_port_t *fcport = sp->fcport;
 	struct scsi_qla_host *vha = sp->vha;
-	struct qla_hw_data *ha = vha->hw;
 	unsigned long flags = 0;
-	int res;
+	int res, h;
 
 	ql_dbg(ql_dbg_io + ql_dbg_disc, vha, 0x3069,
 	    "%s hdl=%x ELS Timeout, %8phC portid=%06x\n",
 	    sp->name, sp->handle, fcport->port_name, fcport->d_id.b24);
 
 	/* Abort the exchange */
-	spin_lock_irqsave(&ha->hardware_lock, flags);
-	res = ha->isp_ops->abort_command(sp);
+	res = qla24xx_async_abort_cmd(sp, false);
 	ql_dbg(ql_dbg_io, vha, 0x3070,
 	    "mbx abort_command %s\n",
 	    (res == QLA_SUCCESS) ? "successful" : "failed");
-	spin_unlock_irqrestore(&ha->hardware_lock, flags);
-
-	sp->done(sp, QLA_FUNCTION_TIMEOUT);
+	if (res) {
+		spin_lock_irqsave(sp->qpair->qp_lock_ptr, flags);
+		for (h = 1; h < sp->qpair->req->num_outstanding_cmds; h++) {
+			if (sp->qpair->req->outstanding_cmds[h] == sp) {
+				sp->qpair->req->outstanding_cmds[h] = NULL;
+				break;
+			}
+		}
+		spin_unlock_irqrestore(sp->qpair->qp_lock_ptr, flags);
+		sp->done(sp, QLA_FUNCTION_TIMEOUT);
+	}
 }
 
 void qla2x00_els_dcmd2_free(scsi_qla_host_t *vha, struct els_plogi *els_plogi)
-- 
2.30.2




  parent reply	other threads:[~2021-04-19 13:26 UTC|newest]

Thread overview: 81+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-19 13:05 [PATCH 5.4 00/73] 5.4.114-rc1 review Greg Kroah-Hartman
2021-04-19 13:05 ` [PATCH 5.4 01/73] Revert "scsi: qla2xxx: Retry PLOGI on FC-NVMe PRLI failure" Greg Kroah-Hartman
2021-04-19 13:05 ` [PATCH 5.4 02/73] Revert "scsi: qla2xxx: Fix stuck login session using prli_pend_timer" Greg Kroah-Hartman
2021-04-19 13:05 ` [PATCH 5.4 03/73] scsi: qla2xxx: Dual FCP-NVMe target port support Greg Kroah-Hartman
2021-04-19 13:05 ` [PATCH 5.4 04/73] scsi: qla2xxx: Fix device connect issues in P2P configuration Greg Kroah-Hartman
2021-04-19 13:05 ` [PATCH 5.4 05/73] scsi: qla2xxx: Retry PLOGI on FC-NVMe PRLI failure Greg Kroah-Hartman
2021-04-19 13:05 ` [PATCH 5.4 06/73] scsi: qla2xxx: Add a shadow variable to hold disc_state history of fcport Greg Kroah-Hartman
2021-04-19 13:05 ` [PATCH 5.4 07/73] scsi: qla2xxx: Fix stuck login session using prli_pend_timer Greg Kroah-Hartman
2021-04-19 13:05 ` Greg Kroah-Hartman [this message]
2021-04-19 13:06 ` [PATCH 5.4 09/73] net/sctp: fix race condition in sctp_destroy_sock Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 10/73] Input: nspire-keypad - enable interrupts only when opened Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 11/73] gpio: sysfs: Obey valid_mask Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 12/73] dmaengine: dw: Make it dependent to HAS_IOMEM Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 13/73] ARM: dts: Drop duplicate sha2md5_fck to fix clk_disable race Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 14/73] ARM: dts: Fix moving mmc devices with aliases for omap4 & 5 Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 15/73] lockdep: Add a missing initialization hint to the "INFO: Trying to register non-static key" message Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 16/73] arc: kernel: Return -EFAULT if copy_to_user() fails Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 17/73] ASoC: max98373: Added 30ms turn on/off time delay Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 18/73] neighbour: Disregard DEAD dst in neigh_update Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 19/73] ARM: keystone: fix integer overflow warning Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 20/73] ARM: omap1: fix building with clang IAS Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 21/73] drm/msm: Fix a5xx/a6xx timestamps Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 22/73] ASoC: fsl_esai: Fix TDM slot setup for I2S mode Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 23/73] scsi: scsi_transport_srp: Dont block target in SRP_PORT_LOST state Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 24/73] net: ieee802154: stop dump llsec keys for monitors Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 25/73] net: ieee802154: forbid monitor for add llsec key Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 26/73] net: ieee802154: forbid monitor for del " Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 27/73] net: ieee802154: stop dump llsec devs for monitors Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 28/73] net: ieee802154: forbid monitor for add llsec dev Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 29/73] net: ieee802154: forbid monitor for del " Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 30/73] net: ieee802154: stop dump llsec devkeys for monitors Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 31/73] net: ieee802154: forbid monitor for add llsec devkey Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 32/73] net: ieee802154: forbid monitor for del " Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 33/73] net: ieee802154: stop dump llsec seclevels for monitors Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 34/73] net: ieee802154: forbid monitor for add llsec seclevel Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 35/73] pcnet32: Use pci_resource_len to validate PCI resource Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 36/73] net/rds: Avoid potential use after free in rds_send_remove_from_sock Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 37/73] net: tipc: Fix spelling errors in net/tipc module Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 38/73] mac80211: clear sta->fast_rx when STA removed from 4-addr VLAN Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 39/73] virt_wifi: Return micros for BSS TSF values Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 40/73] Input: s6sy761 - fix coordinate read bit shift Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 41/73] Input: i8042 - fix Pegatron C15B ID entry Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 42/73] HID: wacom: set EV_KEY and EV_ABS only for non-HID_GENERIC type of devices Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 43/73] dm verity fec: fix misaligned RS roots IO Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 44/73] readdir: make sure to verify directory entry for legacy interfaces too Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 45/73] arm64: fix inline asm in load_unaligned_zeropad() Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 46/73] arm64: alternatives: Move length validation in alternative_{insn, endif} Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 47/73] vfio/pci: Add missing range check in vfio_pci_mmap Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 48/73] riscv: Fix spelling mistake "SPARSEMEM" to "SPARSMEM" Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 49/73] scsi: libsas: Reset num_scatter if libata marks qc as NODATA Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 50/73] netfilter: conntrack: do not print icmpv6 as unknown via /proc Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 51/73] libnvdimm/region: Fix nvdimm_has_flush() to handle ND_REGION_ASYNC Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 52/73] netfilter: bridge: add pre_exit hooks for ebtable unregistration Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 53/73] netfilter: arp_tables: add pre_exit hook for table unregister Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 54/73] net: macb: fix the restore of cmp registers Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 55/73] netfilter: nft_limit: avoid possible divide error in nft_limit_init Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 56/73] net: davicom: Fix regulator not turned off on failed probe Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 57/73] net: sit: Unregister catch-all devices Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 58/73] net: ip6_tunnel: " Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 59/73] i40e: fix the panic when running bpf in xdpdrv mode Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 60/73] ibmvnic: avoid calling napi_disable() twice Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 61/73] ibmvnic: remove duplicate napi_schedule call in do_reset function Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 62/73] ibmvnic: remove duplicate napi_schedule call in open function Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 63/73] gro: ensure frag0 meets IP header alignment Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 64/73] ARM: footbridge: fix PCI interrupt mapping Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 65/73] arm64: dts: allwinner: Fix SD card CD GPIO for SOPine systems Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 66/73] r8169: remove fiddling with the PCIe max read request size Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 67/73] r8169: simplify setting PCI_EXP_DEVCTL_NOSNOOP_EN Greg Kroah-Hartman
2021-04-19 13:06 ` [PATCH 5.4 68/73] r8169: fix performance regression related to PCIe max read request size Greg Kroah-Hartman
2021-04-19 13:07 ` [PATCH 5.4 69/73] r8169: improve rtl_jumbo_config Greg Kroah-Hartman
2021-04-19 13:07 ` [PATCH 5.4 70/73] r8169: tweak max read request size for newer chips also in jumbo mtu mode Greg Kroah-Hartman
2021-04-19 13:07 ` [PATCH 5.4 71/73] r8169: dont advertise pause in jumbo mode Greg Kroah-Hartman
2021-04-19 13:07 ` [PATCH 5.4 72/73] ARM: 9071/1: uprobes: Dont hook on thumb instructions Greg Kroah-Hartman
2021-04-19 13:07 ` [PATCH 5.4 73/73] net: phy: marvell: fix detection of PHY on Topaz switches Greg Kroah-Hartman
2021-04-19 21:17 ` [PATCH 5.4 00/73] 5.4.114-rc1 review Florian Fainelli
2021-04-20  0:09 ` Shuah Khan
2021-04-20  0:17 ` Guenter Roeck
2021-04-20  6:13 ` Jon Hunter
2021-04-20  8:26 ` Naresh Kamboju
2021-04-20  9:11 ` Sudip Mukherjee
2021-04-20 11:26 ` Samuel Zou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210419130524.085206558@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=hmadhani@marvell.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=qutran@marvell.com \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).