Skip to contentSkip to conversation

lpfc: Update lpfc to revision 12.8.0.11

PATCH Applied James Smart 2 participants 23 messages Jul 7, 2021 – Jul 24, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover lpfc: Update lpfc to revision 12.8.0.11

Update lpfc to revision 12.8.0.11

This patch set contains fixes and improvements for the lpfc driver

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

James Smart (20):
lpfc: Fix NVME support reporting in log message
lpfc: Remove use of kmalloc in trace event logging
lpfc: Improve firmware download logging
lpfc: Fix function description comments for vmid routines
lpfc: Discovery state machine fixes for LOGO handling
lpfc: Fix target reset handler from falsely returning FAILURE
lpfc: Keep ndlp reference until after freeing the iocb after els
handling
lpfc: Fix null ptr dereference with NPIV ports for RDF handling
lpfc: Fix memory leaks in error paths while issuing ELS RDF/SCR
request
lpfc: Remove REG_LOGIN check requirement to issue an ELS RDF
lpfc: Fix KASAN slab-out-of-bounds in lpfc_unreg_rpi routine
lpfc: Clear outstanding active mailbox during PCI function reset
lpfc: Use PBDE feature enabled bit to determine PBDE support
lpfc: Enable adisc discovery after RSCN by default
lpfc: Delay unregistering from transport until GIDFT or ADISC
completes
lpfc: Call discovery state machine when handling PLOGI/ADISC
completions
lpfc: Skip reg_vpi when link is down for SLI3 in ADISC cmpl path
lpfc: Skip issuing ADISC when node is in NPR state
lpfc: Update lpfc version to 12.8.0.11
lpfc: Copyright updates for 12.8.0.11 patches

 drivers/scsi/lpfc/lpfc.h           |   1 -
 drivers/scsi/lpfc/lpfc_attr.c      |   4 +-
 drivers/scsi/lpfc/lpfc_crtn.h      |   2 +
 drivers/scsi/lpfc/lpfc_ct.c        |   5 +-
 drivers/scsi/lpfc/lpfc_disc.h      |   9 +-
 drivers/scsi/lpfc/lpfc_els.c       | 120 ++++++++++--------
 drivers/scsi/lpfc/lpfc_hbadisc.c   | 197 ++++++++++++++++++++++-------
 drivers/scsi/lpfc/lpfc_hw4.h       |  20 ++-
 drivers/scsi/lpfc/lpfc_init.c      |  51 +++++---
 drivers/scsi/lpfc/lpfc_nportdisc.c |  43 ++++---
 drivers/scsi/lpfc/lpfc_nvme.c      |  10 +-
 drivers/scsi/lpfc/lpfc_nvme.h      |   6 +-
 drivers/scsi/lpfc/lpfc_scsi.c      |  68 +++++-----
 drivers/scsi/lpfc/lpfc_sli.c       | 192 +++++++++++++++++++++-------
 drivers/scsi/lpfc/lpfc_sli4.h      |   4 +-
 drivers/scsi/lpfc/lpfc_version.h   |   2 +-
 16 files changed, 497 insertions(+), 237 deletions(-)
Signature · 1 line
2.26.2
#1 lore raw

PATCH 1/20 lpfc: Fix NVME support reporting in log message

The NVME support indicator in log message 6422 is displaying a field that was initialized but never set to indicate NVME support. Remove obsolete nvme_support element from the lpfc_hba structure and change log message to display NVME support status as reported in SLI4 Config Parameters mailbox command.

---
 drivers/scsi/lpfc/lpfc.h      | 1 -
 drivers/scsi/lpfc/lpfc_init.c | 3 +--
 2 files changed, 1 insertion(+), 3 deletions(-)
