Article View: linux.kernel.netdev
Article #27493Re: [PATCH net] bnxt_en: Fix NIC lockup caused by stale NQ consumer index
From: netdev-bot+sashiko
Date: Sat, 05 Dec 2026 20:10
Date: Sat, 05 Dec 2026 20:10
188 lines
15188 bytes
15188 bytes
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
Technical Details
Message-ID:
<179650142046.3148.16138117899076184982@kernel.org>Path:
mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-378117-linux-kernel-netdev=dewy.ruReferences:
<20261204200334.2294555-1-joe@dama.to>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-378117-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net] bnxt_en: Fix NIC lockup caused by stale NQ consumer index Date: Sat, 05 Dec 2026 20:10:20 +0000 Organization: Usenet Network Message-ID: <179650142046.3148.16138117899076184982@kernel.org> References: <20261204200334.2294555-1-joe@dama.to> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="3111631"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:Ipyq/7Hbksy/oEDQecUDQnt71XY= sha256:gqXCxolWxZCnfclOMd2CkEl4iD78R6G0+v8nhPqfXBE= sha1:MUU+PoNgYMhb7Jg8mScIKZKq/w8= sha256:C/8vRLa5BD9RH/E/zTzkNmzEStpnXRj5GYdlx3Adn88= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 77743117EA3; Sat, 5 Dec 2026 23:10:41 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.639 X-Spam-Status: No, score=-3.639 tagged_above=-9999 required=6.31 tests=[DKIMWL_WL_HIGH=-0.14, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id G9xdpDmdgbWD; Sat, 5 Dec 2026 23:10:37 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-378117-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 6502A117E25; Sat, 5 Dec 2026 23:10:28 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id B921228BCD; Sat, 5 Dec 2026 20:10:24 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796501422; b=oJ/Xpj2vcd1H9SP2GglEps0FGrE2n+nLC5HHlXqSjOHW5LmUl6ol1pBh97HiY81wTVtW Oyulh1rxSOq7SeP/FsxT4XtLGWGLgy8oxxFPgCg0uO6zziYYUmNC5HHZt4zw2v2CZ+o9x aMmO1TUsdni9r4AuzueIVf814cUQeLrzo5W4Ar3OQ/83wG34fNhDEOdxvgv7PCOLKGxG4 ToZDYGCmYNwYnPMvaO75XGXCjzWvJ/kUJoVqQ5juRoq16WII/JUhVNYvBSAtTcP8F/+XH ShQqZkv1UKUlQMjyJozW7G+8ih+OhYhgf5v+MD3jDmMVK2d2hiF4NwNn4vknmTpYLdQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796501422; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=5VgebxI22yXo00Jcv1sXm5sUk6cpDmchWFHcjbQu61w=; b=VYDTZ4cDo/wDAINv+re6BpGiC4SzdNKsNnYy7K81azbzDf4mWODxNN1b/b8Su0mERhoA FwqHXEQGXBj21BTuIBGnyy+rJ9GjZI5wAT4yHq3O+ItHOHlvKlkRR/qsDRgFMQPjBWB12 URvceheTwhYkECCmjM3Ppafp90zs4ANudd2YdqeW6pPDka3a97V8LJriFJbHU6NHOzzON D4wwbeISwlwn+RoUklquWt/cFPLLWf6e4Ds2qADqMcQiXJfHnFnWTJK/yb+catwEVsz/C Oow4H+DHc1M1ic4f74aYPwFjrtV5JWdV3mDxD10hTvkMk4gdwc+ggSlo4IlbOc1IPCA== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=JelT3rT2; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8D8D1606A334; Sat, 5 Dec 2026 20:10:22 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=JelT3rT2 X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796501421; b=vpU3YNc9imgDU/kjnKbWaApb00INfdEJ2ELpx7v5iS0Uy/AR1Mb7oDl8xuHj4VIPXH4M 9uJeQWL+SU779vSPeOFfK4SQcELw9Rm5zyWTomUyGsbKQjs3lIO/SOZOInBS5hybZaFN2 oMnZUK8PegcRyxmtGaYcT9UgtLAQKTpG2vEV99tJA0do1mR2ww2wysjJqKt7vNa3Xgymu 5ga0sNKeA7zXV9tA/CH1FEIYEwBwUcrWDsJyOXJvewlX/q55RwEgJe/HY5sKUVGEXtZLM ZIEE+gB44/49A2w4h3iAYfxdWhZ2uEIpu0gtUX5lq9zkz5GvVxnOAYw1b8GJkai6IUg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796501421; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=5VgebxI22yXo00Jcv1sXm5sUk6cpDmchWFHcjbQu61w=; b=DOwLW5NqWlyvIFs9U0+rKTg8/K56ayDG9XDjPlpujn+MJHDRdZOhk3f5kkpZ6nIl2PwG np57BvJTScY0XBbzACSEzSyhEf/7wGxuTOW1I9mxpP1ARDMSOQRbMfEKNU6auXmT90dRE P2gSEtEUQssZA5fkIne6QJJlyGSHTmVdY+duT90zBqdzhVzpSTEbsxqpyvKp7719/h9ky cr4qjfpLm4xTRBEC1adClmp8kHSh6ToJ0hwscJid87hWh9sCV+iW3NAgSWReEbTM5Fhgz l9suWSOXUuoNhtnXRXJPmBL3gcn5JanuLEKRQN9SfwnQPaMVp6zM+MKGzF/nPPKt6pw== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=JelT3rT2; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A8E18606A31F for <netdev@vger.kernel.org>; Sat, 5 Dec 2026 20:10:21 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id ECACB1F0092B; Sat, 5 Dec 2026 20:10:20 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796501421; bh=5VgebxI22yXo00Jcv1sXm5sUk6cpDmchWFHcjbQu61w=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=JelT3rT2yMt9t280i19GZqMAX9cOdliHXMN5tdSUMXVqP4/0e0Aso8Ax6R9EC0X1M jFH6bYwa/RkIdBYFQus8I4esMgshRV+K8wCkGrIlQGAhJpXVznYX9bmb+zrS7z4yOA pCcUPXl9C3f5AULc66JU8YjLhb94HUuZxHWeTF+J/AyuP+91cZvFtfjR3sDHb7upt3 X4No9bPpkjUB4s+J8lyXh64Mqs+DllCzHkHxGIbTiszWbzeYUnVNNT2wzDLsZB1pG3 lgLD2AOr9PtxDrK+BUZ8ciLlEUc7/9K7w7zpDUFh6cfvcTHSJ15ZVb1ooGBgtwIn2J tM147ZIzwI1JQ== X-Cc: netdev@vger.kernel.org, michael.chan@broadcom.com, pavan.chebbi@broadcom.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com X-In-Reply-To: <20261204200334.2294555-1-joe@dama.to> X-sashiko-severity: High X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list