Skip to contentSkip to conversation

bnxt_en: Bug fixes

PATCH Applied Michael Chan 2 participants 5 messages May 3, 2022 – May 4, 2022

Subsystems (3)
lore
Share & tools
lore

Michael Chan

author maintainer
#0 lore raw

cover bnxt_en: Bug fixes

This patch series includes 3 fixes:

1. Fix an occasional VF open failure.
2. Fix a PTP spinlock usage before initialization
3. Fix unnecesary RX packet drops under high TX traffic load.

Michael Chan (2):
bnxt_en: Initiallize bp->ptp_lock first before using it
bnxt_en: Fix unnecessary dropping of RX packets

Somnath Kotur (1):
bnxt_en: Fix possible bnxt_open() failure caused by wrong RFS flag

 drivers/net/ethernet/broadcom/bnxt/bnxt.c     | 13 ++++++++-----
 drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c | 15 +++++++--------
 2 files changed, 15 insertions(+), 13 deletions(-)
Signature · 1 line
2.18.1
author maintainer
#1 lore raw

PATCH 1/3 bnxt_en: Fix possible bnxt_open() failure caused by wrong RFS flag

From: Somnath Kotur <[email protected]>

bnxt_open() can fail in this code path, especially on a VF when it fails to reserve default rings:

bnxt_open()
__bnxt_open_nic()
bnxt_clear_int_mode()
bnxt_init_dflt_ring_mode()

RX rings would be set to 0 when we hit this error path.

It is possible for a subsequent bnxt_open() call to potentially succeed with a code path like this:

bnxt_open()
bnxt_hwrm_if_change()

    bnxt_fw_init_one()
      bnxt_fw_init_one_p3()
        bnxt_set_dflt_rfs()
          bnxt_rfs_capable()
            bnxt_hwrm_reserve_rings()

On older chips, RFS is capable if we can reserve the number of vnics that is equal to RX rings + 1. But since RX rings is still set to 0 in this code path, we may mistakenly think that RFS is supported for 0 RX rings.

Later, when the default RX rings are reserved and we try to enable RFS, it would fail and cause bnxt_open() to fail unnecessarily.

We fix this in 2 places. bnxt_rfs_capable() will always return false if RX rings is not yet set. bnxt_init_dflt_ring_mode() will call bnxt_set_dflt_rfs() which will always clear the RFS flags if RFS is not supported.

Fixes 20d7d1c5c9b1 ("bnxt_en: reliably allocate IRQ table on reset to avoid crash")
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +4 -5
index 874fad0a5cf8..2818cfef42f8 100644
@@ -10983,7 +10983,7 @@ static bool bnxt_rfs_capable(struct bnxt *bp)
 
 	if (bp->flags & BNXT_FLAG_CHIP_P5)
 		return bnxt_rfs_supported(bp);
-	if (!(bp->flags & BNXT_FLAG_MSIX_CAP) || !bnxt_can_reserve_rings(bp))
+	if (!(bp->flags & BNXT_FLAG_MSIX_CAP) || !bnxt_can_reserve_rings(bp) || !bp->rx_nr_rings)
 		return false;
 
 	vnics = 1 + bp->rx_nr_rings;
@@ -13234,10 +13234,9 @@ static int bnxt_init_dflt_ring_mode(struct bnxt *bp)
 		goto init_dflt_ring_err;
 
 	bp->tx_nr_rings_per_tc = bp->tx_nr_rings;
-	if (bnxt_rfs_supported(bp) && bnxt_rfs_capable(bp)) {
-		bp->flags |= BNXT_FLAG_RFS;
-		bp->dev->features |= NETIF_F_NTUPLE;
-	}
+
+	bnxt_set_dflt_rfs(bp);
+
 init_dflt_ring_err:
 	bnxt_ulp_irq_restart(bp, rc);
 	return rc;
Signature · 1 line
2.18.1
author maintainer
#2 lore raw

PATCH 2/3 bnxt_en: Initiallize bp->ptp_lock first before using it

In reply to Michael Chan

bnxt_ptp_init() calls bnxt_ptp_init_rtc() which will acquire the ptp_lock spinlock. The spinlock is not initialized until later. Move the bnxt_ptp_init_rtc() call after the spinlock is initialized.

Fixes 24ac1ecd5240 ("bnxt_en: Add driver support to use Real Time Counter for PTP")
---
 drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c +7 -8
index 9c2ad5e67a5d..00f2f80c0073 100644
@@ -846,13 +846,6 @@ int bnxt_ptp_init(struct bnxt *bp, bool phc_cfg)
 	if (rc)
 		return rc;
 
-	if (bp->fw_cap & BNXT_FW_CAP_PTP_RTC) {
-		bnxt_ptp_timecounter_init(bp, false);
-		rc = bnxt_ptp_init_rtc(bp, phc_cfg);
-		if (rc)
-			goto out;
-	}
-
 	if (ptp->ptp_clock && bnxt_pps_config_ok(bp))
 		return 0;
 
@@ -861,8 +854,14 @@ int bnxt_ptp_init(struct bnxt *bp, bool phc_cfg)
 	atomic_set(&ptp->tx_avail, BNXT_MAX_TX_TS);
 	spin_lock_init(&ptp->ptp_lock);
 
-	if (!(bp->fw_cap & BNXT_FW_CAP_PTP_RTC))
+	if (bp->fw_cap & BNXT_FW_CAP_PTP_RTC) {
+		bnxt_ptp_timecounter_init(bp, false);
+		rc = bnxt_ptp_init_rtc(bp, phc_cfg);
+		if (rc)
+			goto out;
+	} else {
 		bnxt_ptp_timecounter_init(bp, true);
+	}
 
 	ptp->ptp_info = bnxt_ptp_caps;
 	if ((bp->fw_cap & BNXT_FW_CAP_PTP_PPS)) {
Signature · 1 line
2.18.1
author maintainer
#3 lore raw

PATCH 3/3 bnxt_en: Fix unnecessary dropping of RX packets

In reply to Michael Chan

In bnxt_poll_p5(), we first check cpr->has_more_work. If it is true, we are in NAPI polling mode and we will call __bnxt_poll_cqs() to continue polling. It is possible to exhanust the budget again when __bnxt_poll_cqs() returns.

We then enter the main while loop to check for new entries in the NQ. If we had previously exhausted the NAPI budget, we may call __bnxt_poll_work() to process an RX entry with zero budget. This will cause packets to be dropped unnecessarily, thinking that we are in the netpoll path. Fix it by breaking out of the while loop if we need to process an RX NQ entry with no budget left. We will then exit NAPI and stay in polling mode.

Fixes 389a877a3b20 ("bnxt_en: Process the NQ under NAPI continuous polling.")
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +4 -0
index 2818cfef42f8..1d69fe0737a1 100644
@@ -2707,6 +2707,10 @@ static int bnxt_poll_p5(struct napi_struct *napi, int budget)
 			u32 idx = le32_to_cpu(nqcmp->cq_handle_low);
 			struct bnxt_cp_ring_info *cpr2;
 
+			/* No more budget for RX work */
+			if (budget && work_done >= budget && idx == BNXT_RX_HDL)
+				break;
+
 			cpr2 = cpr->cp_ring_arr[idx];
 			work_done += __bnxt_poll_work(bp, cpr2,
 						      budget - work_done);
Signature · 1 line
2.18.1
#4 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 11 lines · On Mon, 2 May 2022 21:13:09 -0400 you wrote:

This patch series includes 3 fixes:

1. Fix an occasional VF open failure.
2. Fix a PTP spinlock usage before initialization
3. Fix unnecesary RX packet drops under high TX traffic load.

Michael Chan (2):
bnxt_en: Initiallize bp->ptp_lock first before using it
bnxt_en: Fix unnecessary dropping of RX packets

[...]

Here is the summary with links:
- [net,1/3] bnxt_en: Fix possible bnxt_open() failure caused by wrong RFS flag

    https://git.kernel.org/netdev/net/c/13ba794397e4
  - [net,2/3] bnxt_en: Initiallize bp->ptp_lock first before using it
    https://git.kernel.org/netdev/net/c/2b156fb57d8f
  - [net,3/3] bnxt_en: Fix unnecessary dropping of RX packets
    https://git.kernel.org/netdev/net/c/195af57914d1

You are awesome, thank you!

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