Skip to contentSkip to conversation

lpfc: Update lpfc to revision 14.2.0.10

PATCH Applied Justin Tee 2 participants 15 messages Jan 9, 2023 – Jan 14, 2023

Subsystems (2)
lore
Share & tools
lore

Justin Tee

author
#0 lore raw

cover lpfc: Update lpfc to revision 14.2.0.10

Update lpfc to revision 14.2.0.10

This patch set contains fixes for bugs, kernel test robot, and introduces new attention type event handling.

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

Justin Tee (12):
lpfc: Fix space indentation in lpfc_xcvr_data
lpfc: Replace outdated strncpy with strscpy
lpfc: Resolve miscellaneous variable set but not used compiler
warnings
lpfc: Set max dma segment size to hba supported SGE length
lpfc: Remove redundant clean up code in disable_vport
lpfc: Remove duplicate ndlp kref decrement in lpfc_cleanup_rpis
lpfc: Exit PRLI completion handling early if ndlp not in PRLI_ISSUE
state
lpfc: Fix use-after-free KFENCE violation during sysfs firmware write
lpfc: Reinitialize internal VMID data structures after FLOGI
completion
lpfc: Introduce new attention types for lpfc_sli4_async_fc_evt hdlr
lpfc: Update lpfc version to 14.2.0.10
Copyright updates for 14.2.0.10 patches

 drivers/scsi/lpfc/lpfc.h         |  4 +-
 drivers/scsi/lpfc/lpfc_attr.c    | 63 +++++++++------------
 drivers/scsi/lpfc/lpfc_crtn.h    |  4 +-
 drivers/scsi/lpfc/lpfc_els.c     | 33 ++++++++++-
 drivers/scsi/lpfc/lpfc_hbadisc.c | 17 +-----
 drivers/scsi/lpfc/lpfc_hw4.h     |  7 ++-
 drivers/scsi/lpfc/lpfc_init.c    | 94 ++++++++++++++++++++++++++------
 drivers/scsi/lpfc/lpfc_scsi.c    |  8 +--
 drivers/scsi/lpfc/lpfc_sli.c     | 83 ++++++++++++++--------------
 drivers/scsi/lpfc/lpfc_sli4.h    |  5 +-
 drivers/scsi/lpfc/lpfc_version.h |  6 +-
 drivers/scsi/lpfc/lpfc_vmid.c    | 41 +++++++++++++-
 drivers/scsi/lpfc/lpfc_vport.c   | 16 +-----
 13 files changed, 238 insertions(+), 143 deletions(-)
Signature · 1 line
2.38.0
author
#1 lore raw

PATCH 1/12 lpfc: Fix space indentation in lpfc_xcvr_data

The kernel test robot detected inconsistent indentations for an if statement block in the lpfc_xcvr_data_show routine.

This patch reduces the extraneous tabs used for the if statement block in question.

---
 drivers/scsi/lpfc/lpfc_attr.c | 46 +++++++++++++++--------------------
 1 file changed, 19 insertions(+), 27 deletions(-)
