public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/8] Update lpfc to revision 14.4.0.4
@ 2024-07-26 23:15 Justin Tee
  2024-07-26 23:15 ` [PATCH 1/8] lpfc: Change diagnostic log flag during receipt of unknown ELS cmds Justin Tee
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: Justin Tee @ 2024-07-26 23:15 UTC (permalink / raw)
  To: linux-scsi; +Cc: jsmart2021, justin.tee, Justin Tee

Update lpfc to revision 14.4.0.4

This patch set contains diagnostic logging improvements, a minor clean up
when submitting abort requests, a bug fix related to reset and errata
paths, and modifications to FLOGI and PRLO ELS command handling.

The patches were cut against Martin's 6.11/scsi-queue tree.

Justin Tee (8):
  lpfc: Change diagnostic log flag during receipt of unknown ELS cmds
  lpfc: Remove redundant vport assignment when building an abort request
  lpfc: Validate hdwq pointers before dereferencing in reset/errata
    paths
  lpfc: Fix unintentional double clearing of vmid_flag
  lpfc: Fix unsolicited FLOGI kref imbalance when in direct attached
    topology
  lpfc: Update PRLO handling in direct attached topology
  lpfc: Update lpfc version to 14.4.0.4
  lpfc: Copyright updates for 14.4.0.4 patches

 drivers/scsi/lpfc/lpfc.h           | 12 +++--
 drivers/scsi/lpfc/lpfc_els.c       | 79 ++++++++++++++++++------------
 drivers/scsi/lpfc/lpfc_hbadisc.c   | 14 ++++--
 drivers/scsi/lpfc/lpfc_nportdisc.c | 22 ++++++++-
 drivers/scsi/lpfc/lpfc_scsi.c      | 13 ++++-
 drivers/scsi/lpfc/lpfc_sli.c       | 13 ++++-
 drivers/scsi/lpfc/lpfc_version.h   |  2 +-
 drivers/scsi/lpfc/lpfc_vmid.c      |  3 +-
 8 files changed, 112 insertions(+), 46 deletions(-)

-- 
2.38.0


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/8] lpfc: Change diagnostic log flag during receipt of unknown ELS cmds
  2024-07-26 23:15 [PATCH 0/8] Update lpfc to revision 14.4.0.4 Justin Tee
@ 2024-07-26 23:15 ` Justin Tee
  2024-07-26 23:15 ` [PATCH 2/8] lpfc: Remove redundant vport assignment when building an abort request Justin Tee
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Justin Tee @ 2024-07-26 23:15 UTC (permalink / raw)
  To: linux-scsi; +Cc: jsmart2021, justin.tee, Justin Tee

During diagnostics, it has been determined that the 0115 log message for
receipt of unknown ELS cmds does not benefit from trace buffer dumps.  The
trace buffer dump floods the console with unnecessary information, and the
singular LOG_ELS flag has proven more beneficial in debugging efforts when
dealing with unknown ELS cmds.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
---
 drivers/scsi/lpfc/lpfc_els.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
index 929cbfc95163..50c0c0c91fdc 100644
--- a/drivers/scsi/lpfc/lpfc_els.c
+++ b/drivers/scsi/lpfc/lpfc_els.c
@@ -10742,7 +10742,7 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
 		rjt_exp = LSEXP_NOTHING_MORE;
 
 		/* Unknown ELS command <elsCmd> received from NPORT <did> */
-		lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
+		lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
 				 "0115 Unknown ELS command x%x "
 				 "received from NPORT x%x\n", cmd, did);
 		if (newnode)
-- 
2.38.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 2/8] lpfc: Remove redundant vport assignment when building an abort request
  2024-07-26 23:15 [PATCH 0/8] Update lpfc to revision 14.4.0.4 Justin Tee
  2024-07-26 23:15 ` [PATCH 1/8] lpfc: Change diagnostic log flag during receipt of unknown ELS cmds Justin Tee
@ 2024-07-26 23:15 ` Justin Tee
  2024-07-26 23:15 ` [PATCH 3/8] lpfc: Validate hdwq pointers before dereferencing in reset/errata paths Justin Tee
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Justin Tee @ 2024-07-26 23:15 UTC (permalink / raw)
  To: linux-scsi; +Cc: jsmart2021, justin.tee, Justin Tee

The lpfc_sli_issue_abort_iotag routine has a redundant assignment of
abtsiocbp->vport = vport;

The duplicate lines are from a previous refactoring, and this patch removes
the accidental redundancy.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
---
 drivers/scsi/lpfc/lpfc_sli.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index 88debef2fb6d..d240bbded4c8 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -12473,8 +12473,6 @@ lpfc_sli_issue_abort_iotag(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
 				cmdiocb->iocb.ulpClass,
 				LPFC_WQE_CQ_ID_DEFAULT, ia, false);
 
-	abtsiocbp->vport = vport;
-
 	/* ABTS WQE must go to the same WQ as the WQE to be aborted */
 	abtsiocbp->hba_wqidx = cmdiocb->hba_wqidx;
 	if (cmdiocb->cmd_flag & LPFC_IO_FCP)
-- 
2.38.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 3/8] lpfc: Validate hdwq pointers before dereferencing in reset/errata paths
  2024-07-26 23:15 [PATCH 0/8] Update lpfc to revision 14.4.0.4 Justin Tee
  2024-07-26 23:15 ` [PATCH 1/8] lpfc: Change diagnostic log flag during receipt of unknown ELS cmds Justin Tee
  2024-07-26 23:15 ` [PATCH 2/8] lpfc: Remove redundant vport assignment when building an abort request Justin Tee
@ 2024-07-26 23:15 ` Justin Tee
  2024-07-26 23:15 ` [PATCH 4/8] lpfc: Fix unintentional double clearing of vmid_flag Justin Tee
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Justin Tee @ 2024-07-26 23:15 UTC (permalink / raw)
  To: linux-scsi; +Cc: jsmart2021, justin.tee, Justin Tee

When the HBA is undergoing a reset or is handling an errata event, NULL ptr
dereference crashes may occur in routines such as lpfc_sli_flush_io_rings,
lpfc_dev_loss_tmo_callbk, or lpfc_abort_handler.

Add NULL ptr checks before dereferencing hdwq pointers that may have been
freed due to operations colliding with a reset or errata event handler.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
---
 drivers/scsi/lpfc/lpfc_hbadisc.c |  3 ++-
 drivers/scsi/lpfc/lpfc_scsi.c    | 13 +++++++++++--
 drivers/scsi/lpfc/lpfc_sli.c     | 11 +++++++++++
 3 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c
index 6943f6c6395c..f21c5993e8d7 100644
--- a/drivers/scsi/lpfc/lpfc_hbadisc.c
+++ b/drivers/scsi/lpfc/lpfc_hbadisc.c
@@ -175,7 +175,8 @@ lpfc_dev_loss_tmo_callbk(struct fc_rport *rport)
 			 ndlp->nlp_state, ndlp->fc4_xpt_flags);
 
 	/* Don't schedule a worker thread event if the vport is going down. */
