Skip to contentSkip to conversation

lpfc: Update lpfc to revision 14.0.0.4

PATCH Applied James Smart 2 participants 12 messages Dec 4, 2021 – Dec 14, 2021

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

cover lpfc: Update lpfc to revision 14.0.0.4

Update lpfc to revision 14.0.0.4

This patch set contains several bug fixes.

The patches were cut against Martin's 5.16/scsi-fixes tree

James Smart (9):
lpfc: Fix leaked lpfc_dmabuf mbox allocations with npiv
lpfc: Change return code on ios received during link bounce
lpfc: Fix lpfc_force_rscn ndlp kref imbalance
lpfc: Fix NPIV port deletion crash
lpfc: Trigger SLI4 firmware dump before doing driver cleanup
lpfc: Adjust CMF total bytes and rxmonitor
lpfc: Cap CMF read bytes to MBPI
lpfc: Add additional debugfs support for CMF
lpfc: Update lpfc version to 14.0.0.4

 drivers/scsi/lpfc/lpfc.h           |  7 ++-
 drivers/scsi/lpfc/lpfc_attr.c      | 62 ++++++++++++++--------
 drivers/scsi/lpfc/lpfc_debugfs.c   | 27 +++++++---
 drivers/scsi/lpfc/lpfc_debugfs.h   |  2 +-
 drivers/scsi/lpfc/lpfc_els.c       | 22 +++++---
 drivers/scsi/lpfc/lpfc_hbadisc.c   | 10 ++--
 drivers/scsi/lpfc/lpfc_hw.h        |  2 +-
 drivers/scsi/lpfc/lpfc_init.c      | 37 +++++++++----
 drivers/scsi/lpfc/lpfc_nportdisc.c |  6 +++
 drivers/scsi/lpfc/lpfc_scsi.c      |  8 +--
 drivers/scsi/lpfc/lpfc_sli.c       |  6 ---
 drivers/scsi/lpfc/lpfc_version.h   |  2 +-
 drivers/scsi/lpfc/lpfc_vport.c     | 83 +++++++++++++++++++++++-------
 13 files changed, 189 insertions(+), 85 deletions(-)
Signature · 1 line
2.26.2
#1 lore raw

PATCH 1/9 lpfc: Fix leaked lpfc_dmabuf mbox allocations with npiv

During rmmod testing, messages appeared indicating lpfc_mbuf_pool entries were still busy. This situation was only seen doing rmmod after at least 1 vport (NPIV) instance was created and destroyed. The number of messages scaled with the number of vports created.

When a vport is created, it can receive a PLOGI from another initiator Nport. When this happens, the driver prepares to ack the plogi and prepares an RPI for registration (via mbx cmd) which includes an mbuf allocation. During the unsolicited plogi processing and after the rpi preparation, the driver recognizes it's one of the vport instances and decides to reject the PLOGI. During the LS_RJT preparation for the PLOGI, the mailbox struct allocated for RPI registration is freed, but the mbuf that was also allocated is not released.

Fix by freeing the mbuf with the mailbox struct in the LS_RJT path.

As part of the code review to figure the issue out, a couple of other areas where found that also would not have released the mbuf. Those are cleaned up as well.

---
 drivers/scsi/lpfc/lpfc_els.c       | 6 +++++-
 drivers/scsi/lpfc/lpfc_init.c      | 8 ++++++--
 drivers/scsi/lpfc/lpfc_nportdisc.c | 6 ++++++
 3 files changed, 17 insertions(+), 3 deletions(-)
drivers/scsi/lpfc/lpfc_els.c +5 -1
index e83453bea2ae..5c10416c1c75 100644
@@ -6899,6 +6899,7 @@ static int
 lpfc_get_rdp_info(struct lpfc_hba *phba, struct lpfc_rdp_context *rdp_context)
 {
 	LPFC_MBOXQ_t *mbox = NULL;
+	struct lpfc_dmabuf *mp;
 	int rc;
 
 	mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
@@ -6914,8 +6915,11 @@ lpfc_get_rdp_info(struct lpfc_hba *phba, struct lpfc_rdp_context *rdp_context)
 	mbox->mbox_cmpl = lpfc_mbx_cmpl_rdp_page_a0;
 	mbox->ctx_ndlp = (struct lpfc_rdp_context *)rdp_context;
 	rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT);
-	if (rc == MBX_NOT_FINISHED)
+	if (rc == MBX_NOT_FINISHED) {
+		mp = (struct lpfc_dmabuf *)mbox->ctx_buf;
+		lpfc_mbuf_free(phba, mp->virt, mp->phys);
 		goto issue_mbox_fail;
+	}
 
 	return 0;
 
drivers/scsi/lpfc/lpfc_init.c +6 -2
index ba17a8f740a9..7628b0634c57 100644
@@ -5373,8 +5373,10 @@ lpfc_sli4_async_link_evt(struct lpfc_hba *phba,
 	 */
 	if (!(phba->hba_flag & HBA_FCOE_MODE)) {
 		rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT);
-		if (rc == MBX_NOT_FINISHED)
+		if (rc == MBX_NOT_FINISHED) {
+			lpfc_mbuf_free(phba, mp->virt, mp->phys);
 			goto out_free_dmabuf;
+		}
 		return;
 	}
 	/*
@@ -6337,8 +6339,10 @@ lpfc_sli4_async_fc_evt(struct lpfc_hba *phba, struct lpfc_acqe_fc_la *acqe_fc)
 	}
 
 	rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT);
-	if (rc == MBX_NOT_FINISHED)
+	if (rc == MBX_NOT_FINISHED) {
+		lpfc_mbuf_free(phba, mp->virt, mp->phys);
 		goto out_free_dmabuf;
+	}
 	return;
 
 out_free_dmabuf:
drivers/scsi/lpfc/lpfc_nportdisc.c +6 -0
index 27263f02ab9f..7d717a4ac14d 100644
@@ -322,6 +322,7 @@ lpfc_rcv_plogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
 {
 	struct lpfc_hba    *phba = vport->phba;
 	struct lpfc_dmabuf *pcmd;
+	struct lpfc_dmabuf *mp;
 	uint64_t nlp_portwwn = 0;
 	uint32_t *lp;
 	IOCB_t *icmd;
@@ -571,6 +572,11 @@ lpfc_rcv_plogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
 		 * a default RPI.
 		 */
 		if (phba->sli_rev == LPFC_SLI_REV4) {
+			mp = (struct lpfc_dmabuf *)login_mbox->ctx_buf;
+			if (mp) {
+				lpfc_mbuf_free(phba, mp->virt, mp->phys);
+				kfree(mp);
+			}
 			mempool_free(login_mbox, phba->mbox_mem_pool);
 			login_mbox = NULL;
 		} else {
Signature · 1 line
2.26.2
#2 lore raw

PATCH 2/9 lpfc: Change return code on ios received during link bounce

In reply to James Smart

During heavy I/O testing with issue_lip to bounce the link, occasionally I/O is terminated with status 3 result 9, which means the RPI is suspended. The io is completed and this type of error will result in immediate retry by the scsi layer. The retry count expires and the io fails and returns error to the application.

To avoid these quick retry/retries exhausted scenarios change the return code given to the midlayer to DID_REQUEUE rather than DID_ERROR. This gets them retried, and eventually succeed when the link recovers.

---
 drivers/scsi/lpfc/lpfc_hw.h   | 2 +-
 drivers/scsi/lpfc/lpfc_scsi.c | 8 +++++---
 2 files changed, 6 insertions(+), 4 deletions(-)
drivers/scsi/lpfc/lpfc_hw.h +1 -1
index 634f8fff7425..61c9db31d9da 100644
@@ -3746,7 +3746,7 @@ typedef struct {
 #define IOERR_ILLEGAL_COMMAND         0x06
 #define IOERR_XCHG_DROPPED            0x07
 #define IOERR_ILLEGAL_FIELD           0x08
-#define IOERR_BAD_CONTINUE            0x09
+#define IOERR_RPI_SUSPENDED           0x09
 #define IOERR_TOO_MANY_BUFFERS        0x0A
 #define IOERR_RCV_BUFFER_WAITING      0x0B
 #define IOERR_NO_CONNECTION           0x0C
drivers/scsi/lpfc/lpfc_scsi.c +5 -3
index 6ccf573acdec..5a3da38a9067 100644
@@ -4393,6 +4393,7 @@ lpfc_fcp_io_cmd_wqe_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pwqeIn,
 		if (lpfc_cmd->result == IOERR_INVALID_RPI ||
 		    lpfc_cmd->result == IOERR_NO_RESOURCES ||
 		    lpfc_cmd->result == IOERR_ABORT_REQUESTED ||
+		    lpfc_cmd->result == IOERR_RPI_SUSPENDED ||
 		    lpfc_cmd->result == IOERR_SLER_CMD_RCV_FAILURE) {
 			cmd->result = DID_REQUEUE << 16;
 			break;
@@ -4448,10 +4449,11 @@ lpfc_fcp_io_cmd_wqe_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pwqeIn,
 
 		lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP,
 				 "9039 Iodone <%d/%llu> cmd x%px, error "
-				 "x%x SNS x%x x%x Data: x%x x%x\n",
+				 "x%x SNS x%x x%x LBA x%llx Data: x%x x%x\n",
 				 cmd->device->id, cmd->device->lun, cmd,
-				 cmd->result, *lp, *(lp + 3), cmd->retries,
-				 scsi_get_resid(cmd));
+				 cmd->result, *lp, *(lp + 3),
+				 (u64)scsi_get_lba(cmd),
+				 cmd->retries, scsi_get_resid(cmd));
 	}
 
 	lpfc_update_stats(vport, lpfc_cmd);
