Skip to contentSkip to conversation

Update lpfc to revision 14.4.0.4

PATCH Applied Justin Tee 2 participants 11 messages Jul 26, 2024 – Aug 5, 2024

Subsystems (2)
lore
Share & tools
lore

Justin Tee

author
#0 lore raw

cover Update lpfc to revision 14.4.0.4

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(-)
Signature · 1 line
2.38.0
author
#1 lore raw

PATCH 1/8 lpfc: Change diagnostic log flag during receipt of unknown ELS cmds

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.

---
 drivers/scsi/lpfc/lpfc_els.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/lpfc/lpfc_els.c +1 -1
index 929cbfc95163..50c0c0c91fdc 100644
@@ -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)
Signature · 1 line
2.38.0
author
#2 lore raw

PATCH 2/8 lpfc: Remove redundant vport assignment when building an abort request

In reply to 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.

---
 drivers/scsi/lpfc/lpfc_sli.c | 2 --
 1 file changed, 2 deletions(-)
drivers/scsi/lpfc/lpfc_sli.c +0 -2
index 88debef2fb6d..d240bbded4c8 100644
@@ -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)
Signature · 1 line
2.38.0
author
#3 lore raw

PATCH 3/8 lpfc: Validate hdwq pointers before dereferencing in reset/errata paths

In reply to 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.

---
 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(-)
drivers/scsi/lpfc/lpfc_hbadisc.c +2 -1
index 6943f6c6395c..f21c5993e8d7 100644
@@ -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;
 
drivers/scsi/lpfc/lpfc_scsi.c +11 -2
index 98ce9d97a225..60cd60ebff38 100644
@@ -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 */
drivers/scsi/lpfc/lpfc_sli.c +11 -0
index d240bbded4c8..332b8d2348e9 100644
@@ -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);
Signature · 1 line
2.38.0
author
#4 lore raw

PATCH 4/8 lpfc: Fix unintentional double clearing of vmid_flag

In reply to 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.

---
 drivers/scsi/lpfc/lpfc_els.c  | 4 +++-
 drivers/scsi/lpfc/lpfc_vmid.c | 1 -
 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/scsi/lpfc/lpfc_els.c +3 -1
index 50c0c0c91fdc..6d49e23f6a62 100644
@@ -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);
drivers/scsi/lpfc/lpfc_vmid.c +0 -1
index 773e02ae20c3..cf8ba840d0ea 100644
@@ -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);
 }
Signature · 1 line
2.38.0
author
#5 lore raw

PATCH 5/8 lpfc: Fix unsolicited FLOGI kref imbalance when in direct attached topology

In reply to 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.

---
 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(-)
drivers/scsi/lpfc/lpfc.h +9 -3
index 7c147d6ea8a8..e5a9c5a323f8 100644
@@ -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;
drivers/scsi/lpfc/lpfc_els.c +28 -18

96 lines not on this page · raw message

drivers/scsi/lpfc/lpfc_hbadisc.c +9 -2
index f21c5993e8d7..35c9181c6608 100644
@@ -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);
Signature · 1 line
2.38.0
author
#6 lore raw

PATCH 6/8 lpfc: Update PRLO handling in direct attached topology

In reply to 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.

---
 drivers/scsi/lpfc/lpfc_els.c       | 27 ++++++++++++++++-----------
 drivers/scsi/lpfc/lpfc_nportdisc.c | 22 ++++++++++++++++++++--
 2 files changed, 36 insertions(+), 13 deletions(-)
drivers/scsi/lpfc/lpfc_els.c +16 -11
index b5a8d050419a..de0ec945d2f1 100644
@@ -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.
drivers/scsi/lpfc/lpfc_nportdisc.c +20 -2
index f6a53446e57f..4574716c8764 100644
@@ -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;
 }
 
Signature · 1 line
2.38.0
author
#7 lore raw

PATCH 7/8 lpfc: Update lpfc version to 14.4.0.4

In reply to Justin Tee

Update lpfc version to 14.4.0.4

---
 drivers/scsi/lpfc/lpfc_version.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/lpfc/lpfc_version.h +1 -1
index 7ac9ef281881..2fe0386a1fee 100644
@@ -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 */
Signature · 1 line
2.38.0
author
#8 lore raw

PATCH 8/8 lpfc: Copyright updates for 14.4.0.4 patches

In reply to Justin Tee

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

---
 drivers/scsi/lpfc/lpfc_vmid.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/lpfc/lpfc_vmid.c +1 -1
index cf8ba840d0ea..cc3e4736f2fe 100644
@@ -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.                        *
Signature · 1 line
2.38.0
#10 lore raw
In reply to Justin Tee
Quoted 9 lines · 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.

[...]

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
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering