Skip to contentSkip to conversation

bnxt_en: 5 Bug fixes

PATCH Applied Michael Chan 2 participants 7 messages Jul 12, 2022 – Jul 13, 2022

Subsystems (4)
lore
Share & tools
lore

Michael Chan

author maintainer
#0 lore raw

cover bnxt_en: 5 Bug fixes

This patchset fixes various issues, including SRIOV error unwinding, one error recovery path, live patch reporting, XDP transmit path, and PHC clock reading.

Kashyap Desai (1):
bnxt_en: reclaim max resources if sriov enable fails

Michael Chan (2):
bnxt_en: Fix bnxt_reinit_after_abort() code path
bnxt_en: Fix and simplify XDP transmit path

Pavan Chebbi (1):
bnxt_en: Fix bnxt_refclk_read()

Vikas Gupta (1):
bnxt_en: fix livepatch query

 drivers/net/ethernet/broadcom/bnxt/bnxt.c         |  5 +++--
 drivers/net/ethernet/broadcom/bnxt/bnxt.h         |  1 +
 drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c |  8 +++++---
 drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c     | 13 +++++++++++--
 drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c   |  7 ++++++-
 drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c     | 10 +++++-----
 6 files changed, 31 insertions(+), 13 deletions(-)
Signature · 1 line
2.18.1
author maintainer
#1 lore raw

PATCH 1/5 bnxt_en: reclaim max resources if sriov enable fails

From: Kashyap Desai <[email protected]>

If bnxt_sriov_enable() fails after some resources have been reserved for the VFs, the current code is not unwinding properly and the reserved resources become unavailable afterwards. Fix it by properly unwinding with a call to bnxt_hwrm_func_qcaps() to reset all maximum resources.

Also, add the missing bnxt_ulp_sriov_cfg() call to let the RDMA driver know to abort.

Fixes c0c050c58d84 ("bnxt_en: New Broadcom ethernet driver.")
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c       | 2 +-
 drivers/net/ethernet/broadcom/bnxt/bnxt.h       | 1 +
 drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c | 7 ++++++-
 3 files changed, 8 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +1 -1
index 56b46b8206a7..7ba181ccaac2 100644
@@ -7790,7 +7790,7 @@ static void bnxt_hwrm_dbg_qcaps(struct bnxt *bp)
 
 static int bnxt_hwrm_queue_qportcfg(struct bnxt *bp);
 
-static int bnxt_hwrm_func_qcaps(struct bnxt *bp)
+int bnxt_hwrm_func_qcaps(struct bnxt *bp)
 {
 	int rc;
 
drivers/net/ethernet/broadcom/bnxt/bnxt.h +1 -0
index a1dca8c58f54..075c6206325c 100644
@@ -2314,6 +2314,7 @@ int bnxt_cancel_reservations(struct bnxt *bp, bool fw_reset);
 int bnxt_hwrm_alloc_wol_fltr(struct bnxt *bp);
 int bnxt_hwrm_free_wol_fltr(struct bnxt *bp);
 int bnxt_hwrm_func_resc_qcaps(struct bnxt *bp, bool all);
+int bnxt_hwrm_func_qcaps(struct bnxt *bp);
 int bnxt_hwrm_fw_set_time(struct bnxt *);
 int bnxt_open_nic(struct bnxt *, bool, bool);
 int bnxt_half_open_nic(struct bnxt *bp);
drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c +6 -1
index ddf2f3963abe..a1a2c7a64fd5 100644
@@ -823,8 +823,10 @@ static int bnxt_sriov_enable(struct bnxt *bp, int *num_vfs)
 		goto err_out2;
 
 	rc = pci_enable_sriov(bp->pdev, *num_vfs);
-	if (rc)
+	if (rc) {
+		bnxt_ulp_sriov_cfg(bp, 0);
 		goto err_out2;
+	}
 
 	return 0;
 
@@ -832,6 +834,9 @@ static int bnxt_sriov_enable(struct bnxt *bp, int *num_vfs)
 	/* Free the resources reserved for various VF's */
 	bnxt_hwrm_func_vf_resource_free(bp, *num_vfs);
 
+	/* Restore the max resources */
+	bnxt_hwrm_func_qcaps(bp);
+
 err_out1:
 	bnxt_free_vf_resources(bp);
 
Signature · 1 line
2.18.1
author maintainer
#2 lore raw

PATCH 2/5 bnxt_en: Fix bnxt_reinit_after_abort() code path

In reply to Michael Chan

bnxt_reinit_after_abort() is called during ifup when a previous FW reset sequence has aborted or a previous ifup has failed after detecting FW reset. In all cases, it is safe to assume that a previous FW reset has completed and the driver may not have fully reinitialized.

Prior to this patch, it is assumed that the FUNC_DRV_IF_CHANGE_RESP_FLAGS_HOT_FW_RESET_DONE flag will always be set by the firmware in bnxt_hwrm_if_change(). This may not be true if the driver has already attempted to register with the firmware. The firmware may not set the RESET_DONE flag again after the driver has registered, assuming that the driver has seen the flag already.

Fix it to always go through the FW reset initialization path if the BNXT_STATE_FW_RESET_DET flag is set. This flag is always set by the driver after successfully going through bnxt_reinit_after_abort().

Fixes 6882c36cf82e ("bnxt_en: attempt to reinitialize after aborted reset")
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +2 -1
index 7ba181ccaac2..cf9b00576ed3 100644
@@ -10065,7 +10065,8 @@ static int bnxt_hwrm_if_change(struct bnxt *bp, bool up)
 
 	if (flags & FUNC_DRV_IF_CHANGE_RESP_FLAGS_RESC_CHANGE)
 		resc_reinit = true;
-	if (flags & FUNC_DRV_IF_CHANGE_RESP_FLAGS_HOT_FW_RESET_DONE)
+	if (flags & FUNC_DRV_IF_CHANGE_RESP_FLAGS_HOT_FW_RESET_DONE ||
+	    test_bit(BNXT_STATE_FW_RESET_DET, &bp->state))
 		fw_reset = true;
 	else
 		bnxt_remap_fw_health_regs(bp);
Signature · 1 line
2.18.1
author maintainer
#3 lore raw

PATCH 3/5 bnxt_en: fix livepatch query

In reply to Michael Chan

From: Vikas Gupta <[email protected]>

In the livepatch query fw_target BNXT_FW_SRT_PATCH is applicable for P5 chips only.

Fixes 3c4153394e2c ("bnxt_en: implement firmware live patching")
---
 drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c +5 -3
index 3528ce9849e6..6b3d4f4c2a75 100644
@@ -979,9 +979,11 @@ static int bnxt_dl_info_get(struct devlink *dl, struct devlink_info_req *req,
 	if (rc)
 		return rc;
 
-	rc = bnxt_dl_livepatch_info_put(bp, req, BNXT_FW_SRT_PATCH);
-	if (rc)
-		return rc;
+	if (BNXT_CHIP_P5(bp)) {
+		rc = bnxt_dl_livepatch_info_put(bp, req, BNXT_FW_SRT_PATCH);
+		if (rc)
+			return rc;
+	}
 	return bnxt_dl_livepatch_info_put(bp, req, BNXT_FW_CRT_PATCH);
 
 }
Signature · 1 line
2.18.1
author maintainer
#4 lore raw

PATCH 4/5 bnxt_en: Fix and simplify XDP transmit path

In reply to Michael Chan

Fix the missing length hint in the TX BD for the XDP transmit path. The length hint is required on legacy chips.

Also, simplify the code by eliminating the first_buf local variable. tx_buf contains the same value. The opaque value only needs to be set on the first BD. Fix this also for correctness.

Fixes a7559bc8c17c ("bnxt: support transmit and free of aggregation buffers")
---
 drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c +5 -5
index f02fe906dedb..f53387ed0167 100644
@@ -28,7 +28,7 @@ struct bnxt_sw_tx_bd *bnxt_xmit_bd(struct bnxt *bp,
 				   struct xdp_buff *xdp)
 {
 	struct skb_shared_info *sinfo;
-	struct bnxt_sw_tx_bd *tx_buf, *first_buf;
+	struct bnxt_sw_tx_bd *tx_buf;
 	struct tx_bd *txbd;
 	int num_frags = 0;
 	u32 flags;
@@ -43,13 +43,14 @@ struct bnxt_sw_tx_bd *bnxt_xmit_bd(struct bnxt *bp,
 	/* fill up the first buffer */
 	prod = txr->tx_prod;
 	tx_buf = &txr->tx_buf_ring[prod];
-	first_buf = tx_buf;
 	tx_buf->nr_frags = num_frags;
 	if (xdp)
 		tx_buf->page = virt_to_head_page(xdp->data);
 
 	txbd = &txr->tx_desc_ring[TX_RING(prod)][TX_IDX(prod)];
-	flags = ((len) << TX_BD_LEN_SHIFT) | ((num_frags + 1) << TX_BD_FLAGS_BD_CNT_SHIFT);
+	flags = (len << TX_BD_LEN_SHIFT) |
+		((num_frags + 1) << TX_BD_FLAGS_BD_CNT_SHIFT) |
+		bnxt_lhint_arr[len >> 9];
 	txbd->tx_bd_len_flags_type = cpu_to_le32(flags);
 	txbd->tx_bd_opaque = prod;
 	txbd->tx_bd_haddr = cpu_to_le64(mapping);
@@ -82,7 +83,6 @@ struct bnxt_sw_tx_bd *bnxt_xmit_bd(struct bnxt *bp,
 
 		flags = frag_len << TX_BD_LEN_SHIFT;
 		txbd->tx_bd_len_flags_type = cpu_to_le32(flags);
-		txbd->tx_bd_opaque = prod;
 		txbd->tx_bd_haddr = cpu_to_le64(frag_mapping);
 
 		len = frag_len;
@@ -96,7 +96,7 @@ struct bnxt_sw_tx_bd *bnxt_xmit_bd(struct bnxt *bp,
 	prod = NEXT_TX(prod);
 	txr->tx_prod = prod;
 
-	return first_buf;
+	return tx_buf;
 }
 
 static void __bnxt_xmit_xdp(struct bnxt *bp, struct bnxt_tx_ring_info *txr,
Signature · 1 line
2.18.1
author maintainer
#5 lore raw

PATCH 5/5 bnxt_en: Fix bnxt_refclk_read()

In reply to Michael Chan

From: Pavan Chebbi <[email protected]>

The upper 32-bit PHC register is not latched when reading the lower 32-bit PHC register. Current code leaves a small window where we may not read correct higher order bits if the lower order bits are just about to wrap around.

This patch fixes this by reading higher order bits twice and makes sure that final value is correctly paired with its lower 32 bits.

Fixes 30e96f487f64 ("bnxt_en: Do not read the PTP PHC during chip reset")
Cc Richard Cochran <[email protected]>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c +11 -2
index 562f8f68a47d..7f3c0875b6f5 100644
@@ -76,14 +76,23 @@ static int bnxt_refclk_read(struct bnxt *bp, struct ptp_system_timestamp *sts,
 			    u64 *ns)
 {
 	struct bnxt_ptp_cfg *ptp = bp->ptp_cfg;
+	u32 high_before, high_now, low;
 
 	if (test_bit(BNXT_STATE_IN_FW_RESET, &bp->state))
 		return -EIO;
 
+	high_before = readl(bp->bar0 + ptp->refclk_mapped_regs[1]);
 	ptp_read_system_prets(sts);
-	*ns = readl(bp->bar0 + ptp->refclk_mapped_regs[0]);
+	low = readl(bp->bar0 + ptp->refclk_mapped_regs[0]);
 	ptp_read_system_postts(sts);
-	*ns |= (u64)readl(bp->bar0 + ptp->refclk_mapped_regs[1]) << 32;
+	high_now = readl(bp->bar0 + ptp->refclk_mapped_regs[1]);
+	if (high_now != high_before) {
+		ptp_read_system_prets(sts);
+		low = readl(bp->bar0 + ptp->refclk_mapped_regs[0]);
+		ptp_read_system_postts(sts);
+	}
+	*ns = ((u64)high_now << 32) | low;
+
 	return 0;
 }
 
Signature · 1 line
2.18.1
#6 lore raw
In reply to Michael Chan
This series was applied to netdev/net.git (master) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net.git (master) by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Mon, 11 Jul 2022 22:26:13 -0400 you wrote:

This patchset fixes various issues, including SRIOV error unwinding, one error recovery path, live patch reporting, XDP transmit path, and PHC clock reading.

Kashyap Desai (1):
bnxt_en: reclaim max resources if sriov enable fails

[...]

Here is the summary with links:
- [net,1/5] bnxt_en: reclaim max resources if sriov enable fails

    https://git.kernel.org/netdev/net/c/c5b744d38c36
  - [net,2/5] bnxt_en: Fix bnxt_reinit_after_abort() code path
    https://git.kernel.org/netdev/net/c/4279414bff8a
  - [net,3/5] bnxt_en: fix livepatch query
    https://git.kernel.org/netdev/net/c/619b9b1622c2
  - [net,4/5] bnxt_en: Fix and simplify XDP transmit path
    https://git.kernel.org/netdev/net/c/53f8c2d37efb
  - [net,5/5] bnxt_en: Fix bnxt_refclk_read()
    https://git.kernel.org/netdev/net/c/ddde5412fdaa

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html