Signature · 1 line
2.26.2
#3 lore raw

PATCH 3/9 lpfc: Fix lpfc_force_rscn ndlp kref imbalance

In reply to James Smart

Issuing lpfc_force_rscn twice results in an ndlp kref use-after-free call trace.

A prior patch reworked the get/put handling by ensuring nlp_get was done before WQE submission and a put was done in the completion path. Unfortunately, the issue_els_rscn path had a piece of legacy code that did a nlp_put, causing an imbalance on the ref counts.

Fixed by removing the unnecessary legacy code snippet.

Fixes 4430f7fd09ec ("scsi: lpfc: Rework locations of ndlp reference taking")
Cc <[email protected]> # v5.11+
---
 drivers/scsi/lpfc/lpfc_els.c | 5 -----
 1 file changed, 5 deletions(-)
drivers/scsi/lpfc/lpfc_els.c +0 -5
index 5c10416c1c75..78024f11b794 100644
@@ -3538,11 +3538,6 @@ lpfc_issue_els_rscn(struct lpfc_vport *vport, uint8_t retry)
 		return 1;
 	}
 
-	/* This will cause the callback-function lpfc_cmpl_els_cmd to
-	 * trigger the release of node.
-	 */
-	if (!(vport->fc_flag & FC_PT2PT))
-		lpfc_nlp_put(ndlp);
 	return 0;
 }
 
Signature · 1 line
2.26.2
#4 lore raw

PATCH 4/9 lpfc: Fix NPIV port deletion crash

In reply to James Smart

The driver is calling schedule_timeout after the DA_ID nameserver request and LOGO commands are issued to the fabric by the initiator virtual endport. These fixed delay functions are causing long delays in the driver's worker thread when processing discovery IOs in a serialized fashion, which is then triggering mailbox timeout errors artificially.

To fix this, don't wait on the DA_ID request to complete and call wait_event_timeout to allow the vport delete thread to make progress on an event driven basis rather than fixing the wait time.

---
 drivers/scsi/lpfc/lpfc.h         |  2 -
 drivers/scsi/lpfc/lpfc_els.c     | 11 ++++-
 drivers/scsi/lpfc/lpfc_hbadisc.c |  2 -
 drivers/scsi/lpfc/lpfc_vport.c   | 83 ++++++++++++++++++++++++--------
 4 files changed, 73 insertions(+), 25 deletions(-)
