From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 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== 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== 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 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 ; Sat, 5 Dec 2026 20:10:21 +0000 (UTC) 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 Received: by smtp.kernel.org (Postfix) with ESMTPSA id ECACB1F0092B; Sat, 5 Dec 2026 20:10:20 +0000 (UTC) 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== Subject: Re: [PATCH net] bnxt_en: Fix NIC lockup caused by stale NQ consumer index 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@kernel.org, kuba@kernel.org, pabeni@redhat.com Date: Sat, 05 Dec 2026 20:10:20 +0000 Message-ID: <179650142046.3148.16138117899076184982@kernel.org> In-Reply-To: <20261204200334.2294555-1-joe@dama.to> References: <20261204200334.2294555-1-joe@dama.to> X-sashiko-severity: High Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 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 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