From: netdev-bot+sashiko@kernel.org
To: joe@dama.to
Cc: netdev@vger.kernel.org, michael.chan@broadcom.com,
pavan.chebbi@broadcom.com, andrew+netdev@lunn.ch,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, prashant@broadcom.com, eddie.wai@broadcom.com,
huangjw@broadcom.com, horms@kernel.org,
kalesh-anakkur.purayil@broadcom.com,
colin.winegarden@broadcom.com, rukhsana.ansari@broadcom.com,
linux-kernel@vger.kernel.org, raphaelcf@meta.com,
sashiko-bot+sashiko@kernel.org, stable@vger.kernel.org
Subject: Re: [net,v5,4/6] bnxt_en: Handle buffer allocation failure in bnxt_rx_ring_reset()
Date: Thu, 03 Sep 2026 07:51:55 +0000 [thread overview]
Message-ID: <178842191510.3394541.8694280493608696004@kernel.org> (raw)
In-Reply-To: <20260902015652.2421609-5-joe@dama.to>
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider:
Critical: 0 · High: 0 · Medium: 1 · Low: 1
- [Medium] Commit message misdescribes the failure mechanism it is
fixing.
- [Low] The new error path in `bnxt_rx_ring_reset()`
(drivers/net/ethernet/broadcom/bnxt/bnxt.c:14606-14616) loses the…
--
bnxt_en: Handle buffer allocation failure in bnxt_rx_ring_reset()
bnxt_rx_ring_reset() used to ignore the return value of
bnxt_alloc_one_rx_ring(). The patch checks it and, on failure, logs a
warning and falls back to a global reset instead of re-enabling TPA with a
partially populated rxr->rx_tpa[] array.
Link: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260828190900.1767611-1-joe%40dama.to
A couple of questions below, one about the commit message and one about the
new error path.
> bnxt_alloc_one_rx_ring() can fail in bnxt_alloc_one_tpa_info_data(), which
> returns -ENOMEM on the first failed allocation and leaves the remaining
> rxr->rx_tpa[] entries zeroed.
>
> This means that when the agg_id from hardware is mapped to a SW index in
> rxr->rx_tpa[], an uninitialized slot can be chosen which would hand a
> zero DMA address to the device.
[Severity: Medium]
Is the "entries zeroed" / "zero DMA address" description accurate for the
reset path?
bnxt_rx_ring_reset() calls bnxt_free_one_rx_ring_skbs() ->
bnxt_free_one_tpa_info_data() first, and that only clears ->data:
for (i = 0; i < bp->max_tpa; i++) {
struct bnxt_tpa_info *tpa_info = &rxr->rx_tpa[i];
u8 *data = tpa_info->data;
if (!data)
continue;
tpa_info->data = NULL;
page_pool_free_va(rxr->head_pool, data, false);
}
->data_ptr and ->mapping are left pointing at the buffer that was just
returned to the head pool. bnxt_alloc_one_tpa_info_data() then bails out
at the first failure:
for (i = 0; i < bp->max_tpa; i++) {
data = __bnxt_alloc_rx_frag(bp, &mapping, rxr, GFP_KERNEL);
if (!data)
return -ENOMEM;
...
}
so entries [i, bp->max_tpa) keep the stale mapping from before the reset
rather than becoming zero. In the unfixed code bnxt_tpa_start() would then
program that stale address into the RX BD:
mapping = tpa_info->mapping;
prod_rx_buf->mapping = mapping;
prod_bd = &rxr->rx_desc_ring[RX_RING(bp, prod)][RX_IDX(prod)];
prod_bd->rx_bd_haddr = cpu_to_le64(mapping);
Would it be more precise to say the device would DMA into a recycled
page-pool buffer (and prod_rx_buf->data would be NULL), instead of a zero
DMA address? Since this is tagged for stable, the description is what
backporters will read.
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> index 3755a30f8d403..a8e5fdfcdf591 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> @@ -14604,7 +14604,14 @@ static void bnxt_rx_ring_reset(struct bnxt *bp)
> rxr->rx_sw_agg_prod = 0;
> rxr->rx_next_cons = 0;
> rxr->bnapi->in_reset = false;
> - bnxt_alloc_one_rx_ring(bp, i);
> + rc = bnxt_alloc_one_rx_ring(bp, i);
> + if (rc) {
> + netdev_warn(bp->dev, "RX ring reset failed to allocate buffers, rc = %d, falling back to global reset\n",
> + rc);
> + bnxt_reset_task(bp, true);
> + bnxt_rtnl_unlock_sp(bp);
> + return;
> + }
> cpr = &rxr->bnapi->cp_ring;
> cpr->sw_stats->rx.rx_resets++;
[Severity: Low]
Does this new path lose the rx_resets accounting for the reset it just did?
rxr->bnapi->in_reset = false is done just above the allocation, and the new
error path returns before reaching cpr->sw_stats->rx.rx_resets++.
The fallback bnxt_reset_task(bp, true) -> bnxt_close_nic() ->
bnxt_disable_napi() is the only other place that bumps this counter, and it
is gated on in_reset:
if (bnapi->in_reset)
cpr->sw_stats->rx.rx_resets++;
which is already false for this ring, so the event is counted nowhere.
Contrast with the sibling failure path in the same function: the
bnxt_hwrm_rx_ring_reset() failure does a break with in_reset still set, so
its global reset does get counted by bnxt_disable_napi(). That leaves two
paths that both do an RX ring reset plus a global reset reporting different
rx_resets values via ethtool -S.
cpr->sw_stats is only freed by bnxt_free_ring_stats(), which is not reached
for an irq_re_init == false close, so the missing increment stays visible in
rx_resets and rx_total_resets.
Would incrementing rx_resets before the early return, or only clearing
in_reset after a successful bnxt_alloc_one_rx_ring(), be preferable here?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260902015652.2421609-1-joe%40dama.to
next prev parent reply other threads:[~2026-09-03 7:51 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-02 1:56 [PATCH net v5 0/6] Fix a variety of TPA bugs Joe Damato
2026-09-02 1:56 ` [PATCH net v5 1/6] bnxt_en: Only restore LRO if the device supports TPA Joe Damato
2026-09-02 1:56 ` [PATCH net v5 2/6] bnxt_en: Don't free the live ring's TPA state on queue restart failure Joe Damato
2026-09-02 1:56 ` [PATCH net v5 3/6] bnxt_en: Propagate TPA buffer allocation failures in bnxt_queue_mem_alloc() Joe Damato
2026-09-02 1:56 ` [PATCH net v5 4/6] bnxt_en: Handle buffer allocation failure in bnxt_rx_ring_reset() Joe Damato
2026-09-03 7:51 ` netdev-bot+sashiko [this message]
2026-09-02 1:56 ` [PATCH net v5 5/6] bnxt_en: Propagate RX ring init failures in bnxt_init_nic() Joe Damato
2026-09-02 1:56 ` [PATCH net v5 6/6] bnxt_en: Bound SW TPA IDs to prevent crashes Joe Damato
2026-09-03 9:37 ` [PATCH net v5 0/6] Fix a variety of TPA bugs Paolo Abeni
2026-09-03 15:19 ` Joe Damato
2026-09-03 15:45 ` Paolo Abeni
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=178842191510.3394541.8694280493608696004@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=colin.winegarden@broadcom.com \
--cc=davem@davemloft.net \
--cc=eddie.wai@broadcom.com \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=huangjw@broadcom.com \
--cc=joe@dama.to \
--cc=kalesh-anakkur.purayil@broadcom.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michael.chan@broadcom.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pavan.chebbi@broadcom.com \
--cc=prashant@broadcom.com \
--cc=raphaelcf@meta.com \
--cc=rukhsana.ansari@broadcom.com \
--cc=sashiko-bot+sashiko@kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).