drivers/scsi/lpfc/lpfc.h +0 -2
index 2f8e6d0a926f..a04995832459 100644
@@ -669,8 +669,6 @@ struct lpfc_vport {
 	struct timer_list els_tmofunc;
 	struct timer_list delayed_disc_tmo;
 
-	int unreg_vpi_cmpl;
-
 	uint8_t load_flag;
 #define FC_LOADING		0x1	/* HBA in process of loading drvr */
 #define FC_UNLOADING		0x2	/* HBA in process of unloading drvr */
drivers/scsi/lpfc/lpfc_els.c +10 -1
index 78024f11b794..db5ccae1b63d 100644
@@ -10973,10 +10973,19 @@ lpfc_cmpl_els_npiv_logo(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
 		lpfc_can_disctmo(vport);
 	}
 
+	if (ndlp->save_flags & NLP_WAIT_FOR_LOGO) {
+		/* Wake up lpfc_vport_delete if waiting...*/
+		if (ndlp->logo_waitq)
+			wake_up(ndlp->logo_waitq);
+		spin_lock_irq(&ndlp->lock);
+		ndlp->nlp_flag &= ~(NLP_ISSUE_LOGO | NLP_LOGO_SND);
+		ndlp->save_flags &= ~NLP_WAIT_FOR_LOGO;
+		spin_unlock_irq(&ndlp->lock);
+	}
+
 	/* Safe to release resources now. */
 	lpfc_els_free_iocb(phba, cmdiocb);
 	lpfc_nlp_put(ndlp);
-	vport->unreg_vpi_cmpl = VPORT_ERROR;
 }
 
 /**
drivers/scsi/lpfc/lpfc_hbadisc.c +0 -2
index 9fe6e5b386ce..802fd30a9fb8 100644
@@ -3928,7 +3928,6 @@ lpfc_mbx_cmpl_unreg_vpi(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
 	vport->vpi_state &= ~LPFC_VPI_REGISTERED;
 	vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI;
 	spin_unlock_irq(shost->host_lock);
-	vport->unreg_vpi_cmpl = VPORT_OK;
 	mempool_free(pmb, phba->mbox_mem_pool);
 	lpfc_cleanup_vports_rrqs(vport, NULL);
 	/*
@@ -3958,7 +3957,6 @@ lpfc_mbx_unreg_vpi(struct lpfc_vport *vport)
 		lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
 				 "1800 Could not issue unreg_vpi\n");
 		mempool_free(mbox, phba->mbox_mem_pool);
-		vport->unreg_vpi_cmpl = VPORT_ERROR;
 		return rc;
 	}
 	return 0;
drivers/scsi/lpfc/lpfc_vport.c +63 -20

119 lines not on this page · raw message

Signature · 1 line
2.26.2
#5 lore raw

PATCH 5/9 lpfc: Trigger SLI4 firmware dump before doing driver cleanup

In reply to James Smart

Extraneous teardown routines are present in the firmware dump path causing altered states in firmware captures.

When a firmware dump is requested via sysfs, trigger the dump immediately without tearing down structures and changing adapter state.

The driver shall rely on pre-existing firmware error state clean up handlers to restore the adapter.

---
 drivers/scsi/lpfc/lpfc.h         |  2 +-
 drivers/scsi/lpfc/lpfc_attr.c    | 62 ++++++++++++++++++++------------
 drivers/scsi/lpfc/lpfc_hbadisc.c |  8 ++++-
 drivers/scsi/lpfc/lpfc_sli.c     |  6 ----
 4 files changed, 48 insertions(+), 30 deletions(-)
drivers/scsi/lpfc/lpfc.h +1 -1
index a04995832459..e652926fb47a 100644
@@ -1021,7 +1021,6 @@ struct lpfc_hba {
 #define HBA_DEVLOSS_TMO         0x2000 /* HBA in devloss timeout */
 #define HBA_RRQ_ACTIVE		0x4000 /* process the rrq active list */
 #define HBA_IOQ_FLUSH		0x8000 /* FCP/NVME I/O queues being flushed */
-#define HBA_FW_DUMP_OP		0x10000 /* Skips fn reset before FW dump */
 #define HBA_RECOVERABLE_UE	0x20000 /* Firmware supports recoverable UE */
 #define HBA_FORCED_LINK_SPEED	0x40000 /*
 					 * Firmware supports Forced Link Speed
@@ -1038,6 +1037,7 @@ struct lpfc_hba {
 #define HBA_HBEAT_TMO		0x8000000 /* HBEAT initiated after timeout */
 #define HBA_FLOGI_OUTSTANDING	0x10000000 /* FLOGI is outstanding */
 
+	struct completion *fw_dump_cmpl; /* cmpl event tracker for fw_dump */
 	uint32_t fcp_ring_in_use; /* When polling test if intr-hndlr active*/
 	struct lpfc_dmabuf slim2p;
 
drivers/scsi/lpfc/lpfc_attr.c +40 -22

89 lines not on this page · raw message

drivers/scsi/lpfc/lpfc_hbadisc.c +7 -1
index 802fd30a9fb8..816fc406135b 100644
@@ -869,10 +869,16 @@ lpfc_work_done(struct lpfc_hba *phba)
 	if (phba->pci_dev_grp == LPFC_PCI_DEV_OC)
 		lpfc_sli4_post_async_mbox(phba);
 
-	if (ha_copy & HA_ERATT)
+	if (ha_copy & HA_ERATT) {
 		/* Handle the error attention event */
 		lpfc_handle_eratt(phba);
 
+		if (phba->fw_dump_cmpl) {
+			complete(phba->fw_dump_cmpl);
+			phba->fw_dump_cmpl = NULL;
+		}
+	}
+
 	if (ha_copy & HA_MBATT)
 		lpfc_sli_handle_mb_event(phba);
 
drivers/scsi/lpfc/lpfc_sli.c +0 -6
index 5dedb3de271d..513a78d08b1d 100644
@@ -5046,12 +5046,6 @@ lpfc_sli4_brdreset(struct lpfc_hba *phba)
 	phba->fcf.fcf_flag = 0;
 	spin_unlock_irq(&phba->hbalock);
 
-	/* SLI4 INTF 2: if FW dump is being taken skip INIT_PORT */
-	if (phba->hba_flag & HBA_FW_DUMP_OP) {
-		phba->hba_flag &= ~HBA_FW_DUMP_OP;
-		return rc;
-	}
-
 	/* Now physically reset the device */
 	lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
 			"0389 Performing PCI function reset!\n");
Signature · 1 line
2.26.2
#6 lore raw

PATCH 6/9 lpfc: Adjust CMF total bytes and rxmonitor

In reply to James Smart

Calculate any extra bytes needed to account for timer accuracy. If we are less than LPFC_CMF_INTERVAL, then calculate the adjustment needed for total to reflect a full LPFC_CMF_INTERVAL.

Add additional info to rxmonitor, and adjust some log formatting.

---
 drivers/scsi/lpfc/lpfc.h         |  1 +
 drivers/scsi/lpfc/lpfc_debugfs.c | 14 ++++++++------
 drivers/scsi/lpfc/lpfc_debugfs.h |  2 +-
 drivers/scsi/lpfc/lpfc_init.c    | 20 ++++++++++++--------
 4 files changed, 22 insertions(+), 15 deletions(-)
drivers/scsi/lpfc/lpfc.h +1 -0
index e652926fb47a..49abbf132bee 100644
@@ -1602,6 +1602,7 @@ struct lpfc_hba {
 #define LPFC_MAX_RXMONITOR_ENTRY	800
 #define LPFC_MAX_RXMONITOR_DUMP		32
 struct rxtable_entry {
+	uint64_t cmf_bytes;	/* Total no of read bytes for CMF_SYNC_WQE */
 	uint64_t total_bytes;   /* Total no of read bytes requested */
 	uint64_t rcv_bytes;     /* Total no of read bytes completed */
 	uint64_t avg_io_size;
drivers/scsi/lpfc/lpfc_debugfs.c +8 -6
index bd6d459afce5..ab2550ad0597 100644
@@ -5561,22 +5561,24 @@ lpfc_rx_monitor_read(struct file *file, char __user *buf, size_t nbytes,
 	start = tail;
 
 	len += scnprintf(buffer + len, MAX_DEBUGFS_RX_TABLE_SIZE - len,
-			"        MaxBPI\t Total Data Cmd  Total Data Cmpl "
-			"  Latency(us)    Avg IO Size\tMax IO Size   IO cnt "
-			"Info BWutil(ms)\n");
+			"        MaxBPI    Tot_Data_CMF Tot_Data_Cmd "
+			"Tot_Data_Cmpl  Lat(us)  Avg_IO  Max_IO "
+			"Bsy IO_cnt Info BWutil(ms)\n");
 get_table:
 	for (i = start; i < last; i++) {
 		entry = &phba->rxtable[i];
 		len += scnprintf(buffer + len, MAX_DEBUGFS_RX_TABLE_SIZE - len,
-				"%3d:%12lld  %12lld\t%12lld\t"
-				"%8lldus\t%8lld\t%10lld "
-				"%8d   %2d %2d(%2d)\n",
+				"%3d:%12lld %12lld %12lld %12lld "
+				"%7lldus %8lld %7lld "
+				"%2d   %4d   %2d   %2d(%2d)\n",
 				i, entry->max_bytes_per_interval,
+				entry->cmf_bytes,
 				entry->total_bytes,
 				entry->rcv_bytes,
 				entry->avg_io_latency,
 				entry->avg_io_size,
 				entry->max_read_cnt,
+				entry->cmf_busy,
 				entry->io_cnt,
 				entry->cmf_info,
 				entry->timer_utilization,
drivers/scsi/lpfc/lpfc_debugfs.h +1 -1
index a5bf71b34972..6dd361c1fd31 100644
@@ -282,7 +282,7 @@ struct lpfc_idiag {
 	void *ptr_private;
 };
 
-#define MAX_DEBUGFS_RX_TABLE_SIZE	(100 * LPFC_MAX_RXMONITOR_ENTRY)
+#define MAX_DEBUGFS_RX_TABLE_SIZE	(128 * LPFC_MAX_RXMONITOR_ENTRY)
 struct lpfc_rx_monitor_debug {
 	char *i_private;
 	char *buffer;
drivers/scsi/lpfc/lpfc_init.c +12 -8
index 7628b0634c57..132f2e60bdb4 100644
@@ -5927,7 +5927,7 @@ lpfc_cmf_timer(struct hrtimer *timer)
 	uint32_t io_cnt;
 	uint32_t head, tail;
 	uint32_t busy, max_read;
-	uint64_t total, rcv, lat, mbpi, extra;
+	uint64_t total, rcv, lat, mbpi, extra, cnt;
 	int timer_interval = LPFC_CMF_INTERVAL;
 	uint32_t ms;
 	struct lpfc_cgn_stat *cgs;
@@ -5998,20 +5998,23 @@ lpfc_cmf_timer(struct hrtimer *timer)
 
 		/* Calculate any extra bytes needed to account for the
 		 * timer accuracy. If we are less than LPFC_CMF_INTERVAL
-		 * add an extra 3% slop factor, equal to LPFC_CMF_INTERVAL
-		 * add an extra 2%. The goal is to equalize total with a
-		 * time > LPFC_CMF_INTERVAL or <= LPFC_CMF_INTERVAL + 1
+		 * calculate the adjustment needed for total to reflect
+		 * a full LPFC_CMF_INTERVAL.
 		 */
-		if (ms == LPFC_CMF_INTERVAL)
-			extra = div_u64(total, 50);
-		else if (ms < LPFC_CMF_INTERVAL)
-			extra = div_u64(total, 33);
+		if (ms && ms < LPFC_CMF_INTERVAL) {
+			cnt = div_u64(total, ms); /* bytes per ms */
+			cnt *= LPFC_CMF_INTERVAL; /* what total should be */
+			if (cnt > mbpi)
+				cnt = mbpi;
+			extra = cnt - total;
+		}
 		lpfc_issue_cmf_sync_wqe(phba, LPFC_CMF_INTERVAL, total + extra);
 	} else {
 		/* For Monitor mode or link down we want mbpi
 		 * to be the full link speed
 		 */
 		mbpi = phba->cmf_link_byte_count;
+		extra = 0;
 	}
 	phba->cmf_timer_cnt++;
 
@@ -6042,6 +6045,7 @@ lpfc_cmf_timer(struct hrtimer *timer)
 				   LPFC_RXMONITOR_TABLE_IN_USE);
 		entry = &phba->rxtable[head];
 		entry->total_bytes = total;
+		entry->cmf_bytes = total + extra;
 		entry->rcv_bytes = rcv;
 		entry->cmf_busy = busy;
 		entry->cmf_info = phba->cmf_active_info;
Signature · 1 line
2.26.2
#7 lore raw

PATCH 7/9 lpfc: Cap CMF read bytes to MBPI

In reply to James Smart

Ensure read bytes data does not go over MBPI for CMF timer intervals that are purposely shortened.

---
 drivers/scsi/lpfc/lpfc.h      |  2 +-
 drivers/scsi/lpfc/lpfc_init.c | 11 ++++++++++-
 2 files changed, 11 insertions(+), 2 deletions(-)
drivers/scsi/lpfc/lpfc.h +1 -1
index 49abbf132bee..3faadcfcdcbb 100644
@@ -1028,7 +1028,7 @@ struct lpfc_hba {
 					 */
 #define HBA_PCI_ERR		0x80000 /* The PCI slot is offline */
 #define HBA_FLOGI_ISSUED	0x100000 /* FLOGI was issued */
-#define HBA_CGN_RSVD1		0x200000 /* Reserved CGN flag */
+#define HBA_SHORT_CMF		0x200000 /* shorter CMF timer routine */
 #define HBA_CGN_DAY_WRAP	0x400000 /* HBA Congestion info day wraps */
 #define HBA_DEFER_FLOGI		0x800000 /* Defer FLOGI till read_sparm cmpl */
 #define HBA_SETUP		0x1000000 /* Signifies HBA setup is completed */
drivers/scsi/lpfc/lpfc_init.c +10 -1
index 132f2e60bdb4..2fe7d9d885d9 100644
@@ -6004,8 +6004,13 @@ lpfc_cmf_timer(struct hrtimer *timer)
 		if (ms && ms < LPFC_CMF_INTERVAL) {
 			cnt = div_u64(total, ms); /* bytes per ms */
 			cnt *= LPFC_CMF_INTERVAL; /* what total should be */
-			if (cnt > mbpi)
+
+			/* If the timeout is scheduled to be shorter,
+			 * this value may skew the data, so cap it at mbpi.
+			 */
+			if ((phba->hba_flag & HBA_SHORT_CMF) && cnt > mbpi)
 				cnt = mbpi;
+
 			extra = cnt - total;
 		}
 		lpfc_issue_cmf_sync_wqe(phba, LPFC_CMF_INTERVAL, total + extra);
@@ -6088,6 +6093,8 @@ lpfc_cmf_timer(struct hrtimer *timer)
 	/* Each minute save Fabric and Driver congestion information */
 	lpfc_cgn_save_evt_cnt(phba);
 
+	phba->hba_flag &= ~HBA_SHORT_CMF;
+
 	/* Since we need to call lpfc_cgn_save_evt_cnt every minute, on the
 	 * minute, adjust our next timer interval, if needed, to ensure a
 	 * 1 minute granularity when we get the next timer interrupt.
@@ -6098,6 +6105,8 @@ lpfc_cmf_timer(struct hrtimer *timer)
 						  jiffies);
 		if (timer_interval <= 0)
 			timer_interval = LPFC_CMF_INTERVAL;
+		else
+			phba->hba_flag |= HBA_SHORT_CMF;
 
 		/* If we adjust timer_interval, max_bytes_per_interval
 		 * needs to be adjusted as well.
Signature · 1 line
2.26.2
#8 lore raw

PATCH 8/9 lpfc: Add additional debugfs support for CMF

In reply to James Smart

Dump raw CMF parameter information in debugfs cgn_buffer.

---
 drivers/scsi/lpfc/lpfc_debugfs.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/scsi/lpfc/lpfc_debugfs.c +12 -1
index ab2550ad0597..21152c9a96ef 100644
@@ -5484,7 +5484,7 @@ lpfc_cgn_buffer_read(struct file *file, char __user *buf, size_t nbytes,
 		if (len > (LPFC_CGN_BUF_SIZE - LPFC_DEBUG_OUT_LINE_SZ)) {
 			len += scnprintf(buffer + len, LPFC_CGN_BUF_SIZE - len,
 					 "Truncated . . .\n");
-			break;
+			goto out;
 		}
 		len += scnprintf(buffer + len, LPFC_CGN_BUF_SIZE - len,
 				 "%03x: %08x %08x %08x %08x "
@@ -5495,6 +5495,17 @@ lpfc_cgn_buffer_read(struct file *file, char __user *buf, size_t nbytes,
 		cnt += 32;
 		ptr += 8;
 	}
+	if (len > (LPFC_CGN_BUF_SIZE - LPFC_DEBUG_OUT_LINE_SZ)) {
+		len += scnprintf(buffer + len, LPFC_CGN_BUF_SIZE - len,
+				 "Truncated . . .\n");
+		goto out;
+	}
+	len += scnprintf(buffer + len, LPFC_CGN_BUF_SIZE - len,
+			 "Parameter Data\n");
+	ptr = (uint32_t *)&phba->cgn_p;
+	len += scnprintf(buffer + len, LPFC_CGN_BUF_SIZE - len,
+			 "%08x %08x %08x %08x\n",
+			 *ptr, *(ptr + 1), *(ptr + 2), *(ptr + 3));
 out:
 	return simple_read_from_buffer(buf, nbytes, ppos, buffer, len);
 }
Signature · 1 line
2.26.2
#9 lore raw

PATCH 9/9 lpfc: Update lpfc version to 14.0.0.4

In reply to James Smart

Update lpfc version to 14.0.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 5a4d3b24fbce..2e9348a6897c 100644
@@ -20,7 +20,7 @@
  * included with this package.                                     *
  *******************************************************************/
 
-#define LPFC_DRIVER_VERSION "14.0.0.3"
+#define LPFC_DRIVER_VERSION "14.0.0.4"
 #define LPFC_DRIVER_NAME		"lpfc"
 
 /* Used for SLI 2/3 */
Signature · 1 line
2.26.2
#11 lore raw
In reply to James Smart
Quoted 17 lines · James Smart

Update lpfc to revision 14.0.0.4

This patch set contains several bug fixes.

The patches were cut against Martin's 5.16/scsi-fixes tree

James Smart (9):
lpfc: Fix leaked lpfc_dmabuf mbox allocations with npiv
lpfc: Change return code on ios received during link bounce
lpfc: Fix lpfc_force_rscn ndlp kref imbalance
lpfc: Fix NPIV port deletion crash
lpfc: Trigger SLI4 firmware dump before doing driver cleanup
lpfc: Adjust CMF total bytes and rxmonitor
lpfc: Cap CMF read bytes to MBPI
lpfc: Add additional debugfs support for CMF
lpfc: Update lpfc version to 14.0.0.4

Quoted 1 line

[...]

Applied to 5.17/scsi-queue, thanks!

[1/9] lpfc: Fix leaked lpfc_dmabuf mbox allocations with npiv

      https://git.kernel.org/mkp/scsi/c/f0d391969749
[2/9] lpfc: Change return code on ios received during link bounce
      https://git.kernel.org/mkp/scsi/c/2e81b1a374da
[3/9] lpfc: Fix lpfc_force_rscn ndlp kref imbalance
      https://git.kernel.org/mkp/scsi/c/7576d48c64f3
[4/9] lpfc: Fix NPIV port deletion crash
      https://git.kernel.org/mkp/scsi/c/8ed190a91950
[5/9] lpfc: Trigger SLI4 firmware dump before doing driver cleanup
      https://git.kernel.org/mkp/scsi/c/7dd2e2a92317
[6/9] lpfc: Adjust CMF total bytes and rxmonitor
      https://git.kernel.org/mkp/scsi/c/a6269f837045
[7/9] lpfc: Cap CMF read bytes to MBPI
      https://git.kernel.org/mkp/scsi/c/05116ef9c4b4
[8/9] lpfc: Add additional debugfs support for CMF
      https://git.kernel.org/mkp/scsi/c/6014a2468f0e
[9/9] lpfc: Update lpfc version to 14.0.0.4
      https://git.kernel.org/mkp/scsi/c/4437503bfbec
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering