🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #26563

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

#26563
From: netdev-bot+sashiko
Date: Thu, 03 Dec 2026 19:17
203 lines
15650 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.

Critical: 0 · High: 1 · Medium: 2 · 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).

- [High] bnxt_stop_dma() (bnxt.c:7845) returns without clearing Bus
  Master Enable and without setting BNXT_STATE_DMA_STOPPED whenever…
- [Medium] This series makes 'rebind the driver' the only recovery after
  bnxt_stop_dma() has run.
- [Medium] bnxt_en: pci_set_master() called when BNXT_STATE_DMA_STOPPED
  is set

--

bnxt_en: refuse to open a device with stopped DMA

This commit adds BNXT_STATE_DMA_STOPPED, sets it in bnxt_stop_dma(), and
refuses to open the device while the bit is set. It also adds the bit to
BNXT_NO_FW_ACCESS(), so most HWRM commands fail right away after DMA has
been stopped. Rebinding the driver is the only way to recover.

> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> index c1c58f5c930a0..1f40914610bb8 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> @@ -7848,9 +7848,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]
bnxt_stop_dma() clears bus mastering so the device cannot DMA into the
ring and RX buffer memory that __bnxt_close_nic() frees next. The new
bit is supposed to keep it that way until the driver is rebound.
bnxt_resume(), bnxt_fw_reset_task() and bnxt_io_slot_reset() still call
pci_set_master() without looking at BNXT_STATE_DMA_STOPPED.

The notes defer those callers to net-next. However, with
BNXT_STATE_DMA_STOPPED in BNXT_NO_FW_ACCESS(), these paths now turn bus
mastering back on and then fail part way through. The device is left
enabled as a bus master with nobody driving it.

Suspend looks like the easiest way to get there. bnxt_suspend() calls
bnxt_close(), which returns 0 even when bnxt_shutdown_nic() hits the
HWRM_RING_FREE timeout and calls bnxt_stop_dma(). On resume:

bnxt_resume()
  pci_set_master(bp->pdev)
  bnxt_hwrm_ver_get()
  bnxt_hwrm_func_reset()
  bnxt_hwrm_func_qcaps()     <- -EBUSY from BNXT_NO_FW_ACCESS()
  goto resume_exit           <- bus mastering left on

The firmware ring state may survive suspend (s2idle, or D3hot without a
soft reset). In that case, can the device write into the freed buffers
between pci_set_master() and HWRM_FUNC_RESET? That includes the VF
bnxt_hwrm_poll() retry loop. If HWRM_VER_GET or HWRM_FUNC_RESET fails
on an unresponsive firmware, that window never closes.

bnxt_fw_reset_task() is similar: BNXT_FW_RESET_STATE_ENABLE_DEV calls
pci_set_master(), then bnxt_open() refuses with -ENODEV. In
bnxt_io_slot_reset(), pci_set_master() runs and bnxt_io_resume() then
fails in bnxt_hwrm_func_qcaps().

Could these paths check BNXT_STATE_DMA_STOPPED before pci_set_master()
and bail out? Or could they clear bus mastering again on their error
exits? This patch is what makes them fail with bus mastering on, so it
seems worth handling here rather than in net-next.

[Severity: High]

bnxt_stop_dma() returns early before it reaches this point:

	/* A firmware reset resets the device, and the fatal error path
	 * already disables it.
	 */
	if (test_bit(BNXT_STATE_IN_FW_RESET, &bp->state) ||
	    test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state))
		return;

When IN_FW_RESET is set, neither pci_clear_master() nor the new set_bit()
runs. Is a reset guaranteed to happen before the device can reach the
freed ring memory?

One path where it doesn't seem to: bnxt_fw_reset() with active VFs sets
IN_FW_RESET and moves to BNXT_FW_RESET_STATE_POLL_VF, and the device
stays open. If the user then closes the device:

bnxt_close()
  bnxt_close_nic()
    set_bit(BNXT_STATE_ABORT_ERR, &bp->state);
    __bnxt_close_nic()
      HWRM_RING_FREE gets no answer (-EBUSY)
      bnxt_stop_dma()   <- returns early, bus mastering stays on
      bnxt_free_mem()

Then the POLL_VF case in bnxt_fw_reset_task() does:

		netdev_lock(bp->dev);
		if (test_bit(BNXT_STATE_ABORT_ERR, &bp->state)) {
			netdev_unlock(bp->dev);
			goto fw_reset_abort;
		}

bnxt_fw_reset_abort() clears IN_FW_RESET and closes the device. It never
issues a reset or calls pci_disable_device(). The VF timeout branch in
POLL_VF also clears IN_FW_RESET without a reset.

Wouldn't the firmware then still own rings that point at freed memory,
with bus mastering on? BNXT_STATE_DMA_STOPPED would also never get set,
so the new open-time check would not fire.

The normal non-fatal reset path seems to have a smaller window too.
bnxt_fw_reset_close() frees ring memory before bus mastering is cleared:

	__bnxt_close_nic(bp, true, false);
	bnxt_vf_reps_free(bp);
	bnxt_clear_int_mode(bp);
	bnxt_hwrm_func_drv_unrgtr(bp);
	if (pci_is_enabled(bp->pdev))
		pci_disable_device(bp->pdev);

bnxt_hwrm_func_drv_unrgtr() can wait for a full HWRM timeout if the
firmware does not respond. Later, a failed bnxt_reset_all() only logs
"Unable to reset FW rc=%d". BNXT_FW_RESET_STATE_ENABLE_DEV then calls
pci_set_master() anyway.

Could the IN_FW_RESET skip depend on a reset or pci_disable_device()
actually happening? Alternatively, could bus mastering be cleared on
these paths as well?

[ ... ]

> 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_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]

Rebinding is now the only recovery. What clears the firmware's ring
state before bus mastering is turned back on at the next probe?

With DMA_STOPPED in BNXT_NO_FW_ACCESS(), bnxt_remove_one() now skips its
bnxt_hwrm_func_drv_unrgtr() call right away. The return value is ignored
and no FLR follows. bnxt_shutdown() handles the same failure with an FLR:

	if (bnxt_hwrm_func_drv_unrgtr(bp)) {
		pcie_flr(pdev);
		goto shutdown_exit;
	}

On rebind, the order is:

bnxt_init_one()
  bnxt_init_board()
    pci_set_master(pdev);
  ...
  bnxt_fw_init_one_p1()
    bnxt_hwrm_ver_get()
    (on failure: msleep(100), bnxt_try_recover_fw(), ver_get again)
    bnxt_hwrm_func_reset()

bnxt_hwrm_ring_free() says:

	/* -EBUSY means the firmware never answered, so it may still own
	 * the ring.
	 */

Between pci_set_master() and HWRM_FUNC_RESET, could DMA engines that
still hold the previous binding's rings read descriptors from, or write
packets, completions or stats into, memory the previous instance freed?

bnxt_kdump_reset() already clears bus mastering and runs pcie_flr()
before probe to clear pending DMA from a previous instance, but only in
the kdump case.

Would either of these close the window: a pcie_flr() in bnxt_remove_one()
when BNXT_STATE_DMA_STOPPED is set, or a reset before pci_set_master()
at probe?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202185628.847699-1-joe%40dama.to
Technical Details
Message-ID: <179632543413.3146.13728964654428418135@kernel.org>
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!newsfeed.endofthelinebbs.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376838-linux-kernel-netdev=dewy.ru
References: <20261202185628.847699-5-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!newsfeed.endofthelinebbs.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376838-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v7 4/4] bnxt_en: refuse to open a device with stopped DMA
Date: Thu, 03 Dec 2026 19:17:14 +0000
Organization: Usenet Network
Message-ID: <179632543413.3146.13728964654428418135@kernel.org>
References: <20261202185628.847699-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="2574777"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:XeS9iS5DkCf4woLl374n2U04arU= sha256:e6rI6ZiJiCyW9zwqdNwdT2hQJFWdaawTbNTBVYT2LDM=
	sha1:LOfzjdFCrkCRhSmHyv6KOntFI5g= sha256:Q3LK6tQdmHj4C6ntyjZxTzxK9wygc8EbtfGKkdONu7c=
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 04EA0117A1F; Thu,  3 Dec 2026 22:17:45 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.64
X-Spam-Status: No, score=-3.64 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.24, 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] 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 OUyilChRRE0x;
	Thu,  3 Dec 2026 22:17:41 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-376838-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 sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
	by mail.dewy.ru (Postfix) with ESMTPS id 66D64117A1E; Thu,  3 Dec 2026 22:17:30 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sin.lore.kernel.org (Postfix) with ESMTP id 44FF3221AA; Thu,  3 Dec 2026 19:17:26 +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=1796325436;
	b=C037PJZZoFsZ1GIZZUrKKFH8NPqneZIy73U6Y3ZsQGGVXs2B75lJNt9vDeIrAA7jYIgS
	 KMkgax9yvsSL4O8i8ndBSqWE+poMMJYDMI3dEpcFgyJPSPoVRxU3AiShw4tU2IjxxbF75
	 3fyUcvbGQBKav/MBaJ1SanESOQXHd9k3T8Wl+TEqa4zFE2K6G1tOfMRTS/iVyfkzgi4BE
	 h5SMsQFyJadu69lhUMTcjkZTd8/85UnBlZ+R1YQ9FnQ9zyiZzlO0c/g3HtSUDjH5DEKs0
	 8FHiOiQypqVv1qC5qMd3mf/k5SgasIDiz+FxbLBWPXT1jnX3lMqE5Xs6QShJIbYGFsQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796325436;
	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=Lomg7NKmvKMaKTNuhaQmiL+xxhD6kqSwiGMcDjVy/rc=;
	b=PosZbWg3AGM7efA6DoI78UGfX+u7coDox0vJhcyzjRzyWmEIuAR7Tcp2peRZZHJewtwB
	 YR3ZgWPhmu7rfyIypwz87mis1L6CnfVgoqN9cMV5U1F0vIgFGbj1WniEgBYWBDheqOKj9
	 Ltnj/NukcZgB8BuiVWYSP9E2AR/b/cpGx/11J6limiy2iL3RSt+MD3m8qoID1hYQ8ypyF
	 zVuTSCaBNUhbFK4pT20TSoId2P/M0xtN9NBYlEWOT6WkRhu/bs6rObAbEqVgbFiFdJHOC
	 vzj7eA6lBLUQbflk/BWPylHMBBsstFf9jjDHOF4ZwzJyFUsKj/6Nm074+WR0AsXo74A==
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=ZlTt8BcG;
	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 8032F60A2620;
	Thu,  3 Dec 2026 19:17:16 +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=ZlTt8BcG
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=1796325435;
	b=pZu1aPCSp9BH+YfyXzrqTWBPDREP/kd30tORFU9c2Nl/3E/Kar0CraLTClozG44NYyB6
	 uBtlSKiUbrjtBDnxhcG04QUdNtERWTGomm1n4/89M10hfIRf3JcdIlivlzXJ9i4VJPTga
	 bu2UT+B4ELDY2YMaLf07nh2jXpEV0egCkSK6zFsOP7CjCRqizJgulDmp81aJWe/ep2ki+
	 JN0RMC/+THubBl+ir8kSjRs82pNLdE8Sh9wxBr/DHzojpa8XsHs3sD+kMajteXPd4bj1J
	 DCDzlHvVvHHwFrZ520YBchNPeppp1jLJpSQlJ7X4ujTy6wDbEc1e+q42DIZIOgQefqw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796325435;
	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=Lomg7NKmvKMaKTNuhaQmiL+xxhD6kqSwiGMcDjVy/rc=;
	b=XX0L/YwoupEIf/dxM6Dca7Eqho1wJLkcF3k19fs33OJsGcedTMLbdnVrXPVX3HqN1C+a
	 OehZMhK4dFkUOa6Qx84iRrjzOrvaLdzPKNPXV2sjGBLSVOG2AVDlRctHzFtGNnIuWNZnA
	 1j8L8xV/rttQ5OVmKa/jgQh/c6Tb9toc1EhZriyez8dFPcLjXKfFURV8eZfw74OXTozb9
	 GB1ZvKUmd5TIH7cf/ogsHyW+3EIF5vGiLHNL0S0yAiyZyyUu1u+1PMNTnGHkvb6amiH2E
	 X9swMNHdnzQhvFfq5FdjbRB+dmu8TdMq65S/kfO9VTDrfbeFoTU4UeMf3WGaIRj8v/w==
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=ZlTt8BcG;
	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 A2D81606A6A9;
	Thu,  3 Dec 2026 19:17:15 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8BB011F000C2;
	Thu,  3 Dec 2026 19:17:14 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796325435;
	bh=Lomg7NKmvKMaKTNuhaQmiL+xxhD6kqSwiGMcDjVy/rc=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=ZlTt8BcGImslmFyy6ZRztyH+5cBBLOX7rTOb/Zct1jJmvlYbAYSVK0zD2x7MV/apd
	 XaA2X06zVGVI7cqao95qQM1wTskf51dNHMbYYlhxPpJHKcmt7xLIZrdEblgdagwJkG
	 vHaPgYXJia2ebiJ3LI0Orb1gWu4LmKSYRtFpFc1zpt+rnKSKFFb99btX1Xttby1KUt
	 hq3owqax8K08U7C2Hn0mZajP19GnSO0u/+JLck7xd005zJj2fx3UFrRE+fprU9WFem
	 JxExdtkoPZfWDX4sxInU+qKiKgryi/0zfdaftsVT0/B826kC7UR4Krt46hZq4zeYhn
	 9a/OrEEil5htQ==
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, selvin.xavier@broadcom.com,
 kalesh-anakkur.purayil@broadcom.com, edumazet@google.com, horms@kernel.org,
 linux-kernel@vger.kernel.org
X-In-Reply-To: <20261202185628.847699-5-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