From: Nilesh Javali <njavali@marvell.com>
To: <martin.petersen@oracle.com>
Cc: <linux-scsi@vger.kernel.org>, <GR-QLogic-Storage-Upstream@marvell.com>
Subject: [PATCH v2 03/13] qla2xxx: Fix loss of NVME namespaces after driver reload test
Date: Thu, 10 Mar 2022 01:25:54 -0800 [thread overview]
Message-ID: <20220310092604.22950-4-njavali@marvell.com> (raw)
In-Reply-To: <20220310092604.22950-1-njavali@marvell.com>
From: Arun Easi <aeasi@marvell.com>
Driver registration of localport can race when it
happens at the remote port discovery time. Fix
this by calling the registration under a mutex.
Reported-by: Marco Patalano <mpatalan@redhat.com>
Tested-by: Marco Patalano <mpatalan@redhat.com>
Cc: stable@vger.kernel.org
Fixes: e84067d74301 ("scsi: qla2xxx: Add FC-NVMe F/W initialization and transport registration")
Signed-off-by: Arun Easi <aeasi@marvell.com>
Signed-off-by: Nilesh Javali <njavali@marvell.com>
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
---
drivers/scsi/qla2xxx/qla_nvme.c | 30 ++++++++++++++++++++----------
1 file changed, 20 insertions(+), 10 deletions(-)
diff --git a/drivers/scsi/qla2xxx/qla_nvme.c b/drivers/scsi/qla2xxx/qla_nvme.c
index 5723082d94d6..3bf5cbd754a7 100644
--- a/drivers/scsi/qla2xxx/qla_nvme.c
+++ b/drivers/scsi/qla2xxx/qla_nvme.c
@@ -782,8 +782,6 @@ int qla_nvme_register_hba(struct scsi_qla_host *vha)
ha = vha->hw;
tmpl = &qla_nvme_fc_transport;
- WARN_ON(vha->nvme_local_port);
-
if (ql2xnvme_queues < MIN_NVME_HW_QUEUES || ql2xnvme_queues > MAX_NVME_HW_QUEUES) {
ql_log(ql_log_warn, vha, 0xfffd,
"ql2xnvme_queues=%d is out of range(MIN:%d - MAX:%d). Resetting ql2xnvme_queues to:%d\n",
@@ -797,7 +795,7 @@ int qla_nvme_register_hba(struct scsi_qla_host *vha)
(uint8_t)(ha->max_qpairs ? ha->max_qpairs : 1));
ql_log(ql_log_info, vha, 0xfffb,
- "Number of NVME queues used for this port: %d\n",
+ "Number of NVME queues used for this port: %d\n",
qla_nvme_fc_transport.max_hw_queues);
pinfo.node_name = wwn_to_u64(vha->node_name);
@@ -805,13 +803,25 @@ int qla_nvme_register_hba(struct scsi_qla_host *vha)
pinfo.port_role = FC_PORT_ROLE_NVME_INITIATOR;
pinfo.port_id = vha->d_id.b24;
- ql_log(ql_log_info, vha, 0xffff,
- "register_localport: host-traddr=nn-0x%llx:pn-0x%llx on portID:%x\n",
- pinfo.node_name, pinfo.port_name, pinfo.port_id);
- qla_nvme_fc_transport.dma_boundary = vha->host->dma_boundary;
-
- ret = nvme_fc_register_localport(&pinfo, tmpl,
- get_device(&ha->pdev->dev), &vha->nvme_local_port);
+ mutex_lock(&ha->vport_lock);
+ /*
+ * Check again for nvme_local_port to see if any other thread raced
+ * with this one and finished registration.
+ */
+ if (!vha->nvme_local_port) {
+ ql_log(ql_log_info, vha, 0xffff,
+ "register_localport: host-traddr=nn-0x%llx:pn-0x%llx on portID:%x\n",
+ pinfo.node_name, pinfo.port_name, pinfo.port_id);
+ qla_nvme_fc_transport.dma_boundary = vha->host->dma_boundary;
+
+ ret = nvme_fc_register_localport(&pinfo, tmpl,
+ get_device(&ha->pdev->dev),
+ &vha->nvme_local_port);
+ mutex_unlock(&ha->vport_lock);
+ } else {
+ mutex_unlock(&ha->vport_lock);
+ return 0;
+ }
if (ret) {
ql_log(ql_log_warn, vha, 0xffff,
"register_localport failed: ret=%x\n", ret);
--
2.19.0.rc0
next prev parent reply other threads:[~2022-03-10 9:26 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-10 9:25 [PATCH v2 00/13] qla2xxx driver fixes Nilesh Javali
2022-03-10 9:25 ` [PATCH v2 01/13] qla2xxx: Fix incorrect reporting of task management failure Nilesh Javali
2022-03-10 9:25 ` [PATCH v2 02/13] qla2xxx: Fix disk failure to rediscover Nilesh Javali
2022-03-10 9:25 ` Nilesh Javali [this message]
2022-03-10 9:25 ` [PATCH v2 04/13] qla2xxx: Fix missed DMA unmap for NVME ls requests Nilesh Javali
2022-03-10 9:25 ` [PATCH v2 05/13] qla2xxx: Fix crash during module load unload test Nilesh Javali
2022-03-10 9:25 ` [PATCH v2 06/13] qla2xxx: fix n2n inconsistent plogi Nilesh Javali
2022-03-10 9:25 ` [PATCH v2 07/13] qla2xxx: Fix hang due to session stuck Nilesh Javali
2022-03-10 9:25 ` [PATCH v2 08/13] qla2xxx: Fix laggy FC remote port session recovery Nilesh Javali
2022-03-10 9:26 ` [PATCH v2 09/13] qla2xxx: reduce false trigger to login Nilesh Javali
2022-03-10 9:26 ` [PATCH v2 10/13] qla2xxx: Fix stuck session of prli reject Nilesh Javali
2022-03-10 9:26 ` [PATCH v2 11/13] qla2xxx: Use correct feature type field during rffid processing Nilesh Javali
2022-03-10 9:26 ` [PATCH v2 12/13] qla2xxx: Increase max limit of ql2xnvme_queues Nilesh Javali
2022-03-10 9:26 ` [PATCH v2 13/13] qla2xxx: Update version to 10.02.07.400-k Nilesh Javali
2022-03-15 4:29 ` [PATCH v2 00/13] qla2xxx driver fixes Martin K. Petersen
2022-03-19 3:57 ` Martin K. Petersen
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=20220310092604.22950-4-njavali@marvell.com \
--to=njavali@marvell.com \
--cc=GR-QLogic-Storage-Upstream@marvell.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
/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