-	if (test_bit(FC_UNLOADING, &vport->load_flag)) {
+	if (test_bit(FC_UNLOADING, &vport->load_flag) ||
+	    !test_bit(HBA_SETUP, &phba->hba_flag)) {
 		spin_lock_irqsave(&ndlp->lock, iflags);
 		ndlp->rport = NULL;
 
diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
index 98ce9d97a225..60cd60ebff38 100644
--- a/drivers/scsi/lpfc/lpfc_scsi.c
+++ b/drivers/scsi/lpfc/lpfc_scsi.c
@@ -5555,11 +5555,20 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd)
 
 	iocb = &lpfc_cmd->cur_iocbq;
 	if (phba->sli_rev == LPFC_SLI_REV4) {
-		pring_s4 = phba->sli4_hba.hdwq[iocb->hba_wqidx].io_wq->pring;
-		if (!pring_s4) {
+		/* if the io_wq & pring are gone, the port was reset. */
+		if (!phba->sli4_hba.hdwq[iocb->hba_wqidx].io_wq ||
+		    !phba->sli4_hba.hdwq[iocb->hba_wqidx].io_wq->pring) {
+			lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP,
+					 "2877 SCSI Layer I/O Abort Request "
+					 "IO CMPL Status x%x ID %d LUN %llu "
+					 "HBA_SETUP %d\n", FAILED,
+					 cmnd->device->id,
+					 (u64)cmnd->device->lun,
+					 test_bit(HBA_SETUP, &phba->hba_flag));
 			ret = FAILED;
 			goto out_unlock_hba;
 		}
+		pring_s4 = phba->sli4_hba.hdwq[iocb->hba_wqidx].io_wq->pring;
 		spin_lock(&pring_s4->ring_lock);
 	}
 	/* the command is in process of being cancelled */
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index d240bbded4c8..332b8d2348e9 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -4687,6 +4687,17 @@ lpfc_sli_flush_io_rings(struct lpfc_hba *phba)
 	/* Look on all the FCP Rings for the iotag */
 	if (phba->sli_rev >= LPFC_SLI_REV4) {
 		for (i = 0; i < phba->cfg_hdw_queue; i++) {
+			if (!phba->sli4_hba.hdwq ||
+			    !phba->sli4_hba.hdwq[i].io_wq) {
+				lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
+						"7777 hdwq's deleted %lx "
+						"%lx %x %x\n",
+						phba->pport->load_flag,
+						phba->hba_flag,
+						phba->link_state,
+						phba->sli.sli_flag);
+				return;
+			}
 			pring = phba->sli4_hba.hdwq[i].io_wq->pring;
 
 			spin_lock_irq(&pring->ring_lock);
-- 
2.38.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 4/8] lpfc: Fix unintentional double clearing of vmid_flag
  2024-07-26 23:15 [PATCH 0/8] Update lpfc to revision 14.4.0.4 Justin Tee
                   ` (2 preceding siblings ...)
  2024-07-26 23:15 ` [PATCH 3/8] lpfc: Validate hdwq pointers before dereferencing in reset/errata paths Justin Tee
@ 2024-07-26 23:15 ` Justin Tee
  2024-07-26 23:15 ` [PATCH 5/8] lpfc: Fix unsolicited FLOGI kref imbalance when in direct attached topology Justin Tee
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Justin Tee @ 2024-07-26 23:15 UTC (permalink / raw)
  To: linux-scsi; +Cc: jsmart2021, justin.tee, Justin Tee

The vport->vmid_flag is unintentionally cleared twice after an issue_lip
via the lpfc_reinit_vmid routine.

The first call to lpfc_reinit_vmid is in lpfc_cmpl_els_flogi.  Then
lpfc_cmpl_els_flogi_fabric calls lpfc_register_new_vport, which calls
lpfc_cmpl_reg_new_vport when the mbox command completes and calls
lpfc_reinit_vmid a second time.

Fix by moving the vmid_flag clear outside of the lpfc_reinit_vmid routine
so that vmid_flag is only cleared once upon FLOGI completion.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
---
 drivers/scsi/lpfc/lpfc_els.c  | 4 +++-
 drivers/scsi/lpfc/lpfc_vmid.c | 1 -
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
index 50c0c0c91fdc..6d49e23f6a62 100644
--- a/drivers/scsi/lpfc/lpfc_els.c
+++ b/drivers/scsi/lpfc/lpfc_els.c
@@ -1099,8 +1099,10 @@ lpfc_cmpl_els_flogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
 			 sp->cmn.priority_tagging, kref_read(&ndlp->kref));
 
 	/* reinitialize the VMID datastructure before returning */
-	if (lpfc_is_vmid_enabled(phba))
+	if (lpfc_is_vmid_enabled(phba)) {
 		lpfc_reinit_vmid(vport);
+		vport->vmid_flag = 0;
+	}
 	if (sp->cmn.priority_tagging)
 		vport->phba->pport->vmid_flag |= (LPFC_VMID_ISSUE_QFPA |
 						  LPFC_VMID_TYPE_PRIO);
diff --git a/drivers/scsi/lpfc/lpfc_vmid.c b/drivers/scsi/lpfc/lpfc_vmid.c
index 773e02ae20c3..cf8ba840d0ea 100644
--- a/drivers/scsi/lpfc/lpfc_vmid.c
+++ b/drivers/scsi/lpfc/lpfc_vmid.c
@@ -321,6 +321,5 @@ lpfc_reinit_vmid(struct lpfc_vport *vport)
 	if (!hash_empty(vport->hash_table))
 		hash_for_each_safe(vport->hash_table, bucket, tmp, cur, hnode)
 			hash_del(&cur->hnode);
-	vport->vmid_flag = 0;
 	write_unlock(&vport->vmid_lock);
 }
-- 
2.38.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 5/8] lpfc: Fix unsolicited FLOGI kref imbalance when in direct attached topology
  2024-07-26 23:15 [PATCH 0/8] Update lpfc to revision 14.4.0.4 Justin Tee
                   ` (3 preceding siblings ...)
  2024-07-26 23:15 ` [PATCH 4/8] lpfc: Fix unintentional double clearing of vmid_flag Justin Tee
@ 2024-07-26 23:15 ` Justin Tee
  2024-07-26 23:15 ` [PATCH 6/8] lpfc: Update PRLO handling " Justin Tee
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Justin Tee @ 2024-07-26 23:15 UTC (permalink / raw)
  To: linux-scsi; +Cc: jsmart2021, justin.tee, Justin Tee

In direct attached topology, certain target vendors that are quick to issue
FLOGI followed by a cable pull for more than dev_loss_tmo may result in a
kref imbalance for the remote port ndlp object.

Add an nlp_get when the defer_flogi_acc flag is set.  This is expected to
balance the nlp_put in the defer_flogi_acc clause in the
lpfc_issue_els_flogi routine.  Because we need to retain the ndlp ptr,
reorganize all of the defer_flogi_acc information into one
lpfc_defer_flogi_acc struct.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
---
 drivers/scsi/lpfc/lpfc.h         | 12 ++++++---
 drivers/scsi/lpfc/lpfc_els.c     | 46 +++++++++++++++++++-------------
 drivers/scsi/lpfc/lpfc_hbadisc.c | 11 ++++++--
 3 files changed, 46 insertions(+), 23 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
index 7c147d6ea8a8..e5a9c5a323f8 100644
--- a/drivers/scsi/lpfc/lpfc.h
+++ b/drivers/scsi/lpfc/lpfc.h
@@ -306,6 +306,14 @@ struct lpfc_stats {
 
 struct lpfc_hba;
 
+/* Data structure to keep withheld FLOGI_ACC information */
+struct lpfc_defer_flogi_acc {
+	bool flag;
+	u16 rx_id;
+	u16 ox_id;
+	struct lpfc_nodelist *ndlp;
+
+};
 
 #define LPFC_VMID_TIMER   300	/* timer interval in seconds */
 
@@ -1430,9 +1438,7 @@ struct lpfc_hba {
 	uint16_t vlan_id;
 	struct list_head fcf_conn_rec_list;
 
-	bool defer_flogi_acc_flag;
-	uint16_t defer_flogi_acc_rx_id;
-	uint16_t defer_flogi_acc_ox_id;
+	struct lpfc_defer_flogi_acc defer_flogi_acc;
 
 	spinlock_t ct_ev_lock; /* synchronize access to ct_ev_waiters */
 	struct list_head ct_ev_waiters;
diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
index 6d49e23f6a62..b5a8d050419a 100644
--- a/drivers/scsi/lpfc/lpfc_els.c
+++ b/drivers/scsi/lpfc/lpfc_els.c
@@ -1392,7 +1392,7 @@ lpfc_issue_els_flogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
 	phba->link_flag &= ~LS_EXTERNAL_LOOPBACK;
 
 	/* Check for a deferred FLOGI ACC condition */
-	if (phba->defer_flogi_acc_flag) {
+	if (phba->defer_flogi_acc.flag) {
 		/* lookup ndlp for received FLOGI */
 		ndlp = lpfc_findnode_did(vport, 0);
 		if (!ndlp)
@@ -1406,34 +1406,38 @@ lpfc_issue_els_flogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
 		if (phba->sli_rev == LPFC_SLI_REV4) {
 			bf_set(wqe_ctxt_tag,
 			       &defer_flogi_acc.wqe.xmit_els_rsp.wqe_com,
-			       phba->defer_flogi_acc_rx_id);
+			       phba->defer_flogi_acc.rx_id);
 			bf_set(wqe_rcvoxid,
 			       &defer_flogi_acc.wqe.xmit_els_rsp.wqe_com,
-			       phba->defer_flogi_acc_ox_id);
+			       phba->defer_flogi_acc.ox_id);
 		} else {
 			icmd = &defer_flogi_acc.iocb;
-			icmd->ulpContext = phba->defer_flogi_acc_rx_id;
+			icmd->ulpContext = phba->defer_flogi_acc.rx_id;
 			icmd->unsli3.rcvsli3.ox_id =
-				phba->defer_flogi_acc_ox_id;
+				phba->defer_flogi_acc.ox_id;
 		}
 
 		lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
 				 "3354 Xmit deferred FLOGI ACC: rx_id: x%x,"
 				 " ox_id: x%x, hba_flag x%lx\n",
-				 phba->defer_flogi_acc_rx_id,
-				 phba->defer_flogi_acc_ox_id, phba->hba_flag);
+				 phba->defer_flogi_acc.rx_id,
+				 phba->defer_flogi_acc.ox_id, phba->hba_flag);
 
 		/* Send deferred FLOGI ACC */
 		lpfc_els_rsp_acc(vport, ELS_CMD_FLOGI, &defer_flogi_acc,
 				 ndlp, NULL);
 
-		phba->defer_flogi_acc_flag = false;
-		vport->fc_myDID = did;
+		phba->defer_flogi_acc.flag = false;
 
-		/* Decrement ndlp reference count to indicate the node can be
-		 * released when other references are removed.
+		/* Decrement the held ndlp that was incremented when the
+		 * deferred flogi acc flag was set.
 		 */
-		lpfc_nlp_put(ndlp);
+		if (phba->defer_flogi_acc.ndlp) {
+			lpfc_nlp_put(phba->defer_flogi_acc.ndlp);
+			phba->defer_flogi_acc.ndlp = NULL;
+		}
+
+		vport->fc_myDID = did;
 	}
 
 	return 0;
@@ -8456,9 +8460,9 @@ lpfc_els_rcv_flogi(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
 
 	/* Defer ACC response until AFTER we issue a FLOGI */
 	if (!test_bit(HBA_FLOGI_ISSUED, &phba->hba_flag)) {
-		phba->defer_flogi_acc_rx_id = bf_get(wqe_ctxt_tag,
+		phba->defer_flogi_acc.rx_id = bf_get(wqe_ctxt_tag,
 						     &wqe->xmit_els_rsp.wqe_com);
-		phba->defer_flogi_acc_ox_id = bf_get(wqe_rcvoxid,
+		phba->defer_flogi_acc.ox_id = bf_get(wqe_rcvoxid,
 						     &wqe->xmit_els_rsp.wqe_com);
 
 		vport->fc_myDID = did;
@@ -8466,11 +8470,17 @@ lpfc_els_rcv_flogi(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
 		lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
 				 "3344 Deferring FLOGI ACC: rx_id: x%x,"
 				 " ox_id: x%x, hba_flag x%lx\n",
-				 phba->defer_flogi_acc_rx_id,
-				 phba->defer_flogi_acc_ox_id, phba->hba_flag);
+				 phba->defer_flogi_acc.rx_id,
+				 phba->defer_flogi_acc.ox_id, phba->hba_flag);
 
-		phba->defer_flogi_acc_flag = true;
+		phba->defer_flogi_acc.flag = true;
 
+		/* This nlp_get is paired with nlp_puts that reset the
+		 * defer_flogi_acc.flag back to false.  We need to retain
+		 * a kref on the ndlp until the deferred FLOGI ACC is
+		 * processed or cancelled.
+		 */
+		phba->defer_flogi_acc.ndlp = lpfc_nlp_get(ndlp);
 		return 0;
 	}
 
@@ -10506,7 +10516,7 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
 
 		lpfc_els_rcv_flogi(vport, elsiocb, ndlp);
 		/* retain node if our response is deferred */
-		if (phba->defer_flogi_acc_flag)
+		if (phba->defer_flogi_acc.flag)
 			break;
 		if (newnode)
 			lpfc_disc_state_machine(vport, ndlp, NULL,
diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c
index f21c5993e8d7..35c9181c6608 100644
--- a/drivers/scsi/lpfc/lpfc_hbadisc.c
+++ b/drivers/scsi/lpfc/lpfc_hbadisc.c
@@ -1255,7 +1255,14 @@ lpfc_linkdown(struct lpfc_hba *phba)
 	lpfc_scsi_dev_block(phba);
 	offline = pci_channel_offline(phba->pcidev);
 
-	phba->defer_flogi_acc_flag = false;
+	/* Decrement the held ndlp if there is a deferred flogi acc */
+	if (phba->defer_flogi_acc.flag) {
+		if (phba->defer_flogi_acc.ndlp) {
+			lpfc_nlp_put(phba->defer_flogi_acc.ndlp);
+			phba->defer_flogi_acc.ndlp = NULL;
+		}
+	}
+	phba->defer_flogi_acc.flag = false;
 
 	/* Clear external loopback plug detected flag */
 	phba->link_flag &= ~LS_EXTERNAL_LOOPBACK;
@@ -1377,7 +1384,7 @@ lpfc_linkup_port(struct lpfc_vport *vport)
 		(vport != phba->pport))
 		return;
 
-	if (phba->defer_flogi_acc_flag) {
+	if (phba->defer_flogi_acc.flag) {
 		clear_bit(FC_ABORT_DISCOVERY, &vport->fc_flag);
 		clear_bit(FC_RSCN_MODE, &vport->fc_flag);
 		clear_bit(FC_NLP_MORE, &vport->fc_flag);
-- 
2.38.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 6/8] lpfc: Update PRLO handling in direct attached topology
  2024-07-26 23:15 [PATCH 0/8] Update lpfc to revision 14.4.0.4 Justin Tee
                   ` (4 preceding siblings ...)
  2024-07-26 23:15 ` [PATCH 5/8] lpfc: Fix unsolicited FLOGI kref imbalance when in direct attached topology Justin Tee
@ 2024-07-26 23:15 ` Justin Tee
  2024-07-26 23:15 ` [PATCH 7/8] lpfc: Update lpfc version to 14.4.0.4 Justin Tee
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Justin Tee @ 2024-07-26 23:15 UTC (permalink / raw)
  To: linux-scsi; +Cc: jsmart2021, justin.tee, Justin Tee

A kref imbalance occurs when handling an unsolicited PRLO in direct
attached topology.

Rework PRLO rcv handling when in MAPPED state.  Save the state that we were
handling a PRLO by setting nlp_last_elscmd to ELS_CMD_PRLO.  Then in the
lpfc_cmpl_els_logo_acc completion routine, manually restart discovery.  By
issuing the PLOGI, which nlp_gets, before nlp_put at the end of the
lpfc_cmpl_els_logo_acc routine, we are saving us from a final nlp_put.
And, we are still allowing the unreg_rpi to happen.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
---
 drivers/scsi/lpfc/lpfc_els.c       | 27 ++++++++++++++++-----------
 drivers/scsi/lpfc/lpfc_nportdisc.c | 22 ++++++++++++++++++++--
 2 files changed, 36 insertions(+), 13 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
index b5a8d050419a..de0ec945d2f1 100644
--- a/drivers/scsi/lpfc/lpfc_els.c
+++ b/drivers/scsi/lpfc/lpfc_els.c
@@ -5246,9 +5246,10 @@ lpfc_cmpl_els_logo_acc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
 	/* ACC to LOGO completes to NPort <nlp_DID> */
 	lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
 			 "0109 ACC to LOGO completes to NPort x%x refcnt %d "
-			 "Data: x%x x%x x%x\n",
-			 ndlp->nlp_DID, kref_read(&ndlp->kref), ndlp->nlp_flag,
-			 ndlp->nlp_state, ndlp->nlp_rpi);
+			 "last els x%x Data: x%x x%x x%x\n",
+			 ndlp->nlp_DID, kref_read(&ndlp->kref),
+			 ndlp->nlp_last_elscmd, ndlp->nlp_flag, ndlp->nlp_state,
+			 ndlp->nlp_rpi);
 
 	/* This clause allows the LOGO ACC to complete and free resources
 	 * for the Fabric Domain Controller.  It does deliberately skip
@@ -5260,18 +5261,22 @@ lpfc_cmpl_els_logo_acc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
 		goto out;
 
 	if (ndlp->nlp_state == NLP_STE_NPR_NODE) {
-		/* If PLOGI is being retried, PLOGI completion will cleanup the
-		 * node. The NLP_NPR_2B_DISC flag needs to be retained to make
-		 * progress on nodes discovered from last RSCN.
-		 */
-		if ((ndlp->nlp_flag & NLP_DELAY_TMO) &&
-		    (ndlp->nlp_last_elscmd == ELS_CMD_PLOGI))
-			goto out;
-
 		if (ndlp->nlp_flag & NLP_RPI_REGISTERED)
 			lpfc_unreg_rpi(vport, ndlp);
 
+		/* If came from PRLO, then PRLO_ACC is done.
+		 * Start rediscovery now.
+		 */
+		if (ndlp->nlp_last_elscmd == ELS_CMD_PRLO) {
+			spin_lock_irq(&ndlp->lock);
+			ndlp->nlp_flag |= NLP_NPR_2B_DISC;
+			spin_unlock_irq(&ndlp->lock);
+			ndlp->nlp_prev_state = ndlp->nlp_state;
+			lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE);
+			lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0);
+		}
 	}
