netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net 0/3] bnxt_en: Bug fixes
@ 2022-05-03  1:13 Michael Chan
  2022-05-03  1:13 ` [PATCH net 1/3] bnxt_en: Fix possible bnxt_open() failure caused by wrong RFS flag Michael Chan
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Michael Chan @ 2022-05-03  1:13 UTC (permalink / raw)
  To: davem; +Cc: netdev, kuba, gospo

[-- Attachment #1: Type: text/plain, Size: 604 bytes --]

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(-)

-- 
2.18.1


[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4209 bytes --]

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

* [PATCH net 1/3] bnxt_en: Fix possible bnxt_open() failure caused by wrong RFS flag
  2022-05-03  1:13 [PATCH net 0/3] bnxt_en: Bug fixes Michael Chan
@ 2022-05-03  1:13 ` Michael Chan
  2022-05-03  1:13 ` [PATCH net 2/3] bnxt_en: Initiallize bp->ptp_lock first before using it Michael Chan
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Michael Chan @ 2022-05-03  1:13 UTC (permalink / raw)
  To: davem; +Cc: netdev, kuba, gospo, Somnath Kotur

[-- Attachment #1: Type: text/plain, Size: 2445 bytes --]

From: Somnath Kotur <somnath.kotur@broadcom.com>

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")
Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 874fad0a5cf8..2818cfef42f8 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -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;
-- 
2.18.1


[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4209 bytes --]

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

* [PATCH net 2/3] bnxt_en: Initiallize bp->ptp_lock first before using it
  2022-05-03  1:13 [PATCH net 0/3] bnxt_en: Bug fixes Michael Chan
  2022-05-03  1:13 ` [PATCH net 1/3] bnxt_en: Fix possible bnxt_open() failure caused by wrong RFS flag Michael Chan
@ 2022-05-03  1:13 ` Michael Chan
  2022-05-03  1:13 ` [PATCH net 3/3] bnxt_en: Fix unnecessary dropping of RX packets Michael Chan
  2022-05-04  1:00 ` [PATCH net 0/3] bnxt_en: Bug fixes patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: Michael Chan @ 2022-05-03  1:13 UTC (permalink / raw)
  To: davem; +Cc: netdev, kuba, gospo

[-- Attachment #1: Type: text/plain, Size: 1825 bytes --]

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")
Reviewed-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
Reviewed-by: Saravanan Vajravel <saravanan.vajravel@broadcom.com>
Reviewed-by: Andy Gospodarek <andrew.gospodarek@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
Reviewed-by: Damodharam Ammepalli <damodharam.ammepalli@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c
index 9c2ad5e67a5d..00f2f80c0073 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c
@@ -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)) {
-- 
2.18.1


[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4209 bytes --]

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

* [PATCH net 3/3] bnxt_en: Fix unnecessary dropping of RX packets
  2022-05-03  1:13 [PATCH net 0/3] bnxt_en: Bug fixes Michael Chan
  2022-05-03  1:13 ` [PATCH net 1/3] bnxt_en: Fix possible bnxt_open() failure caused by wrong RFS flag Michael Chan
  2022-05-03  1:13 ` [PATCH net 2/3] bnxt_en: Initiallize bp->ptp_lock first before using it Michael Chan
@ 2022-05-03  1:13 ` Michael Chan
  2022-05-04  1:00 ` [PATCH net 0/3] bnxt_en: Bug fixes patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: Michael Chan @ 2022-05-03  1:13 UTC (permalink / raw)
  To: davem; +Cc: netdev, kuba, gospo

[-- Attachment #1: Type: text/plain, Size: 1599 bytes --]

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.")
Reviewed-by: Andy Gospodarek <andrew.gospodarek@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 2818cfef42f8..1d69fe0737a1 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -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);
-- 
2.18.1


[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4209 bytes --]

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

* Re: [PATCH net 0/3] bnxt_en: Bug fixes
  2022-05-03  1:13 [PATCH net 0/3] bnxt_en: Bug fixes Michael Chan
                   ` (2 preceding siblings ...)
  2022-05-03  1:13 ` [PATCH net 3/3] bnxt_en: Fix unnecessary dropping of RX packets Michael Chan
@ 2022-05-04  1:00 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-05-04  1:00 UTC (permalink / raw)
  To: Michael Chan; +Cc: davem, netdev, kuba, gospo

Hello:

This series was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:

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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2022-05-04  1:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-03  1:13 [PATCH net 0/3] bnxt_en: Bug fixes Michael Chan
2022-05-03  1:13 ` [PATCH net 1/3] bnxt_en: Fix possible bnxt_open() failure caused by wrong RFS flag Michael Chan
2022-05-03  1:13 ` [PATCH net 2/3] bnxt_en: Initiallize bp->ptp_lock first before using it Michael Chan
2022-05-03  1:13 ` [PATCH net 3/3] bnxt_en: Fix unnecessary dropping of RX packets Michael Chan
2022-05-04  1:00 ` [PATCH net 0/3] bnxt_en: Bug fixes patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).