All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/12] lpfc: Update lpfc to revision 12.6.0.4
@ 2020-01-28  0:23 James Smart
  2020-01-28  0:23 ` [PATCH 01/12] lpfc: Fix RQ buffer leakage when no IOCBs available James Smart
                   ` (12 more replies)
  0 siblings, 13 replies; 19+ messages in thread
From: James Smart @ 2020-01-28  0:23 UTC (permalink / raw)
  To: linux-scsi; +Cc: James Smart

Update lpfc to revision 12.6.0.4

Patch set contains mainly fixes and a few cleanups.

The patch "lpfc: Change lpfc_lun_queue_depth attribute to writable" is
dependent upon the following patch series, which adds the new
scsi service routine shost_change_max_queue_depths():
https://www.spinics.net/lists/linux-scsi/msg137981.html

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

-- james


James Smart (12):
  lpfc: Fix RQ buffer leakage when no IOCBs available
  lpfc: Fix lpfc_io_buf resource leak in lpfc_get_scsi_buf_s4 error path
  lpfc: Fix broken Credit Recovery after driver load
  lpfc: Fix registration of ELS type support in fdmi
  lpfc: Fix release of hwq to clear the eq relationship
  lpfc: Fix compiler warning on frame size
  lpfc: Fix coverity errors in fmdi attribute handling
  lpfc: Remove handler for obsolete ELS - Read Port Status (RPS)
  lpfc: Clean up hba max_lun_queue_depth checks
  lpfc: Change lpfc_lun_queue_depth attribute to writable
  lpfc: Update lpfc version to 12.6.0.4
  lpfc: Copyright updates for 12.6.0.4 patches

 drivers/scsi/lpfc/lpfc.h         |   7 +-
 drivers/scsi/lpfc/lpfc_attr.c    |  64 +++++++++++--
 drivers/scsi/lpfc/lpfc_ct.c      | 141 ++++++++++++++--------------
 drivers/scsi/lpfc/lpfc_els.c     | 195 ++-------------------------------------
 drivers/scsi/lpfc/lpfc_hbadisc.c |  61 +++++++-----
 drivers/scsi/lpfc/lpfc_hw.h      |  58 ++++--------
 drivers/scsi/lpfc/lpfc_init.c    |  40 ++++----
 drivers/scsi/lpfc/lpfc_scsi.c    |   6 +-
 drivers/scsi/lpfc/lpfc_sli.c     |  15 +--
 drivers/scsi/lpfc/lpfc_version.h |   4 +-
 10 files changed, 227 insertions(+), 364 deletions(-)

-- 
2.13.7


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

* [PATCH 01/12] lpfc: Fix RQ buffer leakage when no IOCBs available
  2020-01-28  0:23 [PATCH 00/12] lpfc: Update lpfc to revision 12.6.0.4 James Smart
@ 2020-01-28  0:23 ` James Smart
  2020-01-28  0:23 ` [PATCH 02/12] lpfc: Fix lpfc_io_buf resource leak in lpfc_get_scsi_buf_s4 error path James Smart
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: James Smart @ 2020-01-28  0:23 UTC (permalink / raw)
  To: linux-scsi; +Cc: James Smart, Dick Kennedy

The driver is occasionally see the following SLI Port error, requiring
reset and reinit:
 Port Status Event: ... error 1=0x52004a01, error 2=0x218

The failure means an RQ timeout. That is, the adapter had received
asynchronous receive frames, ran out of buffer slots to place the frames,
and the driver did not replenish the buffer slots before a timeout
occurred. The driver should not be so slow in replenishing buffers that
a timeout can occur.

When the driver received all the frames of a sequence, it allocates an IOCB
to put the frames in. In a situation where there was no IOCB available
for the frame of a sequence, the RQ buffer corresponding to the first frame
of the sequence was not returned to the FW. Eventually, with enough traffic
encountering the situation, the timeout occurred.

Fix by releasing the buffer back to firmware whenever there is no IOCB
for the first frame.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
---
 drivers/scsi/lpfc/lpfc_sli.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index 64002b0cb02d..ab6f58bc80a4 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -17950,6 +17950,10 @@ lpfc_prep_seq(struct lpfc_vport *vport, struct hbq_dmabuf *seq_dmabuf)
 			list_add_tail(&iocbq->list, &first_iocbq->list);
 		}
 	}
+	/* Free the sequence's header buffer */
+	if (!first_iocbq)
+		lpfc_in_buf_free(vport->phba, &seq_dmabuf->dbuf);
+
 	return first_iocbq;
 }
 
-- 
2.13.7


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

* [PATCH 02/12] lpfc: Fix lpfc_io_buf resource leak in lpfc_get_scsi_buf_s4 error path
  2020-01-28  0:23 [PATCH 00/12] lpfc: Update lpfc to revision 12.6.0.4 James Smart
  2020-01-28  0:23 ` [PATCH 01/12] lpfc: Fix RQ buffer leakage when no IOCBs available James Smart
@ 2020-01-28  0:23 ` James Smart
  2020-01-28  0:23 ` [PATCH 03/12] lpfc: Fix broken Credit Recovery after driver load James Smart
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: James Smart @ 2020-01-28  0:23 UTC (permalink / raw)
  To: linux-scsi; +Cc: James Smart, stable, Dick Kennedy

If a call to lpfc_get_cmd_rsp_buf_per_hdwq returns NULL (memory
allocation failure), a previously allocated lpfc_io_buf resource is
leaked.

Fix by releasing the lpfc_io_buf resource in the failure path.

Fixes: d79c9e9d4b3d ("scsi: lpfc: Support dynamic unbounded SGL lists on G7 hardware.")
Cc: <stable@vger.kernel.org> # v5.4+
Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
---
 drivers/scsi/lpfc/lpfc_scsi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
index 2c7e0b22db2f..96ac4a154c58 100644
--- a/drivers/scsi/lpfc/lpfc_scsi.c
+++ b/drivers/scsi/lpfc/lpfc_scsi.c
@@ -671,8 +671,10 @@ lpfc_get_scsi_buf_s4(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp,
 	lpfc_cmd->prot_data_type = 0;
 #endif
 	tmp = lpfc_get_cmd_rsp_buf_per_hdwq(phba, lpfc_cmd);
-	if (!tmp)
+	if (!tmp) {
+		lpfc_release_io_buf(phba, lpfc_cmd, lpfc_cmd->hdwq);
 		return NULL;
+	}
 
 	lpfc_cmd->fcp_cmnd = tmp->fcp_cmnd;
 	lpfc_cmd->fcp_rsp = tmp->fcp_rsp;
-- 
2.13.7


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

* [PATCH 03/12] lpfc: Fix broken Credit Recovery after driver load
  2020-01-28  0:23 [PATCH 00/12] lpfc: Update lpfc to revision 12.6.0.4 James Smart
  2020-01-28  0:23 ` [PATCH 01/12] lpfc: Fix RQ buffer leakage when no IOCBs available James Smart
  2020-01-28  0:23 ` [PATCH 02/12] lpfc: Fix lpfc_io_buf resource leak in lpfc_get_scsi_buf_s4 error path James Smart
@ 2020-01-28  0:23 ` James Smart
  2020-05-12 21:28   ` Chris Hofstaedtler
  2020-01-28  0:23 ` [PATCH 04/12] lpfc: Fix registration of ELS type support in fdmi James Smart
                   ` (9 subsequent siblings)
  12 siblings, 1 reply; 19+ messages in thread
From: James Smart @ 2020-01-28  0:23 UTC (permalink / raw)
  To: linux-scsi; +Cc: James Smart, stable, Dick Kennedy

When driver is set to enable bb credit recovery, the switch displayed
the setting as inactive.  If the link bounces, it switches to Active.

During link up processing, the driver currently does a MBX_READ_SPARAM
followed by a MBX_CONFIG_LINK. These mbox commands are queued to be
executed, one at a time and the completion is processed by the worker
thread.  Since the MBX_READ_SPARAM is done BEFORE the MBX_CONFIG_LINK,
the BB_SC_N bit is never set the the returned values. BB Credit recovery
status only gets set after the driver requests the feature in
CONFIG_LINK, which is done after the link up. Thus the ordering of
READ_SPARAM needs to follow the CONFIG_LINK.

Fix by reordering so that READ_SPARAM is done after CONFIG_LINK.
Added a HBA_DEFER_FLOGI flag so that any FLOGI handling waits until
after the READ_SPARAM is done so that the proper BB credit value is
set in the FLOGI payload.

Fixes: 6bfb16208298 ("scsi: lpfc: Fix configuration of BB credit recovery in service parameters")
Cc: <stable@vger.kernel.org> # v5.4+
Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
---
 drivers/scsi/lpfc/lpfc.h         |  1 +
 drivers/scsi/lpfc/lpfc_hbadisc.c | 59 ++++++++++++++++++++++++++--------------
 2 files changed, 40 insertions(+), 20 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
index 04d73e2be373..3f2cb17c4574 100644
--- a/drivers/scsi/lpfc/lpfc.h
+++ b/drivers/scsi/lpfc/lpfc.h
@@ -749,6 +749,7 @@ struct lpfc_hba {
 					 * capability
 					 */
 #define HBA_FLOGI_ISSUED	0x100000 /* FLOGI was issued */
+#define HBA_DEFER_FLOGI		0x800000 /* Defer FLOGI till read_sparm cmpl */
 
 	uint32_t fcp_ring_in_use; /* When polling test if intr-hndlr active*/
 	struct lpfc_dmabuf slim2p;
diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c
index dcc8999c6a68..6a2bdae0e52a 100644
--- a/drivers/scsi/lpfc/lpfc_hbadisc.c
+++ b/drivers/scsi/lpfc/lpfc_hbadisc.c
@@ -1163,13 +1163,16 @@ lpfc_mbx_cmpl_local_config_link(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
 	}
 
 	/* Start discovery by sending a FLOGI. port_state is identically
-	 * LPFC_FLOGI while waiting for FLOGI cmpl
+	 * LPFC_FLOGI while waiting for FLOGI cmpl. Check if sending
+	 * the FLOGI is being deferred till after MBX_READ_SPARAM completes.
 	 */
-	if (vport->port_state != LPFC_FLOGI)
-		lpfc_initial_flogi(vport);
-	else if (vport->fc_flag & FC_PT2PT)
-		lpfc_disc_start(vport);
-
+	if (vport->port_state != LPFC_FLOGI) {
+		if (!(phba->hba_flag & HBA_DEFER_FLOGI))
+			lpfc_initial_flogi(vport);
+	} else {
+		if (vport->fc_flag & FC_PT2PT)
+			lpfc_disc_start(vport);
+	}
 	return;
 
 out:
@@ -3094,6 +3097,14 @@ lpfc_mbx_cmpl_read_sparam(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
 	lpfc_mbuf_free(phba, mp->virt, mp->phys);
 	kfree(mp);
 	mempool_free(pmb, phba->mbox_mem_pool);
+
+	/* Check if sending the FLOGI is being deferred to after we get
+	 * up to date CSPs from MBX_READ_SPARAM.
+	 */
+	if (phba->hba_flag & HBA_DEFER_FLOGI) {
+		lpfc_initial_flogi(vport);
+		phba->hba_flag &= ~HBA_DEFER_FLOGI;
+	}
 	return;
 
 out:
@@ -3224,6 +3235,23 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, struct lpfc_mbx_read_top *la)
 	}
 
 	lpfc_linkup(phba);
+	sparam_mbox = NULL;
+
+	if (!(phba->hba_flag & HBA_FCOE_MODE)) {
+		cfglink_mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
+		if (!cfglink_mbox)
+			goto out;
+		vport->port_state = LPFC_LOCAL_CFG_LINK;
+		lpfc_config_link(phba, cfglink_mbox);
+		cfglink_mbox->vport = vport;
+		cfglink_mbox->mbox_cmpl = lpfc_mbx_cmpl_local_config_link;
+		rc = lpfc_sli_issue_mbox(phba, cfglink_mbox, MBX_NOWAIT);
+		if (rc == MBX_NOT_FINISHED) {
+			mempool_free(cfglink_mbox, phba->mbox_mem_pool);
+			goto out;
+		}
+	}
+
 	sparam_mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
 	if (!sparam_mbox)
 		goto out;
@@ -3244,20 +3272,7 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, struct lpfc_mbx_read_top *la)
 		goto out;
 	}
 
-	if (!(phba->hba_flag & HBA_FCOE_MODE)) {
-		cfglink_mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
-		if (!cfglink_mbox)
-			goto out;
-		vport->port_state = LPFC_LOCAL_CFG_LINK;
-		lpfc_config_link(phba, cfglink_mbox);
-		cfglink_mbox->vport = vport;
-		cfglink_mbox->mbox_cmpl = lpfc_mbx_cmpl_local_config_link;
-		rc = lpfc_sli_issue_mbox(phba, cfglink_mbox, MBX_NOWAIT);
-		if (rc == MBX_NOT_FINISHED) {
-			mempool_free(cfglink_mbox, phba->mbox_mem_pool);
-			goto out;
-		}
-	} else {
+	if (phba->hba_flag & HBA_FCOE_MODE) {
 		vport->port_state = LPFC_VPORT_UNKNOWN;
 		/*
 		 * Add the driver's default FCF record at FCF index 0 now. This
@@ -3314,6 +3329,10 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, struct lpfc_mbx_read_top *la)
 		}
 		/* Reset FCF roundrobin bmask for new discovery */
 		lpfc_sli4_clear_fcf_rr_bmask(phba);
+	} else {
+		if (phba->bbcredit_support && phba->cfg_enable_bbcr &&
+		    !(phba->link_flag & LS_LOOPBACK_MODE))
+			phba->hba_flag |= HBA_DEFER_FLOGI;
 	}
 
 	/* Prepare for LINK up registrations */
-- 
2.13.7


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

* [PATCH 04/12] lpfc: Fix registration of ELS type support in fdmi
  2020-01-28  0:23 [PATCH 00/12] lpfc: Update lpfc to revision 12.6.0.4 James Smart
                   ` (2 preceding siblings ...)
  2020-01-28  0:23 ` [PATCH 03/12] lpfc: Fix broken Credit Recovery after driver load James Smart
@ 2020-01-28  0:23 ` James Smart
  2020-01-28  0:23 ` [PATCH 05/12] lpfc: Fix release of hwq to clear the eq relationship James Smart
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: James Smart @ 2020-01-28  0:23 UTC (permalink / raw)
  To: linux-scsi; +Cc: James Smart, Dick Kennedy

Adjust FC4 Types in FDMI settings

The driver sets FDMI information registring ELS as a FC4 type.
ELS is a fc3 type and should not be registered.

Fix by removing ELS type bit when we register for FDMI Port attributes.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
---
 drivers/scsi/lpfc/lpfc_ct.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_ct.c b/drivers/scsi/lpfc/lpfc_ct.c
index 58b35a1442c1..fa70e2001b8e 100644
--- a/drivers/scsi/lpfc/lpfc_ct.c
+++ b/drivers/scsi/lpfc/lpfc_ct.c
@@ -2453,7 +2453,6 @@ lpfc_fdmi_port_attr_fc4type(struct lpfc_vport *vport,
 	ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
 	memset(ae, 0, 32);
 
-	ae->un.AttrTypes[3] = 0x02; /* Type 0x1 - ELS */
 	ae->un.AttrTypes[2] = 0x01; /* Type 0x8 - FCP */
 	ae->un.AttrTypes[7] = 0x01; /* Type 0x20 - CT */
 
@@ -2771,7 +2770,6 @@ lpfc_fdmi_port_attr_active_fc4type(struct lpfc_vport *vport,
 	ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
 	memset(ae, 0, 32);
 
-	ae->un.AttrTypes[3] = 0x02; /* Type 0x1 - ELS */
 	ae->un.AttrTypes[2] = 0x01; /* Type 0x8 - FCP */
 	ae->un.AttrTypes[7] = 0x01; /* Type 0x20 - CT */
 
-- 
2.13.7


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

* [PATCH 05/12] lpfc: Fix release of hwq to clear the eq relationship
  2020-01-28  0:23 [PATCH 00/12] lpfc: Update lpfc to revision 12.6.0.4 James Smart
                   ` (3 preceding siblings ...)
  2020-01-28  0:23 ` [PATCH 04/12] lpfc: Fix registration of ELS type support in fdmi James Smart
@ 2020-01-28  0:23 ` James Smart
  2020-01-28  0:23 ` [PATCH 06/12] lpfc: Fix compiler warning on frame size James Smart
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: James Smart @ 2020-01-28  0:23 UTC (permalink / raw)
  To: linux-scsi; +Cc: James Smart, Dick Kennedy

When performing reset testing, the eq's list for related hwq's was
getting corrupted.  In cases where there is not a 1:1 eq to hwq, the
eq is shared. The eq maintains a list of hwqs utilizing it in case of
cpu offlining and polling. During the reset, the hwqs are being torn
down so they can be recreated. The recreation was getting confused by
seeing a non-null eq assignment on the eq and the eq list became
corrupt.

Correct by clearing the hdwq eq assignment when the hwq is cleaned up.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
---
 drivers/scsi/lpfc/lpfc_init.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index 5a605773dd0a..9fd238d49117 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -9235,6 +9235,7 @@ lpfc_sli4_release_hdwq(struct lpfc_hba *phba)
 		/* Free the CQ/WQ corresponding to the Hardware Queue */
 		lpfc_sli4_queue_free(hdwq[idx].io_cq);
 		lpfc_sli4_queue_free(hdwq[idx].io_wq);
+		hdwq[idx].hba_eq = NULL;
 		hdwq[idx].io_cq = NULL;
 		hdwq[idx].io_wq = NULL;
 		if (phba->cfg_xpsgl && !phba->nvmet_support)
-- 
2.13.7


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

* [PATCH 06/12] lpfc: Fix compiler warning on frame size
  2020-01-28  0:23 [PATCH 00/12] lpfc: Update lpfc to revision 12.6.0.4 James Smart
                   ` (4 preceding siblings ...)
  2020-01-28  0:23 ` [PATCH 05/12] lpfc: Fix release of hwq to clear the eq relationship James Smart
@ 2020-01-28  0:23 ` James Smart
  2020-01-28  0:23 ` [PATCH 07/12] lpfc: Fix coverity errors in fmdi attribute handling James Smart
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: James Smart @ 2020-01-28  0:23 UTC (permalink / raw)
  To: linux-scsi; +Cc: James Smart, Dick Kennedy

The following error is see from the compiler:

  drivers/scsi/lpfc/lpfc_init.c: In function
    ‘lpfc_cpuhp_get_eq’: drivers/scsi/lpfc/lpfc_init.c:12660:1:
      error: the frame size of 1032 bytes is larger than 1024 bytes
         [-Werror=frame-larger-than=]

The issue is due to allocating a cpumask on the stack.

Fix by converting to a dynamical allocation of the cpu mask.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
---
 drivers/scsi/lpfc/lpfc_init.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index 9fd238d49117..9a6191818a23 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -11106,15 +11106,19 @@ lpfc_cpu_affinity_check(struct lpfc_hba *phba, int vectors)
  * @cpu:    cpu going offline
  * @eqlist:
  */
-static void
+static int
 lpfc_cpuhp_get_eq(struct lpfc_hba *phba, unsigned int cpu,
 		  struct list_head *eqlist)
 {
 	const struct cpumask *maskp;
 	struct lpfc_queue *eq;
-	cpumask_t tmp;
+	struct cpumask *tmp;
 	u16 idx;
 
+	tmp = kzalloc(cpumask_size(), GFP_KERNEL);
+	if (!tmp)
+		return -ENOMEM;
+
 	for (idx = 0; idx < phba->cfg_irq_chann; idx++) {
 		maskp = pci_irq_get_affinity(phba->pcidev, idx);
 		if (!maskp)
@@ -11124,7 +11128,7 @@ lpfc_cpuhp_get_eq(struct lpfc_hba *phba, unsigned int cpu,
 		 * then we don't need to poll the eq attached
 		 * to it.
 		 */
-		if (!cpumask_and(&tmp, maskp, cpumask_of(cpu)))
+		if (!cpumask_and(tmp, maskp, cpumask_of(cpu)))
 			continue;
 		/* get the cpus that are online and are affini-
 		 * tized to this irq vector.  If the count is
@@ -11132,8 +11136,8 @@ lpfc_cpuhp_get_eq(struct lpfc_hba *phba, unsigned int cpu,
 		 * down this vector.  Since this cpu has not
 		 * gone offline yet, we need >1.
 		 */
-		cpumask_and(&tmp, maskp, cpu_online_mask);
-		if (cpumask_weight(&tmp) > 1)
+		cpumask_and(tmp, maskp, cpu_online_mask);
+		if (cpumask_weight(tmp) > 1)
 			continue;
 
 		/* Now that we have an irq to shutdown, get the eq
@@ -11144,6 +11148,8 @@ lpfc_cpuhp_get_eq(struct lpfc_hba *phba, unsigned int cpu,
 		eq = phba->sli4_hba.hba_eq_hdl[idx].eq;
 		list_add(&eq->_poll_list, eqlist);
 	}
+	kfree(tmp);
+	return 0;
 }
 
 static void __lpfc_cpuhp_remove(struct lpfc_hba *phba)
@@ -11314,7 +11320,9 @@ static int lpfc_cpu_offline(unsigned int cpu, struct hlist_node *node)
 
 	lpfc_irq_rebalance(phba, cpu, true);
 
-	lpfc_cpuhp_get_eq(phba, cpu, &eqlist);
+	retval = lpfc_cpuhp_get_eq(phba, cpu, &eqlist);
+	if (retval)
+		return retval;
 
 	/* start polling on these eq's */
 	list_for_each_entry_safe(eq, next, &eqlist, _poll_list) {
-- 
2.13.7


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

* [PATCH 07/12] lpfc: Fix coverity errors in fmdi attribute handling
  2020-01-28  0:23 [PATCH 00/12] lpfc: Update lpfc to revision 12.6.0.4 James Smart
                   ` (5 preceding siblings ...)
  2020-01-28  0:23 ` [PATCH 06/12] lpfc: Fix compiler warning on frame size James Smart
@ 2020-01-28  0:23 ` James Smart
  2020-01-28  0:23 ` [PATCH 08/12] lpfc: Remove handler for obsolete ELS - Read Port Status (RPS) James Smart
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: James Smart @ 2020-01-28  0:23 UTC (permalink / raw)
  To: linux-scsi; +Cc: James Smart, Dick Kennedy

Coverity reported a memory corruption error for the fdmi attributes
routines:
  CID 15768 [Memory Corruption] Out-of-bounds access on FDMI

Sloppy coding of the fmdi structures. In both the lpfc_fdmi_attr_def
and lpfc_fdmi_reg_port_list structures, a field was placed at the start
of payload that may have variable content. The field was given an
arbitrary type (uint32_t). The code then uses the field name to derive
an address, which it used in things such as memset and memcpy. The
memset sizes or memcpy lengths were larger than the arbitrary type,
thus coverity reported an error.

Fix by replacing the arbitrary fields with the real field structures
describing the payload.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
---
 drivers/scsi/lpfc/lpfc_ct.c | 137 ++++++++++++++++++++++----------------------
 drivers/scsi/lpfc/lpfc_hw.h |  36 ++++++------
 2 files changed, 85 insertions(+), 88 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_ct.c b/drivers/scsi/lpfc/lpfc_ct.c
index fa70e2001b8e..8db27e84263e 100644
--- a/drivers/scsi/lpfc/lpfc_ct.c
+++ b/drivers/scsi/lpfc/lpfc_ct.c
@@ -2073,8 +2073,8 @@ lpfc_fdmi_hba_attr_wwnn(struct lpfc_vport *vport, struct lpfc_fdmi_attr_def *ad)
 	struct lpfc_fdmi_attr_entry *ae;
 	uint32_t size;
 
-	ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
-	memset(ae, 0, sizeof(struct lpfc_name));
+	ae = &ad->AttrValue;
+	memset(ae, 0, sizeof(*ae));
 
 	memcpy(&ae->un.AttrWWN, &vport->fc_sparam.nodeName,
 	       sizeof(struct lpfc_name));
@@ -2090,8 +2090,8 @@ lpfc_fdmi_hba_attr_manufacturer(struct lpfc_vport *vport,
 	struct lpfc_fdmi_attr_entry *ae;
 	uint32_t len, size;
 
-	ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
-	memset(ae, 0, 256);
+	ae = &ad->AttrValue;
+	memset(ae, 0, sizeof(*ae));
 
 	/* This string MUST be consistent with other FC platforms
 	 * supported by Broadcom.
@@ -2115,8 +2115,8 @@ lpfc_fdmi_hba_attr_sn(struct lpfc_vport *vport, struct lpfc_fdmi_attr_def *ad)
 	struct lpfc_fdmi_attr_entry *ae;
 	uint32_t len, size;
 
-	ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
-	memset(ae, 0, 256);
+	ae = &ad->AttrValue;
+	memset(ae, 0, sizeof(*ae));
 
 	strncpy(ae->un.AttrString, phba->SerialNumber,
 		sizeof(ae->un.AttrString));
@@ -2137,8 +2137,8 @@ lpfc_fdmi_hba_attr_model(struct lpfc_vport *vport,
 	struct lpfc_fdmi_attr_entry *ae;
 	uint32_t len, size;
 
-	ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
-	memset(ae, 0, 256);
+	ae = &ad->AttrValue;
+	memset(ae, 0, sizeof(*ae));
 
 	strncpy(ae->un.AttrString, phba->ModelName,
 		sizeof(ae->un.AttrString));
@@ -2158,8 +2158,8 @@ lpfc_fdmi_hba_attr_description(struct lpfc_vport *vport,
 	struct lpfc_fdmi_attr_entry *ae;
 	uint32_t len, size;
 
-	ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
-	memset(ae, 0, 256);
+	ae = &ad->AttrValue;
+	memset(ae, 0, sizeof(*ae));
 
 	strncpy(ae->un.AttrString, phba->ModelDesc,
 		sizeof(ae->un.AttrString));
@@ -2181,8 +2181,8 @@ lpfc_fdmi_hba_attr_hdw_ver(struct lpfc_vport *vport,
 	struct lpfc_fdmi_attr_entry *ae;
 	uint32_t i, j, incr, size;
 
-	ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
-	memset(ae, 0, 256);
+	ae = &ad->AttrValue;
+	memset(ae, 0, sizeof(*ae));
 
 	/* Convert JEDEC ID to ascii for hardware version */
 	incr = vp->rev.biuRev;
@@ -2211,8 +2211,8 @@ lpfc_fdmi_hba_attr_drvr_ver(struct lpfc_vport *vport,
 	struct lpfc_fdmi_attr_entry *ae;
 	uint32_t len, size;
 
-	ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
-	memset(ae, 0, 256);
+	ae = &ad->AttrValue;
+	memset(ae, 0, sizeof(*ae));
 
 	strncpy(ae->un.AttrString, lpfc_release_version,
 		sizeof(ae->un.AttrString));
@@ -2233,8 +2233,8 @@ lpfc_fdmi_hba_attr_rom_ver(struct lpfc_vport *vport,
 	struct lpfc_fdmi_attr_entry *ae;
 	uint32_t len, size;
 
-	ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
-	memset(ae, 0, 256);
+	ae = &ad->AttrValue;
+	memset(ae, 0, sizeof(*ae));
 
 	if (phba->sli_rev == LPFC_SLI_REV4)
 		lpfc_decode_firmware_rev(phba, ae->un.AttrString, 1);
@@ -2258,8 +2258,8 @@ lpfc_fdmi_hba_attr_fmw_ver(struct lpfc_vport *vport,
 	struct lpfc_fdmi_attr_entry *ae;
 	uint32_t len, size;
 
-	ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
-	memset(ae, 0, 256);
+	ae = &ad->AttrValue;
+	memset(ae, 0, sizeof(*ae));
 
 	lpfc_decode_firmware_rev(phba, ae->un.AttrString, 1);
 	len = strnlen(ae->un.AttrString,
@@ -2278,8 +2278,8 @@ lpfc_fdmi_hba_attr_os_ver(struct lpfc_vport *vport,
 	struct lpfc_fdmi_attr_entry *ae;
 	uint32_t len, size;
 
-	ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
-	memset(ae, 0, 256);
+	ae = &ad->AttrValue;
+	memset(ae, 0, sizeof(*ae));
 
 	snprintf(ae->un.AttrString, sizeof(ae->un.AttrString), "%s %s %s",
 		 init_utsname()->sysname,
@@ -2301,7 +2301,7 @@ lpfc_fdmi_hba_attr_ct_len(struct lpfc_vport *vport,
 	struct lpfc_fdmi_attr_entry *ae;
 	uint32_t size;
 
-	ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
+	ae = &ad->AttrValue;
 
 	ae->un.AttrInt =  cpu_to_be32(LPFC_MAX_CT_SIZE);
 	size = FOURBYTES + sizeof(uint32_t);
@@ -2317,8 +2317,8 @@ lpfc_fdmi_hba_attr_symbolic_name(struct lpfc_vport *vport,
 	struct lpfc_fdmi_attr_entry *ae;
 	uint32_t len, size;
 
-	ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
-	memset(ae, 0, 256);
+	ae = &ad->AttrValue;
+	memset(ae, 0, sizeof(*ae));
 
 	len = lpfc_vport_symbolic_node_name(vport,
 				ae->un.AttrString, 256);
@@ -2336,7 +2336,7 @@ lpfc_fdmi_hba_attr_vendor_info(struct lpfc_vport *vport,
 	struct lpfc_fdmi_attr_entry *ae;
 	uint32_t size;
 
-	ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
+	ae = &ad->AttrValue;
 
 	/* Nothing is defined for this currently */
 	ae->un.AttrInt =  cpu_to_be32(0);
@@ -2353,7 +2353,7 @@ lpfc_fdmi_hba_attr_num_ports(struct lpfc_vport *vport,
 	struct lpfc_fdmi_attr_entry *ae;
 	uint32_t size;
 
-	ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
+	ae = &ad->AttrValue;
 
 	/* Each driver instance corresponds to a single port */
 	ae->un.AttrInt =  cpu_to_be32(1);
@@ -2370,8 +2370,8 @@ lpfc_fdmi_hba_attr_fabric_wwnn(struct lpfc_vport *vport,
 	struct lpfc_fdmi_attr_entry *ae;
 	uint32_t size;
 
-	ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
-	memset(ae, 0, sizeof(struct lpfc_name));
+	ae = &ad->AttrValue;
+	memset(ae, 0, sizeof(*ae));
 
 	memcpy(&ae->un.AttrWWN, &vport->fabric_nodename,
 	       sizeof(struct lpfc_name));
@@ -2389,8 +2389,8 @@ lpfc_fdmi_hba_attr_bios_ver(struct lpfc_vport *vport,
 	struct lpfc_fdmi_attr_entry *ae;
 	uint32_t len, size;
 
-	ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
-	memset(ae, 0, 256);
+	ae = &ad->AttrValue;
+	memset(ae, 0, sizeof(*ae));
 
 	strlcat(ae->un.AttrString, phba->BIOSVersion,
 		sizeof(ae->un.AttrString));
@@ -2410,7 +2410,7 @@ lpfc_fdmi_hba_attr_bios_state(struct lpfc_vport *vport,
 	struct lpfc_fdmi_attr_entry *ae;
 	uint32_t size;
 
-	ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
+	ae = &ad->AttrValue;
 
 	/* Driver doesn't have access to this information */
 	ae->un.AttrInt =  cpu_to_be32(0);
@@ -2427,8 +2427,8 @@ lpfc_fdmi_hba_attr_vendor_id(struct lpfc_vport *vport,
 	struct lpfc_fdmi_attr_entry *ae;
 	uint32_t len, size;
 
-	ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
-	memset(ae, 0, 256);
+	ae = &ad->AttrValue;
+	memset(ae, 0, sizeof(*ae));
 
 	strncpy(ae->un.AttrString, "EMULEX",
 		sizeof(ae->un.AttrString));
@@ -2450,8 +2450,8 @@ lpfc_fdmi_port_attr_fc4type(struct lpfc_vport *vport,
 	struct lpfc_fdmi_attr_entry *ae;
 	uint32_t size;
 
-	ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
-	memset(ae, 0, 32);
+	ae = &ad->AttrValue;
+	memset(ae, 0, sizeof(*ae));
 
 	ae->un.AttrTypes[2] = 0x01; /* Type 0x8 - FCP */
 	ae->un.AttrTypes[7] = 0x01; /* Type 0x20 - CT */
@@ -2475,7 +2475,7 @@ lpfc_fdmi_port_attr_support_speed(struct lpfc_vport *vport,
 	struct lpfc_fdmi_attr_entry *ae;
 	uint32_t size;
 
-	ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
+	ae = &ad->AttrValue;
 
 	ae->un.AttrInt = 0;
 	if (!(phba->hba_flag & HBA_FCOE_MODE)) {
@@ -2529,7 +2529,7 @@ lpfc_fdmi_port_attr_speed(struct lpfc_vport *vport,
 	struct lpfc_fdmi_attr_entry *ae;
 	uint32_t size;
 
-	ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
+	ae = &ad->AttrValue;
 
 	if (!(phba->hba_flag & HBA_FCOE_MODE)) {
 		switch (phba->fc_linkspeed) {
@@ -2599,7 +2599,7 @@ lpfc_fdmi_port_attr_max_frame(struct lpfc_vport *vport,
 	struct lpfc_fdmi_attr_entry *ae;
 	uint32_t size;
 
-	ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
+	ae = &ad->AttrValue;
 
 	hsp = (struct serv_parm *)&vport->fc_sparam;
 	ae->un.AttrInt = (((uint32_t) hsp->cmn.bbRcvSizeMsb & 0x0F) << 8) |
@@ -2619,8 +2619,8 @@ lpfc_fdmi_port_attr_os_devname(struct lpfc_vport *vport,
 	struct lpfc_fdmi_attr_entry *ae;
 	uint32_t len, size;
 
-	ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
-	memset(ae, 0, 256);
+	ae = &ad->AttrValue;
+	memset(ae, 0, sizeof(*ae));
 
 	snprintf(ae->un.AttrString, sizeof(ae->un.AttrString),
 		 "/sys/class/scsi_host/host%d", shost->host_no);
@@ -2640,8 +2640,8 @@ lpfc_fdmi_port_attr_host_name(struct lpfc_vport *vport,
 	struct lpfc_fdmi_attr_entry *ae;
 	uint32_t len, size;
 
-	ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
-	memset(ae, 0, 256);
+	ae = &ad->AttrValue;
+	memset(ae, 0, sizeof(*ae));
 
 	scnprintf(ae->un.AttrString, sizeof(ae->un.AttrString), "%s",
 		  vport->phba->os_host_name);
@@ -2661,8 +2661,8 @@ lpfc_fdmi_port_attr_wwnn(struct lpfc_vport *vport,
 	struct lpfc_fdmi_attr_entry *ae;
 	uint32_t size;
 
-	ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
-	memset(ae, 0,  sizeof(struct lpfc_name));
+	ae = &ad->AttrValue;
+	memset(ae, 0, sizeof(*ae));
 
 	memcpy(&ae->un.AttrWWN, &vport->fc_sparam.nodeName,
 	       sizeof(struct lpfc_name));
@@ -2679,8 +2679,8 @@ lpfc_fdmi_port_attr_wwpn(struct lpfc_vport *vport,
 	struct lpfc_fdmi_attr_entry *ae;
 	uint32_t size;
 
-	ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
-	memset(ae, 0,  sizeof(struct lpfc_name));
+	ae = &ad->AttrValue;
+	memset(ae, 0, sizeof(*ae));
 
 	memcpy(&ae->un.AttrWWN, &vport->fc_sparam.portName,
 	       sizeof(struct lpfc_name));
@@ -2697,8 +2697,8 @@ lpfc_fdmi_port_attr_symbolic_name(struct lpfc_vport *vport,
 	struct lpfc_fdmi_attr_entry *ae;
 	uint32_t len, size;
 
-	ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
-	memset(ae, 0, 256);
+	ae = &ad->AttrValue;
+	memset(ae, 0, sizeof(*ae));
 
 	len = lpfc_vport_symbolic_port_name(vport, ae->un.AttrString, 256);
 	len += (len & 3) ? (4 - (len & 3)) : 4;
@@ -2716,7 +2716,7 @@ lpfc_fdmi_port_attr_port_type(struct lpfc_vport *vport,
 	struct lpfc_fdmi_attr_entry *ae;
 	uint32_t size;
 
-	ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
+	ae = &ad->AttrValue;
 	if (phba->fc_topology == LPFC_TOPOLOGY_LOOP)
 		ae->un.AttrInt =  cpu_to_be32(LPFC_FDMI_PORTTYPE_NLPORT);
 	else
@@ -2734,7 +2734,7 @@ lpfc_fdmi_port_attr_class(struct lpfc_vport *vport,
 	struct lpfc_fdmi_attr_entry *ae;
 	uint32_t size;
 
-	ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
+	ae = &ad->AttrValue;
 	ae->un.AttrInt = cpu_to_be32(FC_COS_CLASS2 | FC_COS_CLASS3);
 	size = FOURBYTES + sizeof(uint32_t);
 	ad->AttrLen = cpu_to_be16(size);
@@ -2749,8 +2749,8 @@ lpfc_fdmi_port_attr_fabric_wwpn(struct lpfc_vport *vport,
 	struct lpfc_fdmi_attr_entry *ae;
 	uint32_t size;
 
-	ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
-	memset(ae, 0,  sizeof(struct lpfc_name));
+	ae = &ad->AttrValue;
+	memset(ae, 0, sizeof(*ae));
 
 	memcpy(&ae->un.AttrWWN, &vport->fabric_portname,
 	       sizeof(struct lpfc_name));
@@ -2767,8 +2767,8 @@ lpfc_fdmi_port_attr_active_fc4type(struct lpfc_vport *vport,
 	struct lpfc_fdmi_attr_entry *ae;
 	uint32_t size;
 
-	ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
-	memset(ae, 0, 32);
+	ae = &ad->AttrValue;
+	memset(ae, 0, sizeof(*ae));
 
 	ae->un.AttrTypes[2] = 0x01; /* Type 0x8 - FCP */
 	ae->un.AttrTypes[7] = 0x01; /* Type 0x20 - CT */
@@ -2790,7 +2790,7 @@ lpfc_fdmi_port_attr_port_state(struct lpfc_vport *vport,
 	struct lpfc_fdmi_attr_entry *ae;
 	uint32_t size;
 
-	ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
+	ae = &ad->AttrValue;
 	/* Link Up - operational */
 	ae->un.AttrInt =  cpu_to_be32(LPFC_FDMI_PORTSTATE_ONLINE);
 	size = FOURBYTES + sizeof(uint32_t);
@@ -2806,7 +2806,7 @@ lpfc_fdmi_port_attr_num_disc(struct lpfc_vport *vport,
 	struct lpfc_fdmi_attr_entry *ae;
 	uint32_t size;
 
-	ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
+	ae = &ad->AttrValue;
 	vport->fdmi_num_disc = lpfc_find_map_node(vport);
 	ae->un.AttrInt = cpu_to_be32(vport->fdmi_num_disc);
 	size = FOURBYTES + sizeof(uint32_t);
@@ -2822,7 +2822,7 @@ lpfc_fdmi_port_attr_nportid(struct lpfc_vport *vport,
 	struct lpfc_fdmi_attr_entry *ae;
 	uint32_t size;
 
-	ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
+	ae = &ad->AttrValue;
 	ae->un.AttrInt =  cpu_to_be32(vport->fc_myDID);
 	size = FOURBYTES + sizeof(uint32_t);
 	ad->AttrLen = cpu_to_be16(size);
@@ -2837,8 +2837,8 @@ lpfc_fdmi_smart_attr_service(struct lpfc_vport *vport,
 	struct lpfc_fdmi_attr_entry *ae;
 	uint32_t len, size;
 
-	ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
-	memset(ae, 0, 256);
+	ae = &ad->AttrValue;
+	memset(ae, 0, sizeof(*ae));
 
 	strncpy(ae->un.AttrString, "Smart SAN Initiator",
 		sizeof(ae->un.AttrString));
@@ -2858,8 +2858,8 @@ lpfc_fdmi_smart_attr_guid(struct lpfc_vport *vport,
 	struct lpfc_fdmi_attr_entry *ae;
 	uint32_t size;
 
-	ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
-	memset(ae, 0, 256);
+	ae = &ad->AttrValue;
+	memset(ae, 0, sizeof(*ae));
 
 	memcpy(&ae->un.AttrString, &vport->fc_sparam.nodeName,
 	       sizeof(struct lpfc_name));
@@ -2879,8 +2879,8 @@ lpfc_fdmi_smart_attr_version(struct lpfc_vport *vport,
 	struct lpfc_fdmi_attr_entry *ae;
 	uint32_t len, size;
 
-	ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
-	memset(ae, 0, 256);
+	ae = &ad->AttrValue;
+	memset(ae, 0, sizeof(*ae));
 
 	strncpy(ae->un.AttrString, "Smart SAN Version 2.0",
 		sizeof(ae->un.AttrString));
@@ -2901,8 +2901,8 @@ lpfc_fdmi_smart_attr_model(struct lpfc_vport *vport,
 	struct lpfc_fdmi_attr_entry *ae;
 	uint32_t len, size;
 
-	ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
-	memset(ae, 0, 256);
+	ae = &ad->AttrValue;
+	memset(ae, 0, sizeof(*ae));
 
 	strncpy(ae->un.AttrString, phba->ModelName,
 		sizeof(ae->un.AttrString));
@@ -2921,7 +2921,7 @@ lpfc_fdmi_smart_attr_port_info(struct lpfc_vport *vport,
 	struct lpfc_fdmi_attr_entry *ae;
 	uint32_t size;
 
-	ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
+	ae = &ad->AttrValue;
 
 	/* SRIOV (type 3) is not supported */
 	if (vport->vpi)
@@ -2941,7 +2941,7 @@ lpfc_fdmi_smart_attr_qos(struct lpfc_vport *vport,
 	struct lpfc_fdmi_attr_entry *ae;
 	uint32_t size;
 
-	ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
+	ae = &ad->AttrValue;
 	ae->un.AttrInt =  cpu_to_be32(0);
 	size = FOURBYTES + sizeof(uint32_t);
 	ad->AttrLen = cpu_to_be16(size);
@@ -2956,7 +2956,7 @@ lpfc_fdmi_smart_attr_security(struct lpfc_vport *vport,
 	struct lpfc_fdmi_attr_entry *ae;
 	uint32_t size;
 
-	ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
+	ae = &ad->AttrValue;
 	ae->un.AttrInt =  cpu_to_be32(1);
 	size = FOURBYTES + sizeof(uint32_t);
 	ad->AttrLen = cpu_to_be16(size);
@@ -3104,7 +3104,8 @@ lpfc_fdmi_cmd(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
 			/* Registered Port List */
 			/* One entry (port) per adapter */
 			rh->rpl.EntryCnt = cpu_to_be32(1);
-			memcpy(&rh->rpl.pe, &phba->pport->fc_sparam.portName,
+			memcpy(&rh->rpl.pe.PortName,
+			       &phba->pport->fc_sparam.portName,
 			       sizeof(struct lpfc_name));
 
 			/* point to the HBA attribute block */
diff --git a/drivers/scsi/lpfc/lpfc_hw.h b/drivers/scsi/lpfc/lpfc_hw.h
index 436cdc8c5ef4..b5642c872593 100644
--- a/drivers/scsi/lpfc/lpfc_hw.h
+++ b/drivers/scsi/lpfc/lpfc_hw.h
@@ -1340,25 +1340,8 @@ struct fc_rdp_res_frame {
 /* lpfc_sli_ct_request defines the CT_IU preamble for FDMI commands */
 #define  SLI_CT_FDMI_Subtypes     0x10	/* Management Service Subtype */
 
-/*
- * Registered Port List Format
- */
-struct lpfc_fdmi_reg_port_list {
-	uint32_t EntryCnt;
-	uint32_t pe;		/* Variable-length array */
-};
-
-
 /* Definitions for HBA / Port attribute entries */
 
-struct lpfc_fdmi_attr_def { /* Defined in TLV format */
-	/* Structure is in Big Endian format */
-	uint32_t AttrType:16;
-	uint32_t AttrLen:16;
-	uint32_t AttrValue;  /* Marks start of Value (ATTRIBUTE_ENTRY) */
-};
-
-
 /* Attribute Entry */
 struct lpfc_fdmi_attr_entry {
 	union {
@@ -1369,7 +1352,13 @@ struct lpfc_fdmi_attr_entry {
 	} un;
 };
 
-#define LPFC_FDMI_MAX_AE_SIZE	sizeof(struct lpfc_fdmi_attr_entry)
+struct lpfc_fdmi_attr_def { /* Defined in TLV format */
+	/* Structure is in Big Endian format */
+	uint32_t AttrType:16;
+	uint32_t AttrLen:16;
+	/* Marks start of Value (ATTRIBUTE_ENTRY) */
+	struct lpfc_fdmi_attr_entry AttrValue;
+} __packed;
 
 /*
  * HBA Attribute Block
@@ -1394,12 +1383,19 @@ struct lpfc_fdmi_hba_ident {
 };
 
 /*
+ * Registered Port List Format
+ */
+struct lpfc_fdmi_reg_port_list {
+	uint32_t EntryCnt;
+	struct lpfc_fdmi_port_entry pe;
+} __packed;
+
+/*
  * Register HBA(RHBA)
  */
 struct lpfc_fdmi_reg_hba {
 	struct lpfc_fdmi_hba_ident hi;
-	struct lpfc_fdmi_reg_port_list rpl;	/* variable-length array */
-/* struct lpfc_fdmi_attr_block   ab; */
+	struct lpfc_fdmi_reg_port_list rpl;
 };
 
 /*
-- 
2.13.7


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

* [PATCH 08/12] lpfc: Remove handler for obsolete ELS - Read Port Status (RPS)
  2020-01-28  0:23 [PATCH 00/12] lpfc: Update lpfc to revision 12.6.0.4 James Smart
                   ` (6 preceding siblings ...)
  2020-01-28  0:23 ` [PATCH 07/12] lpfc: Fix coverity errors in fmdi attribute handling James Smart
@ 2020-01-28  0:23 ` James Smart
  2020-01-28  0:23 ` [PATCH 09/12] lpfc: Clean up hba max_lun_queue_depth checks James Smart
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: James Smart @ 2020-01-28  0:23 UTC (permalink / raw)
  To: linux-scsi; +Cc: James Smart, Dick Kennedy

There was report of an odd "Fix me..." log message, which was tracked
down to the lpfc_els_rcv_rps() routine. This was in handling of a very
old and obsolete ELS - Read Port Status. The RPS ELS was defined in
FC-LS-1, but deprecated in FC-LS-2, and removed from all later FC-LS
revisions. It was replaced by the Read Diagnostic Parameters (RDP) ELS
and the Link Error Status Block descriptor.

There should be no support for the RSP ELS.  Removed support from driver.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
---
 drivers/scsi/lpfc/lpfc.h     |   1 -
 drivers/scsi/lpfc/lpfc_els.c | 193 ++-----------------------------------------
 drivers/scsi/lpfc/lpfc_hw.h  |  20 -----
 3 files changed, 5 insertions(+), 209 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
index 3f2cb17c4574..cebbad1b3e55 100644
--- a/drivers/scsi/lpfc/lpfc.h
+++ b/drivers/scsi/lpfc/lpfc.h
@@ -262,7 +262,6 @@ struct lpfc_stats {
 	uint32_t elsRcvPRLI;
 	uint32_t elsRcvLIRR;
 	uint32_t elsRcvRLS;
-	uint32_t elsRcvRPS;
 	uint32_t elsRcvRPL;
 	uint32_t elsRcvRRQ;
 	uint32_t elsRcvRTV;
diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
index 42a2bf38eaea..371599d67eb4 100644
--- a/drivers/scsi/lpfc/lpfc_els.c
+++ b/drivers/scsi/lpfc/lpfc_els.c
@@ -7135,108 +7135,12 @@ lpfc_els_rsp_rls_acc(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
 }
 
 /**
- * lpfc_els_rsp_rps_acc - Completion callbk func for MBX_READ_LNK_STAT mbox cmd
- * @phba: pointer to lpfc hba data structure.
- * @pmb: pointer to the driver internal queue element for mailbox command.
- *
- * This routine is the completion callback function for the MBX_READ_LNK_STAT
- * mailbox command. This callback function is to actually send the Accept
- * (ACC) response to a Read Port Status (RPS) unsolicited IOCB event. It
- * collects the link statistics from the completion of the MBX_READ_LNK_STAT
- * mailbox command, constructs the RPS response with the link statistics
- * collected, and then invokes the lpfc_sli_issue_iocb() routine to send ACC
- * response to the RPS.
- *
- * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp
- * will be incremented by 1 for holding the ndlp and the reference to ndlp
- * will be stored into the context1 field of the IOCB for the completion
- * callback function to the RPS Accept Response ELS IOCB command.
- *
- **/
-static void
-lpfc_els_rsp_rps_acc(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
-{
-	MAILBOX_t *mb;
-	IOCB_t *icmd;
-	RPS_RSP *rps_rsp;
-	uint8_t *pcmd;
-	struct lpfc_iocbq *elsiocb;
-	struct lpfc_nodelist *ndlp;
-	uint16_t status;
-	uint16_t oxid;
-	uint16_t rxid;
-	uint32_t cmdsize;
-
-	mb = &pmb->u.mb;
-
-	ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp;
-	rxid = (uint16_t)((unsigned long)(pmb->ctx_buf) & 0xffff);
-	oxid = (uint16_t)(((unsigned long)(pmb->ctx_buf) >> 16) & 0xffff);
-	pmb->ctx_ndlp = NULL;
-	pmb->ctx_buf = NULL;
-
-	if (mb->mbxStatus) {
-		mempool_free(pmb, phba->mbox_mem_pool);
-		return;
-	}
-
-	cmdsize = sizeof(RPS_RSP) + sizeof(uint32_t);
-	mempool_free(pmb, phba->mbox_mem_pool);
-	elsiocb = lpfc_prep_els_iocb(phba->pport, 0, cmdsize,
-				     lpfc_max_els_tries, ndlp,
-				     ndlp->nlp_DID, ELS_CMD_ACC);
-
-	/* Decrement the ndlp reference count from previous mbox command */
-	lpfc_nlp_put(ndlp);
-
-	if (!elsiocb)
-		return;
-
-	icmd = &elsiocb->iocb;
-	icmd->ulpContext = rxid;
-	icmd->unsli3.rcvsli3.ox_id = oxid;
-
-	pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);
-	*((uint32_t *) (pcmd)) = ELS_CMD_ACC;
-	pcmd += sizeof(uint32_t); /* Skip past command */
-	rps_rsp = (RPS_RSP *)pcmd;
-
-	if (phba->fc_topology != LPFC_TOPOLOGY_LOOP)
-		status = 0x10;
-	else
-		status = 0x8;
-	if (phba->pport->fc_flag & FC_FABRIC)
-		status |= 0x4;
-
-	rps_rsp->rsvd1 = 0;
-	rps_rsp->portStatus = cpu_to_be16(status);
-	rps_rsp->linkFailureCnt = cpu_to_be32(mb->un.varRdLnk.linkFailureCnt);
-	rps_rsp->lossSyncCnt = cpu_to_be32(mb->un.varRdLnk.lossSyncCnt);
-	rps_rsp->lossSignalCnt = cpu_to_be32(mb->un.varRdLnk.lossSignalCnt);
-	rps_rsp->primSeqErrCnt = cpu_to_be32(mb->un.varRdLnk.primSeqErrCnt);
-	rps_rsp->invalidXmitWord = cpu_to_be32(mb->un.varRdLnk.invalidXmitWord);
-	rps_rsp->crcCnt = cpu_to_be32(mb->un.varRdLnk.crcCnt);
-	/* Xmit ELS RPS ACC response tag <ulpIoTag> */
-	lpfc_printf_vlog(ndlp->vport, KERN_INFO, LOG_ELS,
-			 "0118 Xmit ELS RPS ACC response tag x%x xri x%x, "
-			 "did x%x, nlp_flag x%x, nlp_state x%x, rpi x%x\n",
-			 elsiocb->iotag, elsiocb->iocb.ulpContext,
-			 ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state,
-			 ndlp->nlp_rpi);
-	elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp;
-	phba->fc_stat.elsXmitACC++;
-	if (lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0) == IOCB_ERROR)
-		lpfc_els_free_iocb(phba, elsiocb);
-	return;
-}
-
-/**
  * lpfc_els_rcv_rls - Process an unsolicited rls iocb
  * @vport: pointer to a host virtual N_Port data structure.
  * @cmdiocb: pointer to lpfc command iocb data structure.
  * @ndlp: pointer to a node-list data structure.
  *
- * This routine processes Read Port Status (RPL) IOCB received as an
+ * This routine processes Read Link Status (RLS) IOCB received as an
  * ELS unsolicited event. It first checks the remote port state. If the
  * remote port is not in NLP_STE_UNMAPPED_NODE state or NLP_STE_MAPPED_NODE
  * state, it invokes the lpfc_els_rsl_reject() routine to send the reject
@@ -7258,7 +7162,7 @@ lpfc_els_rcv_rls(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
 
 	if ((ndlp->nlp_state != NLP_STE_UNMAPPED_NODE) &&
 	    (ndlp->nlp_state != NLP_STE_MAPPED_NODE))
-		/* reject the unsolicited RPS request and done with it */
+		/* reject the unsolicited RLS request and done with it */
 		goto reject_out;
 
 	mbox = mempool_alloc(phba->mbox_mem_pool, GFP_ATOMIC);
@@ -7306,7 +7210,7 @@ lpfc_els_rcv_rls(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
  * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp
  * will be incremented by 1 for holding the ndlp and the reference to ndlp
  * will be stored into the context1 field of the IOCB for the completion
- * callback function to the RPS Accept Response ELS IOCB command.
+ * callback function to the RTV Accept Response ELS IOCB command.
  *
  * Return codes
  *   0 - Successfully processed rtv iocb (currently always return 0)
@@ -7325,7 +7229,7 @@ lpfc_els_rcv_rtv(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
 
 	if ((ndlp->nlp_state != NLP_STE_UNMAPPED_NODE) &&
 	    (ndlp->nlp_state != NLP_STE_MAPPED_NODE))
-		/* reject the unsolicited RPS request and done with it */
+		/* reject the unsolicited RTV request and done with it */
 		goto reject_out;
 
 	cmdsize = sizeof(struct RTV_RSP) + sizeof(uint32_t);
@@ -7378,84 +7282,7 @@ lpfc_els_rcv_rtv(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
 	return 0;
 }
 
-/* lpfc_els_rcv_rps - Process an unsolicited rps iocb
- * @vport: pointer to a host virtual N_Port data structure.
- * @cmdiocb: pointer to lpfc command iocb data structure.
- * @ndlp: pointer to a node-list data structure.
- *
- * This routine processes Read Port Status (RPS) IOCB received as an
- * ELS unsolicited event. It first checks the remote port state. If the
- * remote port is not in NLP_STE_UNMAPPED_NODE state or NLP_STE_MAPPED_NODE
- * state, it invokes the lpfc_els_rsp_reject() routine to send the reject
- * response. Otherwise, it issue the MBX_READ_LNK_STAT mailbox command
- * for reading the HBA link statistics. It is for the callback function,
- * lpfc_els_rsp_rps_acc(), set to the MBX_READ_LNK_STAT mailbox command
- * to actually sending out RPS Accept (ACC) response.
- *
- * Return codes
- *   0 - Successfully processed rps iocb (currently always return 0)
- **/
-static int
-lpfc_els_rcv_rps(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
-		 struct lpfc_nodelist *ndlp)
-{
-	struct lpfc_hba *phba = vport->phba;
-	uint32_t *lp;
-	uint8_t flag;
-	LPFC_MBOXQ_t *mbox;
-	struct lpfc_dmabuf *pcmd;
-	RPS *rps;
-	struct ls_rjt stat;
-
-	if ((ndlp->nlp_state != NLP_STE_UNMAPPED_NODE) &&
-	    (ndlp->nlp_state != NLP_STE_MAPPED_NODE))
-		/* reject the unsolicited RPS request and done with it */
-		goto reject_out;
-
-	pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;
-	lp = (uint32_t *) pcmd->virt;
-	flag = (be32_to_cpu(*lp++) & 0xf);
-	rps = (RPS *) lp;
-
-	if ((flag == 0) ||
-	    ((flag == 1) && (be32_to_cpu(rps->un.portNum) == 0)) ||
-	    ((flag == 2) && (memcmp(&rps->un.portName, &vport->fc_portname,
-				    sizeof(struct lpfc_name)) == 0))) {
-
-		printk("Fix me....\n");
-		dump_stack();
-		mbox = mempool_alloc(phba->mbox_mem_pool, GFP_ATOMIC);
-		if (mbox) {
-			lpfc_read_lnk_stat(phba, mbox);
-			mbox->ctx_buf = (void *)((unsigned long)
-				((cmdiocb->iocb.unsli3.rcvsli3.ox_id << 16) |
-				cmdiocb->iocb.ulpContext)); /* rx_id */
-			mbox->ctx_ndlp = lpfc_nlp_get(ndlp);
-			mbox->vport = vport;
-			mbox->mbox_cmpl = lpfc_els_rsp_rps_acc;
-			if (lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT)
-				!= MBX_NOT_FINISHED)
-				/* Mbox completion will send ELS Response */
-				return 0;
-			/* Decrement reference count used for the failed mbox
-			 * command.
-			 */
-			lpfc_nlp_put(ndlp);
-			mempool_free(mbox, phba->mbox_mem_pool);
-		}
-	}
-
-reject_out:
-	/* issue rejection response */
-	stat.un.b.lsRjtRsvd0 = 0;
-	stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
-	stat.un.b.lsRjtRsnCodeExp = LSEXP_CANT_GIVE_DATA;
-	stat.un.b.vendorUnique = 0;
-	lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL);
-	return 0;
-}
-
-/* lpfc_issue_els_rrq - Process an unsolicited rps iocb
+/* lpfc_issue_els_rrq - Process an unsolicited rrq iocb
  * @vport: pointer to a host virtual N_Port data structure.
  * @ndlp: pointer to a node-list data structure.
  * @did: DID of the target.
@@ -8632,16 +8459,6 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
 		if (newnode)
 			lpfc_nlp_put(ndlp);
 		break;
-	case ELS_CMD_RPS:
-		lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
-			"RCV RPS:         did:x%x/ste:x%x flg:x%x",
-			did, vport->port_state, ndlp->nlp_flag);
-
-		phba->fc_stat.elsRcvRPS++;
-		lpfc_els_rcv_rps(vport, elsiocb, ndlp);
-		if (newnode)
-			lpfc_nlp_put(ndlp);
-		break;
 	case ELS_CMD_RPL:
 		lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
 			"RCV RPL:         did:x%x/ste:x%x flg:x%x",
diff --git a/drivers/scsi/lpfc/lpfc_hw.h b/drivers/scsi/lpfc/lpfc_hw.h
index b5642c872593..9a5979075646 100644
--- a/drivers/scsi/lpfc/lpfc_hw.h
+++ b/drivers/scsi/lpfc/lpfc_hw.h
@@ -597,7 +597,6 @@ struct fc_vft_header {
 #define ELS_CMD_ADISC     0x52000000
 #define ELS_CMD_FARP      0x54000000
 #define ELS_CMD_FARPR     0x55000000
-#define ELS_CMD_RPS       0x56000000
 #define ELS_CMD_RPL       0x57000000
 #define ELS_CMD_FAN       0x60000000
 #define ELS_CMD_RSCN      0x61040000
@@ -639,7 +638,6 @@ struct fc_vft_header {
 #define ELS_CMD_ADISC     0x52
 #define ELS_CMD_FARP      0x54
 #define ELS_CMD_FARPR     0x55
-#define ELS_CMD_RPS       0x56
 #define ELS_CMD_RPL       0x57
 #define ELS_CMD_FAN       0x60
 #define ELS_CMD_RSCN      0x0461
@@ -919,24 +917,6 @@ typedef struct _RNID {		/* Structure is in Big Endian format */
 	} un;
 } __packed RNID;
 
-typedef struct  _RPS {		/* Structure is in Big Endian format */
-	union {
-		uint32_t portNum;
-		struct lpfc_name portName;
-	} un;
-} RPS;
-
-typedef struct  _RPS_RSP {	/* Structure is in Big Endian format */
-	uint16_t rsvd1;
-	uint16_t portStatus;
-	uint32_t linkFailureCnt;
-	uint32_t lossSyncCnt;
-	uint32_t lossSignalCnt;
-	uint32_t primSeqErrCnt;
-	uint32_t invalidXmitWord;
-	uint32_t crcCnt;
-} RPS_RSP;
-
 struct RLS {			/* Structure is in Big Endian format */
 	uint32_t rls;
 #define rls_rsvd_SHIFT		24
-- 
2.13.7


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

* [PATCH 09/12] lpfc: Clean up hba max_lun_queue_depth checks
  2020-01-28  0:23 [PATCH 00/12] lpfc: Update lpfc to revision 12.6.0.4 James Smart
                   ` (7 preceding siblings ...)
  2020-01-28  0:23 ` [PATCH 08/12] lpfc: Remove handler for obsolete ELS - Read Port Status (RPS) James Smart
@ 2020-01-28  0:23 ` James Smart
  2020-01-28  0:23 ` [PATCH 10/12] lpfc: Change lpfc_lun_queue_depth attribute to writable James Smart
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: James Smart @ 2020-01-28  0:23 UTC (permalink / raw)
  To: linux-scsi; +Cc: James Smart, Dick Kennedy

The current code does some odd +1 over maximum xri count checks and
requires that the lun_queue_count can't be bigger than maximum xri
count divided by 8. These items are bogus.

Clean the code up to cap lun_queue_count to maximum xri count.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
---
 drivers/scsi/lpfc/lpfc_attr.c |  3 ---
 drivers/scsi/lpfc/lpfc_init.c | 17 ++++-------------
 drivers/scsi/lpfc/lpfc_sli.c  |  9 ---------
 3 files changed, 4 insertions(+), 25 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index 46f56f30f77e..48b6c98ec922 100644
--- a/drivers/scsi/lpfc/lpfc_attr.c
+++ b/drivers/scsi/lpfc/lpfc_attr.c
@@ -3869,9 +3869,6 @@ LPFC_VPORT_ATTR_R(enable_da_id, 1, 0, 1,
 /*
 # lun_queue_depth:  This parameter is used to limit the number of outstanding
 # commands per FCP LUN. Value range is [1,512]. Default value is 30.
-# If this parameter value is greater than 1/8th the maximum number of exchanges
-# supported by the HBA port, then the lun queue depth will be reduced to
-# 1/8th the maximum number of exchanges.
 */
 LPFC_VPORT_ATTR_R(lun_queue_depth, 30, 1, 512,
 		  "Max number of FCP commands we can queue to a specific LUN");
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index 9a6191818a23..6d571e0b74f0 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -512,21 +512,12 @@ lpfc_config_port_post(struct lpfc_hba *phba)
 	lpfc_sli_read_link_ste(phba);
 
 	/* Reset the DFT_HBA_Q_DEPTH to the max xri  */
-	i = (mb->un.varRdConfig.max_xri + 1);
-	if (phba->cfg_hba_queue_depth > i) {
+	if (phba->cfg_hba_queue_depth > mb->un.varRdConfig.max_xri) {
 		lpfc_printf_log(phba, KERN_WARNING, LOG_INIT,
 				"3359 HBA queue depth changed from %d to %d\n",
-				phba->cfg_hba_queue_depth, i);
-		phba->cfg_hba_queue_depth = i;
-	}
-
-	/* Reset the DFT_LUN_Q_DEPTH to (max xri >> 3)  */
-	i = (mb->un.varRdConfig.max_xri >> 3);
-	if (phba->pport->cfg_lun_queue_depth > i) {
-		lpfc_printf_log(phba, KERN_WARNING, LOG_INIT,
-				"3360 LUN queue depth changed from %d to %d\n",
-				phba->pport->cfg_lun_queue_depth, i);
-		phba->pport->cfg_lun_queue_depth = i;
+				phba->cfg_hba_queue_depth,
+				mb->un.varRdConfig.max_xri);
+		phba->cfg_hba_queue_depth = mb->un.varRdConfig.max_xri;
 	}
 
 	phba->lmt = mb->un.varRdConfig.lmt;
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index ab6f58bc80a4..a5fd043e9be4 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -7371,15 +7371,6 @@ lpfc_sli4_hba_setup(struct lpfc_hba *phba)
 			phba->vpd.rev.fcphHigh, phba->vpd.rev.fcphLow,
 			phba->vpd.rev.feaLevelHigh, phba->vpd.rev.feaLevelLow);
 
-	/* Reset the DFT_LUN_Q_DEPTH to (max xri >> 3)  */
-	rc = (phba->sli4_hba.max_cfg_param.max_xri >> 3);
-	if (phba->pport->cfg_lun_queue_depth > rc) {
-		lpfc_printf_log(phba, KERN_WARNING, LOG_INIT,
-				"3362 LUN queue depth changed from %d to %d\n",
-				phba->pport->cfg_lun_queue_depth, rc);
-		phba->pport->cfg_lun_queue_depth = rc;
-	}
-
 	if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) ==
 	    LPFC_SLI_INTF_IF_TYPE_0) {
 		lpfc_set_features(phba, mboxq, LPFC_SET_UE_RECOVERY);
-- 
2.13.7


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

* [PATCH 10/12] lpfc: Change lpfc_lun_queue_depth attribute to writable
  2020-01-28  0:23 [PATCH 00/12] lpfc: Update lpfc to revision 12.6.0.4 James Smart
                   ` (8 preceding siblings ...)
  2020-01-28  0:23 ` [PATCH 09/12] lpfc: Clean up hba max_lun_queue_depth checks James Smart
@ 2020-01-28  0:23 ` James Smart
  2020-01-28  0:23 ` [PATCH 11/12] lpfc: Update lpfc version to 12.6.0.4 James Smart
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: James Smart @ 2020-01-28  0:23 UTC (permalink / raw)
  To: linux-scsi; +Cc: James Smart, Dick Kennedy

Change the lpfc_lun_queue_depth attribute to be writable. When written,
will change the driver's value and calls the new scsi service routine
shost_change_max_queue_depths() to set the maximum and queue depth of
the luns on the shost to the new value.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>

---
This patch is dependent upon this series, which adds the new
scsi service routine shost_change_max_queue_depths():
https://www.spinics.net/lists/linux-scsi/msg137981.html
---
 drivers/scsi/lpfc/lpfc.h      |  3 +++
 drivers/scsi/lpfc/lpfc_attr.c | 59 +++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 60 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
index cebbad1b3e55..d26ae94e6f1e 100644
--- a/drivers/scsi/lpfc/lpfc.h
+++ b/drivers/scsi/lpfc/lpfc.h
@@ -69,6 +69,9 @@ struct lpfc_sli2_slim;
 #define LPFC_TGTQ_RAMPUP_PCENT	5	/* Target queue rampup in percentage */
 #define LPFC_MIN_TGT_QDEPTH	10
 #define LPFC_MAX_TGT_QDEPTH	0xFFFF
+#define LPFC_MIN_LUN_QDEPTH	1
+#define LPFC_DEF_LUN_QDEPTH	30
+#define LPFC_MAX_LUN_QDEPTH	512
 
 #define  LPFC_MAX_BUCKET_COUNT 20	/* Maximum no. of buckets for stat data
 					   collection. */
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index 48b6c98ec922..127484061f18 100644
--- a/drivers/scsi/lpfc/lpfc_attr.c
+++ b/drivers/scsi/lpfc/lpfc_attr.c
@@ -3870,8 +3870,63 @@ LPFC_VPORT_ATTR_R(enable_da_id, 1, 0, 1,
 # lun_queue_depth:  This parameter is used to limit the number of outstanding
 # commands per FCP LUN. Value range is [1,512]. Default value is 30.
 */
-LPFC_VPORT_ATTR_R(lun_queue_depth, 30, 1, 512,
-		  "Max number of FCP commands we can queue to a specific LUN");
+static u16 lpfc_lun_queue_depth = LPFC_DEF_LUN_QDEPTH;
+module_param(lpfc_lun_queue_depth, ushort, 0644);
+MODULE_PARM_DESC(lpfc_lun_queue_depth,
+		 "Max number of FCP commands we can queue to a specific LUN");
+lpfc_vport_param_show(lun_queue_depth);
+lpfc_vport_param_init(lun_queue_depth, LPFC_DEF_LUN_QDEPTH, LPFC_MIN_LUN_QDEPTH,
+		      LPFC_MAX_LUN_QDEPTH);
+
+static ssize_t
+lpfc_lun_queue_depth_store(struct device *dev, struct device_attribute *attr,
+			   const char *buf, size_t count)
+{
+	struct Scsi_Host  *shost = class_to_shost(dev);
+	struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata;
+	struct lpfc_hba   *phba = vport->phba;
+	u16 new_queue_depth;
+	int rc;
+
+	rc = kstrtou16(buf, 0, &new_queue_depth);
+	if (rc) {
+		lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
+				"4385 lpfc_lun_queue_depth: failed to convert "
+				"\"%s\" to u16 (%d)\n",
+				buf, rc);
+		return -EINVAL;
+	}
+
+	/* Check allowed range */
+	if (new_queue_depth < LPFC_MIN_LUN_QDEPTH ||
+	    new_queue_depth > LPFC_MAX_LUN_QDEPTH) {
+		lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
+				"4386 lpfc_lun_queue_depth: %d outside of "
+				"allowed range [%u, %u]\n",
+				new_queue_depth, LPFC_MIN_LUN_QDEPTH,
+				LPFC_MAX_LUN_QDEPTH);
+		return -EINVAL;
+	}
+
+	/* Check if previously set same value */
+	if (new_queue_depth == vport->cfg_lun_queue_depth)
+		goto buffer_done;
+
+	/* Store for future calls to slave_configure */
+	vport->cfg_lun_queue_depth = new_queue_depth;
+
+	/* Change all the current LUNs' queue depths */
+	rc = shost_change_max_queue_depths(shost, new_queue_depth);
+	if (rc)
+		lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
+				"4387 lpfc_lun_queue_depth: error setting lun "
+				"max queue depths (%d)\n",
+				rc);
+
+buffer_done:
+	return strlen(buf);
+}
+static DEVICE_ATTR_RW(lpfc_lun_queue_depth);
 
 /*
 # tgt_queue_depth:  This parameter is used to limit the number of outstanding
-- 
2.13.7


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

* [PATCH 11/12] lpfc: Update lpfc version to 12.6.0.4
  2020-01-28  0:23 [PATCH 00/12] lpfc: Update lpfc to revision 12.6.0.4 James Smart
                   ` (9 preceding siblings ...)
  2020-01-28  0:23 ` [PATCH 10/12] lpfc: Change lpfc_lun_queue_depth attribute to writable James Smart
@ 2020-01-28  0:23 ` James Smart
  2020-01-28  0:23 ` [PATCH 12/12] lpfc: Copyright updates for 12.6.0.4 patches James Smart
  2020-02-05  3:00 ` [PATCH 00/12] lpfc: Update lpfc to revision 12.6.0.4 Martin K. Petersen
  12 siblings, 0 replies; 19+ messages in thread
From: James Smart @ 2020-01-28  0:23 UTC (permalink / raw)
  To: linux-scsi; +Cc: James Smart, Dick Kennedy

Update lpfc version to 12.6.0.4

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
---
 drivers/scsi/lpfc/lpfc_version.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/lpfc/lpfc_version.h b/drivers/scsi/lpfc/lpfc_version.h
index 9563c49f36ab..25193146ef20 100644
--- a/drivers/scsi/lpfc/lpfc_version.h
+++ b/drivers/scsi/lpfc/lpfc_version.h
@@ -20,7 +20,7 @@
  * included with this package.                                     *
  *******************************************************************/
 
-#define LPFC_DRIVER_VERSION "12.6.0.3"
+#define LPFC_DRIVER_VERSION "12.6.0.4"
 #define LPFC_DRIVER_NAME		"lpfc"
 
 /* Used for SLI 2/3 */
-- 
2.13.7


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

* [PATCH 12/12] lpfc: Copyright updates for 12.6.0.4 patches
  2020-01-28  0:23 [PATCH 00/12] lpfc: Update lpfc to revision 12.6.0.4 James Smart
                   ` (10 preceding siblings ...)
  2020-01-28  0:23 ` [PATCH 11/12] lpfc: Update lpfc version to 12.6.0.4 James Smart
@ 2020-01-28  0:23 ` James Smart
  2020-02-05  3:00 ` [PATCH 00/12] lpfc: Update lpfc to revision 12.6.0.4 Martin K. Petersen
  12 siblings, 0 replies; 19+ messages in thread
From: James Smart @ 2020-01-28  0:23 UTC (permalink / raw)
  To: linux-scsi; +Cc: James Smart, Dick Kennedy

Update copyrights to 2020 for files modified in the 12.6.0.4 patch set.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
---
 drivers/scsi/lpfc/lpfc.h         | 2 +-
 drivers/scsi/lpfc/lpfc_attr.c    | 2 +-
 drivers/scsi/lpfc/lpfc_ct.c      | 2 +-
 drivers/scsi/lpfc/lpfc_els.c     | 2 +-
 drivers/scsi/lpfc/lpfc_hbadisc.c | 2 +-
 drivers/scsi/lpfc/lpfc_hw.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_version.h | 2 +-
 10 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
index d26ae94e6f1e..3d985581b470 100644
--- a/drivers/scsi/lpfc/lpfc.h
+++ b/drivers/scsi/lpfc/lpfc.h
@@ -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-2020 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.                        *
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index 127484061f18..b6224487909e 100644
--- a/drivers/scsi/lpfc/lpfc_attr.c
+++ b/drivers/scsi/lpfc/lpfc_attr.c
@@ -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-2020 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.                        *
diff --git a/drivers/scsi/lpfc/lpfc_ct.c b/drivers/scsi/lpfc/lpfc_ct.c
index 8db27e84263e..2aa578d20f8c 100644
--- a/drivers/scsi/lpfc/lpfc_ct.c
+++ b/drivers/scsi/lpfc/lpfc_ct.c
@@ -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-2020 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.                        *
diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
index 371599d67eb4..8a38e6f7f853 100644
--- a/drivers/scsi/lpfc/lpfc_els.c
+++ b/drivers/scsi/lpfc/lpfc_els.c
@@ -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-2020 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.                        *
diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c
index 6a2bdae0e52a..e8937071c748 100644
--- a/drivers/scsi/lpfc/lpfc_hbadisc.c
+++ b/drivers/scsi/lpfc/lpfc_hbadisc.c
@@ -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-2020 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.                        *
diff --git a/drivers/scsi/lpfc/lpfc_hw.h b/drivers/scsi/lpfc/lpfc_hw.h
index 9a5979075646..68f62ae6ef4f 100644
--- a/drivers/scsi/lpfc/lpfc_hw.h
+++ b/drivers/scsi/lpfc/lpfc_hw.h
@@ -1,7 +1,7 @@
 /*******************************************************************
  * This file is part of the Emulex Linux Device Driver for         *
  * Fibre Channel Host Bus Adapters.                                *
- * Copyright (C) 2017-2018 Broadcom. All Rights Reserved. The term *
+ * Copyright (C) 2017-2020 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.                        *
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index 6d571e0b74f0..9d03e9b71efb 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -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-2020 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.                        *
diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
index 96ac4a154c58..0fc9a242bc65 100644
--- a/drivers/scsi/lpfc/lpfc_scsi.c
+++ b/drivers/scsi/lpfc/lpfc_scsi.c
@@ -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-2020 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.                        *
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index a5fd043e9be4..86ac10ecd65a 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -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-2020 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.                        *
diff --git a/drivers/scsi/lpfc/lpfc_version.h b/drivers/scsi/lpfc/lpfc_version.h
index 25193146ef20..c4ab006e6ecc 100644
--- a/drivers/scsi/lpfc/lpfc_version.h
+++ b/drivers/scsi/lpfc/lpfc_version.h
@@ -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-2020 Broadcom. All Rights Reserved. The term *
  * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.     *
  * Copyright (C) 2004-2016 Emulex.  All rights reserved.           *
  * EMULEX and SLI are trademarks of Emulex.                        *
-- 
2.13.7


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

* Re: [PATCH 00/12] lpfc: Update lpfc to revision 12.6.0.4
  2020-01-28  0:23 [PATCH 00/12] lpfc: Update lpfc to revision 12.6.0.4 James Smart
                   ` (11 preceding siblings ...)
  2020-01-28  0:23 ` [PATCH 12/12] lpfc: Copyright updates for 12.6.0.4 patches James Smart
@ 2020-02-05  3:00 ` Martin K. Petersen
  2020-02-05 19:01   ` James Smart
  12 siblings, 1 reply; 19+ messages in thread
From: Martin K. Petersen @ 2020-02-05  3:00 UTC (permalink / raw)
  To: James Smart; +Cc: linux-scsi


James,

> Update lpfc to revision 12.6.0.4
>
> Patch set contains mainly fixes and a few cleanups.

I applied everything except patch #10 because I'd like to dig into the
queue depth stuff a bit more. Especially given the recent concerns about
device_busy contention.

-- 
Martin K. Petersen	Oracle Linux Engineering

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

* Re: [PATCH 00/12] lpfc: Update lpfc to revision 12.6.0.4
  2020-02-05  3:00 ` [PATCH 00/12] lpfc: Update lpfc to revision 12.6.0.4 Martin K. Petersen
@ 2020-02-05 19:01   ` James Smart
  0 siblings, 0 replies; 19+ messages in thread
From: James Smart @ 2020-02-05 19:01 UTC (permalink / raw)
  To: Martin K. Petersen; +Cc: linux-scsi

On 2/4/2020 7:00 PM, Martin K. Petersen wrote:
> 
> James,
> 
>> Update lpfc to revision 12.6.0.4
>>
>> Patch set contains mainly fixes and a few cleanups.
> 
> I applied everything except patch #10 because I'd like to dig into the
> queue depth stuff a bit more. Especially given the recent concerns about
> device_busy contention.

I replied to the other thread.   It is independent of the discussion 
being used with the megaraid guys.  Just a way for the lldd to tune the 
max for the existing algorithm at run time vs at 1st discovery.

-- james



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

* Re: [PATCH 03/12] lpfc: Fix broken Credit Recovery after driver load
  2020-01-28  0:23 ` [PATCH 03/12] lpfc: Fix broken Credit Recovery after driver load James Smart
@ 2020-05-12 21:28   ` Chris Hofstaedtler
  2020-05-12 23:59     ` James Smart
  0 siblings, 1 reply; 19+ messages in thread
From: Chris Hofstaedtler @ 2020-05-12 21:28 UTC (permalink / raw)
  To: James Smart; +Cc: linux-scsi, stable, Dick Kennedy

Hi,

this commit, applied in Ubuntu's 5.4.0-30.34 tree as
77d5805eafdb5c42bdfe78f058ad9c40ee1278b4, appears to cause our
HPE-branded 2-port 8Gb lpfcs to report FLOGI errors. Reverting it fixes target
discovery for me. See below for log messages and HW details.

* James Smart <jsmart2021@gmail.com> [700101 01:00]:
> When driver is set to enable bb credit recovery, the switch displayed
> the setting as inactive.  If the link bounces, it switches to Active.

[..]

> Fixes: 6bfb16208298 ("scsi: lpfc: Fix configuration of BB credit recovery in service parameters")
> Cc: <stable@vger.kernel.org> # v5.4+
> Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
> Signed-off-by: James Smart <jsmart2021@gmail.com>

Broken log messages:

[    5.837826] Emulex LightPulse Fibre Channel SCSI driver 12.6.0.4
[    5.837827] Copyright (C) 2017-2019 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
[    5.838807] scsi host2: Emulex LPe12000 PCIe Fibre Channel Adapter on PCI bus 07 device 00 irq 128
[    8.300583] scsi host4: Emulex LPe12000 PCIe Fibre Channel Adapter on PCI bus 07 device 01 irq 182
[    8.858018] lpfc 0000:07:00.0: 0:1303 Link Up Event x1 received Data: x1 xf7 x20 x0 x0 x0 0
[   11.380022] lpfc 0000:07:00.1: 1:1303 Link Up Event x1 received Data: x1 xf7 x20 x0 x0 x0 0
[   28.819755] lpfc 0000:07:00.1: 1:(0):0237 Pending Link Event during Discovery: State x7
[   28.819963] lpfc 0000:07:00.1: 1:1305 Link Down Event x2 received Data: x2 x7 x98014 x0 x0
[   28.915823] lpfc 0000:07:00.1: 1:1303 Link Up Event x3 received Data: x3 x0 x20 x0 x0 x0 0
[   28.920083] lpfc 0000:07:00.0: 0:(0):2858 FLOGI failure Status:x3/x2 TMO:x10 Data x101000 x0

Reverted:

[   74.838109] Emulex LightPulse Fibre Channel SCSI driver 12.6.0.4-7fbb1b050a65
[   74.838111] Copyright (C) 2017-2019 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
[   74.840310] scsi host2: Emulex LPe12000 PCIe Fibre Channel Adapter on PCI bus 07 device 00 irq 128
[   77.272319] scsi host4: Emulex LPe12000 PCIe Fibre Channel Adapter on PCI bus 07 device 01 irq 182
[   77.813387] lpfc 0000:07:00.0: 0:1303 Link Up Event x1 received Data: x1 xf7 x20 x0 x0 x0 0
[   80.261594] lpfc 0000:07:00.1: 1:1303 Link Up Event x1 received Data: x1 xf7 x20 x0 x0 x0 0
(plus various sd attach messages)

systool info:

    active_fc4s         = "0x00 0x00 0x01 0x00 0x00 0x00 0x00 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 "
    dev_loss_tmo        = "30"
    max_npiv_vports     = "255"
    maxframe_size       = "2048 bytes"
    npiv_vports_inuse   = "0"
    port_id             = "0x0b0260"
    port_state          = "Online"
    port_type           = "NPort (fabric via point-to-point)"
    speed               = "8 Gbit"
    supported_classes   = "Class 3"
    supported_fc4s      = "0x00 0x00 0x01 0x00 0x00 0x00 0x00 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 "
    supported_speeds    = "2 Gbit, 4 Gbit, 8 Gbit"
    symbolic_name       = "Emulex AJ763B/AH403A FV2.10X6 DV12.6.0.4-7fbb1b050a65 HN:pm01-vh03 OS:Linux"
    tgtid_bind_type     = "wwpn (World Wide Port Name)"

Let me know if you need further debug logs or something.

Thanks,
-- 
Chris Hofstaedtler / Deduktiva GmbH (FN 418592 b, HG Wien)
www.deduktiva.com / +43 1 353 1707

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

* Re: [PATCH 03/12] lpfc: Fix broken Credit Recovery after driver load
  2020-05-12 21:28   ` Chris Hofstaedtler
@ 2020-05-12 23:59     ` James Smart
  2020-05-13  7:47       ` Chris Hofstaedtler | Deduktiva
  2020-05-13 10:25       ` Chris Hofstaedtler | Deduktiva
  0 siblings, 2 replies; 19+ messages in thread
From: James Smart @ 2020-05-12 23:59 UTC (permalink / raw)
  To: Chris Hofstaedtler; +Cc: linux-scsi, stable, Dick Kennedy

On 5/12/2020 2:28 PM, Chris Hofstaedtler wrote:
> Hi,
> 
> this commit, applied in Ubuntu's 5.4.0-30.34 tree as
> 77d5805eafdb5c42bdfe78f058ad9c40ee1278b4, appears to cause our
> HPE-branded 2-port 8Gb lpfcs to report FLOGI errors. Reverting it fixes target
> discovery for me. See below for log messages and HW details.
> 
>...
> Let me know if you need further debug logs or something.
> 
> Thanks,
> 

I'm more interested in what other patches you do or do not have in your 
tree.

This is the message that threw it to the left:
0237 Pending Link Event during Discovery

Let me look a little.

-- james

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

* Re: [PATCH 03/12] lpfc: Fix broken Credit Recovery after driver load
  2020-05-12 23:59     ` James Smart
@ 2020-05-13  7:47       ` Chris Hofstaedtler | Deduktiva
  2020-05-13 10:25       ` Chris Hofstaedtler | Deduktiva
  1 sibling, 0 replies; 19+ messages in thread
From: Chris Hofstaedtler | Deduktiva @ 2020-05-13  7:47 UTC (permalink / raw)
  To: James Smart; +Cc: linux-scsi, stable, Dick Kennedy

* James Smart <jsmart2021@gmail.com> [200513 02:00]:
> On 5/12/2020 2:28 PM, Chris Hofstaedtler wrote:
> > this commit, applied in Ubuntu's 5.4.0-30.34 tree as
> > 77d5805eafdb5c42bdfe78f058ad9c40ee1278b4, appears to cause our
> > HPE-branded 2-port 8Gb lpfcs to report FLOGI errors. Reverting it fixes target
> > discovery for me. See below for log messages and HW details.
..
> 
> I'm more interested in what other patches you do or do not have in your
> tree.

I'd imagine the patches come from LP#1855303.

Please find a short log of drivers/scsi/lpfc below.
As an additional info, before we were running off Ubuntu's
5.3.0-43.36 which had lpfc 12.2.0.3.

> This is the message that threw it to the left:
> 0237 Pending Link Event during Discovery
> 
> Let me look a little.

> -- james

Many thanks,
Chris


432bc5a9f5c1 scsi: lpfc: add RDF registration and Link Integrity FPIN logging
40953bf88d5f scsi: lpfc: Copyright updates for 12.6.0.4 patches
dbbf73335448 scsi: lpfc: Update lpfc version to 12.6.0.4
e8b80ff76088 scsi: lpfc: Clean up hba max_lun_queue_depth checks
3c011ebffaef scsi: lpfc: Remove handler for obsolete ELS - Read Port Status (RPS)
9b200f712004 scsi: lpfc: Fix coverity errors in fmdi attribute handling
0be9b30cd635 scsi: lpfc: Fix compiler warning on frame size
2f985fdbaec3 scsi: lpfc: Fix release of hwq to clear the eq relationship
5acd7d9f7eea scsi: lpfc: Fix registration of ELS type support in fdmi
77d5805eafdb scsi: lpfc: Fix broken Credit Recovery after driver load
6b5806410b8f scsi: lpfc: Fix lpfc_io_buf resource leak in lpfc_get_scsi_buf_s4 error path
fa9df073dbce scsi: lpfc: Fix RQ buffer leakage when no IOCBs available
c5198e2e539b scsi: lpfc: Update lpfc version to 12.6.0.3
390e6a77e06f scsi: lpfc: Fix improper flag check for IO type
e2200d875825 scsi: lpfc: Fix MDS Latency Diagnostics Err-drop rates
038e6643ac38 scsi: lpfc: Fix unmap of dpp bars affecting next driver load
42898fe98599 scsi: lpfc: Fix disablement of FC-AL on lpe35000 models
1b6e85b0950d scsi: lpfc: Fix ras_log via debugfs
8d291637e21c scsi: lpfc: Fix Fabric hostname registration if system hostname changes
c7f141b558f6 scsi: lpfc: Fix missing check for CSF in Write Object Mbox Rsp
107a9fe98ada scsi: lpfc: Fix incomplete NVME discovery when target
45dc4914d65f scsi: lpfc: size cpu map by last cpu id set
48d76e9b38a4 scsi: lpfc: Update lpfc version to 12.6.0.2
e667dc171fe4 scsi: lpfc: revise nvme max queues to be hdwq count
db8d6e2ab615 scsi: lpfc: Initialize cpu_map for not present cpus
d7b48a096eb7 scsi: lpfc: fix inlining of lpfc_sli4_cleanup_poll_list()
d0ff88ef8591 scsi: lpfc: Fix lpfc_cpumask_of_node_init()
a41d3723e398 scsi: lpfc: Fix a kernel warning triggered by lpfc_sli4_enable_intr()
723fabed8c5e scsi: lpfc: Update lpfc version to 12.6.0.1
8c708b2e7d79 scsi: lpfc: Add enablement of multiple adapter dumps
c50fd99a1fe9 scsi: lpfc: Change default IRQ model on AMD architectures
79d488b36a1e scsi: lpfc: Add registration for CPU Offline/Online events
328383a3f61b scsi: lpfc: Clarify FAWNN error message
e45f34740925 scsi: lpfc: Sync with FC-NVMe-2 SLER change to require Conf with SLER
eaeaddbfee55 scsi: lpfc: Fix dynamic fw log enablement check
e35dc794fcdd scsi: lpfc: Fix kernel crash at lpfc_nvme_info_show during remote port bounce
4f175d5b6bca scsi: lpfc: Fix configuration of BB credit recovery in service parameters
8b22efb072fc scsi: lpfc: Make lpfc_debugfs_ras_log_data static
3323028b62de scsi: lpfc: Fix NULL check before mempool_destroy is not needed
ae036af7d4f6 scsi: lpfc: fix spelling error in MAGIC_NUMER_xxx
18c38c2053fb scsi: lpfc: fix build error of lpfc_debugfs.c for vfree/vmalloc
0df2dcbaaa0d scsi: lpfc: lpfc_nvmet: Fix Use plain integer as NULL pointer
90c3f71713d5 scsi: lpfc: lpfc_attr: Fix Use plain integer as NULL pointer
a3babc0488ff scsi: lpfc: Update lpfc version to 12.6.0.0
d7d082705c12 scsi: lpfc: Add additional discovery log messages
24dc02b77a1a scsi: lpfc: Add FC-AL support to lpe32000 models
980ed57564f6 scsi: lpfc: Add FA-WWN Async Event reporting
6ac712225cca scsi: lpfc: Add log macros to allow print by serverity or verbosity setting
2c0bc5bbd84a scsi: lpfc: Make FW logging dynamically configurable
3965a40a4e75 scsi: lpfc: Revise interrupt coalescing for missing scenarios
5078750b034c scsi: lpfc: Remove lock contention target write path
8f82561d4ed4 scsi: lpfc: Slight fast-path performance optimizations
632e3ddb91dc scsi: lpfc: fix coverity error of dereference after null check
07a9248d7ea0 scsi: lpfc: Fix lockdep errors in sli_ringtx_put
10662b03cd9f scsi: lpfc: Fix reporting of read-only fw error errors
2c737f5a5c47 scsi: lpfc: fix lpfc_nvmet_mrq to be bound by hdw queue count
ce0e7ee555b1 scsi: lpfc: Make function lpfc_defer_pt2pt_acc static
035922837ebc scsi: lpfc: Update lpfc version to 12.4.0.1
c0e0637b5639 scsi: lpfc: cleanup: remove unused fcp_txcmlpq_cnt
f6f38dbe38dd scsi: lpfc: Complete removal of FCoE T10 PI support on SLI-4 adapters
87ba9f4e1e44 scsi: lpfc: Update async event logging
53aa87d8ac63 scsi: lpfc: Fix host hang at boot or slow boot
5df05a9d6459 scsi: lpfc: Fix coverity errors on NULL pointer checks
c01400547f7a scsi: lpfc: Fix NVMe ABTS in response to receiving an ABTS
e5c93b45be68 scsi: lpfc: Fix GPF on scsi command completion
55863d7f0b03 scsi: lpfc: Fix device recovery errors after PLOGI failures
9084ef6d5222 scsi: lpfc: Fix NVME io abort failures causing hangs
e3537e7f1fe8 scsi: lpfc: Fix miss of register read failure check
88764affd6e3 scsi: lpfc: Fix premature re-enabling of interrupts in lpfc_sli_host_down
fc99d4225045 scsi: lpfc: Fix pt2pt discovery on SLI3 HBAs
15e8455c4668 UBUNTU: SAUCE: Revert "nvme_fc: add module to ops template to allow module references"
190fa9115ac0 scsi: lpfc: Fix: Rework setting of fdmi symbolic node name registration
ebd66c10c8f0 scsi: lpfc: use hdwq assigned cpu for allocation
f42c518b6b1e scsi: lpfc: Fix a kernel warning triggered by lpfc_get_sgl_per_hdwq()
1a8ce116a003 scsi: lpfc: Fix hdwq sgl locks and irq handling
3815dd60ccda scsi: lpfc: Fix list corruption detected in lpfc_put_sgl_per_hdwq
644726cf4623 scsi: lpfc: fix: Coverity: lpfc_get_scsi_buf_s3(): Null pointer dereferences
15d7e5222908 scsi: lpfc: Fix rpi release when deleting vport
5b82af018796 scsi: lpfc: Fix memory leak on lpfc_bsg_write_ebuf_set func
a7441301b20d nvme_fc: add module to ops template to allow module references
ac173a225715 scsi: lpfc: fix: Coverity: lpfc_cmpl_els_rsp(): Null pointer dereferences
170cd3bb6108 scsi: lpfc: Fix duplicate unreg_rpi error in port offline flow
46dc7c48f754 scsi: lpfc: Fix unexpected error messages during RSCN handling
6182634f0d10 scsi: lpfc: Fix SLI3 hba in loop mode not discovering devices
4b4a2235f14f scsi: lpfc: Fix hardlockup in lpfc_abort_handler
d46f5c50c520 scsi: lpfc: Fix list corruption in lpfc_sli_get_iocbq
ba7d99a490e2 scsi: lpfc: Fix locking on mailbox command completion
763e1491d43a scsi: lpfc: Fix discovery failures when target device connectivity bounces
f027d0e29db4 scsi: lpfc: Fix spinlock_irq issues in lpfc_els_flush_cmd()
a3c51276ddfc scsi: lpfc: Fix bad ndlp ptr in xri aborted handling
f83e148a4100 Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
(this merge is in 5.4 mainline)

-- 
Chris Hofstaedtler / Deduktiva GmbH (FN 418592 b, HG Wien)
www.deduktiva.com / +43 1 353 1707

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

* Re: [PATCH 03/12] lpfc: Fix broken Credit Recovery after driver load
  2020-05-12 23:59     ` James Smart
  2020-05-13  7:47       ` Chris Hofstaedtler | Deduktiva
@ 2020-05-13 10:25       ` Chris Hofstaedtler | Deduktiva
  1 sibling, 0 replies; 19+ messages in thread
From: Chris Hofstaedtler | Deduktiva @ 2020-05-13 10:25 UTC (permalink / raw)
  To: James Smart; +Cc: linux-scsi, stable, Dick Kennedy

* James Smart <jsmart2021@gmail.com> [200513 02:00]:
> On 5/12/2020 2:28 PM, Chris Hofstaedtler wrote:
> > this commit, applied in Ubuntu's 5.4.0-30.34 tree as
> > 77d5805eafdb5c42bdfe78f058ad9c40ee1278b4, appears to cause our
> > HPE-branded 2-port 8Gb lpfcs to report FLOGI errors. Reverting it fixes target
> > discovery for me. See below for log messages and HW details.
> > 
> > ...
> > Let me know if you need further debug logs or something.
> > 
> > Thanks,
> > 
> 
> I'm more interested in what other patches you do or do not have in your
> tree.

To save everybody time figuring out patches, I've tried with a 5.7-rc tree
24085f70a6e1b0cb647ec92623284641d8270637, which gives these dmesg messages:

[    4.222975] Emulex LightPulse Fibre Channel SCSI driver 12.8.0.0
[    4.223864] scsi host2: Emulex LPe12000 PCIe Fibre Channel Adapter on PCI bus 07 device 00 irq 128
[    6.654380] scsi host4: Emulex LPe12000 PCIe Fibre Channel Adapter on PCI bus 07 device 01 irq 182
[    7.169041] lpfc 0000:07:00.0: 0:1303 Link Up Event x1 received Data: x1 xf7 x20 x0 x0 x0 0
[    9.578752] lpfc 0000:07:00.1: 1:1303 Link Up Event x1 received Data: x1 xf7 x20 x0 x0 x0 0
[   27.225755] lpfc 0000:07:00.0: 0:(0):2858 FLOGI failure Status:x3/x2 TMO:x10 Data x101000 x0
[   29.637644] lpfc 0000:07:00.1: 1:(0):2858 FLOGI failure Status:x3/x2 TMO:x10 Data x101000 x0
[   47.275946] lpfc 0000:07:00.0: 0:(0):2858 FLOGI failure Status:x3/x2 TMO:x10 Data x101000 x0
[   49.787867] lpfc 0000:07:00.1: 1:(0):2858 FLOGI failure Status:x3/x2 TMO:x10 Data x101000 x0
[   67.356082] lpfc 0000:07:00.0: 0:(0):2858 FLOGI failure Status:x3/x2 TMO:x10 Data x101000 x0
[   69.875049] lpfc 0000:07:00.1: 1:(0):2858 FLOGI failure Status:x3/x2 TMO:x10 Data x101000 x0
[   87.401269] lpfc 0000:07:00.0: 0:(0):2858 FLOGI failure Status:x3/x2 TMO:x10 Data x101000 x0
[   89.929189] lpfc 0000:07:00.1: 1:(0):2858 FLOGI failure Status:x3/x2 TMO:x10 Data x101000 x0
[  105.533242] lpfc 0000:07:00.0: 0:(0):0237 Pending Link Event during Discovery: State x7
[  105.533546] lpfc 0000:07:00.0: 0:1305 Link Down Event x2 received Data: x2 x7 x98014 x0 x0
[  105.615008] lpfc 0000:07:00.0: 0:1303 Link Up Event x3 received Data: x3 x0 x20 x0 x0 x0 0
[  109.989341] lpfc 0000:07:00.1: 1:(0):2858 FLOGI failure Status:x3/x2 TMO:x10 Data x101000 x0
[  124.772701] lpfc 0000:07:00.0: 0:(0):2858 FLOGI failure Status:x3/x2 TMO:x10 Data x101000 x0
 
> This is the message that threw it to the left:
> 0237 Pending Link Event during Discovery
> 
> Let me look a little.
> 
> -- james

Best,
Chris

-- 
Chris Hofstaedtler / Deduktiva GmbH (FN 418592 b, HG Wien)
www.deduktiva.com / +43 1 353 1707

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

end of thread, other threads:[~2020-05-13 10:25 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-28  0:23 [PATCH 00/12] lpfc: Update lpfc to revision 12.6.0.4 James Smart
2020-01-28  0:23 ` [PATCH 01/12] lpfc: Fix RQ buffer leakage when no IOCBs available James Smart
2020-01-28  0:23 ` [PATCH 02/12] lpfc: Fix lpfc_io_buf resource leak in lpfc_get_scsi_buf_s4 error path James Smart
2020-01-28  0:23 ` [PATCH 03/12] lpfc: Fix broken Credit Recovery after driver load James Smart
2020-05-12 21:28   ` Chris Hofstaedtler
2020-05-12 23:59     ` James Smart
2020-05-13  7:47       ` Chris Hofstaedtler | Deduktiva
2020-05-13 10:25       ` Chris Hofstaedtler | Deduktiva
2020-01-28  0:23 ` [PATCH 04/12] lpfc: Fix registration of ELS type support in fdmi James Smart
2020-01-28  0:23 ` [PATCH 05/12] lpfc: Fix release of hwq to clear the eq relationship James Smart
2020-01-28  0:23 ` [PATCH 06/12] lpfc: Fix compiler warning on frame size James Smart
2020-01-28  0:23 ` [PATCH 07/12] lpfc: Fix coverity errors in fmdi attribute handling James Smart
2020-01-28  0:23 ` [PATCH 08/12] lpfc: Remove handler for obsolete ELS - Read Port Status (RPS) James Smart
2020-01-28  0:23 ` [PATCH 09/12] lpfc: Clean up hba max_lun_queue_depth checks James Smart
2020-01-28  0:23 ` [PATCH 10/12] lpfc: Change lpfc_lun_queue_depth attribute to writable James Smart
2020-01-28  0:23 ` [PATCH 11/12] lpfc: Update lpfc version to 12.6.0.4 James Smart
2020-01-28  0:23 ` [PATCH 12/12] lpfc: Copyright updates for 12.6.0.4 patches James Smart
2020-02-05  3:00 ` [PATCH 00/12] lpfc: Update lpfc to revision 12.6.0.4 Martin K. Petersen
2020-02-05 19:01   ` James Smart

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.