+
  out:
 	/*
 	 * The driver received a LOGO from the rport and has ACK'd it.
diff --git a/drivers/scsi/lpfc/lpfc_nportdisc.c b/drivers/scsi/lpfc/lpfc_nportdisc.c
index f6a53446e57f..4574716c8764 100644
--- a/drivers/scsi/lpfc/lpfc_nportdisc.c
+++ b/drivers/scsi/lpfc/lpfc_nportdisc.c
@@ -2652,8 +2652,26 @@ lpfc_rcv_prlo_mapped_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
 	/* flush the target */
 	lpfc_sli_abort_iocb(vport, ndlp->nlp_sid, 0, LPFC_CTX_TGT);
 
-	/* Treat like rcv logo */
-	lpfc_rcv_logo(vport, ndlp, cmdiocb, ELS_CMD_PRLO);
+	/* Send PRLO_ACC */
+	spin_lock_irq(&ndlp->lock);
+	ndlp->nlp_flag |= NLP_LOGO_ACC;
+	spin_unlock_irq(&ndlp->lock);
+	lpfc_els_rsp_acc(vport, ELS_CMD_PRLO, cmdiocb, ndlp, NULL);
+
+	/* Save ELS_CMD_PRLO as the last elscmd and then set to NPR.
+	 * lpfc_cmpl_els_logo_acc is expected to restart discovery.
+	 */
+	ndlp->nlp_last_elscmd = ELS_CMD_PRLO;
+	ndlp->nlp_prev_state = ndlp->nlp_state;
+
+	lpfc_printf_vlog(vport, KERN_INFO, LOG_NODE | LOG_ELS | LOG_DISCOVERY,
+			 "3422 DID x%06x nflag x%x lastels x%x ref cnt %u\n",
+			 ndlp->nlp_DID, ndlp->nlp_flag,
+			 ndlp->nlp_last_elscmd,
+			 kref_read(&ndlp->kref));
+
+	lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
+
 	return ndlp->nlp_state;
 }
 
-- 
2.38.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 7/8] lpfc: Update lpfc version to 14.4.0.4
  2024-07-26 23:15 [PATCH 0/8] Update lpfc to revision 14.4.0.4 Justin Tee
                   ` (5 preceding siblings ...)
  2024-07-26 23:15 ` [PATCH 6/8] lpfc: Update PRLO handling " Justin Tee
@ 2024-07-26 23:15 ` Justin Tee
  2024-07-26 23:15 ` [PATCH 8/8] lpfc: Copyright updates for 14.4.0.4 patches Justin Tee
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Justin Tee @ 2024-07-26 23:15 UTC (permalink / raw)
  To: linux-scsi; +Cc: jsmart2021, justin.tee, Justin Tee

Update lpfc version to 14.4.0.4

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
---
 drivers/scsi/lpfc/lpfc_version.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/lpfc/lpfc_version.h b/drivers/scsi/lpfc/lpfc_version.h
index 7ac9ef281881..2fe0386a1fee 100644
--- a/drivers/scsi/lpfc/lpfc_version.h
+++ b/drivers/scsi/lpfc/lpfc_version.h
@@ -20,7 +20,7 @@
  * included with this package.                                     *
  *******************************************************************/
 
-#define LPFC_DRIVER_VERSION "14.4.0.3"
+#define LPFC_DRIVER_VERSION "14.4.0.4"
 #define LPFC_DRIVER_NAME		"lpfc"
 
 /* Used for SLI 2/3 */
-- 
2.38.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 8/8] lpfc: Copyright updates for 14.4.0.4 patches
  2024-07-26 23:15 [PATCH 0/8] Update lpfc to revision 14.4.0.4 Justin Tee
                   ` (6 preceding siblings ...)
  2024-07-26 23:15 ` [PATCH 7/8] lpfc: Update lpfc version to 14.4.0.4 Justin Tee
@ 2024-07-26 23:15 ` Justin Tee
  2024-08-03  1:50 ` [PATCH 0/8] Update lpfc to revision 14.4.0.4 Martin K. Petersen
  2024-08-05 21:17 ` Martin K. Petersen
  9 siblings, 0 replies; 11+ messages in thread
From: Justin Tee @ 2024-07-26 23:15 UTC (permalink / raw)
  To: linux-scsi; +Cc: jsmart2021, justin.tee, Justin Tee

Update copyrights to 2024 for files modified in the 14.4.0.4 patch set.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
---
 drivers/scsi/lpfc/lpfc_vmid.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/lpfc/lpfc_vmid.c b/drivers/scsi/lpfc/lpfc_vmid.c
index cf8ba840d0ea..cc3e4736f2fe 100644
--- a/drivers/scsi/lpfc/lpfc_vmid.c
+++ b/drivers/scsi/lpfc/lpfc_vmid.c
@@ -1,7 +1,7 @@
 /*******************************************************************
  * This file is part of the Emulex Linux Device Driver for         *
  * Fibre Channel Host Bus Adapters.                                *
- * Copyright (C) 2017-2023 Broadcom. All Rights Reserved. The term *
+ * Copyright (C) 2017-2024 Broadcom. All Rights Reserved. The term *
  * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.     *
  * Copyright (C) 2004-2016 Emulex.  All rights reserved.           *
  * EMULEX and SLI are trademarks of Emulex.                        *
-- 
2.38.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH 0/8] Update lpfc to revision 14.4.0.4
  2024-07-26 23:15 [PATCH 0/8] Update lpfc to revision 14.4.0.4 Justin Tee
                   ` (7 preceding siblings ...)
  2024-07-26 23:15 ` [PATCH 8/8] lpfc: Copyright updates for 14.4.0.4 patches Justin Tee
@ 2024-08-03  1:50 ` Martin K. Petersen
  2024-08-05 21:17 ` Martin K. Petersen
  9 siblings, 0 replies; 11+ messages in thread
From: Martin K. Petersen @ 2024-08-03  1:50 UTC (permalink / raw)
  To: Justin Tee; +Cc: linux-scsi, jsmart2021, justin.tee


Justin,

> Update lpfc to revision 14.4.0.4

Applied to 6.12/scsi-staging, thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 0/8] Update lpfc to revision 14.4.0.4
  2024-07-26 23:15 [PATCH 0/8] Update lpfc to revision 14.4.0.4 Justin Tee
                   ` (8 preceding siblings ...)
  2024-08-03  1:50 ` [PATCH 0/8] Update lpfc to revision 14.4.0.4 Martin K. Petersen
@ 2024-08-05 21:17 ` Martin K. Petersen
  9 siblings, 0 replies; 11+ messages in thread
From: Martin K. Petersen @ 2024-08-05 21:17 UTC (permalink / raw)
  To: linux-scsi, Justin Tee; +Cc: Martin K . Petersen, jsmart2021, justin.tee

On Fri, 26 Jul 2024 16:15:04 -0700, Justin Tee wrote:

> Update lpfc to revision 14.4.0.4
> 
> This patch set contains diagnostic logging improvements, a minor clean up
> when submitting abort requests, a bug fix related to reset and errata
> paths, and modifications to FLOGI and PRLO ELS command handling.
> 
> The patches were cut against Martin's 6.11/scsi-queue tree.
> 
> [...]

Applied to 6.12/scsi-queue, thanks!

[1/8] lpfc: Change diagnostic log flag during receipt of unknown ELS cmds
      https://git.kernel.org/mkp/scsi/c/5b8963c53de1
[2/8] lpfc: Remove redundant vport assignment when building an abort request
      https://git.kernel.org/mkp/scsi/c/f1bfe3207396
[3/8] lpfc: Validate hdwq pointers before dereferencing in reset/errata paths
      https://git.kernel.org/mkp/scsi/c/2be1d4f11944
[4/8] lpfc: Fix unintentional double clearing of vmid_flag
      https://git.kernel.org/mkp/scsi/c/3976beb1b410
[5/8] lpfc: Fix unsolicited FLOGI kref imbalance when in direct attached topology
      https://git.kernel.org/mkp/scsi/c/b5c18c9dd138
[6/8] lpfc: Update PRLO handling in direct attached topology
      https://git.kernel.org/mkp/scsi/c/1f0f7679ad89
[7/8] lpfc: Update lpfc version to 14.4.0.4
      https://git.kernel.org/mkp/scsi/c/62b52495e6a1
[8/8] lpfc: Copyright updates for 14.4.0.4 patches
      https://git.kernel.org/mkp/scsi/c/5b247f03779d

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2024-08-05 21:18 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-26 23:15 [PATCH 0/8] Update lpfc to revision 14.4.0.4 Justin Tee
2024-07-26 23:15 ` [PATCH 1/8] lpfc: Change diagnostic log flag during receipt of unknown ELS cmds Justin Tee
2024-07-26 23:15 ` [PATCH 2/8] lpfc: Remove redundant vport assignment when building an abort request Justin Tee
2024-07-26 23:15 ` [PATCH 3/8] lpfc: Validate hdwq pointers before dereferencing in reset/errata paths Justin Tee
2024-07-26 23:15 ` [PATCH 4/8] lpfc: Fix unintentional double clearing of vmid_flag Justin Tee
2024-07-26 23:15 ` [PATCH 5/8] lpfc: Fix unsolicited FLOGI kref imbalance when in direct attached topology Justin Tee
2024-07-26 23:15 ` [PATCH 6/8] lpfc: Update PRLO handling " Justin Tee
2024-07-26 23:15 ` [PATCH 7/8] lpfc: Update lpfc version to 14.4.0.4 Justin Tee
2024-07-26 23:15 ` [PATCH 8/8] lpfc: Copyright updates for 14.4.0.4 patches Justin Tee
2024-08-03  1:50 ` [PATCH 0/8] Update lpfc to revision 14.4.0.4 Martin K. Petersen
2024-08-05 21:17 ` Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox