🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #21217

Re: [PATCH net v6 4/5] bnxt_en: refuse to open a device with stopped DMA

#21217
From: netdev-bot+sashiko
Date: Mon, 23 Nov 2026 18:31
208 lines
15951 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 3 · Low: 0

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

- [Medium] BNXT_STATE_DMA_STOPPED is set once in bnxt_stop_dma()
  (bnxt.c:7850) and never cleared.
- [Medium] The commit message says DMA_STOPPED is added to
  BNXT_NO_FW_ACCESS() "so HWRM commands sent after DMA is stopped fail…
- [Medium] BNXT_STATE_DMA_STOPPED records a specific hazard: firmware did
  not free its rings, so the device may still hold DMA addresses of…

--

bnxt_en: refuse to open a device with stopped DMA

This patch adds BNXT_STATE_DMA_STOPPED. The bit is set in bnxt_stop_dma(),
and bnxt_open(), bnxt_open_nic() and bnxt_half_open_nic() refuse to open
the device while it is set. The bit is also added to BNXT_NO_FW_ACCESS()
so that HWRM commands fail fast once DMA has been stopped.

> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> index 600a8c866f3c3..9daf053293a42 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> @@ -7847,9 +7847,20 @@ static void bnxt_stop_dma(struct bnxt *bp)
>  
>  	netdev_err(bp->dev,
>  		   "Disabling DMA before releasing ring memory, the driver must be rebound to recover\n");
> +	set_bit(BNXT_STATE_DMA_STOPPED, &bp->state);
>  	pci_clear_master(bp->pdev);
>  }

[Severity: Medium]
Is BNXT_STATE_DMA_STOPPED ever cleared? This set_bit() and the test_bit()
calls are the only places that touch it. Once set, it stays set even
after the PCI function or slot has been reset and bus mastering has been
turned back on.

The comment at the top of bnxt_stop_dma() says "A firmware reset resets
the device". Even so, two recovery paths that reset the function now fail
partway because the bit is stale.

In bnxt_resume():

    pci_set_master(bp->pdev);
    ...
    if (bnxt_hwrm_ver_get(bp)) {
    ...
    rc = bnxt_hwrm_func_reset(bp);
    ...
    rc = bnxt_hwrm_func_qcaps(bp);
    if (rc)
        goto resume_exit;

__hwrm_send() exempts VER_GET and FUNC_RESET, so both reach the firmware
and the function is reset. BNXT_NO_FW_ACCESS() then skips
bnxt_hwrm_func_qcaps(), which returns -EBUSY. Resume fails with bus
mastering on, HWRM_FUNC_DRV_RGTR is never sent, and the netdev stays
detached.

One way to reach this is through the suspend path, when
bnxt_shutdown_nic() fails:

bnxt_suspend()->bnxt_close()->__bnxt_close_nic()->bnxt_stop_dma()

AER recovery has the same problem. bnxt_io_slot_reset() calls
pci_set_master(), bnxt_try_recover_fw() and bnxt_hwrm_func_reset(), then
returns PCI_ERS_RESULT_RECOVERED. bnxt_io_resume() then fails in one of
two places:

    err = bnxt_hwrm_func_qcaps(bp);
    if (!err) {
        if (netif_running(netdev)) {
            err = bnxt_open(netdev);

It fails either in bnxt_hwrm_func_qcaps() or in
bnxt_open()->bnxt_check_dma_stopped(), so the device never reattaches.

Before this patch, with the earlier "stop DMA before releasing rings"
change applied, both paths re-initialized the device. Also,
bnxt_check_dma_stopped() would then print "DMA was disabled ..." even
though bus mastering has been turned back on.

Should the bit be cleared once the function has actually been reset?

[ ... ]

> @@ -13519,6 +13535,10 @@ static int bnxt_open(struct net_device *dev)
>  	struct bnxt *bp = netdev_priv(dev);
>  	int rc;
>  
> +	rc = bnxt_check_dma_stopped(bp);
> +	if (rc)
> +		return rc;
> +

[Severity: Medium]
The new bit is only checked in the three open functions. Can
bnxt_resume() turn DMA back on while the device still holds stale ring
addresses?

The bit is set because the firmware did not free its rings. Clearing bus
mastering is the only thing that stops the device from writing into ring,
RX buffer and stats memory after __bnxt_close_nic() frees it.
bnxt_suspend() runs bnxt_close(), which may set the bit. bnxt_resume()
then does this without looking at BNXT_STATE_DMA_STOPPED:

    pci_set_master(bp->pdev);
    if (BNXT_VF(bp)) {
        for (i = 0; i < BNXT_RESUME_MAX_RETRY; i++) {
            rc = bnxt_hwrm_poll(bp);
    ...
    if (bnxt_hwrm_ver_get(bp)) {
        rc = -ENODEV;
        goto resume_exit;
    }
    rc = bnxt_hwrm_func_reset(bp);
    if (rc) {
        rc = -EBUSY;
        goto resume_exit;
    }

Suppose the function's firmware ring state survives suspend, for example
with s2idle or D3hot with No_Soft_Reset. The device can then do
bus-master DMA from pci_set_master() until FUNC_RESET completes. For a
VF, that window also covers the bnxt_hwrm_poll() retries and their
sleeps. Whether this happens depends on platform and firmware behavior.

VER_GET or FUNC_RESET may well fail here, since the firmware has already
stopped answering RING_FREE. If they do, resume jumps to resume_exit with
bus mastering still on and the stale rings still live. Because the flag
is stale (see the comment above), resume then gives up anyway.

The rebind recovery that the commit message prescribes uses the same
order. bnxt_init_board() calls pci_set_master() before
bnxt_fw_init_one_p1() sends FUNC_RESET. In the kdump case,
bnxt_init_one() calls bnxt_kdump_reset() (pcie_flr()) before probing, to
avoid this kind of stale DMA.

Should bnxt_resume() check BNXT_STATE_DMA_STOPPED, or reset the function
with something like an FLR, before it turns bus mastering back on?

[ ... ]

> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
> index 41d05efd6307a..50c024dd3c6c4 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
> @@ -2474,9 +2474,11 @@ struct bnxt {
>  #define BNXT_STATE_FW_NON_FATAL_COND	13
>  #define BNXT_STATE_FW_ACTIVATE_RESET	14
>  #define BNXT_STATE_HALF_OPEN		15	/* For offline ethtool tests */
> +#define BNXT_STATE_DMA_STOPPED		16
>  
>  #define BNXT_NO_FW_ACCESS(bp)					\
>  	(test_bit(BNXT_STATE_FW_FATAL_COND, &(bp)->state) ||	\
> +	 test_bit(BNXT_STATE_DMA_STOPPED, &(bp)->state) ||	\
>  	 pci_channel_offline((bp)->pdev))

[Severity: Medium]
The commit message says:

    Also add the bit to BNXT_NO_FW_ACCESS() so HWRM commands sent after
    DMA is stopped fail right away instead of waiting for the timeout.

Does that hold for every command? __hwrm_send() still lets two request
types through when BNXT_NO_FW_ACCESS() is true:

    if (BNXT_NO_FW_ACCESS(bp) &&
        (req_type != HWRM_FUNC_RESET && req_type != HWRM_VER_GET)) {

The device writes HWRM responses into ctx->resp by DMA. With bus
mastering cleared, HWRM_VER_GET and HWRM_FUNC_RESET cannot complete, so
they still wait for the full timeout. The exemption list was written for
fatal-error and channel-offline recovery, where bus mastering is or will
be enabled again.

Devlink reload can reach this. The first reload fails in
bnxt_dl_reload_down(): bnxt_hwrm_func_drv_unrgtr() clears
BNXT_STATE_DRV_REGISTERED and then gets -EBUSY. On a second reload,
unrgtr returns 0 and devlink calls bnxt_dl_reload_up():

bnxt_dl_reload_up()
  bnxt_fw_init_one()
    bnxt_fw_init_one_p1()
      bnxt_hwrm_ver_get()       <- waits for the timeout, then msleep(100)
      bnxt_try_recover_fw()
        bnxt_hwrm_poll()        <- another VER_GET
      bnxt_hwrm_ver_get()
      bnxt_hwrm_func_reset()

Nothing on this path checks BNXT_STATE_DMA_STOPPED. Only bnxt_open_nic(),
which runs later, does. Each exempt command sent along the way waits for
the full HWRM timeout.

Should __hwrm_send() also refuse these two commands while
BNXT_STATE_DMA_STOPPED is set, or should the commit message be reworded?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261120152830.699712-1-joe%40dama.to
Technical Details
Message-ID: <179545866233.3135.17505837220604349272@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder2.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369664-linux-kernel-netdev=dewy.ru
References: <20261120152830.699712-5-joe@dama.to>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder2.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369664-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v6 4/5] bnxt_en: refuse to open a device with stopped DMA
Date: Mon, 23 Nov 2026 18:31:02 +0000
Organization: Usenet Network
Message-ID: <179545866233.3135.17505837220604349272@kernel.org>
References: <20261120152830.699712-5-joe@dama.to>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network; logging-data="3953441"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:L5x9z01D9DBx+UovInC+u9Qw39k= sha256:SsANWeNe0r85LfMQf9r/vvw3W4TrDFEUDMZPNXk2gRw= sha1:2HcbAPhjeoRY8gm8M3rrzdUXIQM= sha256:G9IBcate6U86Wjp/wTOEThk7jpBWV08nDH2GRqd+O+s=
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 D740D125DB9; Mon, 23 Nov 2026 21:31:22 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.5
X-Spam-Status: No, score=-3.5 tagged_above=-9999 required=6.31 tests=[DKIMWL_WL_HIGH=-0.001, 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 3_-dALrV-_1G; Mon, 23 Nov 2026 21:31:19 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-369664-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 sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id 3F67F125DC2; Mon, 23 Nov 2026 21:31:10 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id AA1C0604AF2; Mon, 23 Nov 2026 18:31:09 +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=1795458665; b=DKZmqS5ymb/3BuM92XY3tdvEmzxyZoqVGpGd8JysPs6T0G/WJjQ3CVYa+iTLdS3o10Y7 Y1gXRFu05KiLuO0IggjZ9ExuR/zbDHhRbhgNOqrvCojlnbiYGaWPnbFaFEzG5rjK16rmZ vwKkoPkGw+eC8PjqTSRhXigZZHfqcruEA83iabbT35wRxJk/n2Znkla0drLFOkqjoVooM G60l5eLW4Ea3yWE3ZRSkuRypPmztYCaNP+jIIBlk9tQzHLXU99UEG5SRNtCIFw6qzZAvq zHEJW+fHwIIhjYY/qXglXHX6jJiT9JleHFkTX3kTlcjXXNuD8hvGsuNpmHF/cH5+/rQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795458665; 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=0rXnro+trqhO/0C4PaUp7HBy7QJ45IhaqrH1ik2Spjs=; b=Ht7M5f+tzBdfvmTMyWF6FK8JGkO69SbGHxFp2e7bjbanSUtzYMn3YF1cRmh9KeX0r4ZK PWUZrnmsah7iYNQ2DsWtPWFlCoS3ZGupGDQ7xrhVmLnibS3vDIvE7FP5PrDxGSJwoosW0 +kbMHhi5cSuciI8szSldP9HJhFKG/1kM+c9wabGahWnKm1j+oC25eUd+xT+iz7b1Uquw3 ZmRbMuz4xXNHDnBj42qXXjUzAoZPVC9jWgOFyeS9Jbk1rHmKtCeUO7QEl9no4Bztxz414 bvCQdYkJ535n2E7w/FG6tSED3k1WuCmACAnJXIQ62byftQNOpZOzMJ18QeRODaeJEXQ==
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=W7TCwpCJ; 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 28F2D606A688; Mon, 23 Nov 2026 18:31:05 +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=W7TCwpCJ
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=1795458664; b=c7Yu3WcuaTYi7p4n2mI/zyF7OfOouHSw0OJcl/S7FcWZC3LmTy9livX+vgkDsuUjKqea HvkH5naezp9jUzxyrKMwT7k/JvO+rV7DdMWE5L+pwfHh7CjP8SosdpZhE4Hz8Msncjhey jTQE0GYlvJfDjc/YbfqS4lR40ky+DsctxZ7U9k+ySx+mQswabdAdaJr5f4URi7YC77Pod SL6nkYBEapOJ8ETBHyq48rrp5ZjhTLrDIsnHOMtcxxWSkUCwl84cLLFaG9jPO70jQW0+m Bv+jGFI3lutEXPg3iEVlP+9Vgj4o2JdqQu9lJw5g+LCThhFQOOo/mMp3Hp9KFRdgGow==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795458664; 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=0rXnro+trqhO/0C4PaUp7HBy7QJ45IhaqrH1ik2Spjs=; b=M9oWFfC+38Ngn3eKMHWOVNoSlvD2LOeOQ7L486x94l9a1KQdKcUXfi6TCVSVEJHFAuf2 TgfXDaJYlxyC/Iwlo1jSIBnptRciaXLYCDsBgDpJ5YJ4Xyh8W2l6yeSBhHS9q18xpai5A OgTdm1NOBeT5dMedkRi+bYrEO84Ybd+beJH3Rh2TeyuB/VIMa4Nd/zBKCwcNBu4ME1cO8 i69acwpC8/n1LQ/SC/2Wpv6n5zQWym4A07u5NCXtVsqwgHGVIyy9YBTynPr19QoTi5N/O r2HptElLVW9yPewe0335lOW76bzBKnHEaceI30TsORGf82FX6Sq52idTlLme7NkO/lA==
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=W7TCwpCJ; 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 47988606A330; Mon, 23 Nov 2026 18:31:03 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id BD5E31F000D3; Mon, 23 Nov 2026 18:31:02 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795458663; bh=0rXnro+trqhO/0C4PaUp7HBy7QJ45IhaqrH1ik2Spjs=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=W7TCwpCJ8sL6hMtva2JmEMaAV+ZjYUCVBklwtfWF0lERzg3D2FnH0tHfzK3u6bXOH hA9bZ6AQTjGXFOxfxNaS5CHYgSgD+qkojODBcvy5JMQXutHLYDuQsqkqWQzyFhmhUA o+bsaihF3ad7X473FWkx1xnW3d/LusZvlCjH2wLboYvJIDkjVOhxvdunVTwCn+yrih SmQZasyRVIAagsq+F2qpP7kbcaAt92oIEKUVZae25VwS5buNachMxdfKzaDEkLp558 UrozDOGRJny1gXPqzFWHJKkVOTTFqaJ7ZatzfLy+RTe43pFYGPIInmlFa9Y1I4pr86 OGWXoHHTmiBtg==
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, prashant@broadcom.com, edumazet@google.com, horms@kernel.org, selvin.xavier@broadcom.com, kalesh-anakkur.purayil@broadcom.com, linux-kernel@vger.kernel.org
X-In-Reply-To: <20261120152830.699712-5-joe@dama.to>
X-sashiko-severity: Medium
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