drivers/scsi/lpfc/lpfc.h +0 -1
index 17028861234b..dd3ddfa5f761 100644
@@ -922,7 +922,6 @@ struct lpfc_hba {
 	uint8_t  wwpn[8];
 	uint32_t RandomData[7];
 	uint8_t  fcp_embed_io;
-	uint8_t  nvme_support;	/* Firmware supports NVME */
 	uint8_t  nvmet_support;	/* driver supports NVMET */
 #define LPFC_NVMET_MAX_PORTS	32
 	uint8_t  mds_diags_support;
drivers/scsi/lpfc/lpfc_init.c +1 -2
index f3032e30c3e4..cf5bfd27058a 100644
@@ -12241,7 +12241,6 @@ lpfc_get_sli4_parameters(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
 					bf_get(cfg_xib, mbx_sli4_parameters),
 					phba->cfg_enable_fc4_type);
 fcponly:
-			phba->nvme_support = 0;
 			phba->nvmet_support = 0;
 			phba->cfg_nvmet_mrq = 0;
 			phba->cfg_nvme_seg_cnt = 0;
@@ -12299,7 +12298,7 @@ lpfc_get_sli4_parameters(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
 			"6422 XIB %d PBDE %d: FCP %d NVME %d %d %d\n",
 			bf_get(cfg_xib, mbx_sli4_parameters),
 			phba->cfg_enable_pbde,
-			phba->fcp_embed_io, phba->nvme_support,
+			phba->fcp_embed_io, sli4_params->nvme,
 			phba->cfg_nvme_embed_cmd, phba->cfg_suppress_rsp);
 
 	if ((bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) ==
Signature · 1 line
2.26.2
#2 lore raw

PATCH 2/20 lpfc: Remove use of kmalloc in trace event logging

In reply to James Smart

There are instances when trace event logs are triggered from an interrupt context. The trace event log may attempt to alloc memory causing scheduling while atomic bug call traces.

Remove the need for the kmalloc'ed vport array when checking the log_verbose flag, which eliminates the need for any allocation.

---
 drivers/scsi/lpfc/lpfc_init.c | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)
drivers/scsi/lpfc/lpfc_init.c +17 -8
index cf5bfd27058a..51f4058a75b8 100644
@@ -14162,8 +14162,9 @@ void lpfc_dmp_dbg(struct lpfc_hba *phba)
 	unsigned int temp_idx;
 	int i;
 	int j = 0;
-	unsigned long rem_nsec;
-	struct lpfc_vport **vports;
+	unsigned long rem_nsec, iflags;
+	bool log_verbose = false;
+	struct lpfc_vport *port_iterator;
 
 	/* Don't dump messages if we explicitly set log_verbose for the
 	 * physical port or any vport.
@@ -14171,16 +14172,24 @@ void lpfc_dmp_dbg(struct lpfc_hba *phba)
 	if (phba->cfg_log_verbose)
 		return;
 
-	vports = lpfc_create_vport_work_array(phba);
-	if (vports != NULL) {
-		for (i = 0; i <= phba->max_vpi && vports[i] != NULL; i++) {
-			if (vports[i]->cfg_log_verbose) {
-				lpfc_destroy_vport_work_array(phba, vports);
+	spin_lock_irqsave(&phba->port_list_lock, iflags);
+	list_for_each_entry(port_iterator, &phba->port_list, listentry) {
+		if (port_iterator->load_flag & FC_UNLOADING)
+			continue;
+		if (scsi_host_get(lpfc_shost_from_vport(port_iterator))) {
+			if (port_iterator->cfg_log_verbose)
+				log_verbose = true;
+
+			scsi_host_put(lpfc_shost_from_vport(port_iterator));
+
+			if (log_verbose) {
+				spin_unlock_irqrestore(&phba->port_list_lock,
+						       iflags);
 				return;
 			}
 		}
 	}
-	lpfc_destroy_vport_work_array(phba, vports);
+	spin_unlock_irqrestore(&phba->port_list_lock, iflags);
 
 	if (atomic_cmpxchg(&phba->dbg_log_dmping, 0, 1) != 0)
 		return;
Signature · 1 line
2.26.2
#3 lore raw

PATCH 3/20 lpfc: Improve firmware download logging

In reply to James Smart

Define additional status fields in mailbox commands to help provide additional information when downloading new firmware.

---
 drivers/scsi/lpfc/lpfc_hw4.h  |   9 ++
 drivers/scsi/lpfc/lpfc_sli.c  | 152 ++++++++++++++++++++++++----------
 drivers/scsi/lpfc/lpfc_sli4.h |   2 +
 3 files changed, 121 insertions(+), 42 deletions(-)
drivers/scsi/lpfc/lpfc_hw4.h +9 -0
index eb8c735a243b..7d4d179fb534 100644
@@ -959,6 +959,12 @@ union lpfc_sli4_cfg_shdr {
 #define lpfc_mbox_hdr_add_status_SHIFT		8
 #define lpfc_mbox_hdr_add_status_MASK		0x000000FF
 #define lpfc_mbox_hdr_add_status_WORD		word7
+#define LPFC_ADD_STATUS_INCOMPAT_OBJ		0xA2
+#define lpfc_mbox_hdr_add_status_2_SHIFT	16
+#define lpfc_mbox_hdr_add_status_2_MASK		0x000000FF
+#define lpfc_mbox_hdr_add_status_2_WORD		word7
+#define LPFC_ADD_STATUS_2_INCOMPAT_FLASH	0x01
+#define LPFC_ADD_STATUS_2_INCORRECT_ASIC	0x02
 		uint32_t response_length;
 		uint32_t actual_response_length;
 	} response;
@@ -3603,6 +3609,9 @@ struct lpfc_controller_attribute {
 #define lpfc_cntl_attr_eprom_ver_hi_SHIFT	8
 #define lpfc_cntl_attr_eprom_ver_hi_MASK	0x000000ff
 #define lpfc_cntl_attr_eprom_ver_hi_WORD	word17
+#define lpfc_cntl_attr_flash_id_SHIFT		16
+#define lpfc_cntl_attr_flash_id_MASK		0x000000ff
+#define lpfc_cntl_attr_flash_id_WORD		word17
 	uint32_t mbx_da_struct_ver;
 	uint32_t ep_fw_da_struct_ver;
 	uint32_t ncsi_ver_str[3];
drivers/scsi/lpfc/lpfc_sli.c +110 -42

197 lines not on this page · raw message

drivers/scsi/lpfc/lpfc_sli4.h +2 -0
index 26f19c95380f..021edbfbbca5 100644
@@ -978,6 +978,8 @@ struct lpfc_sli4_hba {
 #define lpfc_conf_trunk_port3_nd_WORD	conf_trunk
 #define lpfc_conf_trunk_port3_nd_SHIFT	7
 #define lpfc_conf_trunk_port3_nd_MASK	0x1
+	uint8_t flash_id;
+	uint8_t asic_rev;
 };
 
 enum lpfc_sge_type {
Signature · 1 line
2.26.2
#4 lore raw

PATCH 4/20 lpfc: Fix function description comments for vmid routines

In reply to James Smart

Update comment headers for functions lpfc_vmid_cmd and lpfc_vmid_poll

---
 drivers/scsi/lpfc/lpfc_ct.c   | 5 ++---
 drivers/scsi/lpfc/lpfc_init.c | 2 +-
 2 files changed, 3 insertions(+), 4 deletions(-)
drivers/scsi/lpfc/lpfc_ct.c +2 -3
index 610b6dabb3b5..1acb8820a08e 100644
@@ -3884,9 +3884,8 @@ lpfc_cmpl_ct_cmd_vmid(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
 /**
  * lpfc_vmid_cmd - Build and send a FDMI cmd to the specified NPort
  * @vport: pointer to a host virtual N_Port data structure.
- * @ndlp: ndlp to send FDMI cmd to (if NULL use FDMI_DID)
- * cmdcode: FDMI command to send
- * mask: Mask of HBA or PORT Attributes to send
+ * @cmdcode: application server command code to send
+ * @vmid: pointer to vmid info structure
  *
  * Builds and sends a FDMI command using the CT subsystem.
  */
drivers/scsi/lpfc/lpfc_init.c +1 -1
index 51f4058a75b8..6867b02219b0 100644
@@ -4845,7 +4845,7 @@ lpfc_sli4_fcf_redisc_wait_tmo(struct timer_list *t)
 
 /**
  * lpfc_vmid_poll - VMID timeout detection
- * @ptr: Map to lpfc_hba data structure pointer.
+ * @t: Timer context used to obtain the pointer to lpfc hba data structure.
  *
  * This routine is invoked when there is no I/O on by a VM for the specified
  * amount of time. When this situation is detected, the VMID has to be
Signature · 1 line
2.26.2
#5 lore raw

PATCH 5/20 lpfc: Discovery state machine fixes for LOGO handling

In reply to James Smart

- If a LOGO is received for a node that is in the NPR state, post a DEVICE_RM event to allow clean up of the logged out node.

- Clearing the NLP_NPR_2B_DISC flag upon receipt of a LOGO ACC may cause skipping of processing outstanding PLOGIs triggered by parallel RSCN events. If an outstanding PLOGI is being retried and receipt of a LOGO ACC occurs, then allow the discovery state machine's PLOGI completion to clean up the node.

---
 drivers/scsi/lpfc/lpfc_els.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/scsi/lpfc/lpfc_els.c +12 -0
index e481f5fe29d7..b0c443a0cf92 100644
@@ -4612,6 +4612,15 @@ 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;
+
 		/* NPort Recovery mode or node is just allocated */
 		if (!lpfc_nlp_not_used(ndlp)) {
 			/* A LOGO is completing and the node is in NPR state.
@@ -8948,6 +8957,9 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
 			break;
 		}
 		lpfc_disc_state_machine(vport, ndlp, elsiocb, NLP_EVT_RCV_LOGO);
+		if (newnode)
+			lpfc_disc_state_machine(vport, ndlp, NULL,
+					NLP_EVT_DEVICE_RM);
 		break;
 	case ELS_CMD_PRLO:
 		lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
Signature · 1 line
2.26.2
#6 lore raw

PATCH 6/20 lpfc: Fix target reset handler from falsely returning FAILURE

In reply to James Smart

Previous logic accidentally overrides the status variable to FAILURE when target reset status is SUCCESS.

Refactor the non-SUCCESS logic of lpfc_vmid_vport_cleanup(), which resolves the false override.

---
 drivers/scsi/lpfc/lpfc_scsi.c | 68 +++++++++++++++++++----------------
 1 file changed, 37 insertions(+), 31 deletions(-)
drivers/scsi/lpfc/lpfc_scsi.c +37 -31
index 1b248c237be1..10002a13c5c6 100644
@@ -6273,6 +6273,7 @@ lpfc_target_reset_handler(struct scsi_cmnd *cmnd)
 	struct lpfc_scsi_event_header scsi_event;
 	int status;
 	u32 logit = LOG_FCP;
+	u32 dev_loss_tmo = vport->cfg_devloss_tmo;
 	unsigned long flags;
 	DECLARE_WAIT_QUEUE_HEAD_ONSTACK(waitq);
 
@@ -6314,39 +6315,44 @@ lpfc_target_reset_handler(struct scsi_cmnd *cmnd)
 
 	status = lpfc_send_taskmgmt(vport, cmnd, tgt_id, lun_id,
 					FCP_TARGET_RESET);
-	if (status != SUCCESS)
-		logit =  LOG_TRACE_EVENT;
-	spin_lock_irqsave(&pnode->lock, flags);
-	if (status != SUCCESS &&
-	    (!(pnode->upcall_flags & NLP_WAIT_FOR_LOGO)) &&
-	     !pnode->logo_waitq) {
-		pnode->logo_waitq = &waitq;
-		pnode->nlp_fcp_info &= ~NLP_FCP_2_DEVICE;
-		pnode->nlp_flag |= NLP_ISSUE_LOGO;
-		pnode->upcall_flags |= NLP_WAIT_FOR_LOGO;
-		spin_unlock_irqrestore(&pnode->lock, flags);
-		lpfc_unreg_rpi(vport, pnode);
-		wait_event_timeout(waitq,
-				   (!(pnode->upcall_flags & NLP_WAIT_FOR_LOGO)),
-				    msecs_to_jiffies(vport->cfg_devloss_tmo *
-				    1000));
-
-		if (pnode->upcall_flags & NLP_WAIT_FOR_LOGO) {
-			lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
-				"0725 SCSI layer TGTRST failed & LOGO TMO "
-				" (%d, %llu) return x%x\n", tgt_id,
-				 lun_id, status);
-			spin_lock_irqsave(&pnode->lock, flags);
-			pnode->upcall_flags &= ~NLP_WAIT_FOR_LOGO;
+	if (status != SUCCESS) {
+		logit = LOG_TRACE_EVENT;
+
+		/* Issue LOGO, if no LOGO is outstanding */
+		spin_lock_irqsave(&pnode->lock, flags);
+		if (!(pnode->upcall_flags & NLP_WAIT_FOR_LOGO) &&
+		    !pnode->logo_waitq) {
+			pnode->logo_waitq = &waitq;
+			pnode->nlp_fcp_info &= ~NLP_FCP_2_DEVICE;
+			pnode->nlp_flag |= NLP_ISSUE_LOGO;
+			pnode->upcall_flags |= NLP_WAIT_FOR_LOGO;
+			spin_unlock_irqrestore(&pnode->lock, flags);
+			lpfc_unreg_rpi(vport, pnode);
+			wait_event_timeout(waitq,
+					   (!(pnode->upcall_flags &
+					      NLP_WAIT_FOR_LOGO)),
+					   msecs_to_jiffies(dev_loss_tmo *
+							    1000));
+
+			if (pnode->upcall_flags & NLP_WAIT_FOR_LOGO) {
+				lpfc_printf_vlog(vport, KERN_ERR, logit,
+						 "0725 SCSI layer TGTRST "
+						 "failed & LOGO TMO (%d, %llu) "
+						 "return x%x\n",
+						 tgt_id, lun_id, status);
+				spin_lock_irqsave(&pnode->lock, flags);
+				pnode->upcall_flags &= ~NLP_WAIT_FOR_LOGO;
+			} else {
+				spin_lock_irqsave(&pnode->lock, flags);
+			}
+			pnode->logo_waitq = NULL;
+			spin_unlock_irqrestore(&pnode->lock, flags);
+			status = SUCCESS;
+
 		} else {
-			spin_lock_irqsave(&pnode->lock, flags);
+			spin_unlock_irqrestore(&pnode->lock, flags);
+			status = FAILED;
 		}
-		pnode->logo_waitq = NULL;
-		spin_unlock_irqrestore(&pnode->lock, flags);
-		status = SUCCESS;
-	} else {
-		status = FAILED;
-		spin_unlock_irqrestore(&pnode->lock, flags);
 	}
 
 	lpfc_printf_vlog(vport, KERN_ERR, logit,
Signature · 1 line
2.26.2
#7 lore raw

PATCH 7/20 lpfc: Keep ndlp reference until after freeing the iocb after els handling

In reply to James Smart

In the routine that generically cleans up an els after completion, the ndlp put is done prior to the freeing of the iocb. The iocb may reference the ndlp.

Move the lpfc_nlp_put after freeing the iocb.

---
 drivers/scsi/lpfc/lpfc_sli.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/scsi/lpfc/lpfc_sli.c +7 -1
index b5c224aafea0..1abf63c85c4b 100644
@@ -11623,6 +11623,7 @@ void
 lpfc_ignore_els_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
 		     struct lpfc_iocbq *rspiocb)
 {
+	struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) cmdiocb->context1;
 	IOCB_t *irsp = &rspiocb->iocb;
 
 	/* ELS cmd tag <ulpIoTag> completes */
@@ -11631,11 +11632,16 @@ lpfc_ignore_els_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
 			"x%x x%x x%x\n",
 			irsp->ulpIoTag, irsp->ulpStatus,
 			irsp->un.ulpWord[4], irsp->ulpTimeout);
-	lpfc_nlp_put((struct lpfc_nodelist *)cmdiocb->context1);
+	/*
+	 * Deref the ndlp after free_iocb. sli_release_iocb will access the ndlp
+	 * if exchange is busy.
+	 */
 	if (cmdiocb->iocb.ulpCommand == CMD_GEN_REQUEST64_CR)
 		lpfc_ct_free_iocb(phba, cmdiocb);
 	else
 		lpfc_els_free_iocb(phba, cmdiocb);
+
+	lpfc_nlp_put(ndlp);
 }
 
 /**
Signature · 1 line
2.26.2
#8 lore raw

PATCH 8/20 lpfc: Fix null ptr dereference with NPIV ports for RDF handling

In reply to James Smart

RDF ELS handling for NPIV ports may result in an incorrect ndlp reference count. In the event of a persistent link down, this may lead to premature release of an ndlp structure and subsequent null ptr dereference panic.

Remove extraneous lpfc_nlp_put() call in NPIV port RDF processing.

---
 drivers/scsi/lpfc/lpfc_els.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/scsi/lpfc/lpfc_els.c +2 -5
index b0c443a0cf92..b1ca6f8e5970 100644
@@ -3413,7 +3413,6 @@ lpfc_issue_els_scr(struct lpfc_vport *vport, uint8_t retry)
 		return 1;
 	}
 
-	/* Keep the ndlp just in case RDF is being sent */
 	return 0;
 }
 
@@ -3657,11 +3656,9 @@ lpfc_issue_els_rdf(struct lpfc_vport *vport, uint8_t retry)
 		lpfc_enqueue_node(vport, ndlp);
 	}
 
-	/* RDF ELS is not required on an NPIV VN_Port.  */
-	if (vport->port_type == LPFC_NPIV_PORT) {
-		lpfc_nlp_put(ndlp);
+	/* RDF ELS is not required on an NPIV VN_Port. */
+	if (vport->port_type == LPFC_NPIV_PORT)
 		return -EACCES;
-	}
 
 	elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp,
 				     ndlp->nlp_DID, ELS_CMD_RDF);
Signature · 1 line
2.26.2
#9 lore raw

PATCH 9/20 lpfc: Fix memory leaks in error paths while issuing ELS RDF/SCR request

In reply to James Smart

The els job request structure, that is allocated while issuing els rdf/scr requests path, is not being released in an error path causing a memory leak message on driver unload.

Free the els job structure in the error paths.

---
 drivers/scsi/lpfc/lpfc_els.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/scsi/lpfc/lpfc_els.c +2 -0
index b1ca6f8e5970..3381912bf982 100644
@@ -3375,6 +3375,7 @@ lpfc_issue_els_scr(struct lpfc_vport *vport, uint8_t retry)
 	if (phba->sli_rev == LPFC_SLI_REV4) {
 		rc = lpfc_reg_fab_ctrl_node(vport, ndlp);
 		if (rc) {
+			lpfc_els_free_iocb(phba, elsiocb);
 			lpfc_printf_vlog(vport, KERN_ERR, LOG_NODE,
 					 "0937 %s: Failed to reg fc node, rc %d\n",
 					 __func__, rc);
@@ -3667,6 +3668,7 @@ lpfc_issue_els_rdf(struct lpfc_vport *vport, uint8_t retry)
 
 	if (phba->sli_rev == LPFC_SLI_REV4 &&
 	    !(ndlp->nlp_flag & NLP_RPI_REGISTERED)) {
+		lpfc_els_free_iocb(phba, elsiocb);
 		lpfc_printf_vlog(vport, KERN_ERR, LOG_NODE,
 				 "0939 %s: FC_NODE x%x RPI x%x flag x%x "
 				 "ste x%x type x%x Not registered\n",
Signature · 1 line
2.26.2
#10 lore raw

PATCH 10/20 lpfc: Remove REG_LOGIN check requirement to issue an ELS RDF

In reply to James Smart

Since the REG_LOGIN to the fabric controller happens in parallel with SCR, it may or may not be completed by the time RDF is sent. RDF and SCR are sent to the fabric in parallel, so checking for a completed REG_LOGIN in the RDF submit path is not needed.

Remove the REG_LOGI check from the RDF submission path.

---
 drivers/scsi/lpfc/lpfc_els.c | 12 ------------
 1 file changed, 12 deletions(-)
drivers/scsi/lpfc/lpfc_els.c +0 -12
index 3381912bf982..94dc80dc99b7 100644
@@ -3666,18 +3666,6 @@ lpfc_issue_els_rdf(struct lpfc_vport *vport, uint8_t retry)
 	if (!elsiocb)
 		return -ENOMEM;
 
-	if (phba->sli_rev == LPFC_SLI_REV4 &&
-	    !(ndlp->nlp_flag & NLP_RPI_REGISTERED)) {
-		lpfc_els_free_iocb(phba, elsiocb);
-		lpfc_printf_vlog(vport, KERN_ERR, LOG_NODE,
-				 "0939 %s: FC_NODE x%x RPI x%x flag x%x "
-				 "ste x%x type x%x Not registered\n",
-				 __func__, ndlp->nlp_DID, ndlp->nlp_rpi,
-				 ndlp->nlp_flag, ndlp->nlp_state,
-				 ndlp->nlp_type);
-		return -ENODEV;
-	}
-
 	/* Configure the payload for the supported FPIN events. */
 	prdf = (struct lpfc_els_rdf_req *)
 		(((struct lpfc_dmabuf *)elsiocb->context2)->virt);
Signature · 1 line
2.26.2
#11 lore raw

PATCH 11/20 lpfc: Fix KASAN slab-out-of-bounds in lpfc_unreg_rpi routine

In reply to James Smart

In lpfc_offline_prep() an RPI is freed and nlp_rpi set to 0xFFFF before calling lpfc_unreg_rpi(). Unfortunately, lpfc_unreg_rpi() uses nlp_rpi to index the sli4_hba.rpi_ids[] array.

In lpfc_offline_prep, the unreg rpi before freeing the rpi.

---
 drivers/scsi/lpfc/lpfc_init.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/scsi/lpfc/lpfc_init.c +2 -1
index 6867b02219b0..2d277979a56a 100644
@@ -3541,6 +3541,8 @@ lpfc_offline_prep(struct lpfc_hba *phba, int mbx_action)
 				spin_lock_irq(&ndlp->lock);
 				ndlp->nlp_flag &= ~NLP_NPR_ADISC;
 				spin_unlock_irq(&ndlp->lock);
+
+				lpfc_unreg_rpi(vports[i], ndlp);
 				/*
 				 * Whenever an SLI4 port goes offline, free the
 				 * RPI. Get a new RPI when the adapter port
@@ -3556,7 +3558,6 @@ lpfc_offline_prep(struct lpfc_hba *phba, int mbx_action)
 					lpfc_sli4_free_rpi(phba, ndlp->nlp_rpi);
 					ndlp->nlp_rpi = LPFC_RPI_ALLOC_ERROR;
 				}
-				lpfc_unreg_rpi(vports[i], ndlp);
 
 				if (ndlp->nlp_type & NLP_FABRIC) {
 					lpfc_disc_state_machine(vports[i], ndlp,
Signature · 1 line
2.26.2
#12 lore raw

PATCH 12/20 lpfc: Clear outstanding active mailbox during PCI function reset

In reply to James Smart

Mailbox commands sent via ioctl/bsg from user applications may be interrupted from processing by a concurrently triggered PCI function reset. The command will not generate a completion due to the reset. This results in a user application hang waiting for the mailbox command to complete.

Resolve by changing the function reset handler to detect that there was an outstanding mailbox command and simulate a mailbox completion. Add some additional debug when a mailbox command times out.

---
 drivers/scsi/lpfc/lpfc_init.c | 11 ++++++++++-
 drivers/scsi/lpfc/lpfc_sli.c  | 32 ++++++++++++++++++++++++++++++--
 2 files changed, 40 insertions(+), 3 deletions(-)
drivers/scsi/lpfc/lpfc_init.c +10 -1
index 2d277979a56a..bd3742035e76 100644
@@ -1852,6 +1852,7 @@ lpfc_sli4_port_sta_fn_reset(struct lpfc_hba *phba, int mbx_action,
 {
 	int rc;
 	uint32_t intr_mode;
+	LPFC_MBOXQ_t *mboxq;
 
 	if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) >=
 	    LPFC_SLI_INTF_IF_TYPE_2) {
@@ -1871,11 +1872,19 @@ lpfc_sli4_port_sta_fn_reset(struct lpfc_hba *phba, int mbx_action,
 				"Recovery...\n");
 
 	/* If we are no wait, the HBA has been reset and is not
-	 * functional, thus we should clear LPFC_SLI_ACTIVE flag.
+	 * functional, thus we should clear
+	 * (LPFC_SLI_ACTIVE | LPFC_SLI_MBOX_ACTIVE) flags.
 	 */
 	if (mbx_action == LPFC_MBX_NO_WAIT) {
 		spin_lock_irq(&phba->hbalock);
 		phba->sli.sli_flag &= ~LPFC_SLI_ACTIVE;
+		if (phba->sli.mbox_active) {
+			mboxq = phba->sli.mbox_active;
+			mboxq->u.mb.mbxStatus = MBX_NOT_FINISHED;
+			__lpfc_mbox_cmpl_put(phba, mboxq);
+			phba->sli.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE;
+			phba->sli.mbox_active = NULL;
+		}
 		spin_unlock_irq(&phba->hbalock);
 	}
 
drivers/scsi/lpfc/lpfc_sli.c +30 -2
index 1abf63c85c4b..06ed8d0e6035 100644
@@ -8794,8 +8794,11 @@ static int
 lpfc_sli4_async_mbox_block(struct lpfc_hba *phba)
 {
 	struct lpfc_sli *psli = &phba->sli;
+	LPFC_MBOXQ_t *mboxq;
 	int rc = 0;
 	unsigned long timeout = 0;
+	u32 sli_flag;
+	u8 cmd, subsys, opcode;
 
 	/* Mark the asynchronous mailbox command posting as blocked */
 	spin_lock_irq(&phba->hbalock);
@@ -8813,12 +8816,37 @@ lpfc_sli4_async_mbox_block(struct lpfc_hba *phba)
 	if (timeout)
 		lpfc_sli4_process_missed_mbox_completions(phba);
 
-	/* Wait for the outstnading mailbox command to complete */
+	/* Wait for the outstanding mailbox command to complete */
 	while (phba->sli.mbox_active) {
 		/* Check active mailbox complete status every 2ms */
 		msleep(2);
 		if (time_after(jiffies, timeout)) {
-			/* Timeout, marked the outstanding cmd not complete */
+			/* Timeout, mark the outstanding cmd not complete */
+
+			/* Sanity check sli.mbox_active has not completed or
+			 * cancelled from another context during last 2ms sleep,
+			 * so take hbalock to be sure before logging.
+			 */
+			spin_lock_irq(&phba->hbalock);
+			if (phba->sli.mbox_active) {
+				mboxq = phba->sli.mbox_active;
+				cmd = mboxq->u.mb.mbxCommand;
+				subsys = lpfc_sli_config_mbox_subsys_get(phba,
+									 mboxq);
+				opcode = lpfc_sli_config_mbox_opcode_get(phba,
+									 mboxq);
+				sli_flag = psli->sli_flag;
+				spin_unlock_irq(&phba->hbalock);
+				lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
+						"2352 Mailbox command x%x "
+						"(x%x/x%x) sli_flag x%x could "
+						"not complete\n",
+						cmd, subsys, opcode,
+						sli_flag);
+			} else {
+				spin_unlock_irq(&phba->hbalock);
+			}
+
 			rc = 1;
 			break;
 		}
Signature · 1 line
2.26.2
#13 lore raw

PATCH 13/20 lpfc: Use PBDE feature enabled bit to determine PBDE support

In reply to James Smart

The SLI4 interface changed in the manner to indicate PBDE support. Rework the driver to check for PBDE support via the PBDE feature bit in COMMON_GET_SLI4_PARAMETERS.

---
 drivers/scsi/lpfc/lpfc_hw4.h  | 11 +++++++----
 drivers/scsi/lpfc/lpfc_init.c |  7 ++++---
 2 files changed, 11 insertions(+), 7 deletions(-)
drivers/scsi/lpfc/lpfc_hw4.h +7 -4
index 7d4d179fb534..4d9233de9ead 100644
@@ -3334,17 +3334,20 @@ struct lpfc_sli4_parameters {
 #define cfg_nosr_SHIFT				9
 #define cfg_nosr_MASK				0x00000001
 #define cfg_nosr_WORD				word19
-
 #define cfg_bv1s_SHIFT                          10
 #define cfg_bv1s_MASK                           0x00000001
 #define cfg_bv1s_WORD                           word19
-#define cfg_pvl_SHIFT				13
-#define cfg_pvl_MASK				0x00000001
-#define cfg_pvl_WORD				word19
 
 #define cfg_nsler_SHIFT                         12
 #define cfg_nsler_MASK                          0x00000001
 #define cfg_nsler_WORD                          word19
+#define cfg_pvl_SHIFT				13
+#define cfg_pvl_MASK				0x00000001
+#define cfg_pvl_WORD				word19
+
+#define cfg_pbde_SHIFT				20
+#define cfg_pbde_MASK				0x00000001
+#define cfg_pbde_WORD				word19
 
 	uint32_t word20;
 #define cfg_max_tow_xri_SHIFT			0
drivers/scsi/lpfc/lpfc_init.c +4 -3
index bd3742035e76..b06b2f847df2 100644
@@ -12268,9 +12268,10 @@ lpfc_get_sli4_parameters(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
 	if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME)
 		phba->cfg_sg_seg_cnt = LPFC_MAX_NVME_SEG_CNT;
 
-	/* Only embed PBDE for if_type 6, PBDE support requires xib be set */
-	if ((bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) !=
-	    LPFC_SLI_INTF_IF_TYPE_6) || (!bf_get(cfg_xib, mbx_sli4_parameters)))
+	/* Enable embedded Payload BDE if support is indicated */
+	if (bf_get(cfg_pbde, mbx_sli4_parameters))
+		phba->cfg_enable_pbde = 1;
+	else
 		phba->cfg_enable_pbde = 0;
 
 	/*
Signature · 1 line
2.26.2
#14 lore raw

PATCH 14/20 lpfc: Enable adisc discovery after RSCN by default

In reply to James Smart

Assign a default value of 1 to driver module parameter lpfc_use_adisc

---
 drivers/scsi/lpfc/lpfc_attr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/lpfc/lpfc_attr.c +2 -2
index eb88aaaf36eb..457989cfc0b7 100644
@@ -5412,9 +5412,9 @@ LPFC_VPORT_ATTR_R(fcp_class, 3, 2, 3,
 
 /*
 # lpfc_use_adisc: Use ADISC for FCP rediscovery instead of PLOGI. Value range
-# is [0,1]. Default value is 0.
+# is [0,1]. Default value is 1.
 */
-LPFC_VPORT_ATTR_RW(use_adisc, 0, 0, 1,
+LPFC_VPORT_ATTR_RW(use_adisc, 1, 0, 1,
 		   "Use ADISC on rediscovery to authenticate FCP devices");
 
 /*
Signature · 1 line
2.26.2
#15 lore raw

PATCH 15/20 lpfc: Delay unregistering from transport until GIDFT or ADISC completes

In reply to James Smart

On an RSCN event, the nodes specified in RSCN payload and in MAPPED state are moved to NPR state in order to revalidate the login. This triggers an immediate unregister from SCSI/NVME backend. The assumption is that the node may be missing. The re-registration with the backend happens after either relogin (PLOGI/PRLI; if ADISC is disabled or login truly lost) or when ADISC completes successfully (rediscover with ADISC enabled).

However, the NVME-FC standard provides for an RSCN to be triggered when the remote port supports a discovery controller and there was a change of discovery log content. As the remote port typically also supports storage subsystems, this unregister causes all storage controller connections to fail and require reconnect.

Correct by reworking the code to ensure that the unregistration only occurs when a login state is truly terminated, thereby leaving the nvme storage controllers in place.

The changes made in the patch are:
- Retain node state in ADISC_ISSUE when scheduling ADISC els retry.
- Do not clear wwpn/wwnn values upon ADISC failure.
- Move MAPPED nodes to NPR during RSCN processing, but do not unregister with transport. On GIDFT completion, identify missing nodes (not marked NLP_NPR_2B_DISC) and unregister them.
- Perform unregistration for nodes that will go through ADISC processing if ADISC completion fails.
- Successful ADISC completion will move node back to MAPPED state.

---
 drivers/scsi/lpfc/lpfc_crtn.h      |   2 +
 drivers/scsi/lpfc/lpfc_disc.h      |   9 +-
 drivers/scsi/lpfc/lpfc_els.c       |  66 ++++++----
 drivers/scsi/lpfc/lpfc_hbadisc.c   | 197 ++++++++++++++++++++++-------
 drivers/scsi/lpfc/lpfc_nportdisc.c |   9 +-
 drivers/scsi/lpfc/lpfc_nvme.c      |  10 +-
 drivers/scsi/lpfc/lpfc_nvme.h      |   4 +-
 7 files changed, 207 insertions(+), 90 deletions(-)
drivers/scsi/lpfc/lpfc_crtn.h +2 -0
index 737483c3f01d..41e0d8ef015a 100644
@@ -87,6 +87,8 @@ void lpfc_unregister_vfi_cmpl(struct lpfc_hba *, LPFC_MBOXQ_t *);
 void lpfc_enqueue_node(struct lpfc_vport *, struct lpfc_nodelist *);
 void lpfc_dequeue_node(struct lpfc_vport *, struct lpfc_nodelist *);
 void lpfc_nlp_set_state(struct lpfc_vport *, struct lpfc_nodelist *, int);
+void lpfc_nlp_reg_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp);
+void lpfc_nlp_unreg_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp);
 void lpfc_drop_node(struct lpfc_vport *, struct lpfc_nodelist *);
 void lpfc_set_disctmo(struct lpfc_vport *);
 int  lpfc_can_disctmo(struct lpfc_vport *);
drivers/scsi/lpfc/lpfc_disc.h +5 -4
index 131374a61d7e..871b665bd72e 100644
@@ -78,10 +78,11 @@ struct lpfc_node_rrqs {
 };
 
 enum lpfc_fc4_xpt_flags {
-	NLP_WAIT_FOR_UNREG = 0x1,
-	SCSI_XPT_REGD      = 0x2,
-	NVME_XPT_REGD      = 0x4,
-	NLP_XPT_HAS_HH     = 0x8,
+	NLP_XPT_REGD		= 0x1,
+	SCSI_XPT_REGD		= 0x2,
+	NVME_XPT_REGD		= 0x4,
+	NVME_XPT_UNREG_WAIT	= 0x8,
+	NLP_XPT_HAS_HH		= 0x10
 };
 
 struct lpfc_nodelist {
drivers/scsi/lpfc/lpfc_els.c +40 -26

91 lines not on this page · raw message

drivers/scsi/lpfc/lpfc_hbadisc.c +148 -49

218 lines not on this page · raw message

drivers/scsi/lpfc/lpfc_nportdisc.c +5 -4
index e12f83fb795c..46c1905f6f39 100644
@@ -863,6 +863,9 @@ lpfc_rcv_logo(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
 		ndlp->nlp_last_elscmd = ELS_CMD_PLOGI;
 	}
 out:
+	/* Unregister from backend, could have been skipped due to ADISC */
+	lpfc_nlp_unreg_node(vport, ndlp);
+
 	ndlp->nlp_prev_state = ndlp->nlp_state;
 	lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
 
@@ -1677,9 +1680,6 @@ lpfc_cmpl_adisc_adisc_issue(struct lpfc_vport *vport,
 		spin_unlock_irq(&ndlp->lock);
 		ndlp->nlp_last_elscmd = ELS_CMD_PLOGI;
 
-		memset(&ndlp->nlp_nodename, 0, sizeof(struct lpfc_name));
-		memset(&ndlp->nlp_portname, 0, sizeof(struct lpfc_name));
-
 		ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE;
 		lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
 		lpfc_unreg_rpi(vport, ndlp);
@@ -2597,13 +2597,14 @@ lpfc_device_recov_mapped_node(struct lpfc_vport *vport,
 			      void *arg,
 			      uint32_t evt)
 {
+	lpfc_disc_set_adisc(vport, ndlp);
+
 	ndlp->nlp_prev_state = NLP_STE_MAPPED_NODE;
 	lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
 	spin_lock_irq(&ndlp->lock);
 	ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
 	ndlp->nlp_fc4_type &= ~(NLP_FC4_FCP | NLP_FC4_NVME);
 	spin_unlock_irq(&ndlp->lock);
-	lpfc_disc_set_adisc(vport, ndlp);
 	return ndlp->nlp_state;
 }
 
drivers/scsi/lpfc/lpfc_nvme.c +5 -5
index bcc804cefd30..f36294e9b5dd 100644
@@ -216,8 +216,8 @@ lpfc_nvme_remoteport_delete(struct nvme_fc_remote_port *remoteport)
 	/* The register rebind might have occurred before the delete
 	 * downcall.  Guard against this race.
 	 */
-	if (ndlp->fc4_xpt_flags & NLP_WAIT_FOR_UNREG)
-		ndlp->fc4_xpt_flags &= ~(NLP_WAIT_FOR_UNREG | NVME_XPT_REGD);
+	if (ndlp->fc4_xpt_flags & NVME_XPT_UNREG_WAIT)
+		ndlp->fc4_xpt_flags &= ~(NVME_XPT_UNREG_WAIT | NVME_XPT_REGD);
 
 	spin_unlock_irq(&ndlp->lock);
 
@@ -2324,7 +2324,7 @@ lpfc_nvme_register_port(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
 		 * race that leaves the WAIT flag set.
 		 */
 		spin_lock_irq(&ndlp->lock);
-		ndlp->fc4_xpt_flags &= ~NLP_WAIT_FOR_UNREG;
+		ndlp->fc4_xpt_flags &= ~NVME_XPT_UNREG_WAIT;
 		ndlp->fc4_xpt_flags |= NVME_XPT_REGD;
 		spin_unlock_irq(&ndlp->lock);
 		rport = remote_port->private;
@@ -2336,7 +2336,7 @@ lpfc_nvme_register_port(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
 			 */
 			spin_lock_irq(&ndlp->lock);
 			ndlp->nrport = NULL;
-			ndlp->fc4_xpt_flags &= ~NLP_WAIT_FOR_UNREG;
+			ndlp->fc4_xpt_flags &= ~NVME_XPT_UNREG_WAIT;
 			spin_unlock_irq(&ndlp->lock);
 			rport->ndlp = NULL;
 			rport->remoteport = NULL;
@@ -2488,7 +2488,7 @@ lpfc_nvme_unregister_port(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
 		 * The transport will update it.
 		 */
 		spin_lock_irq(&vport->phba->hbalock);
-		ndlp->fc4_xpt_flags |= NLP_WAIT_FOR_UNREG;
+		ndlp->fc4_xpt_flags |= NVME_XPT_UNREG_WAIT;
 		spin_unlock_irq(&vport->phba->hbalock);
 
 		/* Don't let the host nvme transport keep sending keep-alives
drivers/scsi/lpfc/lpfc_nvme.h +2 -2
index 69a5a844c69c..060a7c111bad 100644
@@ -37,8 +37,8 @@
 #define LPFC_MAX_NVME_INFO_TMP_LEN	100
 #define LPFC_NVME_INFO_MORE_STR		"\nCould be more info...\n"
 
-#define lpfc_ndlp_get_nrport(ndlp)					\
-	((!ndlp->nrport || (ndlp->fc4_xpt_flags & NLP_WAIT_FOR_UNREG))	\
+#define lpfc_ndlp_get_nrport(ndlp)				\
+	((!ndlp->nrport || (ndlp->fc4_xpt_flags & NVME_XPT_UNREG_WAIT))\
 	? NULL : ndlp->nrport)
 
 struct lpfc_nvme_qhandle {
Signature · 1 line
2.26.2
#16 lore raw

PATCH 16/20 lpfc: Call discovery state machine when handling PLOGI/ADISC completions

In reply to James Smart

In the PLOGI and ADISC completion handling, the device removal event could be skipped during some link errors. This could leave a stale node in UNUSED state. Driver unload would hang for a long time waiting for this node to be freed.

Resolve by taking the following steps:
- Always post ADISC completion events to discovery state machine upon ADISC completion.
- In case of a completion error for PLOGI/ADISC, ensure that init refcount is dropped if not registered with transport.

---
 drivers/scsi/lpfc/lpfc_els.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)
drivers/scsi/lpfc/lpfc_els.c +4 -11
index 32f5f00f0a85..11e56534b8f0 100644
@@ -2031,9 +2031,7 @@ lpfc_cmpl_els_plogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
 				 irsp->un.ulpWord[4]);
 
 		/* Do not call DSM for lpfc_els_abort'ed ELS cmds */
-		if (lpfc_error_lost_link(irsp))
-			goto check_plogi;
-		else
+		if (!lpfc_error_lost_link(irsp))
 			lpfc_disc_state_machine(vport, ndlp, cmdiocb,
 						NLP_EVT_CMPL_PLOGI);
 
@@ -2086,7 +2084,6 @@ lpfc_cmpl_els_plogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
 					NLP_EVT_CMPL_PLOGI);
 	}
 
- check_plogi:
 	if (disc && vport->num_disc_nodes) {
 		/* Check to see if there are more PLOGIs to be sent */
 		lpfc_more_plogi(vport);
@@ -2755,12 +2752,9 @@ lpfc_cmpl_els_adisc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
 				 "2755 ADISC failure DID:%06X Status:x%x/x%x\n",
 				 ndlp->nlp_DID, irsp->ulpStatus,
 				 irsp->un.ulpWord[4]);
-		/* Do not call DSM for lpfc_els_abort'ed ELS cmds */
-		if (lpfc_error_lost_link(irsp))
-			goto check_adisc;
-		else
-			lpfc_disc_state_machine(vport, ndlp, cmdiocb,
-						NLP_EVT_CMPL_ADISC);
+
+		lpfc_disc_state_machine(vport, ndlp, cmdiocb,
+				NLP_EVT_CMPL_ADISC);
 
 		/* As long as this node is not registered with the SCSI or NVMe
 		 * transport, it is no longer an active node. Otherwise
@@ -2778,7 +2772,6 @@ lpfc_cmpl_els_adisc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
 		lpfc_disc_state_machine(vport, ndlp, cmdiocb,
 					NLP_EVT_CMPL_ADISC);
 
- check_adisc:
 	/* Check to see if there are more ADISCs to be sent */
 	if (disc && vport->num_disc_nodes)
 		lpfc_more_adisc(vport);
Signature · 1 line
2.26.2
#17 lore raw

PATCH 17/20 lpfc: Skip reg_vpi when link is down for SLI3 in ADISC cmpl path

In reply to James Smart

During RSCN storms, some instances of LIP on SLI-3 adapters lead to a situation where FLOGIs keep failing with firmware indicating an illegal command error code. This situation was preceded by an ADISC completion that was processed while the link was down. This path on SLI-3 performs a CLEAR_LA and attempts to activate a VPI with REG_VPI. Later, as the FLOGI completes, it's no longer in sync with the VPI state. In SLI-3 it is illegal to have an active VPI during FLOGI.

Resolve by circumventing the SLI-3 path that performs the CLEAR_LA and REG_VPI. The path will be taken after the FLOGI after the next Link Up.

---
 drivers/scsi/lpfc/lpfc_els.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/scsi/lpfc/lpfc_els.c +8 -0
index 11e56534b8f0..342c7e28ee95 100644
@@ -2610,6 +2610,14 @@ lpfc_adisc_done(struct lpfc_vport *vport)
 	if ((phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) &&
 	    !(vport->fc_flag & FC_RSCN_MODE) &&
 	    (phba->sli_rev < LPFC_SLI_REV4)) {
+
+		/*
+		 * If link is down, clear_la and reg_vpi will be done after
+		 * flogi following a link up event
+		 */
+		if (!lpfc_is_link_up(phba))
+			return;
+
 		/* The ADISCs are complete.  Doesn't matter if they
 		 * succeeded or failed because the ADISC completion
 		 * routine guarantees to call the state machine and
Signature · 1 line
2.26.2
#18 lore raw

PATCH 18/20 lpfc: Skip issuing ADISC when node is in NPR state

In reply to James Smart

When a node moves to NPR state due to a device recovery event, the nlp_fc4_types in the node are cleared. An ADISC received for a node in the NPR state triggers an ADISC. Without fc4 types being known, the calls to register with the transport are no-op'd, thus no additional references are placed on the node by transport re-registrations. A subsequent RSCN could trigger another unregister request, which will decrement the reference counts, leading to the ref count hitting zero and the node being freed while futher discovery on the node is being attempted by the RSCN event handling.

Fix by skipping the trigger of an ADISC when in NPR state. The normal ADISC process will kick off in the regular discovery path after receiving a response from name server.

---
 drivers/scsi/lpfc/lpfc_nportdisc.c | 34 +++++++++++++++++-------------
 1 file changed, 19 insertions(+), 15 deletions(-)
drivers/scsi/lpfc/lpfc_nportdisc.c +19 -15
index 46c1905f6f39..27263f02ab9f 100644
@@ -736,9 +736,13 @@ lpfc_rcv_padisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
 		 * is already in MAPPED or UNMAPPED state.  Catch this
 		 * condition and don't set the nlp_state again because
 		 * it causes an unnecessary transport unregister/register.
+		 *
+		 * Nodes marked for ADISC will move MAPPED or UNMAPPED state
+		 * after issuing ADISC
 		 */
 		if (ndlp->nlp_type & (NLP_FCP_TARGET | NLP_NVME_TARGET)) {
-			if (ndlp->nlp_state != NLP_STE_MAPPED_NODE)
+			if ((ndlp->nlp_state != NLP_STE_MAPPED_NODE) &&
+			    !(ndlp->nlp_flag & NLP_NPR_ADISC))
 				lpfc_nlp_set_state(vport, ndlp,
 						   NLP_STE_MAPPED_NODE);
 		}
@@ -2646,14 +2650,13 @@ lpfc_rcv_prli_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
 	lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL);
 
 	if (!(ndlp->nlp_flag & NLP_DELAY_TMO)) {
-		if (ndlp->nlp_flag & NLP_NPR_ADISC) {
-			spin_lock_irq(&ndlp->lock);
-			ndlp->nlp_flag &= ~NLP_NPR_ADISC;
-			ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
-			spin_unlock_irq(&ndlp->lock);
-			lpfc_nlp_set_state(vport, ndlp, NLP_STE_ADISC_ISSUE);
-			lpfc_issue_els_adisc(vport, ndlp, 0);
-		} else {
+		/*
+		 * ADISC nodes will be handled in regular discovery path after
+		 * receiving response from NS.
+		 *
+		 * For other nodes, Send PLOGI to trigger an implicit LOGO.
+		 */
+		if (!(ndlp->nlp_flag & NLP_NPR_ADISC)) {
 			ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
 			lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE);
 			lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0);
@@ -2686,12 +2689,13 @@ lpfc_rcv_padisc_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
 	 */
 	if (!(ndlp->nlp_flag & NLP_DELAY_TMO) &&
 	    !(ndlp->nlp_flag & NLP_NPR_2B_DISC)) {
-		if (ndlp->nlp_flag & NLP_NPR_ADISC) {
-			ndlp->nlp_flag &= ~NLP_NPR_ADISC;
-			ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
-			lpfc_nlp_set_state(vport, ndlp, NLP_STE_ADISC_ISSUE);
-			lpfc_issue_els_adisc(vport, ndlp, 0);
-		} else {
+		/*
+		 * ADISC nodes will be handled in regular discovery path after
+		 * receiving response from NS.
+		 *
+		 * For other nodes, Send PLOGI to trigger an implicit LOGO.
+		 */
+		if (!(ndlp->nlp_flag & NLP_NPR_ADISC)) {
 			ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
 			lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE);
 			lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0);
Signature · 1 line
2.26.2
#19 lore raw

PATCH 19/20 lpfc: Update lpfc version to 12.8.0.11

In reply to James Smart

Update lpfc version to 12.8.0.11

---
 drivers/scsi/lpfc/lpfc_version.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/lpfc/lpfc_version.h +1 -1
index 2d62fd2a9824..63b2690ab49f 100644
@@ -20,7 +20,7 @@
  * included with this package.                                     *
  *******************************************************************/
 
-#define LPFC_DRIVER_VERSION "12.8.0.10"
+#define LPFC_DRIVER_VERSION "12.8.0.11"
 #define LPFC_DRIVER_NAME		"lpfc"
 
 /* Used for SLI 2/3 */
Signature · 1 line
2.26.2
#20 lore raw

PATCH 20/20 lpfc: Copyright updates for 12.8.0.11 patches

In reply to James Smart

Update copyrights for files modified by the 12.8.0.11 patch set.

---
 drivers/scsi/lpfc/lpfc_nvme.h | 2 +-
 drivers/scsi/lpfc/lpfc_sli4.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/lpfc/lpfc_nvme.h +1 -1
index 060a7c111bad..f61223fbe644 100644
@@ -1,7 +1,7 @@
 /*******************************************************************
  * This file is part of the Emulex Linux Device Driver for         *
  * Fibre Channel Host Bus Adapters.                                *
- * Copyright (C) 2017-2020 Broadcom. All Rights Reserved. The term *
+ * Copyright (C) 2017-2021 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 021edbfbbca5..f250b666ac57 100644
@@ -1,7 +1,7 @@
 /*******************************************************************
  * This file is part of the Emulex Linux Device Driver for         *
  * Fibre Channel Host Bus Adapters.                                *
- * Copyright (C) 2017-2019 Broadcom. All Rights Reserved. The term *
+ * Copyright (C) 2017-2021 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.                        *
Signature · 1 line
2.26.2
#22 lore raw
In reply to James Smart
Quoted 32 lines · James Smart

Update lpfc to revision 12.8.0.11

This patch set contains fixes and improvements for the lpfc driver

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

James Smart (20):
lpfc: Fix NVME support reporting in log message
lpfc: Remove use of kmalloc in trace event logging
lpfc: Improve firmware download logging
lpfc: Fix function description comments for vmid routines
lpfc: Discovery state machine fixes for LOGO handling
lpfc: Fix target reset handler from falsely returning FAILURE
lpfc: Keep ndlp reference until after freeing the iocb after els
handling
lpfc: Fix null ptr dereference with NPIV ports for RDF handling
lpfc: Fix memory leaks in error paths while issuing ELS RDF/SCR
request
lpfc: Remove REG_LOGIN check requirement to issue an ELS RDF
lpfc: Fix KASAN slab-out-of-bounds in lpfc_unreg_rpi routine
lpfc: Clear outstanding active mailbox during PCI function reset
lpfc: Use PBDE feature enabled bit to determine PBDE support
lpfc: Enable adisc discovery after RSCN by default
lpfc: Delay unregistering from transport until GIDFT or ADISC
completes
lpfc: Call discovery state machine when handling PLOGI/ADISC
completions
lpfc: Skip reg_vpi when link is down for SLI3 in ADISC cmpl path
lpfc: Skip issuing ADISC when node is in NPR state
lpfc: Update lpfc version to 12.8.0.11
lpfc: Copyright updates for 12.8.0.11 patches

Quoted 1 line

[...]

Applied to 5.15/scsi-queue, thanks!

[01/20] lpfc: Fix NVME support reporting in log message

        https://git.kernel.org/mkp/scsi/c/ae463b60235e
[02/20] lpfc: Remove use of kmalloc in trace event logging
        https://git.kernel.org/mkp/scsi/c/e8613084053d
[03/20] lpfc: Improve firmware download logging
        https://git.kernel.org/mkp/scsi/c/16a93e83c87e
[04/20] lpfc: Fix function description comments for vmid routines
        https://git.kernel.org/mkp/scsi/c/50baa1595d30
[05/20] lpfc: Discovery state machine fixes for LOGO handling
        https://git.kernel.org/mkp/scsi/c/e77803bdbf0a
[06/20] lpfc: Fix target reset handler from falsely returning FAILURE
        https://git.kernel.org/mkp/scsi/c/21990d3d1861
[07/20] lpfc: Keep ndlp reference until after freeing the iocb after els handling
        https://git.kernel.org/mkp/scsi/c/4e670c8afd47
[08/20] lpfc: Fix null ptr dereference with NPIV ports for RDF handling
        https://git.kernel.org/mkp/scsi/c/2d338eb55b14
[09/20] lpfc: Fix memory leaks in error paths while issuing ELS RDF/SCR request
        https://git.kernel.org/mkp/scsi/c/cd6047e92c6a
[10/20] lpfc: Remove REG_LOGIN check requirement to issue an ELS RDF
        https://git.kernel.org/mkp/scsi/c/e78c006f4c88
[11/20] lpfc: Fix KASAN slab-out-of-bounds in lpfc_unreg_rpi routine
        https://git.kernel.org/mkp/scsi/c/affbe2442941
[12/20] lpfc: Clear outstanding active mailbox during PCI function reset
        https://git.kernel.org/mkp/scsi/c/a9978e397840
[13/20] lpfc: Use PBDE feature enabled bit to determine PBDE support
        https://git.kernel.org/mkp/scsi/c/137ddf038472
[14/20] lpfc: Enable adisc discovery after RSCN by default
        https://git.kernel.org/mkp/scsi/c/816bd88dffc5
[15/20] lpfc: Delay unregistering from transport until GIDFT or ADISC completes
        https://git.kernel.org/mkp/scsi/c/0614568361b0
[16/20] lpfc: Call discovery state machine when handling PLOGI/ADISC completions
        https://git.kernel.org/mkp/scsi/c/c65436b21c3a
[17/20] lpfc: Skip reg_vpi when link is down for SLI3 in ADISC cmpl path
        https://git.kernel.org/mkp/scsi/c/02607fbaf00d
[18/20] lpfc: Skip issuing ADISC when node is in NPR state
        https://git.kernel.org/mkp/scsi/c/ab8038608825
[19/20] lpfc: Update lpfc version to 12.8.0.11
        https://git.kernel.org/mkp/scsi/c/545a68e711ee
[20/20] lpfc: Copyright updates for 12.8.0.11 patches
        https://git.kernel.org/mkp/scsi/c/f2af8ffc63a1
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering