* [PATCH net] bnxt_en: Fix NIC lockup caused by stale NQ consumer index
@ 2026-12-04 20:03 Joe Damato
2026-12-04 22:22 ` Michael Chan
2026-12-05 20:10 ` netdev-bot+sashiko
0 siblings, 2 replies; 5+ messages in thread
From: Joe Damato @ 2026-12-04 20:03 UTC (permalink / raw)
To: netdev, Michael Chan, Pavan Chebbi, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Joe Damato
On a BCM57504 running firmware 238.1.138.6 or 232.0.159.4, the NIC can
lock up when the NQ consumer index goes stale. This can be reproduced
with iperf3 TCP traffic and hard IRQ deferral enabled:
echo 2 > /sys/class/net/eth0/napi_defer_hard_irqs
echo 200000 > /sys/class/net/eth0/gro_flush_timeout
iperf3 -c $PEER -P 4 -t 300 &
iperf3 -c $PEER -P 4 -t 300 -R &
Traffic stops within seconds. On FW 238.1.138.6 the TX watchdog then
fires and the driver's reset fails (RING_FREE fails and ring allocation
fails on open).
In that state, devlink reload, FLR, and host reboot all fail to recover
the NIC; only removing power from the NIC recovers the device. The same
test did not reproduce the lockup with firmware 225.0.154.0 or
225.0.157.0.
The driver does not update the NQ consumer index when
napi_complete_done() returns false, for example when IRQ deferral is
enabled as above, or when a busy polling socket owns the NAPI.
Fix this by writing the NQ consumer index, without arming the NQ, when
napi_complete_done() returns false. Skip the write if the index has not
moved, to avoid an extra MMIO write while busy polling an idle NAPI.
Fixes: 0fcec9854ab4 ("bnxt_en: Add new NAPI poll function for 57500 chips.")
Signed-off-by: Joe Damato <joe@dama.to>
---
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 85ce4b2e297e..f5cc273b97a5 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -3397,6 +3397,7 @@ static int bnxt_poll_p5(struct napi_struct *napi, int budget)
struct bnxt *bp = bnapi->bp;
struct nqe_cn *nqcmp;
int work_done = 0;
+ bool nq_moved;
u32 cons;
if (unlikely(test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state))) {
@@ -3419,10 +3420,18 @@ static int bnxt_poll_p5(struct napi_struct *napi, int budget)
__bnxt_poll_cqs_done(bp, bnapi, DBR_TYPE_CQ_ARMALL,
budget);
+ nq_moved = raw_cons != cpr->cp_raw_cons;
cpr->cp_raw_cons = raw_cons;
- if (napi_complete_done(napi, work_done))
+ if (napi_complete_done(napi, work_done)) {
BNXT_DB_NQ_ARM_P5(&cpr->cp_db,
cpr->cp_raw_cons);
+ } else if (nq_moved) {
+ /* NAPI stays scheduled (IRQ deferral or busy
+ * poll) and the NQ is not re-armed, but the
+ * HW must still learn how far it was consumed.
+ */
+ BNXT_DB_NQ_P5(&cpr->cp_db, cpr->cp_raw_cons);
+ }
goto poll_done;
}
base-commit: e9d78fc6741ac06d438cf64e314c28e57014432a
--
2.53.1-Meta
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net] bnxt_en: Fix NIC lockup caused by stale NQ consumer index
2026-12-04 20:03 [PATCH net] bnxt_en: Fix NIC lockup caused by stale NQ consumer index Joe Damato
@ 2026-12-04 22:22 ` Michael Chan
2026-12-04 22:58 ` Joe Damato
2026-12-05 20:10 ` netdev-bot+sashiko
1 sibling, 1 reply; 5+ messages in thread
From: Michael Chan @ 2026-12-04 22:22 UTC (permalink / raw)
To: Joe Damato
Cc: netdev, Pavan Chebbi, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni
[-- Attachment #1: Type: text/plain, Size: 1390 bytes --]
On Fri, Dec 4, 2026 at 12:03 PM Joe Damato <joe@dama.to> wrote:
> @@ -3419,10 +3420,18 @@ static int bnxt_poll_p5(struct napi_struct *napi, int budget)
>
> __bnxt_poll_cqs_done(bp, bnapi, DBR_TYPE_CQ_ARMALL,
> budget);
> + nq_moved = raw_cons != cpr->cp_raw_cons;
> cpr->cp_raw_cons = raw_cons;
> - if (napi_complete_done(napi, work_done))
> + if (napi_complete_done(napi, work_done)) {
> BNXT_DB_NQ_ARM_P5(&cpr->cp_db,
> cpr->cp_raw_cons);
> + } else if (nq_moved) {
> + /* NAPI stays scheduled (IRQ deferral or busy
> + * poll) and the NQ is not re-armed, but the
> + * HW must still learn how far it was consumed.
> + */
> + BNXT_DB_NQ_P5(&cpr->cp_db, cpr->cp_raw_cons);
I will check with the HW/FW teams to understand why this is needed.
If we finish polling within budget, the completion rings should be
armed and our NQ should be big enough for any new entries without
updating the NQ doorbell. I'll get back to you in a few days.
Thanks.
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 5469 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net] bnxt_en: Fix NIC lockup caused by stale NQ consumer index
2026-12-04 22:22 ` Michael Chan
@ 2026-12-04 22:58 ` Joe Damato
2026-12-05 15:19 ` Pavan Chebbi
0 siblings, 1 reply; 5+ messages in thread
From: Joe Damato @ 2026-12-04 22:58 UTC (permalink / raw)
To: Michael Chan
Cc: netdev, Pavan Chebbi, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni
On Fri, Dec 04, 2026 at 02:22:49PM -0800, Michael Chan wrote:
> On Fri, Dec 4, 2026 at 12:03 PM Joe Damato <joe@dama.to> wrote:
>
> > @@ -3419,10 +3420,18 @@ static int bnxt_poll_p5(struct napi_struct *napi, int budget)
> >
> > __bnxt_poll_cqs_done(bp, bnapi, DBR_TYPE_CQ_ARMALL,
> > budget);
> > + nq_moved = raw_cons != cpr->cp_raw_cons;
> > cpr->cp_raw_cons = raw_cons;
> > - if (napi_complete_done(napi, work_done))
> > + if (napi_complete_done(napi, work_done)) {
> > BNXT_DB_NQ_ARM_P5(&cpr->cp_db,
> > cpr->cp_raw_cons);
> > + } else if (nq_moved) {
> > + /* NAPI stays scheduled (IRQ deferral or busy
> > + * poll) and the NQ is not re-armed, but the
> > + * HW must still learn how far it was consumed.
> > + */
> > + BNXT_DB_NQ_P5(&cpr->cp_db, cpr->cp_raw_cons);
>
> I will check with the HW/FW teams to understand why this is needed.
> If we finish polling within budget, the completion rings should be
> armed and our NQ should be big enough for any new entries without
> updating the NQ doorbell. I'll get back to you in a few days.
> Thanks.
Thanks for taking a look and following up internally.
I agree that a single poll can't overflow the NQ. The problem is that many
polls in a row can skip the NQ doorbell write.
With defer_hard_irqs, any poll with work_done > 0 resets the defer
count, so napi_complete_done() keeps returning false under steady
traffic. Busy poll always returns false. Each of those polls re-arms
the CQs and consumes the new NQEs, but the consumer index the HW sees
never moves.
The end-of-loop write doesn't help a TX-heavy NAPI. TX completions
don't count toward the budget, so a TCP sender, whose only RX is
ACKs, stays under budget and never reaches it.
FWIW, FW 225 didn't seem to reproduce this issue so it is possible that
something changed between FW 225 and the more recent FWs or that maybe my test
on FW 225 wasn't right for some reason. Not sure.
In any case, I'd encourage the folks on your side to test the reproducer on
different FW versions and see if you can repro.
I tested it a few times on FW 238 and it repro'd every time within seconds.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net] bnxt_en: Fix NIC lockup caused by stale NQ consumer index
2026-12-04 22:58 ` Joe Damato
@ 2026-12-05 15:19 ` Pavan Chebbi
0 siblings, 0 replies; 5+ messages in thread
From: Pavan Chebbi @ 2026-12-05 15:19 UTC (permalink / raw)
To: Joe Damato, Michael Chan, netdev, Pavan Chebbi, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
[-- Attachment #1: Type: text/plain, Size: 2343 bytes --]
On Sat, Dec 5, 2026 at 4:29 AM Joe Damato <joe@dama.to> wrote:
>
> On Fri, Dec 04, 2026 at 02:22:49PM -0800, Michael Chan wrote:
> > On Fri, Dec 4, 2026 at 12:03 PM Joe Damato <joe@dama.to> wrote:
> >
> > > @@ -3419,10 +3420,18 @@ static int bnxt_poll_p5(struct napi_struct *napi, int budget)
> > >
> > > __bnxt_poll_cqs_done(bp, bnapi, DBR_TYPE_CQ_ARMALL,
> > > budget);
> > > + nq_moved = raw_cons != cpr->cp_raw_cons;
> > > cpr->cp_raw_cons = raw_cons;
> > > - if (napi_complete_done(napi, work_done))
> > > + if (napi_complete_done(napi, work_done)) {
> > > BNXT_DB_NQ_ARM_P5(&cpr->cp_db,
> > > cpr->cp_raw_cons);
> > > + } else if (nq_moved) {
> > > + /* NAPI stays scheduled (IRQ deferral or busy
> > > + * poll) and the NQ is not re-armed, but the
> > > + * HW must still learn how far it was consumed.
> > > + */
> > > + BNXT_DB_NQ_P5(&cpr->cp_db, cpr->cp_raw_cons);
> >
> > I will check with the HW/FW teams to understand why this is needed.
> > If we finish polling within budget, the completion rings should be
> > armed and our NQ should be big enough for any new entries without
> > updating the NQ doorbell. I'll get back to you in a few days.
> > Thanks.
>
> Thanks for taking a look and following up internally.
>
> I agree that a single poll can't overflow the NQ. The problem is that many
> polls in a row can skip the NQ doorbell write.
>
> With defer_hard_irqs, any poll with work_done > 0 resets the defer
> count, so napi_complete_done() keeps returning false under steady
> traffic. Busy poll always returns false. Each of those polls re-arms
> the CQs and consumes the new NQEs, but the consumer index the HW sees
> never moves.
>
I see Björn is trying to solve the same problem here:
https://patchwork.kernel.org/project/netdevbpf/patch/20261203112343.3524699-1-bjorn@kernel.org/
Michael, should that patch also wait? We should let Björn know if so..
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 5469 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net] bnxt_en: Fix NIC lockup caused by stale NQ consumer index
2026-12-04 20:03 [PATCH net] bnxt_en: Fix NIC lockup caused by stale NQ consumer index Joe Damato
2026-12-04 22:22 ` Michael Chan
@ 2026-12-05 20:10 ` netdev-bot+sashiko
1 sibling, 0 replies; 5+ messages in thread
From: netdev-bot+sashiko @ 2026-12-05 20:10 UTC (permalink / raw)
To: joe
Cc: netdev, michael.chan, pavan.chebbi, andrew+netdev, davem,
edumazet, kuba, pabeni
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 1 · Low: 1
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [High] bnxt_en: netpoll in bnxt_poll_p5() can disarm P5 NQ interrupts
- [Medium] In bnxt_poll_p5() (drivers/net/ethernet/broadcom/bnxt/bnxt.c,
line 3433), the new `else if (nq_moved)` branch rings the NQ doorbell,…
- [Low] The new comment in bnxt_poll_p5()
(drivers/net/ethernet/broadcom/bnxt/bnxt.c, lines 3429-3432) says…
--
bnxt_en: Fix NIC lockup caused by stale NQ consumer index
When napi_complete_done() returns false, for example with hard IRQ
deferral or busy polling, bnxt_poll_p5() now writes the NQ consumer
index without arming the NQ. The write is skipped if the index has not
moved. This addresses a NIC lockup on BCM57504 with some firmware
versions when the NQ consumer index goes stale.
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> index 85ce4b2e297ec..f5cc273b97a5a 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
[ ... ]
> @@ -3419,10 +3420,18 @@ static int bnxt_poll_p5(struct napi_struct *napi, int budget)
>
> __bnxt_poll_cqs_done(bp, bnapi, DBR_TYPE_CQ_ARMALL,
> budget);
> + nq_moved = raw_cons != cpr->cp_raw_cons;
> cpr->cp_raw_cons = raw_cons;
> - if (napi_complete_done(napi, work_done))
> + if (napi_complete_done(napi, work_done)) {
> BNXT_DB_NQ_ARM_P5(&cpr->cp_db,
> cpr->cp_raw_cons);
> + } else if (nq_moved) {
> + /* NAPI stays scheduled (IRQ deferral or busy
> + * poll) and the NQ is not re-armed, but the
> + * HW must still learn how far it was consumed.
> + */
[Severity: High]
Does this new branch also run from netpoll? If so, can it leave the NQ
disarmed with nothing left to re-arm it?
poll_one_napi() in net/core/netpoll.c sets NAPI_STATE_NPSVC and calls
napi->poll(napi, 0) for every NAPI on dev->napi_list. That includes
idle ones whose NQ is armed in hardware. It never sets
NAPI_STATE_SCHED, and it does not schedule the NAPI afterwards.
With budget == 0, bnxt_poll_p5() never takes the budget exhaustion
break, and __bnxt_poll_work() does not set has_more_work. Suppose an NQE
is already visible, for example a TX completion for netconsole output
that landed before the MSI-X fired. Then raw_cons advances, nq_moved
is true, the loop falls into the !NQ_CMP_VALID() path, and it calls
napi_complete_done(). That returns false right away because
NAPIF_STATE_NPSVC is set, with no reschedule and no timer.
The new else branch then writes BNXT_DB_NQ_P5(), i.e. DBR_TYPE_NQ.
bnxt_disable_int() and bnxt_queue_stop() use the same doorbell, through
bnxt_db_nq(), to mask the NQ on P5 chips.
When poll_one_napi() clears NPSVC and returns, the NAPI is not
scheduled, no deferral timer is pending, and the NQ is no longer
armed. RX, TX completions and, on ring 0, HWRM async events on that NQ
would then stall until the TX watchdog resets the device.
Before this patch nothing was written on this path, so an armed NQ
stayed armed. The comment above the write also assumes the NAPI stays
scheduled, which is not true for netpoll.
The legacy bnxt_poll() handles this case explicitly: it re-arms with
BNXT_DB_CQ_ARM() when budget is 0. Should bnxt_poll_p5() do something
similar? For example, it could issue BNXT_DB_NQ_ARM_P5() when budget is
0. Or it could avoid calling napi_complete_done() for budget == 0
altogether, as Documentation/networking/napi.rst asks.
[Severity: Low]
Is this comment accurate for the IRQ deferral case?
The reproducer in the commit message sets napi_defer_hard_irqs > 0 and a
non-zero gro_flush_timeout. In that setup, napi_complete_done() clears
NAPIF_STATE_SCHED and starts the hrtimer before it returns false:
net/core/dev.c:napi_complete_done() {
...
if (n->defer_hard_irqs_count > 0) {
n->defer_hard_irqs_count--;
timeout = napi_get_gro_flush_timeout(n);
if (timeout)
ret = false;
}
...
new = val & ~(NAPIF_STATE_MISSED | NAPIF_STATE_SCHED |
NAPIF_STATE_SCHED_THREADED |
NAPIF_STATE_PREFER_BUSY_POLL);
...
if (timeout)
napi_timer_start(n, timeout);
return ret;
}
napi_watchdog() later has to set NAPI_STATE_SCHED again with
test_and_set_bit(). So when this doorbell is written, the NAPI is idle
with a pending timer. It is not still scheduled.
The "stays scheduled" wording seems to fit only two cases: the early
return for NAPIF_STATE_IN_BUSY_POLL / NAPIF_STATE_NPSVC, and the
NAPIF_STATE_MISSED path. The comment also does not mention MISSED or
netpoll as reasons for a false return.
Could the comment be reworded so it does not suggest the driver still
owns the NAPI at this point?
> + BNXT_DB_NQ_P5(&cpr->cp_db, cpr->cp_raw_cons);
[Severity: Medium]
Can this doorbell write race with a busy poller on another CPU in the
deferral case?
In the gro_flush_timeout path, napi_complete_done() has already cleared
NAPIF_STATE_SCHED. That lets __napi_busy_loop() on another CPU claim the
instance:
net/core/dev.c:__napi_busy_loop() {
...
if (cmpxchg(&napi->state, val,
val | NAPIF_STATE_IN_BUSY_POLL |
NAPIF_STATE_SCHED) != val) {
...
}
It can then run bnxt_poll_p5() at the same time. One possible sequence:
CPU1 (bnxt_poll_p5)
cpr->cp_raw_cons = X;
napi_complete_done() returns false, SCHED cleared
<delayed by hardirq, vCPU preemption, or PREEMPT_RT preemption>
CPU2 (busy poll -> bnxt_poll_p5)
consumes more NQEs
cpr->cp_raw_cons = X + n;
BNXT_DB_NQ_P5() with X + n, or BNXT_DB_NQ_ARM_P5() with X + n
via busy_poll_stop()->napi->poll()
CPU1
BNXT_DB_NQ_P5(&cpr->cp_db, cpr->cp_raw_cons) re-reads
cpr->cp_raw_cons, may still see X, and writes DBR_TYPE_NQ | X
Nothing orders the MMIO writes from the two CPUs. The device could get
the older consumer index after the newer one. The commit message says
that a stale NQ index is what locks up this firmware.
If the ring then stays idle, the nq_moved check blocks any further
non-arm writes. The stale index is only corrected when new NQEs arrive,
or when napi_complete_done() finally returns true and the ARM write is
issued.
Re-reading cpr->cp_raw_cons after ownership is dropped is also a plain
data race with the other poller's store.
It is not clear how the hardware handles an index that moves backwards.
It may correct itself on the next NQE or ARM write.
Would it be safer to write the non-arm NQ doorbell before calling
napi_complete_done(), while the NAPI is still owned? Then only the ARM
write would be needed when it returns true.
The existing ARM write in the true branch already writes after
ownership is released. This patch adds a second such write in the
deferral case it is meant to fix.
> + }
> goto poll_done;
> }
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204200334.2294555-1-joe%40dama.to
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-12-05 20:10 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 20:03 [PATCH net] bnxt_en: Fix NIC lockup caused by stale NQ consumer index Joe Damato
2026-12-04 22:22 ` Michael Chan
2026-12-04 22:58 ` Joe Damato
2026-12-05 15:19 ` Pavan Chebbi
2026-12-05 20:10 ` netdev-bot+sashiko
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.