drivers/scsi/lpfc/lpfc_attr.c +19 -27
index 77e1b2911cb4..9df90c0ab44d 100644
@@ -1941,33 +1941,25 @@ lpfc_xcvr_data_show(struct device *dev, struct device_attribute *attr,
 			&rdp_context->page_a0[SSF_TRANSCEIVER_CODE_B7];
 
 	len += scnprintf(buf + len, PAGE_SIZE - len, "Speeds: \t");
-		if (*(uint8_t *)trasn_code_byte7 == 0) {
-			len += scnprintf(buf + len, PAGE_SIZE - len,
-					 "Unknown\n");
-		} else {
-			if (trasn_code_byte7->fc_sp_100MB)
-				len += scnprintf(buf + len, PAGE_SIZE - len,
-						 "1 ");
-			if (trasn_code_byte7->fc_sp_200mb)
-				len += scnprintf(buf + len, PAGE_SIZE - len,
-						 "2 ");
-			if (trasn_code_byte7->fc_sp_400MB)
-				len += scnprintf(buf + len, PAGE_SIZE - len,
-						 "4 ");
-			if (trasn_code_byte7->fc_sp_800MB)
-				len += scnprintf(buf + len, PAGE_SIZE - len,
-						 "8 ");
-			if (trasn_code_byte7->fc_sp_1600MB)
-				len += scnprintf(buf + len, PAGE_SIZE - len,
-						 "16 ");
-			if (trasn_code_byte7->fc_sp_3200MB)
-				len += scnprintf(buf + len, PAGE_SIZE - len,
-						 "32 ");
-			if (trasn_code_byte7->speed_chk_ecc)
-				len += scnprintf(buf + len, PAGE_SIZE - len,
-						 "64 ");
-			len += scnprintf(buf + len, PAGE_SIZE - len, "GB\n");
-		}
+	if (*(uint8_t *)trasn_code_byte7 == 0) {
+		len += scnprintf(buf + len, PAGE_SIZE - len, "Unknown\n");
+	} else {
+		if (trasn_code_byte7->fc_sp_100MB)
+			len += scnprintf(buf + len, PAGE_SIZE - len, "1 ");
+		if (trasn_code_byte7->fc_sp_200mb)
+			len += scnprintf(buf + len, PAGE_SIZE - len, "2 ");
+		if (trasn_code_byte7->fc_sp_400MB)
+			len += scnprintf(buf + len, PAGE_SIZE - len, "4 ");
+		if (trasn_code_byte7->fc_sp_800MB)
+			len += scnprintf(buf + len, PAGE_SIZE - len, "8 ");
+		if (trasn_code_byte7->fc_sp_1600MB)
+			len += scnprintf(buf + len, PAGE_SIZE - len, "16 ");
+		if (trasn_code_byte7->fc_sp_3200MB)
+			len += scnprintf(buf + len, PAGE_SIZE - len, "32 ");
+		if (trasn_code_byte7->speed_chk_ecc)
+			len += scnprintf(buf + len, PAGE_SIZE - len, "64 ");
+		len += scnprintf(buf + len, PAGE_SIZE - len, "GB\n");
+	}
 	temperature = (rdp_context->page_a2[SFF_TEMPERATURE_B1] << 8 |
 		       rdp_context->page_a2[SFF_TEMPERATURE_B0]);
 	vcc = (rdp_context->page_a2[SFF_VCC_B1] << 8 |
Signature · 1 line
2.38.0
author
#2 lore raw

PATCH 2/12 lpfc: Replace outdated strncpy with strscpy

In reply to Justin Tee

The kernel test robot pointed out non-NULL terminated string possibilities when using strncpy in lpfc_xcvr_data_show routine. Although we manually set the NULL character after strncpy, strncpy usage is outdated.

Replace all strncpy usages with the preferred strscpy API.

---
 drivers/scsi/lpfc/lpfc_attr.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)
drivers/scsi/lpfc/lpfc_attr.c +5 -10
index 9df90c0ab44d..c95401225057 100644
@@ -1905,8 +1905,7 @@ lpfc_xcvr_data_show(struct device *dev, struct device_attribute *attr,
 		goto out_free_rdp;
 	}
 
-	strncpy(chbuf, &rdp_context->page_a0[SSF_VENDOR_NAME], 16);
-	chbuf[16] = 0;
+	strscpy(chbuf, &rdp_context->page_a0[SSF_VENDOR_NAME], 16);
 
 	len = scnprintf(buf, PAGE_SIZE - len, "VendorName:\t%s\n", chbuf);
 	len += scnprintf(buf + len, PAGE_SIZE - len,
@@ -1914,17 +1913,13 @@ lpfc_xcvr_data_show(struct device *dev, struct device_attribute *attr,
 			 (uint8_t)rdp_context->page_a0[SSF_VENDOR_OUI],
 			 (uint8_t)rdp_context->page_a0[SSF_VENDOR_OUI + 1],
 			 (uint8_t)rdp_context->page_a0[SSF_VENDOR_OUI + 2]);
-	strncpy(chbuf, &rdp_context->page_a0[SSF_VENDOR_PN], 16);
-	chbuf[16] = 0;
+	strscpy(chbuf, &rdp_context->page_a0[SSF_VENDOR_PN], 16);
 	len += scnprintf(buf + len, PAGE_SIZE - len, "VendorPN:\t%s\n", chbuf);
-	strncpy(chbuf, &rdp_context->page_a0[SSF_VENDOR_SN], 16);
-	chbuf[16] = 0;
+	strscpy(chbuf, &rdp_context->page_a0[SSF_VENDOR_SN], 16);
 	len += scnprintf(buf + len, PAGE_SIZE - len, "VendorSN:\t%s\n", chbuf);
-	strncpy(chbuf, &rdp_context->page_a0[SSF_VENDOR_REV], 4);
-	chbuf[4] = 0;
+	strscpy(chbuf, &rdp_context->page_a0[SSF_VENDOR_REV], 4);
 	len += scnprintf(buf + len, PAGE_SIZE - len, "VendorRev:\t%s\n", chbuf);
-	strncpy(chbuf, &rdp_context->page_a0[SSF_DATE_CODE], 8);
-	chbuf[8] = 0;
+	strscpy(chbuf, &rdp_context->page_a0[SSF_DATE_CODE], 8);
 	len += scnprintf(buf + len, PAGE_SIZE - len, "DateCode:\t%s\n", chbuf);
 	len += scnprintf(buf + len, PAGE_SIZE - len, "Identifier:\t%xh\n",
 			 (uint8_t)rdp_context->page_a0[SSF_IDENTIFIER]);
Signature · 1 line
2.38.0
author
#3 lore raw

PATCH 3/12 lpfc: Resolve miscellaneous variable set but not used compiler warnings

In reply to Justin Tee

The local variables called curr_data are incremented, but not actually used for anything so they are removed.

The return value of lpfc_sli4_poll_eq is not used anywhere and is not called outside of lpfc_sli.c. Thus, its declaration is removed from lpfc_crtn.h Also, lpfc_sli4_poll_eq's path argument is not used in the routine so it is removed along with corresponding macros.

---
 drivers/scsi/lpfc/lpfc.h      |  2 --
 drivers/scsi/lpfc/lpfc_crtn.h |  1 -
 drivers/scsi/lpfc/lpfc_scsi.c |  6 ++--
 drivers/scsi/lpfc/lpfc_sli.c  | 62 ++++++++++++++++-------------------
 4 files changed, 31 insertions(+), 40 deletions(-)
drivers/scsi/lpfc/lpfc.h +0 -2
index 9ad233b40a9e..1095595ca3a2 100644
@@ -1592,8 +1592,6 @@ struct lpfc_hba {
 	struct timer_list cpuhp_poll_timer;
 	struct list_head poll_list;	/* slowpath eq polling list */
 #define LPFC_POLL_HB	1		/* slowpath heartbeat */
-#define LPFC_POLL_FASTPATH	0	/* called from fastpath */
-#define LPFC_POLL_SLOWPATH	1	/* called from slowpath */
 
 	char os_host_name[MAXHOSTNAMELEN];
 
drivers/scsi/lpfc/lpfc_crtn.h +0 -1
index 8928f016d09e..6f63e0acf9dd 100644
@@ -253,7 +253,6 @@ int lpfc_read_object(struct lpfc_hba *phba, char *s, uint32_t *datap,
 		     uint32_t len);
 
 void lpfc_sli4_cleanup_poll_list(struct lpfc_hba *phba);
-int lpfc_sli4_poll_eq(struct lpfc_queue *q, uint8_t path);
 void lpfc_sli4_poll_hbtimer(struct timer_list *t);
 void lpfc_sli4_start_polling(struct lpfc_queue *q);
 void lpfc_sli4_stop_polling(struct lpfc_queue *q);
drivers/scsi/lpfc/lpfc_scsi.c +2 -4
index 7a1563564df7..9b6580eb7ed6 100644
@@ -1689,7 +1689,7 @@ lpfc_bg_setup_bpl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc,
 	struct lpfc_pde6 *pde6 = NULL;
 	struct lpfc_pde7 *pde7 = NULL;
 	dma_addr_t dataphysaddr, protphysaddr;
-	unsigned short curr_data = 0, curr_prot = 0;
+	unsigned short curr_prot = 0;
 	unsigned int split_offset;
 	unsigned int protgroup_len, protgroup_offset = 0, protgroup_remainder;
 	unsigned int protgrp_blks, protgrp_bytes;
@@ -1858,7 +1858,6 @@ lpfc_bg_setup_bpl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc,
 			bpl->tus.w = le32_to_cpu(bpl->tus.w);
 
 			num_bde++;
-			curr_data++;
 
 			if (split_offset)
 				break;
@@ -2119,7 +2118,7 @@ lpfc_bg_setup_sgl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc,
 	struct scatterlist *sgpe = NULL; /* s/g prot entry */
 	struct sli4_sge_diseed *diseed = NULL;
 	dma_addr_t dataphysaddr, protphysaddr;
-	unsigned short curr_data = 0, curr_prot = 0;
+	unsigned short curr_prot = 0;
 	unsigned int split_offset;
 	unsigned int protgroup_len, protgroup_offset = 0, protgroup_remainder;
 	unsigned int protgrp_blks, protgrp_bytes;
@@ -2364,7 +2363,6 @@ lpfc_bg_setup_sgl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc,
 				dma_offset += dma_len;
 
 				num_sge++;
-				curr_data++;
 
 				if (split_offset) {
 					sgl++;
drivers/scsi/lpfc/lpfc_sli.c +29 -33

108 lines not on this page · raw message

Signature · 1 line
2.38.0
author
#4 lore raw

PATCH 4/12 lpfc: Set max dma segment size to hba supported SGE length

In reply to Justin Tee

During I/O, the following warning message occasionally appears.

DMA-API: lpfc 0000:04:00.0: mapping sg segment longer than device claims to support [len=131072] [max=65536]

The hba is capable of supporting 131,072 bytes, so notify DMA layer via the dma_set_max_seg_size API during hba initialization.

---
 drivers/scsi/lpfc/lpfc_init.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/scsi/lpfc/lpfc_init.c +7 -0
index 25ba20e42825..4d58373f6ab6 100644
@@ -13917,6 +13917,13 @@ lpfc_get_sli4_parameters(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
 	if (sli4_params->sge_supp_len > LPFC_MAX_SGE_SIZE)
 		sli4_params->sge_supp_len = LPFC_MAX_SGE_SIZE;
 
+	rc = dma_set_max_seg_size(&phba->pcidev->dev, sli4_params->sge_supp_len);
+	if (unlikely(rc)) {
+		lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
+				"6400 Can't set dma maximum segment size\n");
+		return rc;
+	}
+
 	/*
 	 * Check whether the adapter supports an embedded copy of the
 	 * FCP CMD IU within the WQE for FCP_Ixxx commands. In order
Signature · 1 line
2.38.0
author
#5 lore raw

PATCH 5/12 lpfc: Remove redundant clean up code in disable_vport

In reply to Justin Tee

The disable_vport path calls the discovery state machine on all ndlps, puts them into NPR state, and then calls lpfc_cleanup_rpis with the remove flag set. This unintentionally decrements an ndlp's kref twice and can result in premature release of an ndlp because lpfc_dev_loss_tmo_handler triggers clean up of the ndlp again later.

Remove redundant code in disable_vport that sets all the ndlps to NPR, and change the call to cleanup_rpis to not remove the ndlps. lpfc_dev_loss_tmo_handler will handle final removal of the ndlps.

---
 drivers/scsi/lpfc/lpfc_vport.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)
drivers/scsi/lpfc/lpfc_vport.c +2 -12
index 4d171f5c213f..5aeda245369b 100644
@@ -534,7 +534,7 @@ disable_vport(struct fc_vport *fc_vport)
 {
 	struct lpfc_vport *vport = *(struct lpfc_vport **)fc_vport->dd_data;
 	struct lpfc_hba   *phba = vport->phba;
-	struct lpfc_nodelist *ndlp = NULL, *next_ndlp = NULL;
+	struct lpfc_nodelist *ndlp = NULL;
 	struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
 
 	/* Can't disable during an outstanding delete. */
@@ -546,17 +546,7 @@ disable_vport(struct fc_vport *fc_vport)
 		(void)lpfc_send_npiv_logo(vport, ndlp);
 
 	lpfc_sli_host_down(vport);
-
-	/* Mark all nodes for discovery so we can remove them by
-	 * calling lpfc_cleanup_rpis(vport, 1)
-	 */
-	list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) {
-		if (ndlp->nlp_state == NLP_STE_UNUSED_NODE)
-			continue;
-		lpfc_disc_state_machine(vport, ndlp, NULL,
-					NLP_EVT_DEVICE_RECOVERY);
-	}
-	lpfc_cleanup_rpis(vport, 1);
+	lpfc_cleanup_rpis(vport, 0);
 
 	lpfc_stop_vport_timers(vport);
 	lpfc_unreg_all_rpis(vport);
Signature · 1 line
2.38.0
author
#6 lore raw

PATCH 6/12 lpfc: Remove duplicate ndlp kref decrement in lpfc_cleanup_rpis

In reply to Justin Tee

With faulty cables in PT2PT topology, an unintentional ndlp double kref decrement can occur.

If a FLOGI request is outstanding before the link goes down, the missing FLOGI_ACC causes an F_Port ndlp to remain in the UNUSED state. During link down, lpfc_cleanup_rpis is called and decrements an ndlp kref. Additionally, when the driver later decides to abort the FLOGI, the FLOGI completion handler decrements the ndlp kref a second time.

Remove duplicate clean up logic in lpfc_cleanup_rpis because the updated FLOGI completion handler already handles the ndlp kref decrement.

---
 drivers/scsi/lpfc/lpfc_hbadisc.c | 15 ---------------
 1 file changed, 15 deletions(-)
drivers/scsi/lpfc/lpfc_hbadisc.c +0 -15
index 80375d73b732..af0acf55b343 100644
@@ -1129,21 +1129,6 @@ lpfc_cleanup_rpis(struct lpfc_vport *vport, int remove)
 	struct lpfc_nodelist *ndlp, *next_ndlp;
 
 	list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) {
-		if (ndlp->nlp_state == NLP_STE_UNUSED_NODE) {
-			/* It's possible the FLOGI to the fabric node never
-			 * successfully completed and never registered with the
-			 * transport.  In this case there is no way to clean up
-			 * the node.
-			 */
-			if (ndlp->nlp_DID == Fabric_DID) {
-				if (ndlp->nlp_prev_state ==
-				    NLP_STE_UNUSED_NODE &&
-				    !ndlp->fc4_xpt_flags)
-					lpfc_nlp_put(ndlp);
-			}
-			continue;
-		}
-
 		if ((phba->sli3_options & LPFC_SLI3_VPORT_TEARDOWN) ||
 		    ((vport->port_type == LPFC_NPIV_PORT) &&
 		     ((ndlp->nlp_DID == NameServer_DID) ||
Signature · 1 line
2.38.0
author
#7 lore raw

PATCH 7/12 lpfc: Exit PRLI completion handling early if ndlp not in PRLI_ISSUE state

In reply to Justin Tee

In a large SAN testing configuration, frequent target port toggle tests are occasionally resulting in missing lun path rediscoveries. An outstanding PRLI can be inflight when a target RSCN dissappearance occurs, causing the driver to retry PRLIs using invalid rpi contexts.

Fix by verifying that an ndlp's state was not restarted from PRLI_ISSUE due to an intermediate RSCN. If not in a valid state, early exit PRLI completion handling.

The last follow up RSCN indicating target reappearance retriggers PLOGI/PRLI with a valid rpi context and is expected to succeed in lun path rediscovery.

---
 drivers/scsi/lpfc/lpfc_els.c | 28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)
drivers/scsi/lpfc/lpfc_els.c +26 -2
index 919741bbe267..4d3b8f2036d2 100644
@@ -2373,15 +2373,30 @@ lpfc_cmpl_els_prli(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
 		/* PRLI failed */
 		lpfc_printf_vlog(vport, mode, loglevel,
 				 "2754 PRLI failure DID:%06X Status:x%x/x%x, "
-				 "data: x%x\n",
+				 "data: x%x x%x\n",
 				 ndlp->nlp_DID, ulp_status,
-				 ulp_word4, ndlp->fc4_prli_sent);
+				 ulp_word4, ndlp->nlp_state,
+				 ndlp->fc4_prli_sent);
 
 		/* Do not call DSM for lpfc_els_abort'ed ELS cmds */
 		if (!lpfc_error_lost_link(ulp_status, ulp_word4))
 			lpfc_disc_state_machine(vport, ndlp, cmdiocb,
 						NLP_EVT_CMPL_PRLI);
 
+		/* The following condition catches an inflight transition
+		 * mismatch typically caused by an RSCN. Skip any
+		 * processing to allow recovery.
+		 */
+		if (ndlp->nlp_state >= NLP_STE_PLOGI_ISSUE &&
+		    ndlp->nlp_state <= NLP_STE_REG_LOGIN_ISSUE) {
+			lpfc_printf_vlog(vport, KERN_WARNING, LOG_NODE,
+					 "2784 PRLI cmpl: state mismatch "
+					 "DID x%06x nstate x%x nflag x%x\n",
+					 ndlp->nlp_DID, ndlp->nlp_state,
+					 ndlp->nlp_flag);
+				goto out;
+		}
+
 		/*
 		 * For P2P topology, retain the node so that PLOGI can be
 		 * attempted on it again.
@@ -4673,6 +4688,15 @@ lpfc_els_retry(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
 				/* the nameserver fails */
 				maxretry = 0;
 				delay = 100;
+			} else if (cmd == ELS_CMD_PRLI &&
+				   ndlp->nlp_state != NLP_STE_PRLI_ISSUE) {
+				/* State-command disagreement.  The PRLI was
+				 * failed with an invalid rpi meaning there
+				 * some unexpected state change.  Don't retry.
+				 */
+				maxretry = 0;
+				retry = 0;
+				break;
 			}
 			retry = 1;
 			break;
Signature · 1 line
2.38.0
author
#8 lore raw

PATCH 8/12 lpfc: Fix use-after-free KFENCE violation during sysfs firmware write

In reply to Justin Tee

During the sysfs firmware write process, a use-after-free read warning is logged from the lpfc_wr_object routine.

BUG: KFENCE: use-after-free read in lpfc_wr_object+0x235/0x310 [lpfc]
Use-after-free read at 0x0000000000cf164d (in kfence-#111):
lpfc_wr_object+0x235/0x310 [lpfc]
lpfc_write_firmware.cold+0x206/0x30d [lpfc]
lpfc_sli4_request_firmware_update+0xa6/0x100 [lpfc]
lpfc_request_firmware_upgrade_store+0x66/0xb0 [lpfc]
kernfs_fop_write_iter+0x121/0x1b0
new_sync_write+0x11c/0x1b0
vfs_write+0x1ef/0x280
ksys_write+0x5f/0xe0
do_syscall_64+0x59/0x90
entry_SYSCALL_64_after_hwframe+0x63/0xcd

The driver accessed wr_object pointer data, which was initialized into mailbox payload memory, after the mailbox object was released back to the mailbox pool.

Fix by moving the mailbox free calls to the end of the routine ensuring that we don't reference internal mailbox memory after release.

---
 drivers/scsi/lpfc/lpfc_sli.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)
drivers/scsi/lpfc/lpfc_sli.c +13 -6
index c21187c93a5f..55dfab9ae3c9 100644
@@ -20815,6 +20815,7 @@ lpfc_wr_object(struct lpfc_hba *phba, struct list_head *dmabuf_list,
 	struct lpfc_mbx_wr_object *wr_object;
 	LPFC_MBOXQ_t *mbox;
 	int rc = 0, i = 0;
+	int mbox_status = 0;
 	uint32_t shdr_status, shdr_add_status, shdr_add_status_2;
 	uint32_t shdr_change_status = 0, shdr_csf = 0;
 	uint32_t mbox_tmo;
@@ -20860,11 +20861,15 @@ lpfc_wr_object(struct lpfc_hba *phba, struct list_head *dmabuf_list,
 	wr_object->u.request.bde_count = i;
 	bf_set(lpfc_wr_object_write_length, &wr_object->u.request, written);
 	if (!phba->sli4_hba.intr_enable)
-		rc = lpfc_sli_issue_mbox(phba, mbox, MBX_POLL);
+		mbox_status = lpfc_sli_issue_mbox(phba, mbox, MBX_POLL);
 	else {
 		mbox_tmo = lpfc_mbox_tmo_val(phba, mbox);
-		rc = lpfc_sli_issue_mbox_wait(phba, mbox, mbox_tmo);
+		mbox_status = lpfc_sli_issue_mbox_wait(phba, mbox, mbox_tmo);
 	}
+
+	/* The mbox status needs to be maintained to detect MBOX_TIMEOUT. */
+	rc = mbox_status;
+
 	/* The IOCTL status is embedded in the mailbox subheader. */
 	shdr_status = bf_get(lpfc_mbox_hdr_status,
 			     &wr_object->header.cfg_shdr.response);
@@ -20879,10 +20884,6 @@ lpfc_wr_object(struct lpfc_hba *phba, struct list_head *dmabuf_list,
 				  &wr_object->u.response);
 	}
 
-	if (!phba->sli4_hba.intr_enable)
-		mempool_free(mbox, phba->mbox_mem_pool);
-	else if (rc != MBX_TIMEOUT)
-		mempool_free(mbox, phba->mbox_mem_pool);
 	if (shdr_status || shdr_add_status || shdr_add_status_2 || rc) {
 		lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
 				"3025 Write Object mailbox failed with "
@@ -20900,6 +20901,12 @@ lpfc_wr_object(struct lpfc_hba *phba, struct list_head *dmabuf_list,
 		lpfc_log_fw_write_cmpl(phba, shdr_status, shdr_add_status,
 				       shdr_add_status_2, shdr_change_status,
 				       shdr_csf);
+
+	if (!phba->sli4_hba.intr_enable)
+		mempool_free(mbox, phba->mbox_mem_pool);
+	else if (mbox_status != MBX_TIMEOUT)
+		mempool_free(mbox, phba->mbox_mem_pool);
+
 	return rc;
 }
 
Signature · 1 line
2.38.0
author
#9 lore raw

PATCH 9/12 lpfc: Reinitialize internal VMID data structures after FLOGI completion

In reply to Justin Tee

After enabling VMID, an issue lip test was erasing fabric switch VMID information.

Introduce a lpfc_reinit_vmid routine, which reinitializes all VMID data structures upon FLOGI completion in fabric topology.

---
 drivers/scsi/lpfc/lpfc_crtn.h |  1 +
 drivers/scsi/lpfc/lpfc_els.c  |  3 +++
 drivers/scsi/lpfc/lpfc_vmid.c | 39 +++++++++++++++++++++++++++++++++++
 3 files changed, 43 insertions(+)
drivers/scsi/lpfc/lpfc_crtn.h +1 -0
index 6f63e0acf9dd..e72a2504163a 100644
@@ -683,6 +683,7 @@ int lpfc_vmid_get_appid(struct lpfc_vport *vport, char *uuid,
 			union lpfc_vmid_io_tag *tag);
 void lpfc_vmid_vport_cleanup(struct lpfc_vport *vport);
 int lpfc_issue_els_qfpa(struct lpfc_vport *vport);
+void lpfc_reinit_vmid(struct lpfc_vport *vport);
 
 void lpfc_sli_rpi_release(struct lpfc_vport *vport,
 			  struct lpfc_nodelist *ndlp);
drivers/scsi/lpfc/lpfc_els.c +3 -0
index 4d3b8f2036d2..264a3db6cd69 100644
@@ -1123,6 +1123,9 @@ lpfc_cmpl_els_flogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
 	if (sp->cmn.priority_tagging)
 		vport->phba->pport->vmid_flag |= (LPFC_VMID_ISSUE_QFPA |
 						  LPFC_VMID_TYPE_PRIO);
+	/* reinitialize the VMID datastructure before returning */
+	if (lpfc_is_vmid_enabled(phba))
+		lpfc_reinit_vmid(vport);
 
 	/*
 	 * Address a timing race with dev_loss.  If dev_loss is active on
drivers/scsi/lpfc/lpfc_vmid.c +39 -0
index ed1d7f7b88a3..9175982066f8 100644
@@ -284,3 +284,42 @@ int lpfc_vmid_get_appid(struct lpfc_vport *vport, char *uuid,
 	}
 	return rc;
 }
+
+/*
+ * lpfc_reinit_vmid - reinitializes the vmid data structure
+ * @vport: pointer to vport data structure
+ *
+ * This routine reinitializes the vmid post flogi completion
+ *
+ * Return codes
+ *	None
+ */
+void
+lpfc_reinit_vmid(struct lpfc_vport *vport)
+{
+	u32 bucket, i, cpu;
+	struct lpfc_vmid *cur;
+	struct lpfc_vmid *vmp = NULL;
+	struct hlist_node *tmp;
+
+	write_lock(&vport->vmid_lock);
+	vport->cur_vmid_cnt = 0;
+
+	for (i = 0; i < vport->max_vmid; i++) {
+		vmp = &vport->vmid[i];
+		vmp->flag = LPFC_VMID_SLOT_FREE;
+		memset(vmp->host_vmid, 0, sizeof(vmp->host_vmid));
+		vmp->io_rd_cnt = 0;
+		vmp->io_wr_cnt = 0;
+
+		if (vmp->last_io_time)
+			for_each_possible_cpu(cpu)
+				*per_cpu_ptr(vmp->last_io_time, cpu) = 0;
+	}
+
+	/* for all elements in the hash table */
+	if (!hash_empty(vport->hash_table))
+		hash_for_each_safe(vport->hash_table, bucket, tmp, cur, hnode)
+			hash_del(&cur->hnode);
+	write_unlock(&vport->vmid_lock);
+}
Signature · 1 line
2.38.0
author
#10 lore raw

PATCH 10/12 lpfc: Introduce new attention types for lpfc_sli4_async_fc_evt hdlr

In reply to Justin Tee

Define new FC Link ACQE with new attention types 0x8 (Link Activation Failure) and 0x9 (Link Reset Protocol Event).

Both attention types are meant to be informational-only type ACQEs with no action required.

0x8 is reported for diagnostic purposes, while 0x9 is posted during a normal link up transition when activating BB Credit Recovery feature.

As such, modify lpfc_sli4_async_fc_evt logic to log the attention types according to its severity and early return when informational-only attention types are encountered.

---
 drivers/scsi/lpfc/lpfc_hw4.h  |  5 +++
 drivers/scsi/lpfc/lpfc_init.c | 85 ++++++++++++++++++++++++++++-------
 drivers/scsi/lpfc/lpfc_sli4.h |  3 +-
 3 files changed, 77 insertions(+), 16 deletions(-)
drivers/scsi/lpfc/lpfc_hw4.h +5 -0
index fb3504dbb899..58589eb1a358 100644
@@ -4201,6 +4201,8 @@ struct lpfc_acqe_fc_la {
 #define LPFC_FC_LA_TYPE_MDS_LOOPBACK	0x5
 #define LPFC_FC_LA_TYPE_UNEXP_WWPN	0x6
 #define LPFC_FC_LA_TYPE_TRUNKING_EVENT  0x7
+#define LPFC_FC_LA_TYPE_ACTIVATE_FAIL		0x8
+#define LPFC_FC_LA_TYPE_LINK_RESET_PRTCL_EVT	0x9
 #define lpfc_acqe_fc_la_port_type_SHIFT		6
 #define lpfc_acqe_fc_la_port_type_MASK		0x00000003
 #define lpfc_acqe_fc_la_port_type_WORD		word0
@@ -4242,6 +4244,9 @@ struct lpfc_acqe_fc_la {
 #define lpfc_acqe_fc_la_fault_SHIFT		0
 #define lpfc_acqe_fc_la_fault_MASK		0x000000FF
 #define lpfc_acqe_fc_la_fault_WORD		word1
+#define lpfc_acqe_fc_la_link_status_SHIFT	8
+#define lpfc_acqe_fc_la_link_status_MASK	0x0000007F
+#define lpfc_acqe_fc_la_link_status_WORD	word1
 #define lpfc_acqe_fc_la_trunk_fault_SHIFT		0
 #define lpfc_acqe_fc_la_trunk_fault_MASK		0x0000000F
 #define lpfc_acqe_fc_la_trunk_fault_WORD		word1
drivers/scsi/lpfc/lpfc_init.c +70 -15

117 lines not on this page · raw message

drivers/scsi/lpfc/lpfc_sli4.h +2 -1
index f927c2a25d54..babdf29245d4 100644
@@ -291,8 +291,9 @@ struct lpfc_sli4_link {
 	uint8_t type;
 	uint8_t number;
 	uint8_t fault;
-	uint32_t logical_speed;
+	uint8_t link_status;
 	uint16_t topology;
+	uint32_t logical_speed;
 };
 
 struct lpfc_fcf_rec {
Signature · 1 line
2.38.0
author
#11 lore raw

PATCH 11/12 lpfc: Update lpfc version to 14.2.0.10

In reply to Justin Tee

Update lpfc version to 14.2.0.10

---
 drivers/scsi/lpfc/lpfc_version.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/lpfc/lpfc_version.h +1 -1
index 41a1128f8651..c06d981cf8c9 100644
@@ -20,7 +20,7 @@
  * included with this package.                                     *
  *******************************************************************/
 
-#define LPFC_DRIVER_VERSION "14.2.0.9"
+#define LPFC_DRIVER_VERSION "14.2.0.10"
 #define LPFC_DRIVER_NAME		"lpfc"
 
 /* Used for SLI 2/3 */
Signature · 1 line
2.38.0
author
#12 lore raw

PATCH 12/12 Copyright updates for 14.2.0.10 patches

In reply to Justin Tee

Update copyrights to 2023 for files modified in the 14.2.0.10 patch set.

---
 drivers/scsi/lpfc/lpfc.h         | 2 +-
 drivers/scsi/lpfc/lpfc_attr.c    | 2 +-
 drivers/scsi/lpfc/lpfc_crtn.h    | 2 +-
 drivers/scsi/lpfc/lpfc_els.c     | 2 +-
 drivers/scsi/lpfc/lpfc_hbadisc.c | 2 +-
 drivers/scsi/lpfc/lpfc_hw4.h     | 2 +-
 drivers/scsi/lpfc/lpfc_init.c    | 2 +-
 drivers/scsi/lpfc/lpfc_scsi.c    | 2 +-
 drivers/scsi/lpfc/lpfc_sli.c     | 2 +-
 drivers/scsi/lpfc/lpfc_sli4.h    | 2 +-
 drivers/scsi/lpfc/lpfc_version.h | 4 ++--
 drivers/scsi/lpfc/lpfc_vmid.c    | 2 +-
 drivers/scsi/lpfc/lpfc_vport.c   | 2 +-
 13 files changed, 14 insertions(+), 14 deletions(-)
drivers/scsi/lpfc/lpfc.h +1 -1
index 1095595ca3a2..cf55f8e3bd9f 100644
@@ -1,7 +1,7 @@
 /*******************************************************************
  * This file is part of the Emulex Linux Device Driver for         *
  * Fibre Channel Host Bus Adapters.                                *
- * Copyright (C) 2017-2022 Broadcom. All Rights Reserved. The term *
+ * Copyright (C) 2017-2023 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.                        *
drivers/scsi/lpfc/lpfc_attr.c +1 -1
index c95401225057..76c3434f8976 100644
@@ -1,7 +1,7 @@
 /*******************************************************************
  * This file is part of the Emulex Linux Device Driver for         *
  * Fibre Channel Host Bus Adapters.                                *
- * Copyright (C) 2017-2022 Broadcom. All Rights Reserved. The term *
+ * Copyright (C) 2017-2023 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.                        *
drivers/scsi/lpfc/lpfc_crtn.h +1 -1
index e72a2504163a..976fd5ee7f7e 100644
@@ -1,7 +1,7 @@
 /*******************************************************************
  * This file is part of the Emulex Linux Device Driver for         *
  * Fibre Channel Host Bus Adapters.                                *
- * Copyright (C) 2017-2022 Broadcom. All Rights Reserved. The term *
+ * Copyright (C) 2017-2023 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.                        *
drivers/scsi/lpfc/lpfc_els.c +1 -1
index 264a3db6cd69..569639dc8b2c 100644
@@ -1,7 +1,7 @@
 /*******************************************************************
  * This file is part of the Emulex Linux Device Driver for         *
  * Fibre Channel Host Bus Adapters.                                *
- * Copyright (C) 2017-2022 Broadcom. All Rights Reserved. The term *
+ * Copyright (C) 2017-2023 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.                        *
drivers/scsi/lpfc/lpfc_hbadisc.c +1 -1
index af0acf55b343..a6df0a5b4006 100644
@@ -1,7 +1,7 @@
 /*******************************************************************
  * This file is part of the Emulex Linux Device Driver for         *
  * Fibre Channel Host Bus Adapters.                                *
- * Copyright (C) 2017-2022 Broadcom. All Rights Reserved. The term *
+ * Copyright (C) 2017-2023 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.                        *
drivers/scsi/lpfc/lpfc_hw4.h +1 -1
index 58589eb1a358..58fa39c403a0 100644
@@ -1,7 +1,7 @@
 /*******************************************************************
  * This file is part of the Emulex Linux Device Driver for         *
  * Fibre Channel Host Bus Adapters.                                *
- * Copyright (C) 2017-2022 Broadcom. All Rights Reserved. The term *
+ * Copyright (C) 2017-2023 Broadcom. All Rights Reserved. The term *
  * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.  *
  * Copyright (C) 2009-2016 Emulex.  All rights reserved.           *
  * EMULEX and SLI are trademarks of Emulex.                        *
drivers/scsi/lpfc/lpfc_init.c +1 -1
index 0fef8cd38ecf..faaaeae25d44 100644
@@ -1,7 +1,7 @@
 /*******************************************************************
  * This file is part of the Emulex Linux Device Driver for         *
  * Fibre Channel Host Bus Adapters.                                *
- * Copyright (C) 2017-2022 Broadcom. All Rights Reserved. The term *
+ * Copyright (C) 2017-2023 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.                        *
drivers/scsi/lpfc/lpfc_scsi.c +1 -1
index 9b6580eb7ed6..e989f130434e 100644
@@ -1,7 +1,7 @@
 /*******************************************************************
  * This file is part of the Emulex Linux Device Driver for         *
  * Fibre Channel Host Bus Adapters.                                *
- * Copyright (C) 2017-2022 Broadcom. All Rights Reserved. The term *
+ * Copyright (C) 2017-2023 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.                        *
drivers/scsi/lpfc/lpfc_sli.c +1 -1
index 55dfab9ae3c9..edbd81c3b643 100644
@@ -1,7 +1,7 @@
 /*******************************************************************
  * This file is part of the Emulex Linux Device Driver for         *
  * Fibre Channel Host Bus Adapters.                                *
- * Copyright (C) 2017-2022 Broadcom. All Rights Reserved. The term *
+ * Copyright (C) 2017-2023 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.                        *
drivers/scsi/lpfc/lpfc_sli4.h +1 -1
index babdf29245d4..3b62c4032c31 100644
@@ -1,7 +1,7 @@
 /*******************************************************************
  * This file is part of the Emulex Linux Device Driver for         *
  * Fibre Channel Host Bus Adapters.                                *
- * Copyright (C) 2017-2022 Broadcom. All Rights Reserved. The term *
+ * Copyright (C) 2017-2023 Broadcom. All Rights Reserved. The term *
  * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.     *
  * Copyright (C) 2009-2016 Emulex.  All rights reserved.           *
  * EMULEX and SLI are trademarks of Emulex.                        *
drivers/scsi/lpfc/lpfc_version.h +2 -2
index c06d981cf8c9..0238208cdd11 100644
@@ -1,7 +1,7 @@
 /*******************************************************************
  * This file is part of the Emulex Linux Device Driver for         *
  * Fibre Channel Host Bus Adapters.                                *
- * Copyright (C) 2017-2022 Broadcom. All Rights Reserved. The term *
+ * Copyright (C) 2017-2023 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.                        *
@@ -32,6 +32,6 @@
 
 #define LPFC_MODULE_DESC "Emulex LightPulse Fibre Channel SCSI driver " \
 		LPFC_DRIVER_VERSION
-#define LPFC_COPYRIGHT "Copyright (C) 2017-2022 Broadcom. All Rights " \
+#define LPFC_COPYRIGHT "Copyright (C) 2017-2023 Broadcom. All Rights " \
 		"Reserved. The term \"Broadcom\" refers to Broadcom Inc. " \
 		"and/or its subsidiaries."
drivers/scsi/lpfc/lpfc_vmid.c +1 -1
index 9175982066f8..cf8ba840d0ea 100644
@@ -1,7 +1,7 @@
 /*******************************************************************
  * This file is part of the Emulex Linux Device Driver for         *
  * Fibre Channel Host Bus Adapters.                                *
- * Copyright (C) 2017-2022 Broadcom. All Rights Reserved. The term *
+ * Copyright (C) 2017-2023 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.                        *
drivers/scsi/lpfc/lpfc_vport.c +1 -1
index 5aeda245369b..6c7559cf1a4b 100644
@@ -1,7 +1,7 @@
 /*******************************************************************
  * This file is part of the Emulex Linux Device Driver for         *
  * Fibre Channel Host Bus Adapters.                                *
- * Copyright (C) 2017-2022 Broadcom. All Rights Reserved. The term *
+ * Copyright (C) 2017-2023 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
#13 lore raw
In reply to Justin Tee

Justin,

Quoted 4 lines

Update lpfc to revision 14.2.0.10

This patch set contains fixes for bugs, kernel test robot, and introduces new attention type event handling.

Applied to 6.3/scsi-staging, thanks!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering
#14 lore raw
In reply to Justin Tee
Quoted 8 lines · Justin Tee

Update lpfc to revision 14.2.0.10

This patch set contains fixes for bugs, kernel test robot, and introduces new attention type event handling.

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

[...]

Applied to 6.3/scsi-queue, thanks!

[01/12] lpfc: Fix space indentation in lpfc_xcvr_data

	https://git.kernel.org/mkp/scsi/c/6058304a66ba
[02/12] lpfc: Replace outdated strncpy with strscpy
	https://git.kernel.org/mkp/scsi/c/1f7b5f94f8d0
[03/12] lpfc: Resolve miscellaneous variable set but not used compiler warnings
	https://git.kernel.org/mkp/scsi/c/7ab07683aa4c
[04/12] lpfc: Set max dma segment size to hba supported SGE length
	https://git.kernel.org/mkp/scsi/c/b5c894cf430e
[05/12] lpfc: Remove redundant clean up code in disable_vport
	https://git.kernel.org/mkp/scsi/c/f81395570e6c
[06/12] lpfc: Remove duplicate ndlp kref decrement in lpfc_cleanup_rpis
	https://git.kernel.org/mkp/scsi/c/ecdf4ddf4eb7
[07/12] lpfc: Exit PRLI completion handling early if ndlp not in PRLI_ISSUE state
	https://git.kernel.org/mkp/scsi/c/c051f1a424a1
[08/12] lpfc: Fix use-after-free KFENCE violation during sysfs firmware write
	https://git.kernel.org/mkp/scsi/c/21681b81b9ae
[09/12] lpfc: Reinitialize internal VMID data structures after FLOGI completion
	https://git.kernel.org/mkp/scsi/c/f1d2337d3e58
[10/12] lpfc: Introduce new attention types for lpfc_sli4_async_fc_evt hdlr
	https://git.kernel.org/mkp/scsi/c/96fb8c34e5c1
[11/12] lpfc: Update lpfc version to 14.2.0.10
	https://git.kernel.org/mkp/scsi/c/41cf6bbe3d99
[12/12] Copyright updates for 14.2.0.10 patches
	https://git.kernel.org/mkp/scsi/c/191b5a38771d
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering