Netdev List
 help / color / mirror / Atom feed
* [PATCH net v6 0/5] bnxt_en: Make RING FREE more robust
@ 2026-11-20 15:28 Joe Damato
  2026-11-20 15:28 ` [PATCH net v6 1/5] bnxt_en: return the RING_FREE status to callers Joe Damato
                   ` (5 more replies)
  0 siblings, 6 replies; 17+ messages in thread
From: Joe Damato @ 2026-11-20 15:28 UTC (permalink / raw)
  To: netdev
  Cc: andrew+netdev, davem, edumazet, kuba, pabeni, horms, michael.chan,
	pavan.chebbi, selvin.xavier, kalesh-anakkur.purayil, linux-kernel,
	Joe Damato

Greetings:

On two production systems, I saw the following dmesg pattern:

  NETDEV WATCHDOG: transmit queue 0 timed out 6073 ms
  Resp cmpl intr err msg: 0x51                  x20
  hwrm_ring_free type 1 failed                  x12
  hwrm_ring_free type 2 failed                  x8
  AMD-Vi: IO_PAGE_FAULT  x3

This suggests that, for some currently unknown reason, TX completions stall
and the netdev watchdog fires. The driver asks FW to free the rings, this
times out, but the driver ignores the possible failure and frees ring memory.
Since the FW didn't respond to the ring free command, it is possible that the
FW is still DMAing to the memory which was freed.

To address this, this series makes the driver stop DMA before freeing ring
memory when the firmware did not answer RING_FREE.

Since the RFCv4, I found a third system that hit this repeatedly:

  NETDEV WATCHDOG: CPU: 35: transmit queue 0 timed out 5459 ms
  hwrm_ring_free type 1 failed. rc:fffffff0 err:0    x64
  hwrm_ring_free type 2 failed. rc:fffffff0 err:0    x32
  hwrm_ring_free type 0 failed. rc:fffffffb err:1    x64
  hwrm_ring_alloc type 1 failed. rc:ffffffe4 err:4
  hwrm_ring_free type 1 failed. rc:fffffff0 err:0    x44
  Abandoning msg {0x51 0x3e35} len: 0 due to firmware status: 0x408100
  nic open fail (rc: fffffffb)
  DMAR: [DMA Write NO_PASID] Request device [47:00.0] fault addr
  0xffffa07ef000 [fault reason 0x05] PTE Write access is not set

This case differs from the first two in a few ways, but this series would have
still helped:

 - The ring frees fail on the close path and again on the error path of
   the reopen (bnxt_init_chip()), and the device then writes to memory the
   driver has already unmapped. The series stops DMA on both paths.

 - The interface came back up later, the watchdog fired again, and the
   cycle started over. The host logged 79 DMAR write faults in about 20
   hours. Patch 4 breaks this loop by refusing to reopen after DMA has
   been stopped.

 - The firmware answers each RING_FREE about 5 seconds late, after the
   driver has given up, and finally reports an error in its health
   register. Patch 2 does not treat these late responses as success because
   their sequence ids do not match.

In this most recent case, I suspect the hardware is faulty, but the driver
shouldn't hand memory back to the system while the device could still write to
it.

In all of the above cases, the IOMMU caught the error. If the system had no
IOMMU or the IOMMU was in passthrough mode, data corruption or crash would
have occurred.

In the future, this could possibly be extended to make recovery automatic.

I wonder if Sashiko reads cover letters and then avoids flagging stuff, let's
find out. (Unrelated: I wonder if anyone reads cover letters).

Sashiko: you pointed out a few issues which are real bugs but were not
observed in production and I am leaving out of this series which only
addresses an issue I've seen in production.

In particular, I am leaving out:
  - the per queue paths (real, but not observed in production)
  - completion and nq failures are not counted as stuck (all rings fail in
    prod, have not observed only nq failures)
  - The polling path in __hwrm_send() probably needs a dma_rmb (sashiko
    pointed out this pre-existing issue that is probably unlikely but also
    unobserved)
  - bnxt_resume, bnxt_fw_reset_task, and bnxt_io_slot_reset all call
    pci_set_master without checking the DMA bit

All of the above was outlined in the thread about the v5 [1].

Thanks,
Joe

[1]: https://lore.kernel.org/netdev/avIpEpoCYvLHYl3j@devvm20253.cco0.facebook.com/

v6:
 - Commit messages across all patches were updated and a new patch was added
   to the series, patch 5.
 - Patch 1:
    - Return the errno from hwrm_req_send instead of always -EIO.

 - Patch 2:
    - Respect BNXT_HWRM_CTX_SILENT for the new warning.
    - Read the valid byte with READ_ONCE(), then dma_rmb() before reading
      the rest of the response, including error_code.
    - Only check the response for HWRM_RING_FREE. HWRM_SELFTEST_IRQ and
      HWRM_RING_RESET keep the existing behavior.

 - Patch 3:
    - Count a ring as stuck only when no response arrived, not when the
      firmware replied with an error.
    - Don't stop DMA when BNXT_STATE_IN_FW_RESET or BNXT_STATE_FW_FATAL_COND is
      set.

 - Patch 4:
   - Add BNXT_STATE_DMA_STOPPED to BNXT_NO_FW_ACCESS() so HWRM commands sent
     after DMA is stopped fail right away instead of waiting for the timeout.

 - Patch 5 (new):
   - stop the ULP around bnxt_reset() and leave it stopped if DMA was
     stopped. The silent reset after a VF config change leaves the ULP
     running.

v5: https://lore.kernel.org/netdev/20261106191423.4194081-1-joe@dama.to/
 - Switched from RFC to actual submission
 - Patch 4 updated to use an un-used bit to make backporting easier.

v4: https://lore.kernel.org/netdev/20260925174404.2789072-1-joe@dama.to/
  - No changes to patch 1 or 2
  - Patch 3: reworded the message logged when DMA is stopped, a rebind is
    what recovers the device, not a firmware reset. No functional change.
  - Patch 4 added which adds a new bit (BNXT_STATE_DMA_STOPPED) that is set
    when DMA is disabled. When this bit is set, the device requires user
    intervention to bring back up.

v3: https://lore.kernel.org/netdev/20260923210744.3406861-1-joe@dama.to/
  - No changes to patch 1
  - Patch 2: Don't poll for the valid bit as Michael suggested.
  - Patch 3: bnxt_hwrm_ring_free now returns -EIO instead of stopping the
    device, so the remaining resources can be freed and the remaining commands
    can be sent before stopping the device, as Michael suggested. Note the
    switch to using pci_clear_master in this patch instead of
    pci_disable_device. This was done so that the normal shutdown paths can
    call pci_disable_device without generating a warning.

v2: https://lore.kernel.org/netdev/20260922182405.1290749-1-joe@dama.to/
  - No changes to patch 1
  - Patch 2 from v1 dropped
  - Patch 2 in the v2 now checks the response and logs state before giving up
  - Patch 3 in the v2 disables the device to stop DMA before freeing ring
    memory

RFCv1: https://lore.kernel.org/netdev/20260917233218.1160001-1-joe@dama.to/


Joe Damato (5):
  bnxt_en: return the RING_FREE status to callers
  bnxt_en: check HWRM response if completion never arrives
  bnxt_en: stop DMA before releasing rings the firmware did not free
  bnxt_en: refuse to open a device with stopped DMA
  bnxt_en: stop the ULP around the reset task

 drivers/net/ethernet/broadcom/bnxt/bnxt.c     | 141 +++++++++++++-----
 drivers/net/ethernet/broadcom/bnxt/bnxt.h     |   2 +
 .../net/ethernet/broadcom/bnxt/bnxt_hwrm.c    |  47 +++++-
 3 files changed, 149 insertions(+), 41 deletions(-)


base-commit: 00f445721c7f0e48aaff9813cfe1c065c6eb3b71
-- 
2.53.1-Meta


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH net v6 1/5] bnxt_en: return the RING_FREE status to callers
  2026-11-20 15:28 [PATCH net v6 0/5] bnxt_en: Make RING FREE more robust Joe Damato
@ 2026-11-20 15:28 ` Joe Damato
  2026-11-23 18:30   ` netdev-bot+sashiko
  2026-11-20 15:28 ` [PATCH net v6 2/5] bnxt_en: check HWRM response if completion never arrives Joe Damato
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 17+ messages in thread
From: Joe Damato @ 2026-11-20 15:28 UTC (permalink / raw)
  To: netdev, Michael Chan, Pavan Chebbi, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Prashant Sreedharan
  Cc: edumazet, horms, selvin.xavier, kalesh-anakkur.purayil,
	linux-kernel, Joe Damato

hwrm_ring_free_send_msg() reports failure to its caller, but always as
-EIO, so a caller cannot tell whether the firmware rejected
HWRM_RING_FREE or never answered it. The TX, RX and AGG ring free
helpers discard the value.

Return the errno from hwrm_req_send() instead. -EBUSY means no response
arrived: the wait timed out, was abandoned, or the firmware channel is
down. An error reported by the firmware keeps its own errno, for example
a firmware BUSY reply becomes -EAGAIN. Return the value from the TX, RX
and AGG ring free helpers.

No caller acts on it yet, so there is no functional change.

Fixes: 74608fc98d28 ("bnxt_en: Ring free response from close path should use completion ring")
Signed-off-by: Joe Damato <joe@dama.to>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 50 +++++++++++++----------
 1 file changed, 29 insertions(+), 21 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index e78cf7ad3cbc..c3413354e758 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -7673,55 +7673,62 @@ static int hwrm_ring_free_send_msg(struct bnxt *bp,
 	if (rc || error_code) {
 		netdev_err(bp->dev, "hwrm_ring_free type %d failed. rc:%x err:%x\n",
 			   ring_type, rc, error_code);
+		if (rc)
+			return rc;
 		return -EIO;
 	}
 	return 0;
 }
 
-static void bnxt_hwrm_tx_ring_free(struct bnxt *bp,
-				   struct bnxt_tx_ring_info *txr,
-				   bool close_path)
+static int bnxt_hwrm_tx_ring_free(struct bnxt *bp,
+				  struct bnxt_tx_ring_info *txr,
+				  bool close_path)
 {
 	struct bnxt_ring_struct *ring = &txr->tx_ring_struct;
 	u32 cmpl_ring_id;
+	int rc;
 
 	if (ring->fw_ring_id == INVALID_HW_RING_ID)
-		return;
+		return 0;
 
 	cmpl_ring_id = close_path ? bnxt_cp_ring_for_tx(bp, txr) :
 		       INVALID_HW_RING_ID;
-	hwrm_ring_free_send_msg(bp, ring, RING_FREE_REQ_RING_TYPE_TX,
-				cmpl_ring_id);
+	rc = hwrm_ring_free_send_msg(bp, ring, RING_FREE_REQ_RING_TYPE_TX,
+				     cmpl_ring_id);
 	ring->fw_ring_id = INVALID_HW_RING_ID;
+	return rc;
 }
 
-static void bnxt_hwrm_rx_ring_free(struct bnxt *bp,
-				   struct bnxt_rx_ring_info *rxr,
-				   bool close_path)
+static int bnxt_hwrm_rx_ring_free(struct bnxt *bp,
+				  struct bnxt_rx_ring_info *rxr,
+				  bool close_path)
 {
 	struct bnxt_ring_struct *ring = &rxr->rx_ring_struct;
 	u32 grp_idx = rxr->bnapi->index;
 	u32 cmpl_ring_id;
+	int rc;
 
 	if (ring->fw_ring_id == INVALID_HW_RING_ID)
-		return;
+		return 0;
 
 	cmpl_ring_id = bnxt_cp_ring_for_rx(bp, rxr);
-	hwrm_ring_free_send_msg(bp, ring,
-				RING_FREE_REQ_RING_TYPE_RX,
-				close_path ? cmpl_ring_id :
-				INVALID_HW_RING_ID);
+	rc = hwrm_ring_free_send_msg(bp, ring,
+				     RING_FREE_REQ_RING_TYPE_RX,
+				     close_path ? cmpl_ring_id :
+				     INVALID_HW_RING_ID);
 	ring->fw_ring_id = INVALID_HW_RING_ID;
 	bp->grp_info[grp_idx].rx_fw_ring_id = INVALID_HW_RING_ID;
+	return rc;
 }
 
-static void bnxt_hwrm_rx_agg_ring_free(struct bnxt *bp,
-				       struct bnxt_rx_ring_info *rxr,
-				       bool close_path)
+static int bnxt_hwrm_rx_agg_ring_free(struct bnxt *bp,
+				      struct bnxt_rx_ring_info *rxr,
+				      bool close_path)
 {
 	struct bnxt_ring_struct *ring = &rxr->rx_agg_ring_struct;
 	u32 grp_idx = rxr->bnapi->index;
 	u32 type, cmpl_ring_id;
+	int rc;
 
 	if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS)
 		type = RING_FREE_REQ_RING_TYPE_RX_AGG;
@@ -7729,14 +7736,15 @@ static void bnxt_hwrm_rx_agg_ring_free(struct bnxt *bp,
 		type = RING_FREE_REQ_RING_TYPE_RX;
 
 	if (ring->fw_ring_id == INVALID_HW_RING_ID)
-		return;
+		return 0;
 
 	cmpl_ring_id = bnxt_cp_ring_for_rx(bp, rxr);
-	hwrm_ring_free_send_msg(bp, ring, type,
-				close_path ? cmpl_ring_id :
-				INVALID_HW_RING_ID);
+	rc = hwrm_ring_free_send_msg(bp, ring, type,
+				     close_path ? cmpl_ring_id :
+				     INVALID_HW_RING_ID);
 	ring->fw_ring_id = INVALID_HW_RING_ID;
 	bp->grp_info[grp_idx].agg_fw_ring_id = INVALID_HW_RING_ID;
+	return rc;
 }
 
 static void bnxt_hwrm_cp_ring_free(struct bnxt *bp,
-- 
2.53.1-Meta


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH net v6 2/5] bnxt_en: check HWRM response if completion never arrives
  2026-11-20 15:28 [PATCH net v6 0/5] bnxt_en: Make RING FREE more robust Joe Damato
  2026-11-20 15:28 ` [PATCH net v6 1/5] bnxt_en: return the RING_FREE status to callers Joe Damato
@ 2026-11-20 15:28 ` Joe Damato
  2026-11-23 18:30   ` netdev-bot+sashiko
  2026-11-20 15:28 ` [PATCH net v6 3/5] bnxt_en: stop DMA before releasing rings the firmware did not free Joe Damato
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 17+ messages in thread
From: Joe Damato @ 2026-11-20 15:28 UTC (permalink / raw)
  To: netdev, Michael Chan, Pavan Chebbi, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Prashant Sreedharan
  Cc: edumazet, horms, selvin.xavier, kalesh-anakkur.purayil,
	linux-kernel, Joe Damato

When HWRM_RING_FREE is sent over a completion ring, __hwrm_send() waits
for NAPI to consume the completion and gives up if it never arrives,
without looking at the response.

If a completion is not posted within the timeout, check the response
before giving up. If resp_len is set, the sequence id matches, and the
valid byte is set then the firmware completed the command and only the
notification was lost. Fall through to the normal error_code handling in
that case.

This check runs only after the full command timeout. A response that is
still being written reads a zero valid byte, so the command is still
treated as failed. The rest of the response is read only after the valid
byte has been seen.

Log the response state on both paths so there is more data when this rare
event occurs.

Fixes: 74608fc98d28 ("bnxt_en: Ring free response from close path should use completion ring")
Signed-off-by: Joe Damato <joe@dama.to>
---
 .../net/ethernet/broadcom/bnxt/bnxt_hwrm.c    | 47 +++++++++++++++++--
 1 file changed, 43 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_hwrm.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_hwrm.c
index de02d1baa751..53667c0c38aa 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_hwrm.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_hwrm.c
@@ -582,11 +582,50 @@ static int __hwrm_send(struct bnxt *bp, struct bnxt_hwrm_ctx *ctx)
 		}
 
 		if (READ_ONCE(token->state) != BNXT_HWRM_COMPLETE) {
-			hwrm_err(bp, ctx, "Resp cmpl intr err msg: 0x%x\n",
-				 req_type);
-			goto exit;
+			__le16 resp_seq_id;
+			u8 valid_byte = 0;
+
+			/* Only HWRM_RING_FREE checks the response here. The
+			 * other users of a completion ring depend on the
+			 * completion itself: the IRQ self test, and
+			 * HWRM_RING_RESET, which reuses the ring. A cancelled
+			 * wait means the device is being torn down.
+			 */
+			if (req_type != HWRM_RING_FREE ||
+			    READ_ONCE(token->state) == BNXT_HWRM_CANCELLED) {
+				hwrm_err(bp, ctx, "Resp cmpl intr err msg: 0x%x\n",
+					 req_type);
+				goto exit;
+			}
+
+			/* The completion was not delivered, but the firmware
+			 * may still have freed the ring. Check the response
+			 * before giving up and log the state.
+			 */
+			resp_seq_id = READ_ONCE(ctx->resp->seq_id);
+			len = le16_to_cpu(READ_ONCE(ctx->resp->resp_len));
+			if (len && resp_seq_id == ctx->req->seq_id)
+				valid_byte = READ_ONCE(*((u8 *)ctx->resp + len - 1));
+
+			if (!valid_byte) {
+				hwrm_err(bp, ctx,
+					 "Resp cmpl intr err msg: 0x%x len:%d seq:0x%x/0x%x\n",
+					 req_type, len,
+					 le16_to_cpu(resp_seq_id),
+					 le16_to_cpu(ctx->req->seq_id));
+				goto exit;
+			}
+
+			/* Read the rest of the response after the valid byte */
+			dma_rmb();
+			if (!(ctx->flags & BNXT_HWRM_CTX_SILENT))
+				netdev_warn(bp->dev,
+					    "Resp cmpl intr not delivered, msg: 0x%x completed anyway (len:%d valid:0x%x err:0x%x)\n",
+					    req_type, len, valid_byte,
+					    le16_to_cpu(ctx->resp->error_code));
+		} else {
+			len = le16_to_cpu(READ_ONCE(ctx->resp->resp_len));
 		}
-		len = le16_to_cpu(READ_ONCE(ctx->resp->resp_len));
 		valid = ((u8 *)ctx->resp) + len - 1;
 	} else {
 		__le16 seen_out_of_seq = ctx->req->seq_id; /* will never see */
-- 
2.53.1-Meta


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH net v6 3/5] bnxt_en: stop DMA before releasing rings the firmware did not free
  2026-11-20 15:28 [PATCH net v6 0/5] bnxt_en: Make RING FREE more robust Joe Damato
  2026-11-20 15:28 ` [PATCH net v6 1/5] bnxt_en: return the RING_FREE status to callers Joe Damato
  2026-11-20 15:28 ` [PATCH net v6 2/5] bnxt_en: check HWRM response if completion never arrives Joe Damato
@ 2026-11-20 15:28 ` Joe Damato
  2026-11-23 18:31   ` netdev-bot+sashiko
  2026-11-20 15:28 ` [PATCH net v6 4/5] bnxt_en: refuse to open a device with stopped DMA Joe Damato
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 17+ messages in thread
From: Joe Damato @ 2026-11-20 15:28 UTC (permalink / raw)
  To: netdev, Michael Chan, Pavan Chebbi, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Prashant Sreedharan
  Cc: edumazet, horms, selvin.xavier, kalesh-anakkur.purayil,
	linux-kernel, Joe Damato

When HWRM_RING_FREE is not answered, bnxt_hwrm_ring_free() clears
fw_ring_id and __bnxt_close_nic() goes on to call bnxt_free_mem(), which
unmaps the ring memory and the RX buffers that the FW may still be
using.

This is reachable in production. On a BCM57504 the first sign is the TX
watchdog; the close that follows times out a subset of its RING_FREEs and
the driver releases those rings anyway:

  05:30:12  NETDEV WATCHDOG: transmit queue 0 timed out 6073 ms
  05:30:12  Resp cmpl intr err msg: 0x51                  x20
  05:30:12  hwrm_ring_free type 1 failed                  x12
  05:30:12  hwrm_ring_free type 2 failed                  x8
  05:30:12  AMD-Vi: IO_PAGE_FAULT  x3

Count the TX, RX and AGG rings whose RING_FREE got no response and
report that to the caller, which stops DMA before the ring memory is
released. This is skipped during a firmware reset or after a fatal
firmware error, where the reset path already handles the device.

The device stays unusable until the driver is rebound.

Fixes: 74608fc98d28 ("bnxt_en: Ring free response from close path should use completion ring")
Signed-off-by: Joe Damato <joe@dama.to>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 61 ++++++++++++++++++-----
 1 file changed, 48 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index c3413354e758..600a8c866f3c 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -7774,21 +7774,31 @@ static void bnxt_clear_one_cp_ring(struct bnxt *bp, struct bnxt_cp_ring_info *cp
 			memset(cpr->cp_desc_ring[i], 0, size);
 }
 
-static void bnxt_hwrm_ring_free(struct bnxt *bp, bool close_path)
+static int bnxt_hwrm_ring_free(struct bnxt *bp, bool close_path)
 {
+	int stuck = 0;
 	u32 type;
 	int i;
 
 	if (!bp->bnapi)
-		return;
+		return 0;
 
+	/* -EBUSY means the firmware never answered, so it may still own
+	 * the ring.
+	 */
 	for (i = 0; i < bp->tx_nr_rings; i++)
-		bnxt_hwrm_tx_ring_free(bp, &bp->tx_ring[i], close_path);
+		if (bnxt_hwrm_tx_ring_free(bp, &bp->tx_ring[i],
+					   close_path) == -EBUSY)
+			stuck++;
 
 	bnxt_cancel_dim(bp);
 	for (i = 0; i < bp->rx_nr_rings; i++) {
-		bnxt_hwrm_rx_ring_free(bp, &bp->rx_ring[i], close_path);
-		bnxt_hwrm_rx_agg_ring_free(bp, &bp->rx_ring[i], close_path);
+		struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i];
+
+		if (bnxt_hwrm_rx_ring_free(bp, rxr, close_path) == -EBUSY)
+			stuck++;
+		if (bnxt_hwrm_rx_agg_ring_free(bp, rxr, close_path) == -EBUSY)
+			stuck++;
 	}
 
 	/* The completion rings are about to be freed.  After that the
@@ -7818,6 +7828,26 @@ static void bnxt_hwrm_ring_free(struct bnxt *bp, bool close_path)
 			bp->grp_info[i].cp_fw_ring_id = INVALID_HW_RING_ID;
 		}
 	}
+
+	if (!stuck)
+		return 0;
+
+	netdev_err(bp->dev, "Firmware did not free %d ring(s)\n", stuck);
+	return -EIO;
+}
+
+static void bnxt_stop_dma(struct bnxt *bp)
+{
+	/* 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;
+
+	netdev_err(bp->dev,
+		   "Disabling DMA before releasing ring memory, the driver must be rebound to recover\n");
+	pci_clear_master(bp->pdev);
 }
 
 static int __bnxt_trim_rings(struct bnxt *bp, int *rx, int *tx, int max,
@@ -10852,16 +10882,19 @@ static void bnxt_clear_vnic(struct bnxt *bp)
 		bnxt_hwrm_vnic_ctx_free(bp);
 }
 
-static void bnxt_hwrm_resource_free(struct bnxt *bp, bool close_path,
-				    bool irq_re_init)
+static int bnxt_hwrm_resource_free(struct bnxt *bp, bool close_path,
+				   bool irq_re_init)
 {
+	int rc;
+
 	bnxt_clear_vnic(bp);
-	bnxt_hwrm_ring_free(bp, close_path);
+	rc = bnxt_hwrm_ring_free(bp, close_path);
 	bnxt_hwrm_ring_grp_free(bp);
 	if (irq_re_init) {
 		bnxt_hwrm_stat_ctx_free(bp);
 		bnxt_hwrm_free_tunnel_ports(bp);
 	}
+	return rc;
 }
 
 static int bnxt_hwrm_set_br_mode(struct bnxt *bp, u16 br_mode)
@@ -11383,15 +11416,15 @@ static int bnxt_init_chip(struct bnxt *bp, bool irq_re_init)
 	return 0;
 
 err_out:
-	bnxt_hwrm_resource_free(bp, 0, true);
+	if (bnxt_hwrm_resource_free(bp, 0, true))
+		bnxt_stop_dma(bp);
 
 	return rc;
 }
 
 static int bnxt_shutdown_nic(struct bnxt *bp, bool irq_re_init)
 {
-	bnxt_hwrm_resource_free(bp, 1, irq_re_init);
-	return 0;
+	return bnxt_hwrm_resource_free(bp, 1, irq_re_init);
 }
 
 static int bnxt_init_nic(struct bnxt *bp, bool irq_re_init)
@@ -13462,7 +13495,8 @@ int bnxt_half_open_nic(struct bnxt *bp)
  */
 void bnxt_half_close_nic(struct bnxt *bp)
 {
-	bnxt_hwrm_resource_free(bp, false, true);
+	if (bnxt_hwrm_resource_free(bp, false, true))
+		bnxt_stop_dma(bp);
 	bnxt_del_napi(bp);
 	bnxt_free_skbs(bp);
 	bnxt_free_mem(bp, true);
@@ -13541,7 +13575,8 @@ static void __bnxt_close_nic(struct bnxt *bp, bool irq_re_init,
 	if (BNXT_SUPPORTS_MULTI_RSS_CTX(bp))
 		bnxt_clear_rss_ctxs(bp);
 	/* Flush rings and disable interrupts */
-	bnxt_shutdown_nic(bp, irq_re_init);
+	if (bnxt_shutdown_nic(bp, irq_re_init))
+		bnxt_stop_dma(bp);
 
 	/* TODO CHIMP_FW: Link/PHY related cleanup if (link_re_init) */
 
-- 
2.53.1-Meta


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH net v6 4/5] bnxt_en: refuse to open a device with stopped DMA
  2026-11-20 15:28 [PATCH net v6 0/5] bnxt_en: Make RING FREE more robust Joe Damato
                   ` (2 preceding siblings ...)
  2026-11-20 15:28 ` [PATCH net v6 3/5] bnxt_en: stop DMA before releasing rings the firmware did not free Joe Damato
@ 2026-11-20 15:28 ` Joe Damato
  2026-11-23 18:31   ` netdev-bot+sashiko
  2026-11-20 15:28 ` [PATCH net v6 5/5] bnxt_en: stop the ULP around the reset task Joe Damato
  2026-11-23 23:27 ` [PATCH net v6 0/5] bnxt_en: Make RING FREE more robust Joe Damato
  5 siblings, 1 reply; 17+ messages in thread
From: Joe Damato @ 2026-11-20 15:28 UTC (permalink / raw)
  To: netdev, Michael Chan, Pavan Chebbi, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Prashant Sreedharan
  Cc: edumazet, horms, selvin.xavier, kalesh-anakkur.purayil,
	linux-kernel, Joe Damato

Add BNXT_STATE_DMA_STOPPED and set it in bnxt_stop_dma() to signal that
the device had DMA disabled. When opening the device later, check this
bit and exit with an error. 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.

This is a very rare case, but when it happens the driver must be rebound
to make the device usable again.

Fixes: 74608fc98d28 ("bnxt_en: Ring free response from close path should use completion ring")
Signed-off-by: Joe Damato <joe@dama.to>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 26 ++++++++++++++++++++---
 drivers/net/ethernet/broadcom/bnxt/bnxt.h |  2 ++
 2 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 600a8c866f3c..9daf053293a4 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);
 }
 
+static int bnxt_check_dma_stopped(struct bnxt *bp)
+{
+	if (!test_bit(BNXT_STATE_DMA_STOPPED, &bp->state))
+		return 0;
+
+	netdev_err(bp->dev,
+		   "DMA was disabled after the firmware failed to free rings, rebind the driver to recover\n");
+	return -ENODEV;
+}
+
 static int __bnxt_trim_rings(struct bnxt *bp, int *rx, int *tx, int max,
 			     bool shared);
 static int bnxt_trim_rings(struct bnxt *bp, int *rx, int *tx, int max,
@@ -13440,9 +13451,10 @@ static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)
 
 int bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)
 {
-	int rc = 0;
+	int rc;
 
-	if (test_bit(BNXT_STATE_ABORT_ERR, &bp->state))
+	rc = bnxt_check_dma_stopped(bp);
+	if (!rc && test_bit(BNXT_STATE_ABORT_ERR, &bp->state))
 		rc = -EIO;
 	if (!rc)
 		rc = __bnxt_open_nic(bp, irq_re_init, link_re_init);
@@ -13459,7 +13471,11 @@ int bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)
  */
 int bnxt_half_open_nic(struct bnxt *bp)
 {
-	int rc = 0;
+	int rc;
+
+	rc = bnxt_check_dma_stopped(bp);
+	if (rc)
+		goto half_open_err;
 
 	if (test_bit(BNXT_STATE_ABORT_ERR, &bp->state)) {
 		netdev_err(bp->dev, "A previous firmware reset has not completed, aborting half open\n");
@@ -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;
+
 	if (test_bit(BNXT_STATE_ABORT_ERR, &bp->state)) {
 		rc = bnxt_reinit_after_abort(bp);
 		if (rc) {
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
index 41d05efd6307..50c024dd3c6c 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))
 
 	struct bnxt_irq	*irq_tbl;
-- 
2.53.1-Meta


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH net v6 5/5] bnxt_en: stop the ULP around the reset task
  2026-11-20 15:28 [PATCH net v6 0/5] bnxt_en: Make RING FREE more robust Joe Damato
                   ` (3 preceding siblings ...)
  2026-11-20 15:28 ` [PATCH net v6 4/5] bnxt_en: refuse to open a device with stopped DMA Joe Damato
@ 2026-11-20 15:28 ` Joe Damato
  2026-11-23 18:31   ` netdev-bot+sashiko
  2026-11-23 23:27 ` [PATCH net v6 0/5] bnxt_en: Make RING FREE more robust Joe Damato
  5 siblings, 1 reply; 17+ messages in thread
From: Joe Damato @ 2026-11-20 15:28 UTC (permalink / raw)
  To: netdev, Michael Chan, Pavan Chebbi, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Prashant Sreedharan
  Cc: edumazet, horms, selvin.xavier, kalesh-anakkur.purayil,
	linux-kernel, Joe Damato

The reset task can now stop DMA when the firmware does not free the
rings, but the RDMA driver is not told and keeps using the device.

Stop the ULP before bnxt_reset() takes its locks, as bnxt_fw_reset()
does, and start it again afterwards unless DMA was stopped. The silent
reset for a VF config change is left alone.

Fixes: 74608fc98d28 ("bnxt_en: Ring free response from close path should use completion ring")
Signed-off-by: Joe Damato <joe@dama.to>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 9daf053293a4..2abb721d87de 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -14710,10 +14710,14 @@ static void bnxt_tph_update(struct bnxt *bp)
 /* Only called from bnxt_sp_task() */
 static void bnxt_reset(struct bnxt *bp, bool silent)
 {
+	if (!silent)
+		bnxt_ulp_stop(bp);
 	bnxt_rtnl_lock_sp(bp);
 	if (test_bit(BNXT_STATE_OPEN, &bp->state))
 		bnxt_reset_task(bp, silent);
 	bnxt_rtnl_unlock_sp(bp);
+	if (!silent && !test_bit(BNXT_STATE_DMA_STOPPED, &bp->state))
+		bnxt_ulp_start(bp);
 }
 
 /* Only called from bnxt_sp_task() */
-- 
2.53.1-Meta


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH net v6 1/5] bnxt_en: return the RING_FREE status to callers
  2026-11-20 15:28 ` [PATCH net v6 1/5] bnxt_en: return the RING_FREE status to callers Joe Damato
@ 2026-11-23 18:30   ` netdev-bot+sashiko
  2026-11-23 21:18     ` Joe Damato
  0 siblings, 1 reply; 17+ messages in thread
From: netdev-bot+sashiko @ 2026-11-23 18:30 UTC (permalink / raw)
  To: joe
  Cc: netdev, michael.chan, pavan.chebbi, andrew+netdev, davem,
	edumazet, kuba, pabeni, prashant, edumazet, horms, selvin.xavier,
	kalesh-anakkur.purayil, linux-kernel

Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.

Critical: 0 · High: 0 (1) · Medium: 1 · Low: 2

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] The commit message describes an errno contract that
  hwrm_ring_free_send_msg() (drivers/net/ethernet/broadcom/bnxt/bnxt.c)…
- [Low] The commit message says 'No caller acts on it yet, so there is no
  functional change' but still carries `Fixes: 74608fc98d28`.
- [Low] In hwrm_ring_free_send_msg()
  (drivers/net/ethernet/broadcom/bnxt/bnxt.c), the `return -EIO;` left…

Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but it is still
  present at the end of the series.

--

bnxt_en: return the RING_FREE status to callers

This patch makes hwrm_ring_free_send_msg() pass up the errno from the HWRM
layer on failure. Before, it always returned -EIO. It also changes
bnxt_hwrm_tx_ring_free(), bnxt_hwrm_rx_ring_free() and
bnxt_hwrm_rx_agg_ring_free() to return that status, though no caller uses
it yet.

> No caller acts on it yet, so there is no functional change.
>
> Fixes: 74608fc98d28 ("bnxt_en: Ring free response from close path should use completion ring")

[Severity: Low]
This isn't a bug, but is the Fixes tag meant to be here? The commit message
says there is no functional change. At this commit, every caller of the TX,
RX and AGG helpers still ignores the return value.

Later patches in the series carry the same Fixes tag and depend on these
return values, for example "bnxt_en: stop DMA before releasing rings the
firmware did not free". If the tag is there so stable takes this patch
together with them, could the commit message say so?

> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> index e78cf7ad3cbc8..c3413354e7582 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> @@ -7673,55 +7673,62 @@ static int hwrm_ring_free_send_msg(struct bnxt *bp,
>  	if (rc || error_code) {
>  		netdev_err(bp->dev, "hwrm_ring_free type %d failed. rc:%x err:%x\n",
>  			   ring_type, rc, error_code);
> +		if (rc)
> +			return rc;

[Severity: Medium]
Does the errno returned here match what the commit message describes? The
message says:

    Return the errno from hwrm_req_send() instead. -EBUSY means no response
    arrived: the wait timed out, was abandoned, or the firmware channel is
    down.

If the channel is already down, the request never reaches __hwrm_send(),
because hwrm_ring_free_send_msg() returns success first:

	if (BNXT_NO_FW_ACCESS(bp))
		return 0;

So the only channel-down case that comes back as -EBUSY is a FW_FATAL_COND
that gets set during the wait.

Some cases where RING_FREE never reaches firmware return -ENOMEM, not
-EBUSY. The first is hwrm_req_init() failing in __hwrm_req_init():

	req_addr = dma_pool_alloc(bp->hwrm_dma_pool, GFP_KERNEL | __GFP_ZERO,
				  &dma_handle);
	if (!req_addr)
		return -ENOMEM;

The second is __hwrm_send() failing before it sends anything:

	token = __hwrm_acquire_token(bp, dst);
	if (!token) {
		rc = -ENOMEM;
		goto exit;
	}

__hwrm_to_stderr() also maps a firmware HWRM_ERR_CODE_NO_BUFFER reply to
-ENOMEM. A caller therefore can't tell "never sent" from "firmware
rejected" for that errno. Also, the hwrm_req_init() error is returned here
as well, not only the errno from hwrm_req_send().

Later in the series, bnxt_hwrm_ring_free() counts a ring as stuck only
when the helper returns -EBUSY:

	if (bnxt_hwrm_tx_ring_free(bp, &bp->tx_ring[i], close_path) == -EBUSY)
		stuck++;

On the -ENOMEM path, would the ring then be released through
bnxt_free_mem() without bnxt_stop_dma()? Firmware never got the RING_FREE
and still owns the ring. The path would be:

__bnxt_close_nic()->bnxt_shutdown_nic()->bnxt_hwrm_resource_free()->
  bnxt_hwrm_ring_free()->bnxt_hwrm_tx_ring_free()->
    hwrm_ring_free_send_msg()->hwrm_req_init() returns -ENOMEM

>  		return -EIO;

[Severity: Low]
Can this return -EIO still be reached? __hwrm_send() sets rc with
__hwrm_to_stderr() from the same response error_code, and only
HWRM_ERR_CODE_SUCCESS maps to 0. So rc == 0 with a nonzero error_code
doesn't look possible. On the hwrm_req_init() failure path, error_code
stays 0 and rc is nonzero.

This isn't a bug, but rc is now the errno handed to callers, and the
netdev_err() above prints it as rc:%x (for example rc:fffffff0). Would %d
be clearer? The %x format predates this patch. After a timeout or abandon,
the err:%x value also comes from a response buffer that firmware never
wrote.

>  	}
>  	return 0;
>  }

[ ... ]

> -static void bnxt_hwrm_rx_ring_free(struct bnxt *bp,
> -				   struct bnxt_rx_ring_info *rxr,
> -				   bool close_path)
> +static int bnxt_hwrm_rx_ring_free(struct bnxt *bp,
> +				  struct bnxt_rx_ring_info *rxr,
> +				  bool close_path)
>  {

[ ... ]

> -	hwrm_ring_free_send_msg(bp, ring,
> -				RING_FREE_REQ_RING_TYPE_RX,
> -				close_path ? cmpl_ring_id :
> -				INVALID_HW_RING_ID);
> +	rc = hwrm_ring_free_send_msg(bp, ring,
> +				     RING_FREE_REQ_RING_TYPE_RX,
> +				     close_path ? cmpl_ring_id :
> +				     INVALID_HW_RING_ID);
>  	ring->fw_ring_id = INVALID_HW_RING_ID;
>  	bp->grp_info[grp_idx].rx_fw_ring_id = INVALID_HW_RING_ID;
> +	return rc;
>  }

[Severity: High]
This is a pre-existing issue that this patch did not introduce, but it is
still there at the end of the series.

bnxt_hwrm_tx_ring_free(), bnxt_hwrm_rx_ring_free() and
bnxt_hwrm_rx_agg_ring_free() clear fw_ring_id on every path. The RX and AGG
helpers also clear the grp_info rx_fw_ring_id and agg_fw_ring_id. The queue
management callers ignore the status these helpers now return.

bnxt_queue_stop() does:

	bnxt_hwrm_rx_ring_free(bp, rxr, false);
	bnxt_hwrm_rx_agg_ring_free(bp, rxr, false);
	page_pool_disable_direct_recycling(rxr->page_pool);

It then hands the old ring and page pool to qmem, and ndo_queue_mem_free
frees them later.

bnxt_tx_queue_stop() does:

	bnxt_hwrm_tx_ring_free(bp, txr, true);
	bnxt_hwrm_cp_ring_free(bp, txr->tx_cpr);
	bnxt_free_one_tx_ring_skbs(bp, txr, txr->txq_index);

This unmaps and frees the TX buffers right after an -EBUSY that nobody
checks.

If firmware doesn't answer RING_FREE here, can the device keep writing into
freed RX pages, or keep reading from unmapped TX buffers?

The close path log in this series shows firmware can keep doing DMA after
an unanswered RING_FREE (AMD-Vi IO_PAGE_FAULT). However, only the close,
half-close and init-error paths through bnxt_hwrm_ring_free() were changed
to stop DMA.

The RX side is reachable through netdev_rx_queue_restart()->
bnxt_queue_stop(), for example from the TPH IRQ affinity notifier or from
binding a devmem or io_uring zcrx queue. The TX side is reachable through
bnxt_tx_queue_stop() when BNXT_FLAG_SHARED_RINGS or tph_mode is set.

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261120152830.699712-1-joe%40dama.to

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH net v6 2/5] bnxt_en: check HWRM response if completion never arrives
  2026-11-20 15:28 ` [PATCH net v6 2/5] bnxt_en: check HWRM response if completion never arrives Joe Damato
@ 2026-11-23 18:30   ` netdev-bot+sashiko
  2026-11-23 22:43     ` Joe Damato
  0 siblings, 1 reply; 17+ messages in thread
From: netdev-bot+sashiko @ 2026-11-23 18:30 UTC (permalink / raw)
  To: joe
  Cc: netdev, michael.chan, pavan.chebbi, andrew+netdev, davem,
	edumazet, kuba, pabeni, prashant, edumazet, horms, selvin.xavier,
	kalesh-anakkur.purayil, linux-kernel

Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · 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] In __hwrm_send()
  (drivers/net/ethernet/broadcom/bnxt/bnxt_hwrm.c), when the HWRM_DONE…

--

bnxt_en: check HWRM response if completion never arrives

Before this patch, an HWRM_RING_FREE sent over a completion ring failed
if __hwrm_send() timed out waiting for the completion. With this patch,
__hwrm_send() checks the response buffer first. If resp_len is set, the
sequence id matches and the valid byte is set, the command is treated as
completed and goes through the normal error_code handling.

> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_hwrm.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_hwrm.c
> index de02d1baa7514..53667c0c38aaf 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_hwrm.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_hwrm.c
> @@ -582,11 +582,50 @@ static int __hwrm_send(struct bnxt *bp, struct bnxt_hwrm_ctx *ctx)

[ ... ]

> +			/* The completion was not delivered, but the firmware
> +			 * may still have freed the ring. Check the response
> +			 * before giving up and log the state.
> +			 */
> +			resp_seq_id = READ_ONCE(ctx->resp->seq_id);
> +			len = le16_to_cpu(READ_ONCE(ctx->resp->resp_len));
> +			if (len && resp_seq_id == ctx->req->seq_id)
> +				valid_byte = READ_ONCE(*((u8 *)ctx->resp + len - 1));
> +
> +			if (!valid_byte) {
> +				hwrm_err(bp, ctx,
> +					 "Resp cmpl intr err msg: 0x%x len:%d seq:0x%x/0x%x\n",
> +					 req_type, len,
> +					 le16_to_cpu(resp_seq_id),
> +					 le16_to_cpu(ctx->req->seq_id));
> +				goto exit;
> +			}
> +
> +			/* Read the rest of the response after the valid byte */
> +			dma_rmb();
> +			if (!(ctx->flags & BNXT_HWRM_CTX_SILENT))
> +				netdev_warn(bp->dev,
> +					    "Resp cmpl intr not delivered, msg: 0x%x completed anyway (len:%d valid:0x%x err:0x%x)\n",
> +					    req_type, len, valid_byte,
> +					    le16_to_cpu(ctx->resp->error_code));
> +		} else {
> +			len = le16_to_cpu(READ_ONCE(ctx->resp->resp_len));
>  		}
> -		len = le16_to_cpu(READ_ONCE(ctx->resp->resp_len));
>  		valid = ((u8 *)ctx->resp) + len - 1;

[Severity: Medium]
Is a set valid byte in ctx->resp enough to show that the ring is safe to
free?

The commit message calls this case one where "only the notification was
lost". But the commit in the Fixes: tag, 74608fc98d28, sent the
RING_FREE response to the completion ring so that the completion entry
itself would act as the fence:

  "The response will be the last entry in the ring and we can free the
  ring after getting the response.  This will guarantee no spurious DMA
  to freed memory."

The response buffer and the HWRM_DONE completion entry are two separate
device writes. Once token->state is BNXT_HWRM_COMPLETE, the existing
success path reads resp_len without waiting for the valid byte. That
suggests the response buffer is written before the completion entry.

So a set valid byte may not mean that the HWRM_DONE entry has landed. It
also may not mean that the TX/RX completions queued ahead of it on the
same ring have landed.

This path runs when NAPI has stopped draining the completion ring, for
example after a TX watchdog timeout, a lost IRQ or a full completion
ring. In that situation the hardware may still have completion DMA
pending.

Before this patch, this case returned -EBUSY. Later in this series,
"bnxt_en: stop DMA before releasing rings the firmware did not free"
makes bnxt_hwrm_ring_free() count only -EBUSY results as stuck rings.
__bnxt_close_nic() then calls bnxt_stop_dma():

    if (bnxt_hwrm_tx_ring_free(bp, &bp->tx_ring[i],
                               close_path) == -EBUSY)
            stuck++;
    ...
    if (bnxt_shutdown_nic(bp, irq_re_init))
            bnxt_stop_dma(bp);

This is the close path that reaches this code:

__bnxt_close_nic()
  bnxt_shutdown_nic()
    bnxt_hwrm_resource_free()
      bnxt_hwrm_ring_free()
        bnxt_hwrm_tx_ring_free() / bnxt_hwrm_rx_ring_free() (close_path)
          hwrm_ring_free_send_msg()
            __hwrm_send()

This patch returns 0 when the fence was never seen. Would those rings
then skip the stuck count and bnxt_stop_dma()? If so, bnxt_free_skbs()
and bnxt_free_mem() would release the ring memory while bus mastering is
still enabled.

Also, if the HWRM_DONE entry shows up late and NAPI processes it after
the token has been released, does hwrm_update_token() just log an
"Invalid hwrm seq id" error?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261120152830.699712-1-joe%40dama.to

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH net v6 3/5] bnxt_en: stop DMA before releasing rings the firmware did not free
  2026-11-20 15:28 ` [PATCH net v6 3/5] bnxt_en: stop DMA before releasing rings the firmware did not free Joe Damato
@ 2026-11-23 18:31   ` netdev-bot+sashiko
  2026-11-23 23:03     ` Joe Damato
  0 siblings, 1 reply; 17+ messages in thread
From: netdev-bot+sashiko @ 2026-11-23 18:31 UTC (permalink / raw)
  To: joe
  Cc: netdev, michael.chan, pavan.chebbi, andrew+netdev, davem,
	edumazet, kuba, pabeni, prashant, edumazet, horms, selvin.xavier,
	kalesh-anakkur.purayil, linux-kernel

Thank you for your contribution! Sashiko AI review found 7 potential
issue(s) to consider.

Critical: 0 · High: 2 · Medium: 5 · 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] The fix leaves the per-queue restart paths uncovered.
- [High] bnxt_stop_dma() skips pci_clear_master() whenever
  BNXT_STATE_IN_FW_RESET or BNXT_STATE_FW_FATAL_COND is set.
- [Medium] bnxt_hwrm_ring_free() counts only TX, RX and AGG RING_FREE
  failures in 'stuck'.
- [Medium] bnxt_stop_dma() clears Bus Master Enable for the whole PCI
  function from ordinary L2 close paths, but the users that share the…
- [Medium] bnxt_hwrm_ring_free() marks a ring as stuck only when the
  helper returns exactly -EBUSY.
- [Medium] The patch presents driver rebind as the recovery ("The device
  stays unusable until the driver is rebound"), but rebind is not safe…
- [Medium] -EBUSY from hwrm_ring_free_send_msg() does not always mean the
  firmware never answered and may still own the ring.

--

bnxt_en: stop DMA before releasing rings the firmware did not free

This patch makes bnxt_hwrm_ring_free() count the TX, RX and AGG rings whose
HWRM_RING_FREE returned -EBUSY, and report an error to its callers. In that
case __bnxt_close_nic(), bnxt_half_close_nic() and the bnxt_init_chip()
error path call the new bnxt_stop_dma(). It clears bus mastering unless a
firmware reset or a fatal firmware error is in progress.

> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> index c3413354e7582..600a8c866f3c3 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> @@ -7774,21 +7774,31 @@ static void bnxt_clear_one_cp_ring(struct bnxt *bp, struct bnxt_cp_ring_info *cp
>  			memset(cpr->cp_desc_ring[i], 0, size);
>  }
>  
> -static void bnxt_hwrm_ring_free(struct bnxt *bp, bool close_path)
> +static int bnxt_hwrm_ring_free(struct bnxt *bp, bool close_path)
>  {
> +	int stuck = 0;
>  	u32 type;
>  	int i;
>  
>  	if (!bp->bnapi)
> -		return;
> +		return 0;
>  
> +	/* -EBUSY means the firmware never answered, so it may still own
> +	 * the ring.
> +	 */

[Severity: Medium]
Does -EBUSY always mean the firmware never answered?

__hwrm_send() starts with rc = -EBUSY. It returns that value when
hwrm_wait_must_abort() finds the firmware health register in a not-healthy
state, for example while the firmware is resetting:

drivers/net/ethernet/broadcom/bnxt/bnxt_hwrm.c:hwrm_wait_must_abort() {
    ...
	*fw_status = bnxt_fw_health_readl(bp, BNXT_FW_HEALTH_REG);
	return *fw_status && !BNXT_FW_IS_HEALTHY(*fw_status);
}

bnxt_stop_dma() only checks the driver bits BNXT_STATE_IN_FW_RESET and
BNXT_STATE_FW_FATAL_COND. During __bnxt_close_nic() those bits can lag
behind the hardware:

- BNXT_STATE_OPEN is already cleared, so bnxt_sp_task() and
  bnxt_fw_reset() return early and never set IN_FW_RESET.
- A non-fatal RESET_NOTIFY only sets FW_NON_FATAL_COND.

Say a firmware reset overlaps an ifdown, started either by another
function or by devlink fw_activate. The aborted RING_FREEs are counted as
stuck and bus mastering is cleared. Later in the series this also sets
BNXT_STATE_DMA_STOPPED, which is never cleared.

The chip reset would have discarded the ring state anyway. Normally the
next open recovers through the hot reset handling in
bnxt_hwrm_if_change(), but bnxt_check_dma_stopped() now refuses that open,
and HWRMs fail fast.

Can this turn a recoverable firmware reset into an outage that needs a
rebind?

>  	for (i = 0; i < bp->tx_nr_rings; i++)
> -		bnxt_hwrm_tx_ring_free(bp, &bp->tx_ring[i], close_path);
> +		if (bnxt_hwrm_tx_ring_free(bp, &bp->tx_ring[i],
> +					   close_path) == -EBUSY)
> +			stuck++;

[Severity: Medium]
Should this check be limited to -EBUSY? Other errors from
hwrm_ring_free_send_msg() can also leave the ring live in the firmware.

hwrm_ring_free_send_msg() passes rc from hwrm_req_init() and
hwrm_req_send() through unchanged. __hwrm_req_init() returns -ENOMEM when
dma_pool_alloc() fails. __hwrm_send() returns -ENOMEM when
__hwrm_acquire_token() fails:

drivers/net/ethernet/broadcom/bnxt/bnxt_hwrm.c:__hwrm_send() {
    ...
	token = __hwrm_acquire_token(bp, dst);
	if (!token) {
		rc = -ENOMEM;
		goto exit;
	}
    ...
}

Both of these fail before the request reaches the firmware, so the ring is
certainly still active. A firmware error reply is either mapped through
__hwrm_to_stderr() or returned as -EIO when error_code is non-zero. That
can also mean the ring was not freed.

In each of these cases the helper still clears fw_ring_id and stuck stays
at zero. bnxt_stop_dma() is skipped, and __bnxt_close_nic(),
bnxt_half_close_nic() or bnxt_init_chip() go on to bnxt_free_skbs() and
bnxt_free_mem() with bus mastering still enabled.

Would it be safer to count any non-zero return here, and in the RX and AGG
checks below?

>  
>  	bnxt_cancel_dim(bp);
>  	for (i = 0; i < bp->rx_nr_rings; i++) {
> -		bnxt_hwrm_rx_ring_free(bp, &bp->rx_ring[i], close_path);
> -		bnxt_hwrm_rx_agg_ring_free(bp, &bp->rx_ring[i], close_path);
> +		struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i];
> +
> +		if (bnxt_hwrm_rx_ring_free(bp, rxr, close_path) == -EBUSY)
> +			stuck++;
> +		if (bnxt_hwrm_rx_agg_ring_free(bp, rxr, close_path) == -EBUSY)
> +			stuck++;
>  	}

[Severity: High]
The per-queue restart paths call the same helpers but still ignore what
they return. Can they free memory the firmware is still using?

bnxt_queue_stop() is reached through netdev_rx_queue_restart(), for
example when devmem or io_uring zero-copy RX is bound, or when a queue is
reconfigured:

drivers/net/ethernet/broadcom/bnxt/bnxt.c:bnxt_queue_stop() {
    ...
	cancel_work_sync(&cpr->dim.work);
	bnxt_hwrm_rx_ring_free(bp, rxr, false);
	bnxt_hwrm_rx_agg_ring_free(bp, rxr, false);
    ...
	memcpy(qmem, rxr, sizeof(*rxr));
	bnxt_init_rx_ring_struct(bp, qmem);

	return 0;
}

The core then calls bnxt_queue_mem_free() on that qmem. It runs
bnxt_free_one_rx_ring_skbs(), page_pool_destroy() and bnxt_free_ring() on
the RX and AGG descriptor rings without stopping DMA first.

In TPH mode, bnxt_tx_queue_stop() does the same for TX:

drivers/net/ethernet/broadcom/bnxt/bnxt.c:bnxt_tx_queue_stop() {
    ...
		bnxt_hwrm_tx_ring_free(bp, txr, true);
		bnxt_hwrm_cp_ring_free(bp, txr->tx_cpr);
		bnxt_free_one_tx_ring_skbs(bp, txr, txr->txq_index);
		bnxt_clear_one_cp_ring(bp, txr->tx_cpr);
    ...
}

The previous commit in this series ("bnxt_en: return the RING_FREE status
to callers") made these helpers return -EBUSY so callers can detect a
missing response. Only bnxt_hwrm_ring_free() checks it. Through the end of
the series ("bnxt_en: stop the ULP around the reset task"), both of these
call sites still ignore the result.

Would a RING_FREE timeout during a queue restart still produce the
IO_PAGE_FAULTs from the commit message under an IOMMU, or silent memory
corruption without one?

[ ... ]

> @@ -7818,6 +7828,26 @@ static void bnxt_hwrm_ring_free(struct bnxt *bp, bool close_path)
>  			bp->grp_info[i].cp_fw_ring_id = INVALID_HW_RING_ID;
>  		}
>  	}
> +
> +	if (!stuck)
> +		return 0;

[Severity: Medium]
Only TX, RX and AGG failures are counted in stuck. What happens if one of
the other teardown commands times out?

Three other teardown commands ignore their results and invalidate the
firmware IDs anyway:

- the completion ring frees through bnxt_hwrm_cp_ring_free(), which
  returns void
- the NQ/L2_CMPL free in the bnapi loop above
- bnxt_hwrm_stat_ctx_free():

drivers/net/ethernet/broadcom/bnxt/bnxt.c:bnxt_hwrm_stat_ctx_free() {
    ...
			hwrm_req_send(bp, req);

			cpr->hw_stats_ctx_id = INVALID_STATS_CTX_ID;
    ...
}

On the close path, the TX/RX/AGG responses come back on the completion
ring. The CP/NQ/STAT_CTX frees use the default response channel, so they
can fail independently.

If only those later commands time out, stuck is zero and
bnxt_hwrm_resource_free() returns 0. __bnxt_close_nic()->bnxt_free_mem()
then frees:

- the completion and NQ descriptor pages, through bnxt_free_cp_rings()
  and bnxt_free_all_cp_arrays()
- with irq_re_init, the hw_stats buffers, through bnxt_free_ring_stats()

The firmware keeps DMAing stats into those buffers until STAT_CTX_FREE
succeeds.

The commit message limits the scope to TX, RX and AGG rings. Should these
failures also lead to bnxt_stop_dma()?

> +
> +	netdev_err(bp->dev, "Firmware did not free %d ring(s)\n", stuck);
> +	return -EIO;
> +}
> +
> +static void bnxt_stop_dma(struct bnxt *bp)
> +{
> +	/* 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;

[Severity: High]
Does either of these bits guarantee that DMA has stopped before
__bnxt_close_nic() frees memory?

For a non-fatal firmware reset, bnxt_fw_reset() and bnxt_force_fw_reset()
set IN_FW_RESET and call bnxt_fw_reset_close():

drivers/net/ethernet/broadcom/bnxt/bnxt.c:bnxt_fw_reset_close() {
    ...
	__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);
    ...
}

In the non-fatal case, __bnxt_close_nic() runs while the firmware is still
reachable (BNXT_NO_FW_ACCESS does not include IN_FW_RESET) and bus
mastering is still on. pci_disable_device() only comes after
bnxt_hwrm_func_drv_unrgtr(), which can itself wait out the HWRM timeout.
The chip reset comes later still, from the reset task.

A RING_FREE that returns -EBUSY in this window is counted as stuck. This
early return then lets bnxt_free_skbs() and bnxt_free_mem() release the
rings and RX buffers while the device can still DMA.

For FW_FATAL_COND: NAPI is still enabled while the TX/RX/AGG RING_FREEs
are sent. bnxt_async_event_process() can set the bit at any time on a
fatal RESET_NOTIFY. __hwrm_send() then aborts the in-flight RING_FREE:

drivers/net/ethernet/broadcom/bnxt/bnxt_hwrm.c:__hwrm_send() {
    ...
			if (test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state))
				goto exit;
    ...
}

rc is still -EBUSY at that point, so stuck is incremented and this
function returns early.

bnxt_fw_fatal_close(), which disables bus mastering, never runs.
bnxt_sp_task(), bnxt_fw_reset() and bnxt_force_fw_reset() all return early
once BNXT_STATE_OPEN is cleared, and __bnxt_close_nic() clears it first.

The comment in bnxt_fw_reset_close() says the fatal case needs bus master
disabled "to prevent any potential bad DMAs before freeing kernel memory".
Does this early return leave that window open in both cases?

> +
> +	netdev_err(bp->dev,
> +		   "Disabling DMA before releasing ring memory, the driver must be rebound to recover\n");

[Severity: Medium]
Is a rebind safe with the state this leaves behind?

bnxt_stop_dma() only clears bus mastering. The function is not reset, and
the firmware is not told to drop the rings it never freed.
bnxt_free_mem() then frees the descriptor rings and buffers that those
ring contexts still point at.

Unbind does not reset the function either. Once BNXT_STATE_DMA_STOPPED is
added later in the series, BNXT_NO_FW_ACCESS makes
bnxt_hwrm_func_drv_unrgtr() fail fast in bnxt_remove_one().
bnxt_free_ctx_mem() also frees the P5+ context backing store.

On rebind, bnxt_init_board() calls pci_set_master() before
bnxt_fw_init_one_p1() sends HWRM_VER_GET and then HWRM_FUNC_RESET:

drivers/net/ethernet/broadcom/bnxt/bnxt.c:bnxt_fw_init_one_p1() {
    ...
	rc = bnxt_hwrm_func_reset(bp);
	if (rc)
		return -ENODEV;
    ...
}

If the stale rings are still active, can the device resume DMA in that
window, using descriptor and context addresses that now point at freed or
reused memory?

> +	pci_clear_master(bp->pdev);

[Severity: Medium]
This clears bus mastering for the whole PCI function, which is shared with
the bnxt_re RDMA auxiliary device. Should the ULP be stopped first?

At this commit no state bit is recorded either, so later open and HWRM
paths keep waiting for DMA'd responses that can never arrive.

Later patches in the series fix part of this:

- "bnxt_en: refuse to open a device with stopped DMA" adds
  BNXT_STATE_DMA_STOPPED, gates bnxt_open(), bnxt_open_nic() and
  bnxt_half_open_nic() on it, and adds the bit to BNXT_NO_FW_ACCESS so
  HWRMs fail fast.
- "bnxt_en: stop the ULP around the reset task" stops the ULP, but only
  in bnxt_reset().

At the end of the series, these paths can still reach bnxt_stop_dma()
without bnxt_ulp_stop():

  bnxt_close()->bnxt_close_nic()->__bnxt_close_nic()
  bnxt_self_test()->bnxt_half_close_nic(), followed directly by
    bnxt_open_nic()
  bnxt_close_nic() from the channels/rings/MTU/XDP reconfiguration paths
  the bnxt_init_chip() err_out unwind

In those cases bnxt_re stays bound with live QPs/CQs and RCFW CMDQ/CREQ
rings in host memory, and its DMA stops without any notification. The
other paths that disable the device (bnxt_fw_reset(),
bnxt_fw_exception(), AER, suspend) notify the ULP first.

Separately, the log message says the driver must be rebound to recover.
However, bnxt_resume() and the ENABLE_DEV state of bnxt_fw_reset_task()
both call pci_set_master() again, without a rebind and without resetting
the stale ring state:

drivers/net/ethernet/broadcom/bnxt/bnxt.c:bnxt_fw_reset_task() {
    ...
		pci_set_master(bp->pdev);
		bp->fw_reset_state = BNXT_FW_RESET_STATE_POLL_FW;
    ...
}

Is re-enabling bus mastering on those paths intended?

>  }

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261120152830.699712-1-joe%40dama.to

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH net v6 4/5] bnxt_en: refuse to open a device with stopped DMA
  2026-11-20 15:28 ` [PATCH net v6 4/5] bnxt_en: refuse to open a device with stopped DMA Joe Damato
@ 2026-11-23 18:31   ` netdev-bot+sashiko
  2026-11-23 23:10     ` Joe Damato
  0 siblings, 1 reply; 17+ messages in thread
From: netdev-bot+sashiko @ 2026-11-23 18:31 UTC (permalink / raw)
  To: joe
  Cc: netdev, michael.chan, pavan.chebbi, andrew+netdev, davem,
	edumazet, kuba, pabeni, prashant, edumazet, horms, selvin.xavier,
	kalesh-anakkur.purayil, linux-kernel

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

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH net v6 5/5] bnxt_en: stop the ULP around the reset task
  2026-11-20 15:28 ` [PATCH net v6 5/5] bnxt_en: stop the ULP around the reset task Joe Damato
@ 2026-11-23 18:31   ` netdev-bot+sashiko
  2026-11-23 23:16     ` Joe Damato
  0 siblings, 1 reply; 17+ messages in thread
From: netdev-bot+sashiko @ 2026-11-23 18:31 UTC (permalink / raw)
  To: joe
  Cc: netdev, michael.chan, pavan.chebbi, andrew+netdev, davem,
	edumazet, kuba, pabeni, prashant, edumazet, horms, selvin.xavier,
	kalesh-anakkur.purayil, linux-kernel

Thank you for your contribution! Sashiko AI review found 6 potential
issue(s) to consider.

Critical: 0 · High: 3 · 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).

- [High] Possible deadlock.
- [High] bnxt_reset() decides to call bnxt_ulp_start() only from !silent
  && !BNXT_STATE_DMA_STOPPED, after dropping its locks.
- [High] Incomplete fix.
- [Medium] bnxt_reset_task() discards the return value of
  bnxt_open_nic(), and bnxt_reset() calls bnxt_ulp_start() whenever…
- [Medium] The new DMA_STOPPED check exists only at the bnxt_reset() call
  site.
- [Medium] Every non-silent reset now unregisters and re-registers the
  RoCE IB device, including the common case where DMA is never stopped,…

--

bnxt_en: stop the ULP around the reset task

For non-silent resets, bnxt_reset() now calls bnxt_ulp_stop() before it
takes rtnl and the netdev lock. Afterwards it calls bnxt_ulp_start() unless
BNXT_STATE_DMA_STOPPED was set. The goal is to keep the RDMA driver off the
device once the reset task has stopped DMA.

> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> index 9daf053293a42..2abb721d87de8 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> @@ -14710,10 +14710,14 @@ static void bnxt_tph_update(struct bnxt *bp)
>  /* Only called from bnxt_sp_task() */
>  static void bnxt_reset(struct bnxt *bp, bool silent)
>  {
> +	if (!silent)
> +		bnxt_ulp_stop(bp);
>  	bnxt_rtnl_lock_sp(bp);

[Severity: High]
Can this deadlock against bnxt_close()?

bnxt_sp_task() sets BNXT_STATE_IN_SP_TASK before it calls bnxt_reset().
bnxt_rtnl_lock_sp() clears that bit only after bnxt_ulp_stop() has
returned, and bnxt_rtnl_unlock_sp() sets it again before bnxt_ulp_start()
runs. So both new ULP calls run with IN_SP_TASK set.

Both ULP callbacks take rtnl_lock():

bnxt_ulp_stop()
  bnxt_re_suspend()
    bnxt_re_update_en_info_rdev()
      rtnl_lock()

bnxt_ulp_start()
  bnxt_re_resume()
    bnxt_re_add_device()
      bnxt_re_update_en_info_rdev()
        rtnl_lock()
      bnxt_re_ib_init()->ib_register_device()->...->enum_all_gids_of_dev_cb()
        rtnl_lock()

ndo_stop, meanwhile, holds rtnl and the netdev instance lock and waits for
IN_SP_TASK to clear, with no timeout:

__bnxt_close_nic() {
	clear_bit(BNXT_STATE_OPEN, &bp->state);
	smp_mb__after_atomic();
	while (bnxt_drv_busy(bp))
		msleep(20);
	...
}

Suppose "ip link set dev X down" runs just after a TX timeout has scheduled
BNXT_RESET_TASK_SP_EVENT. sp_task can block on rtnl inside bnxt_ulp_stop()
(or bnxt_ulp_start()), while bnxt_close() spins on bnxt_drv_busy() holding
rtnl. The comment above bnxt_lock_sp() warns about this exact case.

Before this patch, only the rare RESTART_ULP and firmware reset events
called into the ULP with IN_SP_TASK set. The frequent reset path did not.

Should the ULP calls happen only while IN_SP_TASK is clear?

[Severity: Medium]
Does this tear down every RDMA resource on each TX timeout or ring error?

bnxt_reset(bp, false) handles every BNXT_RESET_TASK_SP_EVENT. That event
comes from bnxt_tx_timeout(), from bnxt_sched_reset_txr(), and from
bnxt_sched_reset_rxr() for RX ring errors on P5+ chips. bnxt_ulp_stop() now
runs unconditionally, even when BNXT_STATE_OPEN or netif_running() is false
and bnxt_reset_task() does nothing.

For bnxt_re this is not a lightweight pause:

bnxt_ulp_stop()
  bnxt_re_suspend()
    bnxt_re_remove_device(rdev, BNXT_RE_PRE_RECOVERY_REMOVE, adev)
      ib_unregister_device()

That destroys all QPs, CQs, MRs and PDs owned by RDMA applications.
bnxt_ulp_start() then registers a new IB device.

Before this patch, an L2 close/open in the reset task left RoCE alone.
bnxt_hwrm_resource_free() only frees L2 rings, VNICs and stat contexts, and
the RoCE MSI-X vectors are handed over through bnxt_ulp_irq_stop() and
bnxt_ulp_irq_restart().

The commit message compares this to bnxt_fw_reset(), but a firmware reset
resets the whole device.

Would it be enough to stop the ULP after bnxt_rtnl_unlock_sp(), and only
when DMA_STOPPED was actually set? If the current behaviour stays, could the
commit message mention this cost?

[Severity: High]
The commit message says:

  The reset task can now stop DMA when the firmware does not free the
  rings, but the RDMA driver is not told and keeps using the device.

Does this patch cover all the places where that can happen?

bnxt_stop_dma() sets BNXT_STATE_DMA_STOPPED and calls pci_clear_master()
for the whole function. __bnxt_close_nic() calls it whenever
bnxt_shutdown_nic() fails, whatever the value of irq_re_init:

	if (bnxt_shutdown_nic(bp, irq_re_init))
		bnxt_stop_dma(bp);

bnxt_half_close_nic() and the bnxt_init_chip() error unwind call it too.

Two reset-task paths are still not covered:

- The silent VF_CFG_CHANGE reset, bnxt_reset(bp, true). It runs on VFs,
  where bnxt_re also runs.
- The bnxt_rx_ring_reset() fallback on pre-P5 chips. It calls
  bnxt_reset_task(bp, true) directly, and the commit message does not
  mention it:

bnxt_rx_ring_reset()
  bnxt_reset_task(bp, true)
    bnxt_close_nic(bp, false, false)
      __bnxt_close_nic()
        bnxt_shutdown_nic() fails
          bnxt_stop_dma()

Several other paths share the same close code: ndo_stop, ethtool channel
and ring changes, the offline self-test via bnxt_half_close_nic(),
MTU/feature reinit, XDP attach and DCB. In all of them, RoCE stays
registered with live QPs, CQs and NQs after bus mastering is cleared.

Would it make more sense to notify the ULP wherever DMA_STOPPED is set
(outside rtnl), instead of at this one caller?

>  	if (test_bit(BNXT_STATE_OPEN, &bp->state))
>  		bnxt_reset_task(bp, silent);
>  	bnxt_rtnl_unlock_sp(bp);
> +	if (!silent && !test_bit(BNXT_STATE_DMA_STOPPED, &bp->state))
> +		bnxt_ulp_start(bp);

[Severity: High]
Is it safe to restart the ULP based only on DMA_STOPPED?

bnxt_rtnl_lock_sp() clears IN_SP_TASK before taking rtnl, so other recovery
paths can run while bnxt_reset() waits. The new condition does not check:

- whether bnxt_reset_task() actually ran
- whether IN_FW_RESET or FW_FATAL_COND is set
- whether the PCI channel is offline, meaning another path now owns the
  stopped ULP

BNXT_EN_FLAG_ULP_STOPPED is a single flag. A second bnxt_ulp_stop() does
nothing, and the first bnxt_ulp_start() wins.

Case 1: devlink health recover runs while bnxt_reset() waits on rtnl.

__bnxt_fw_recover()
  bnxt_fw_reset()
    set_bit(BNXT_STATE_IN_FW_RESET)
    bnxt_fw_reset_close()
      __bnxt_close_nic()      <- clears OPEN
      bnxt_clear_int_mode()   <- bp->irq_tbl = NULL
      pci_disable_device()

bnxt_reset() then gets the lock and skips the reset because OPEN is clear.
It sees DMA_STOPPED clear and calls bnxt_ulp_start(). The RoCE edev is
still registered, with ULP_STOPPED set and msix_requested non-zero, so:

bnxt_ulp_start()
  bnxt_fill_msix_vecs()
    ent[i].vector = bp->irq_tbl[i].vector;

Can that dereference a NULL bp->irq_tbl?

Case 2: PCI AER.

bnxt_io_error_detected() calls bnxt_ulp_stop(), which does nothing if
bnxt_reset() already stopped the ULP. It then sets IN_FW_RESET, closes the
NIC and disables the device. bnxt_stop_dma() returns early in that state:

	if (test_bit(BNXT_STATE_IN_FW_RESET, &bp->state) ||
	    test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state))
		return;

So DMA_STOPPED stays clear, and bnxt_reset() resumes RDMA in the middle of
PCI error recovery.

With no firmware access, bnxt_re_dev_init() fails. bnxt_re_add_device()
then frees rdev while en_info->rdev still points to it, and
bnxt_re_resume() reads it in ibdev_info().

Later, bnxt_io_resume()->bnxt_ulp_start() finds ULP_STOPPED clear and does
nothing, so RDMA never comes back.

Case 3: bnxt_fw_reset() has entered POLL_VF, so OPEN is still set and
IN_FW_RESET is set.

A TX timeout now makes bnxt_reset() run bnxt_reset_task() and then
bnxt_ulp_start(). RDMA keeps running through the following
bnxt_fw_reset_close() and the firmware reset. bnxt_fw_reset_task()'s own
bnxt_ulp_start() later does nothing.

[Severity: Medium]
Should the restart also depend on bnxt_open_nic() succeeding?
bnxt_reset_task() discards its return value:

	bnxt_close_nic(bp, !silent, false);
	bnxt_open_nic(bp, !silent, false);

Other stop/start pairs restart only on success. For example,
bnxt_fw_reset_task() does:

ulp_start:
	if (!rc)
		bnxt_ulp_start(bp);

bnxt_resume(), bnxt_io_resume() and devlink reload_up follow the same
pattern.

One failure path can leave bp->irq_tbl NULL. bnxt_reserve_rings(bp, true),
reached from bnxt_open_nic()->__bnxt_open_nic(), calls
bnxt_clear_int_mode() when all of these hold:

- BNXT_NEW_RM
- irqs_required != bp->total_irqs
- !pci_msix_can_alloc_dyn()

If __bnxt_reserve_rings() or bnxt_init_int_mode() then fails, irq_tbl stays
NULL, and bnxt_ulp_start()->bnxt_fill_msix_vecs() dereferences it.

It isn't clear that this combination happens in a routine reset, because
bnxt_need_reserve_rings() is normally false when the configuration has not
changed. Other open failures would still resume RDMA on a device whose L2
bring-up failed.

[Severity: Medium]
The DMA_STOPPED check exists only at this call site. bnxt_ulp_start() in
bnxt_ulp.c resumes any registered edev that has BNXT_EN_FLAG_ULP_STOPPED
set:

	if (i == BNXT_AUXDEV_FWCTL || !bnxt_ulp_registered(edev) ||
	    !(edev->flags & BNXT_EN_FLAG_ULP_STOPPED)) {
		goto clear_flag_continue;
	}

Once bnxt_reset() has left the ULP parked after DMA was stopped, can
another caller resume it?

bnxt_dl_reload_down() for DRIVER_REINIT is one example. Its
bnxt_ulp_stop() does nothing here, and its early error returns call
bnxt_ulp_start() unconditionally:

	if (bnxt_sriov_cfg(bp)) {
		...
		netdev_unlock(bp->dev);
		rtnl_unlock();
		bnxt_ulp_start(bp);
		return -EOPNOTSUPP;

bnxt_ulp_restart() also does a bare stop and start.

Either way, bnxt_re_resume() runs on a function with bus mastering cleared
and no firmware access. bnxt_re_dev_init() then fails, which can leave
en_info->rdev pointing at a freed rdev.

Would moving the DMA_STOPPED check into bnxt_ulp_start() keep every caller
consistent?

>  }

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261120152830.699712-1-joe%40dama.to

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH net v6 1/5] bnxt_en: return the RING_FREE status to callers
  2026-11-23 18:30   ` netdev-bot+sashiko
@ 2026-11-23 21:18     ` Joe Damato
  0 siblings, 0 replies; 17+ messages in thread
From: Joe Damato @ 2026-11-23 21:18 UTC (permalink / raw)
  To: netdev-bot+sashiko
  Cc: netdev, michael.chan, pavan.chebbi, andrew+netdev, davem,
	edumazet, kuba, pabeni, prashant, edumazet, horms, selvin.xavier,
	kalesh-anakkur.purayil, linux-kernel

On Mon, Nov 23, 2026 at 06:30:57PM +0000, netdev-bot+sashiko@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 3 potential
> issue(s) to consider.
> 
> Critical: 0 · High: 0 (1) · Medium: 1 · Low: 2
> 
> 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] The commit message describes an errno contract that
>   hwrm_ring_free_send_msg() (drivers/net/ethernet/broadcom/bnxt/bnxt.c)…
> - [Low] The commit message says 'No caller acts on it yet, so there is no
>   functional change' but still carries `Fixes: 74608fc98d28`.
> - [Low] In hwrm_ring_free_send_msg()
>   (drivers/net/ethernet/broadcom/bnxt/bnxt.c), the `return -EIO;` left…
> 
> Pre-existing issues:
> - [High] This problem wasn't introduced by this patch, but it is still
>   present at the end of the series.
> 
> --
> 
> bnxt_en: return the RING_FREE status to callers
> 
> This patch makes hwrm_ring_free_send_msg() pass up the errno from the HWRM
> layer on failure. Before, it always returned -EIO. It also changes
> bnxt_hwrm_tx_ring_free(), bnxt_hwrm_rx_ring_free() and
> bnxt_hwrm_rx_agg_ring_free() to return that status, though no caller uses
> it yet.
> 
> > No caller acts on it yet, so there is no functional change.
> >
> > Fixes: 74608fc98d28 ("bnxt_en: Ring free response from close path should use completion ring")
> 
> [Severity: Low]
> This isn't a bug, but is the Fixes tag meant to be here? The commit message
> says there is no functional change. At this commit, every caller of the TX,
> RX and AGG helpers still ignores the return value.
> 
> Later patches in the series carry the same Fixes tag and depend on these
> return values, for example "bnxt_en: stop DMA before releasing rings the
> firmware did not free". If the tag is there so stable takes this patch
> together with them, could the commit message say so?

The fixed tag belongs there, yea, and I think it being there already explains
to stable what the situation is. So, I'm going to pass on this feedback.

> > diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> > index e78cf7ad3cbc8..c3413354e7582 100644
> > --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> > +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> > @@ -7673,55 +7673,62 @@ static int hwrm_ring_free_send_msg(struct bnxt *bp,
> >  	if (rc || error_code) {
> >  		netdev_err(bp->dev, "hwrm_ring_free type %d failed. rc:%x err:%x\n",
> >  			   ring_type, rc, error_code);
> > +		if (rc)
> > +			return rc;
> 
> [Severity: Medium]
> Does the errno returned here match what the commit message describes? The
> message says:
> 
>     Return the errno from hwrm_req_send() instead. -EBUSY means no response
>     arrived: the wait timed out, was abandoned, or the firmware channel is
>     down.
> 
> If the channel is already down, the request never reaches __hwrm_send(),
> because hwrm_ring_free_send_msg() returns success first:

Yes, you are correct that the commit message could be adjusted. If there is a
v7, I will fix the commit message but I am not sure it is worth respinning
this if only the commit message is slightly imprecise.
 
> 	if (BNXT_NO_FW_ACCESS(bp))
> 		return 0;
> 
> So the only channel-down case that comes back as -EBUSY is a FW_FATAL_COND
> that gets set during the wait.
> 
> Some cases where RING_FREE never reaches firmware return -ENOMEM, not
> -EBUSY. The first is hwrm_req_init() failing in __hwrm_req_init():
> 
> 	req_addr = dma_pool_alloc(bp->hwrm_dma_pool, GFP_KERNEL | __GFP_ZERO,
> 				  &dma_handle);
> 	if (!req_addr)
> 		return -ENOMEM;
> 
> The second is __hwrm_send() failing before it sends anything:
> 
> 	token = __hwrm_acquire_token(bp, dst);
> 	if (!token) {
> 		rc = -ENOMEM;
> 		goto exit;
> 	}
> 
> __hwrm_to_stderr() also maps a firmware HWRM_ERR_CODE_NO_BUFFER reply to
> -ENOMEM. A caller therefore can't tell "never sent" from "firmware
> rejected" for that errno. Also, the hwrm_req_init() error is returned here
> as well, not only the errno from hwrm_req_send().
> 
> Later in the series, bnxt_hwrm_ring_free() counts a ring as stuck only
> when the helper returns -EBUSY:
> 
> 	if (bnxt_hwrm_tx_ring_free(bp, &bp->tx_ring[i], close_path) == -EBUSY)
> 		stuck++;
> 
> On the -ENOMEM path, would the ring then be released through
> bnxt_free_mem() without bnxt_stop_dma()? Firmware never got the RING_FREE
> and still owns the ring. The path would be:
> 
> __bnxt_close_nic()->bnxt_shutdown_nic()->bnxt_hwrm_resource_free()->
>   bnxt_hwrm_ring_free()->bnxt_hwrm_tx_ring_free()->
>     hwrm_ring_free_send_msg()->hwrm_req_init() returns -ENOMEM

Yea, I don't buy this one.

This would need a small allocation to fail on the close path. The driver
already released the ring in that case before this series, so nothing gets
worse with this change.

Every RING_FREE failure in the production logs from the cover letter was a
no-response (rc:fffffff0, -EBUSY).

That is the case this series handles.

> >  		return -EIO;
> 
> [Severity: Low]
> Can this return -EIO still be reached?

Probably not, but leaving it is harmless.

> This isn't a bug, but rc is now the errno handed to callers, and the
> netdev_err() above prints it as rc:%x (for example rc:fffffff0). Would %d
> be clearer? The %x format predates this patch. After a timeout or abandon,
> the err:%x value also comes from a response buffer that firmware never
> wrote.

The response buffer is zeroed before the request is sent, so err reads 0 in
that case. That matches the logs (err:0).

> >  	}
> >  	return 0;
> >  }
> 
> [ ... ]
> 
> > -static void bnxt_hwrm_rx_ring_free(struct bnxt *bp,
> > -				   struct bnxt_rx_ring_info *rxr,
> > -				   bool close_path)
> > +static int bnxt_hwrm_rx_ring_free(struct bnxt *bp,
> > +				  struct bnxt_rx_ring_info *rxr,
> > +				  bool close_path)
> >  {
> 
> [ ... ]
> 
> > -	hwrm_ring_free_send_msg(bp, ring,
> > -				RING_FREE_REQ_RING_TYPE_RX,
> > -				close_path ? cmpl_ring_id :
> > -				INVALID_HW_RING_ID);
> > +	rc = hwrm_ring_free_send_msg(bp, ring,
> > +				     RING_FREE_REQ_RING_TYPE_RX,
> > +				     close_path ? cmpl_ring_id :
> > +				     INVALID_HW_RING_ID);
> >  	ring->fw_ring_id = INVALID_HW_RING_ID;
> >  	bp->grp_info[grp_idx].rx_fw_ring_id = INVALID_HW_RING_ID;
> > +	return rc;
> >  }
> 
> [Severity: High]
> This is a pre-existing issue that this patch did not introduce, but it is
> still there at the end of the series.
> 
> bnxt_hwrm_tx_ring_free(), bnxt_hwrm_rx_ring_free() and
> bnxt_hwrm_rx_agg_ring_free() clear fw_ring_id on every path. The RX and AGG
> helpers also clear the grp_info rx_fw_ring_id and agg_fw_ring_id. The queue
> management callers ignore the status these helpers now return.
> 
> bnxt_queue_stop() does:
> 
> 	bnxt_hwrm_rx_ring_free(bp, rxr, false);
> 	bnxt_hwrm_rx_agg_ring_free(bp, rxr, false);
> 	page_pool_disable_direct_recycling(rxr->page_pool);
> 
> It then hands the old ring and page pool to qmem, and ndo_queue_mem_free
> frees them later.
> 
> bnxt_tx_queue_stop() does:
> 
> 	bnxt_hwrm_tx_ring_free(bp, txr, true);
> 	bnxt_hwrm_cp_ring_free(bp, txr->tx_cpr);
> 	bnxt_free_one_tx_ring_skbs(bp, txr, txr->txq_index);
> 
> This unmaps and frees the TX buffers right after an -EBUSY that nobody
> checks.
> 
> If firmware doesn't answer RING_FREE here, can the device keep writing into
> freed RX pages, or keep reading from unmapped TX buffers?
> 
> The close path log in this series shows firmware can keep doing DMA after
> an unanswered RING_FREE (AMD-Vi IO_PAGE_FAULT). However, only the close,
> half-close and init-error paths through bnxt_hwrm_ring_free() were changed
> to stop DMA.
> 
> The RX side is reachable through netdev_rx_queue_restart()->
> bnxt_queue_stop(), for example from the TPH IRQ affinity notifier or from
> binding a devmem or io_uring zcrx queue. The TX side is reachable through
> bnxt_tx_queue_stop() when BNXT_FLAG_SHARED_RINGS or tph_mode is set.
> 

The above is the first item in the "leaving out" section of the cover letter.
It is a real proble, but I haven't seen it in production. Every failure I've
seen was on the close path.

I think fixing the paths mentioned above are a separate series from this one
which addresses an issue I observed.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH net v6 2/5] bnxt_en: check HWRM response if completion never arrives
  2026-11-23 18:30   ` netdev-bot+sashiko
@ 2026-11-23 22:43     ` Joe Damato
  0 siblings, 0 replies; 17+ messages in thread
From: Joe Damato @ 2026-11-23 22:43 UTC (permalink / raw)
  To: netdev-bot+sashiko
  Cc: netdev, michael.chan, pavan.chebbi, andrew+netdev, davem,
	edumazet, kuba, pabeni, prashant, edumazet, horms, selvin.xavier,
	kalesh-anakkur.purayil, linux-kernel

On Mon, Nov 23, 2026 at 06:30:59PM +0000, netdev-bot+sashiko@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue(s) to consider.
> 
> Critical: 0 · High: 0 · Medium: 1 · 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] In __hwrm_send()
>   (drivers/net/ethernet/broadcom/bnxt/bnxt_hwrm.c), when the HWRM_DONE…
> 
> --
> 
> bnxt_en: check HWRM response if completion never arrives
> 
> Before this patch, an HWRM_RING_FREE sent over a completion ring failed
> if __hwrm_send() timed out waiting for the completion. With this patch,
> __hwrm_send() checks the response buffer first. If resp_len is set, the
> sequence id matches and the valid byte is set, the command is treated as
> completed and goes through the normal error_code handling.
> 
> > diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_hwrm.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_hwrm.c
> > index de02d1baa7514..53667c0c38aaf 100644
> > --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_hwrm.c
> > +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_hwrm.c
> > @@ -582,11 +582,50 @@ static int __hwrm_send(struct bnxt *bp, struct bnxt_hwrm_ctx *ctx)
> 
> [ ... ]
> 
> > +			/* The completion was not delivered, but the firmware
> > +			 * may still have freed the ring. Check the response
> > +			 * before giving up and log the state.
> > +			 */
> > +			resp_seq_id = READ_ONCE(ctx->resp->seq_id);
> > +			len = le16_to_cpu(READ_ONCE(ctx->resp->resp_len));
> > +			if (len && resp_seq_id == ctx->req->seq_id)
> > +				valid_byte = READ_ONCE(*((u8 *)ctx->resp + len - 1));
> > +
> > +			if (!valid_byte) {
> > +				hwrm_err(bp, ctx,
> > +					 "Resp cmpl intr err msg: 0x%x len:%d seq:0x%x/0x%x\n",
> > +					 req_type, len,
> > +					 le16_to_cpu(resp_seq_id),
> > +					 le16_to_cpu(ctx->req->seq_id));
> > +				goto exit;
> > +			}
> > +
> > +			/* Read the rest of the response after the valid byte */
> > +			dma_rmb();
> > +			if (!(ctx->flags & BNXT_HWRM_CTX_SILENT))
> > +				netdev_warn(bp->dev,
> > +					    "Resp cmpl intr not delivered, msg: 0x%x completed anyway (len:%d valid:0x%x err:0x%x)\n",
> > +					    req_type, len, valid_byte,
> > +					    le16_to_cpu(ctx->resp->error_code));
> > +		} else {
> > +			len = le16_to_cpu(READ_ONCE(ctx->resp->resp_len));
> >  		}
> > -		len = le16_to_cpu(READ_ONCE(ctx->resp->resp_len));
> >  		valid = ((u8 *)ctx->resp) + len - 1;
> 
> [Severity: Medium]
> Is a set valid byte in ctx->resp enough to show that the ring is safe to
> free?
> 
> The commit message calls this case one where "only the notification was
> lost". But the commit in the Fixes: tag, 74608fc98d28, sent the
> RING_FREE response to the completion ring so that the completion entry
> itself would act as the fence:
> 
>   "The response will be the last entry in the ring and we can free the
>   ring after getting the response.  This will guarantee no spurious DMA
>   to freed memory."
> 
> The response buffer and the HWRM_DONE completion entry are two separate
> device writes. Once token->state is BNXT_HWRM_COMPLETE, the existing
> success path reads resp_len without waiting for the valid byte. That
> suggests the response buffer is written before the completion entry.
> 
> So a set valid byte may not mean that the HWRM_DONE entry has landed. It
> also may not mean that the TX/RX completions queued ahead of it on the
> same ring have landed.

Agreed. The valid byte shows that the firmware finished HWRM_RING_FREE for
the TX/RX/AGG ring. It does not show that HWRM_DONE was posted to the
completion ring.

Michael, can you confirm that the firmware has stopped DMA for the ring
(other than completions to the completion ring) by the time it writes
the RING_FREE response?

If the response is written before the ring is quiesced, then this patch is
wrong.

> This path runs when NAPI has stopped draining the completion ring, for
> example after a TX watchdog timeout, a lost IRQ or a full completion
> ring. In that situation the hardware may still have completion DMA
> pending.
> 
> Before this patch, this case returned -EBUSY. Later in this series,
> "bnxt_en: stop DMA before releasing rings the firmware did not free"
> makes bnxt_hwrm_ring_free() count only -EBUSY results as stuck rings.
> __bnxt_close_nic() then calls bnxt_stop_dma():
> 
>     if (bnxt_hwrm_tx_ring_free(bp, &bp->tx_ring[i],
>                                close_path) == -EBUSY)
>             stuck++;
>     ...
>     if (bnxt_shutdown_nic(bp, irq_re_init))
>             bnxt_stop_dma(bp);
> 
> This is the close path that reaches this code:
> 
> __bnxt_close_nic()
>   bnxt_shutdown_nic()
>     bnxt_hwrm_resource_free()
>       bnxt_hwrm_ring_free()
>         bnxt_hwrm_tx_ring_free() / bnxt_hwrm_rx_ring_free() (close_path)
>           hwrm_ring_free_send_msg()
>             __hwrm_send()
> 
> This patch returns 0 when the fence was never seen. Would those rings
> then skip the stuck count and bnxt_stop_dma()? If so, bnxt_free_skbs()
> and bnxt_free_mem() would release the ring memory while bus mastering is
> still enabled.
> 
> Also, if the HWRM_DONE entry shows up late and NAPI processes it after
> the token has been released, does hwrm_update_token() just log an
> "Invalid hwrm seq id" error?

Yes. NAPI is still enabled at this point in the close path, so a late
HWRM_DONE only produces that error message.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH net v6 3/5] bnxt_en: stop DMA before releasing rings the firmware did not free
  2026-11-23 18:31   ` netdev-bot+sashiko
@ 2026-11-23 23:03     ` Joe Damato
  0 siblings, 0 replies; 17+ messages in thread
From: Joe Damato @ 2026-11-23 23:03 UTC (permalink / raw)
  To: netdev-bot+sashiko
  Cc: netdev, michael.chan, pavan.chebbi, andrew+netdev, davem,
	edumazet, kuba, pabeni, prashant, edumazet, horms, selvin.xavier,
	kalesh-anakkur.purayil, linux-kernel

On Mon, Nov 23, 2026 at 06:31:00PM +0000, netdev-bot+sashiko@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 7 potential
> issue(s) to consider.
> 
> Critical: 0 · High: 2 · Medium: 5 · 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] The fix leaves the per-queue restart paths uncovered.
> - [High] bnxt_stop_dma() skips pci_clear_master() whenever
>   BNXT_STATE_IN_FW_RESET or BNXT_STATE_FW_FATAL_COND is set.
> - [Medium] bnxt_hwrm_ring_free() counts only TX, RX and AGG RING_FREE
>   failures in 'stuck'.
> - [Medium] bnxt_stop_dma() clears Bus Master Enable for the whole PCI
>   function from ordinary L2 close paths, but the users that share the…
> - [Medium] bnxt_hwrm_ring_free() marks a ring as stuck only when the
>   helper returns exactly -EBUSY.
> - [Medium] The patch presents driver rebind as the recovery ("The device
>   stays unusable until the driver is rebound"), but rebind is not safe…
> - [Medium] -EBUSY from hwrm_ring_free_send_msg() does not always mean the
>   firmware never answered and may still own the ring.
> 
> --
> 
> bnxt_en: stop DMA before releasing rings the firmware did not free
> 
> This patch makes bnxt_hwrm_ring_free() count the TX, RX and AGG rings whose
> HWRM_RING_FREE returned -EBUSY, and report an error to its callers. In that
> case __bnxt_close_nic(), bnxt_half_close_nic() and the bnxt_init_chip()
> error path call the new bnxt_stop_dma(). It clears bus mastering unless a
> firmware reset or a fatal firmware error is in progress.
> 
> > diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> > index c3413354e7582..600a8c866f3c3 100644
> > --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> > +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> > @@ -7774,21 +7774,31 @@ static void bnxt_clear_one_cp_ring(struct bnxt *bp, struct bnxt_cp_ring_info *cp
> >  			memset(cpr->cp_desc_ring[i], 0, size);
> >  }
> >  
> > -static void bnxt_hwrm_ring_free(struct bnxt *bp, bool close_path)
> > +static int bnxt_hwrm_ring_free(struct bnxt *bp, bool close_path)
> >  {
> > +	int stuck = 0;
> >  	u32 type;
> >  	int i;
> >  
> >  	if (!bp->bnapi)
> > -		return;
> > +		return 0;
> >  
> > +	/* -EBUSY means the firmware never answered, so it may still own
> > +	 * the ring.
> > +	 */
> 
> [Severity: Medium]
> Does -EBUSY always mean the firmware never answered?
> 
> __hwrm_send() starts with rc = -EBUSY. It returns that value when
> hwrm_wait_must_abort() finds the firmware health register in a not-healthy
> state, for example while the firmware is resetting:
> 
> drivers/net/ethernet/broadcom/bnxt/bnxt_hwrm.c:hwrm_wait_must_abort() {
>     ...
> 	*fw_status = bnxt_fw_health_readl(bp, BNXT_FW_HEALTH_REG);
> 	return *fw_status && !BNXT_FW_IS_HEALTHY(*fw_status);
> }
> 
> bnxt_stop_dma() only checks the driver bits BNXT_STATE_IN_FW_RESET and
> BNXT_STATE_FW_FATAL_COND. During __bnxt_close_nic() those bits can lag
> behind the hardware:
> 
> - BNXT_STATE_OPEN is already cleared, so bnxt_sp_task() and
>   bnxt_fw_reset() return early and never set IN_FW_RESET.
> - A non-fatal RESET_NOTIFY only sets FW_NON_FATAL_COND.
> 
> Say a firmware reset overlaps an ifdown, started either by another
> function or by devlink fw_activate. The aborted RING_FREEs are counted as
> stuck and bus mastering is cleared. Later in the series this also sets
> BNXT_STATE_DMA_STOPPED, which is never cleared.
> 
> The chip reset would have discarded the ring state anyway. Normally the
> next open recovers through the hot reset handling in
> bnxt_hwrm_if_change(), but bnxt_check_dma_stopped() now refuses that open,
> and HWRMs fail fast.
> 
> Can this turn a recoverable firmware reset into an outage that needs a
> rebind?

This is intentional. The third system in the cover letter logged:

  Abandoning msg {0x51 0x3e35} len: 0 due to firmware status: 0x408100

and the DMAR write faults came after that. The health register can't
tell a firmware that is resetting apart from one that is unhealthy and
still doing DMA, so an abandoned RING_FREE is treated as stuck.

> >  	for (i = 0; i < bp->tx_nr_rings; i++)
> > -		bnxt_hwrm_tx_ring_free(bp, &bp->tx_ring[i], close_path);
> > +		if (bnxt_hwrm_tx_ring_free(bp, &bp->tx_ring[i],
> > +					   close_path) == -EBUSY)
> > +			stuck++;
> 
> [Severity: Medium]
> Should this check be limited to -EBUSY? Other errors from
> hwrm_ring_free_send_msg() can also leave the ring live in the firmware.

Limiting it to -EBUSY was a deliberate change in this version, discussed
on the v5 thread. An error reply means the firmware is alive and
answering, and every TX/RX/AGG failure in the production logs was a
no-response. I covered the -ENOMEM case in my reply to patch 1.

> hwrm_ring_free_send_msg() passes rc from hwrm_req_init() and
> hwrm_req_send() through unchanged. __hwrm_req_init() returns -ENOMEM when
> dma_pool_alloc() fails. __hwrm_send() returns -ENOMEM when
> __hwrm_acquire_token() fails:
> 
> drivers/net/ethernet/broadcom/bnxt/bnxt_hwrm.c:__hwrm_send() {
>     ...
> 	token = __hwrm_acquire_token(bp, dst);
> 	if (!token) {
> 		rc = -ENOMEM;
> 		goto exit;
> 	}
>     ...
> }
> 
> Both of these fail before the request reaches the firmware, so the ring is
> certainly still active. A firmware error reply is either mapped through
> __hwrm_to_stderr() or returned as -EIO when error_code is non-zero. That
> can also mean the ring was not freed.
> 
> In each of these cases the helper still clears fw_ring_id and stuck stays
> at zero. bnxt_stop_dma() is skipped, and __bnxt_close_nic(),
> bnxt_half_close_nic() or bnxt_init_chip() go on to bnxt_free_skbs() and
> bnxt_free_mem() with bus mastering still enabled.
> 
> Would it be safer to count any non-zero return here, and in the RX and AGG
> checks below?
> 
> >  
> >  	bnxt_cancel_dim(bp);
> >  	for (i = 0; i < bp->rx_nr_rings; i++) {
> > -		bnxt_hwrm_rx_ring_free(bp, &bp->rx_ring[i], close_path);
> > -		bnxt_hwrm_rx_agg_ring_free(bp, &bp->rx_ring[i], close_path);
> > +		struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i];
> > +
> > +		if (bnxt_hwrm_rx_ring_free(bp, rxr, close_path) == -EBUSY)
> > +			stuck++;
> > +		if (bnxt_hwrm_rx_agg_ring_free(bp, rxr, close_path) == -EBUSY)
> > +			stuck++;
> >  	}
> 
> [Severity: High]
> The per-queue restart paths call the same helpers but still ignore what
> they return. Can they free memory the firmware is still using?

Answered in the reply to patch 1; this is in the "leaving out" section
of the cover letter.

[...]

> 
> [Severity: Medium]
> Only TX, RX and AGG failures are counted in stuck. What happens if one of
> the other teardown commands times out?

Also in the "leaving out" section of the cover letter. The commit message
explains why only TX/RX/AGG are counted.

> Three other teardown commands ignore their results and invalidate the
> firmware IDs anyway:
> 
> - the completion ring frees through bnxt_hwrm_cp_ring_free(), which
>   returns void
> - the NQ/L2_CMPL free in the bnapi loop above
> - bnxt_hwrm_stat_ctx_free():
> 
> drivers/net/ethernet/broadcom/bnxt/bnxt.c:bnxt_hwrm_stat_ctx_free() {
>     ...
> 			hwrm_req_send(bp, req);
> 
> 			cpr->hw_stats_ctx_id = INVALID_STATS_CTX_ID;
>     ...
> }
> 
> On the close path, the TX/RX/AGG responses come back on the completion
> ring. The CP/NQ/STAT_CTX frees use the default response channel, so they
> can fail independently.
> 
> If only those later commands time out, stuck is zero and
> bnxt_hwrm_resource_free() returns 0. __bnxt_close_nic()->bnxt_free_mem()
> then frees:
> 
> - the completion and NQ descriptor pages, through bnxt_free_cp_rings()
>   and bnxt_free_all_cp_arrays()
> - with irq_re_init, the hw_stats buffers, through bnxt_free_ring_stats()
> 
> The firmware keeps DMAing stats into those buffers until STAT_CTX_FREE
> succeeds.
> 
> The commit message limits the scope to TX, RX and AGG rings. Should these
> failures also lead to bnxt_stop_dma()?
> 
> > +
> > +	netdev_err(bp->dev, "Firmware did not free %d ring(s)\n", stuck);
> > +	return -EIO;
> > +}
> > +
> > +static void bnxt_stop_dma(struct bnxt *bp)
> > +{
> > +	/* 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;
> 
> [Severity: High]
> Does either of these bits guarantee that DMA has stopped before
> __bnxt_close_nic() frees memory?
> 
> For a non-fatal firmware reset, bnxt_fw_reset() and bnxt_force_fw_reset()
> set IN_FW_RESET and call bnxt_fw_reset_close():
> 
> drivers/net/ethernet/broadcom/bnxt/bnxt.c:bnxt_fw_reset_close() {
>     ...
> 	__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);
>     ...
> }
> 
> In the non-fatal case, __bnxt_close_nic() runs while the firmware is still
> reachable (BNXT_NO_FW_ACCESS does not include IN_FW_RESET) and bus
> mastering is still on. pci_disable_device() only comes after
> bnxt_hwrm_func_drv_unrgtr(), which can itself wait out the HWRM timeout.
> The chip reset comes later still, from the reset task.
> 
> A RING_FREE that returns -EBUSY in this window is counted as stuck. This
> early return then lets bnxt_free_skbs() and bnxt_free_mem() release the
> rings and RX buffers while the device can still DMA.
> 
> For FW_FATAL_COND: NAPI is still enabled while the TX/RX/AGG RING_FREEs
> are sent. bnxt_async_event_process() can set the bit at any time on a
> fatal RESET_NOTIFY. __hwrm_send() then aborts the in-flight RING_FREE:

In the fatal case bnxt_fw_reset_close() calls bnxt_fw_fatal_close() before
__bnxt_close_nic(), so DMA is already off when memory is freed.

In the non-fatal case the firmware is healthy during the close and
is expected to answer RING_FREE. The ordering there is the same as before
this series.

The check exists so that a coordinated firmware reset does not end in a
forced rebind. The remaining case is a fatal event arriving in the middle
of an ifdown. That is narrow, I haven't seen it, and it behaves the same
as before the series.

> drivers/net/ethernet/broadcom/bnxt/bnxt_hwrm.c:__hwrm_send() {
>     ...
> 			if (test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state))
> 				goto exit;
>     ...
> }
> 
> rc is still -EBUSY at that point, so stuck is incremented and this
> function returns early.
> 
> bnxt_fw_fatal_close(), which disables bus mastering, never runs.
> bnxt_sp_task(), bnxt_fw_reset() and bnxt_force_fw_reset() all return early
> once BNXT_STATE_OPEN is cleared, and __bnxt_close_nic() clears it first.
> 
> The comment in bnxt_fw_reset_close() says the fatal case needs bus master
> disabled "to prevent any potential bad DMAs before freeing kernel memory".
> Does this early return leave that window open in both cases?
> 
> > +
> > +	netdev_err(bp->dev,
> > +		   "Disabling DMA before releasing ring memory, the driver must be rebound to recover\n");
> 
> [Severity: Medium]
> Is a rebind safe with the state this leaves behind?

Probably not completely? I think there's a window between pci_set_master() in
probe and HWRM_FUNC_RESET.

That said: before this series the memory was freed with DMA on and no window
at all, so this is still a big improvement, IMHO.

[...]

> 
> [Severity: Medium]
> This clears bus mastering for the whole PCI function, which is shared with
> the bnxt_re RDMA auxiliary device. Should the ULP be stopped first?
>
> At this commit no state bit is recorded either, so later open and HWRM
> paths keep waiting for DMA'd responses that can never arrive.
> 
> Later patches in the series fix part of this:
> 
> - "bnxt_en: refuse to open a device with stopped DMA" adds
>   BNXT_STATE_DMA_STOPPED, gates bnxt_open(), bnxt_open_nic() and
>   bnxt_half_open_nic() on it, and adds the bit to BNXT_NO_FW_ACCESS so
>   HWRMs fail fast.
> - "bnxt_en: stop the ULP around the reset task" stops the ULP, but only
>   in bnxt_reset().
> 
> At the end of the series, these paths can still reach bnxt_stop_dma()
> without bnxt_ulp_stop():
> 
>   bnxt_close()->bnxt_close_nic()->__bnxt_close_nic()
>   bnxt_self_test()->bnxt_half_close_nic(), followed directly by
>     bnxt_open_nic()
>   bnxt_close_nic() from the channels/rings/MTU/XDP reconfiguration paths
>   the bnxt_init_chip() err_out unwind
> 
> In those cases bnxt_re stays bound with live QPs/CQs and RCFW CMDQ/CREQ
> rings in host memory, and its DMA stops without any notification. The
> other paths that disable the device (bnxt_fw_reset(),
> bnxt_fw_exception(), AER, suspend) notify the ULP first.

The state bit comes in patch 4.

Patch 5 stops the ULP in bnxt_reset(), which is the path seen in production
(TX timeout).

The other close paths need a way for bnxt_re to detach after DMA has stopped,
which needs the RDMA maintainers and probably a separate series.

> Separately, the log message says the driver must be rebound to recover.
> However, bnxt_resume() and the ENABLE_DEV state of bnxt_fw_reset_task()
> both call pci_set_master() again, without a rebind and without resetting
> the stale ring state:
> 
> drivers/net/ethernet/broadcom/bnxt/bnxt.c:bnxt_fw_reset_task() {
>     ...
> 		pci_set_master(bp->pdev);
> 		bp->fw_reset_state = BNXT_FW_RESET_STATE_POLL_FW;
>     ...
> }
> 
> Is re-enabling bus mastering on those paths intended?

This is part of the "leaving out" section of the cover letter.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH net v6 4/5] bnxt_en: refuse to open a device with stopped DMA
  2026-11-23 18:31   ` netdev-bot+sashiko
@ 2026-11-23 23:10     ` Joe Damato
  0 siblings, 0 replies; 17+ messages in thread
From: Joe Damato @ 2026-11-23 23:10 UTC (permalink / raw)
  To: netdev-bot+sashiko
  Cc: netdev, michael.chan, pavan.chebbi, andrew+netdev, davem,
	edumazet, kuba, pabeni, prashant, edumazet, horms, selvin.xavier,
	kalesh-anakkur.purayil, linux-kernel

On Mon, Nov 23, 2026 at 06:31:02PM +0000, netdev-bot+sashiko@kernel.org wrote:
> 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?

No, this is intentional. Recovery is rebind only. The device gets into
this state because the firmware stopped answering. I don't want resume
or AER recovery to turn the device back on without knowing the stale
ring state is gone.

Resume and AER only fail if a RING_FREE has already failed before them.
I haven't seen that. If it happens, the device stays down and has to be
rebound.

> [ ... ]
> 
> > @@ -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?

This is in the "leaving out" section of the cover letter.

> [ ... ]
> 
> > 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?

Yea the commit message could be reworded. I don't know if it's worth a respin
just for that. Like I said in response to an earlier patch (I think patch 1?)
if I need to send a v7, I'll include a commit message update.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH net v6 5/5] bnxt_en: stop the ULP around the reset task
  2026-11-23 18:31   ` netdev-bot+sashiko
@ 2026-11-23 23:16     ` Joe Damato
  0 siblings, 0 replies; 17+ messages in thread
From: Joe Damato @ 2026-11-23 23:16 UTC (permalink / raw)
  To: netdev-bot+sashiko
  Cc: netdev, michael.chan, pavan.chebbi, andrew+netdev, davem,
	edumazet, kuba, pabeni, prashant, edumazet, horms, selvin.xavier,
	kalesh-anakkur.purayil, linux-kernel

On Mon, Nov 23, 2026 at 06:31:04PM +0000, netdev-bot+sashiko@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 6 potential
> issue(s) to consider.
> 
> Critical: 0 · High: 3 · 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).
> 
> - [High] Possible deadlock.
> - [High] bnxt_reset() decides to call bnxt_ulp_start() only from !silent
>   && !BNXT_STATE_DMA_STOPPED, after dropping its locks.
> - [High] Incomplete fix.
> - [Medium] bnxt_reset_task() discards the return value of
>   bnxt_open_nic(), and bnxt_reset() calls bnxt_ulp_start() whenever…
> - [Medium] The new DMA_STOPPED check exists only at the bnxt_reset() call
>   site.
> - [Medium] Every non-silent reset now unregisters and re-registers the
>   RoCE IB device, including the common case where DMA is never stopped,…
> 
> --
> 
> bnxt_en: stop the ULP around the reset task
> 
> For non-silent resets, bnxt_reset() now calls bnxt_ulp_stop() before it
> takes rtnl and the netdev lock. Afterwards it calls bnxt_ulp_start() unless
> BNXT_STATE_DMA_STOPPED was set. The goal is to keep the RDMA driver off the
> device once the reset task has stopped DMA.
> 
> > diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> > index 9daf053293a42..2abb721d87de8 100644
> > --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> > +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> > @@ -14710,10 +14710,14 @@ static void bnxt_tph_update(struct bnxt *bp)
> >  /* Only called from bnxt_sp_task() */
> >  static void bnxt_reset(struct bnxt *bp, bool silent)
> >  {
> > +	if (!silent)
> > +		bnxt_ulp_stop(bp);
> >  	bnxt_rtnl_lock_sp(bp);
> 
> [Severity: High]
> Can this deadlock against bnxt_close()?
> 
> bnxt_sp_task() sets BNXT_STATE_IN_SP_TASK before it calls bnxt_reset().
> bnxt_rtnl_lock_sp() clears that bit only after bnxt_ulp_stop() has
> returned, and bnxt_rtnl_unlock_sp() sets it again before bnxt_ulp_start()
> runs. So both new ULP calls run with IN_SP_TASK set.
> 
> Both ULP callbacks take rtnl_lock():
> 
> bnxt_ulp_stop()
>   bnxt_re_suspend()
>     bnxt_re_update_en_info_rdev()
>       rtnl_lock()
> 
> bnxt_ulp_start()
>   bnxt_re_resume()
>     bnxt_re_add_device()
>       bnxt_re_update_en_info_rdev()
>         rtnl_lock()
>       bnxt_re_ib_init()->ib_register_device()->...->enum_all_gids_of_dev_cb()
>         rtnl_lock()
> 
> ndo_stop, meanwhile, holds rtnl and the netdev instance lock and waits for
> IN_SP_TASK to clear, with no timeout:
> 
> __bnxt_close_nic() {
> 	clear_bit(BNXT_STATE_OPEN, &bp->state);
> 	smp_mb__after_atomic();
> 	while (bnxt_drv_busy(bp))
> 		msleep(20);
> 	...
> }
> 
> Suppose "ip link set dev X down" runs just after a TX timeout has scheduled
> BNXT_RESET_TASK_SP_EVENT. sp_task can block on rtnl inside bnxt_ulp_stop()
> (or bnxt_ulp_start()), while bnxt_close() spins on bnxt_drv_busy() holding
> rtnl. The comment above bnxt_lock_sp() warns about this exact case.
> 
> Before this patch, only the rare RESTART_ULP and firmware reset events
> called into the ULP with IN_SP_TASK set. The frequent reset path did not.
> 
> Should the ULP calls happen only while IN_SP_TASK is clear?

Yea, I think this is real.

Not sure if Michael or the other Broadcom folks have a suggestion here? Maybe
the minimal fix is to clear IN_SP_TASK before bnxt_ulp_stop() and call
bnxt_ulp_start() only after unlock.

The RDMA teardown on every TX timeout and restart races below would still need
answers, though.

> [Severity: Medium]
> Does this tear down every RDMA resource on each TX timeout or ring error?
> 
> bnxt_reset(bp, false) handles every BNXT_RESET_TASK_SP_EVENT. That event
> comes from bnxt_tx_timeout(), from bnxt_sched_reset_txr(), and from
> bnxt_sched_reset_rxr() for RX ring errors on P5+ chips. bnxt_ulp_stop() now
> runs unconditionally, even when BNXT_STATE_OPEN or netif_running() is false
> and bnxt_reset_task() does nothing.
> 
> For bnxt_re this is not a lightweight pause:
> 
> bnxt_ulp_stop()
>   bnxt_re_suspend()
>     bnxt_re_remove_device(rdev, BNXT_RE_PRE_RECOVERY_REMOVE, adev)
>       ib_unregister_device()
> 
> That destroys all QPs, CQs, MRs and PDs owned by RDMA applications.
> bnxt_ulp_start() then registers a new IB device.
> 
> Before this patch, an L2 close/open in the reset task left RoCE alone.
> bnxt_hwrm_resource_free() only frees L2 rings, VNICs and stat contexts, and
> the RoCE MSI-X vectors are handed over through bnxt_ulp_irq_stop() and
> bnxt_ulp_irq_restart().
> 
> The commit message compares this to bnxt_fw_reset(), but a firmware reset
> resets the whole device.
> 
> Would it be enough to stop the ULP after bnxt_rtnl_unlock_sp(), and only
> when DMA_STOPPED was actually set? If the current behaviour stays, could the
> commit message mention this cost?
> 
> [Severity: High]
> The commit message says:
> 
>   The reset task can now stop DMA when the firmware does not free the
>   rings, but the RDMA driver is not told and keeps using the device.
> 
> Does this patch cover all the places where that can happen?
> 
> bnxt_stop_dma() sets BNXT_STATE_DMA_STOPPED and calls pci_clear_master()
> for the whole function. __bnxt_close_nic() calls it whenever
> bnxt_shutdown_nic() fails, whatever the value of irq_re_init:
> 
> 	if (bnxt_shutdown_nic(bp, irq_re_init))
> 		bnxt_stop_dma(bp);
> 
> bnxt_half_close_nic() and the bnxt_init_chip() error unwind call it too.
> 
> Two reset-task paths are still not covered:
> 
> - The silent VF_CFG_CHANGE reset, bnxt_reset(bp, true). It runs on VFs,
>   where bnxt_re also runs.
> - The bnxt_rx_ring_reset() fallback on pre-P5 chips. It calls
>   bnxt_reset_task(bp, true) directly, and the commit message does not
>   mention it:
> 
> bnxt_rx_ring_reset()
>   bnxt_reset_task(bp, true)
>     bnxt_close_nic(bp, false, false)
>       __bnxt_close_nic()
>         bnxt_shutdown_nic() fails
>           bnxt_stop_dma()
> 
> Several other paths share the same close code: ndo_stop, ethtool channel
> and ring changes, the offline self-test via bnxt_half_close_nic(),
> MTU/feature reinit, XDP attach and DCB. In all of them, RoCE stays
> registered with live QPs, CQs and NQs after bus mastering is cleared.
> 
> Would it make more sense to notify the ULP wherever DMA_STOPPED is set
> (outside rtnl), instead of at this one caller?
> 
> >  	if (test_bit(BNXT_STATE_OPEN, &bp->state))
> >  		bnxt_reset_task(bp, silent);
> >  	bnxt_rtnl_unlock_sp(bp);
> > +	if (!silent && !test_bit(BNXT_STATE_DMA_STOPPED, &bp->state))
> > +		bnxt_ulp_start(bp);
> 
> [Severity: High]
> Is it safe to restart the ULP based only on DMA_STOPPED?
> 
> bnxt_rtnl_lock_sp() clears IN_SP_TASK before taking rtnl, so other recovery
> paths can run while bnxt_reset() waits. The new condition does not check:
> 
> - whether bnxt_reset_task() actually ran
> - whether IN_FW_RESET or FW_FATAL_COND is set
> - whether the PCI channel is offline, meaning another path now owns the
>   stopped ULP
> 
> BNXT_EN_FLAG_ULP_STOPPED is a single flag. A second bnxt_ulp_stop() does
> nothing, and the first bnxt_ulp_start() wins.
> 
> Case 1: devlink health recover runs while bnxt_reset() waits on rtnl.
> 
> __bnxt_fw_recover()
>   bnxt_fw_reset()
>     set_bit(BNXT_STATE_IN_FW_RESET)
>     bnxt_fw_reset_close()
>       __bnxt_close_nic()      <- clears OPEN
>       bnxt_clear_int_mode()   <- bp->irq_tbl = NULL
>       pci_disable_device()
> 
> bnxt_reset() then gets the lock and skips the reset because OPEN is clear.
> It sees DMA_STOPPED clear and calls bnxt_ulp_start(). The RoCE edev is
> still registered, with ULP_STOPPED set and msix_requested non-zero, so:
> 
> bnxt_ulp_start()
>   bnxt_fill_msix_vecs()
>     ent[i].vector = bp->irq_tbl[i].vector;
> 
> Can that dereference a NULL bp->irq_tbl?
> 
> Case 2: PCI AER.
> 
> bnxt_io_error_detected() calls bnxt_ulp_stop(), which does nothing if
> bnxt_reset() already stopped the ULP. It then sets IN_FW_RESET, closes the
> NIC and disables the device. bnxt_stop_dma() returns early in that state:
> 
> 	if (test_bit(BNXT_STATE_IN_FW_RESET, &bp->state) ||
> 	    test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state))
> 		return;
> 
> So DMA_STOPPED stays clear, and bnxt_reset() resumes RDMA in the middle of
> PCI error recovery.
> 
> With no firmware access, bnxt_re_dev_init() fails. bnxt_re_add_device()
> then frees rdev while en_info->rdev still points to it, and
> bnxt_re_resume() reads it in ibdev_info().
> 
> Later, bnxt_io_resume()->bnxt_ulp_start() finds ULP_STOPPED clear and does
> nothing, so RDMA never comes back.
> 
> Case 3: bnxt_fw_reset() has entered POLL_VF, so OPEN is still set and
> IN_FW_RESET is set.
> 
> A TX timeout now makes bnxt_reset() run bnxt_reset_task() and then
> bnxt_ulp_start(). RDMA keeps running through the following
> bnxt_fw_reset_close() and the firmware reset. bnxt_fw_reset_task()'s own
> bnxt_ulp_start() later does nothing.
> 
> [Severity: Medium]
> Should the restart also depend on bnxt_open_nic() succeeding?
> bnxt_reset_task() discards its return value:
> 
> 	bnxt_close_nic(bp, !silent, false);
> 	bnxt_open_nic(bp, !silent, false);
> 
> Other stop/start pairs restart only on success. For example,
> bnxt_fw_reset_task() does:
> 
> ulp_start:
> 	if (!rc)
> 		bnxt_ulp_start(bp);
> 
> bnxt_resume(), bnxt_io_resume() and devlink reload_up follow the same
> pattern.
> 
> One failure path can leave bp->irq_tbl NULL. bnxt_reserve_rings(bp, true),
> reached from bnxt_open_nic()->__bnxt_open_nic(), calls
> bnxt_clear_int_mode() when all of these hold:
> 
> - BNXT_NEW_RM
> - irqs_required != bp->total_irqs
> - !pci_msix_can_alloc_dyn()
> 
> If __bnxt_reserve_rings() or bnxt_init_int_mode() then fails, irq_tbl stays
> NULL, and bnxt_ulp_start()->bnxt_fill_msix_vecs() dereferences it.
> 
> It isn't clear that this combination happens in a routine reset, because
> bnxt_need_reserve_rings() is normally false when the configuration has not
> changed. Other open failures would still resume RDMA on a device whose L2
> bring-up failed.
> 
> [Severity: Medium]
> The DMA_STOPPED check exists only at this call site. bnxt_ulp_start() in
> bnxt_ulp.c resumes any registered edev that has BNXT_EN_FLAG_ULP_STOPPED
> set:
> 
> 	if (i == BNXT_AUXDEV_FWCTL || !bnxt_ulp_registered(edev) ||
> 	    !(edev->flags & BNXT_EN_FLAG_ULP_STOPPED)) {
> 		goto clear_flag_continue;
> 	}
> 
> Once bnxt_reset() has left the ULP parked after DMA was stopped, can
> another caller resume it?
> 
> bnxt_dl_reload_down() for DRIVER_REINIT is one example. Its
> bnxt_ulp_stop() does nothing here, and its early error returns call
> bnxt_ulp_start() unconditionally:
> 
> 	if (bnxt_sriov_cfg(bp)) {
> 		...
> 		netdev_unlock(bp->dev);
> 		rtnl_unlock();
> 		bnxt_ulp_start(bp);
> 		return -EOPNOTSUPP;
> 
> bnxt_ulp_restart() also does a bare stop and start.
> 
> Either way, bnxt_re_resume() runs on a function with bus mastering cleared
> and no firmware access. bnxt_re_dev_init() then fails, which can leave
> en_info->rdev pointing at a freed rdev.
> 
> Would moving the DMA_STOPPED check into bnxt_ulp_start() keep every caller
> consistent?
> 
> >  }
> 
> -- 
> Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261120152830.699712-1-joe%40dama.to

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH net v6 0/5] bnxt_en: Make RING FREE more robust
  2026-11-20 15:28 [PATCH net v6 0/5] bnxt_en: Make RING FREE more robust Joe Damato
                   ` (4 preceding siblings ...)
  2026-11-20 15:28 ` [PATCH net v6 5/5] bnxt_en: stop the ULP around the reset task Joe Damato
@ 2026-11-23 23:27 ` Joe Damato
  5 siblings, 0 replies; 17+ messages in thread
From: Joe Damato @ 2026-11-23 23:27 UTC (permalink / raw)
  To: netdev
  Cc: andrew+netdev, davem, edumazet, kuba, pabeni, horms, michael.chan,
	pavan.chebbi, selvin.xavier, kalesh-anakkur.purayil, linux-kernel

On Fri, Nov 20, 2026 at 07:28:22AM -0800, Joe Damato wrote:
> Greetings:
> 
> On two production systems, I saw the following dmesg pattern:
> 
>   NETDEV WATCHDOG: transmit queue 0 timed out 6073 ms
>   Resp cmpl intr err msg: 0x51                  x20
>   hwrm_ring_free type 1 failed                  x12
>   hwrm_ring_free type 2 failed                  x8
>   AMD-Vi: IO_PAGE_FAULT  x3
> 
> This suggests that, for some currently unknown reason, TX completions stall
> and the netdev watchdog fires. The driver asks FW to free the rings, this
> times out, but the driver ignores the possible failure and frees ring memory.
> Since the FW didn't respond to the ring free command, it is possible that the
> FW is still DMAing to the memory which was freed.
> 
> To address this, this series makes the driver stop DMA before freeing ring
> memory when the firmware did not answer RING_FREE.
> 
> Since the RFCv4, I found a third system that hit this repeatedly:
> 
>   NETDEV WATCHDOG: CPU: 35: transmit queue 0 timed out 5459 ms
>   hwrm_ring_free type 1 failed. rc:fffffff0 err:0    x64
>   hwrm_ring_free type 2 failed. rc:fffffff0 err:0    x32
>   hwrm_ring_free type 0 failed. rc:fffffffb err:1    x64
>   hwrm_ring_alloc type 1 failed. rc:ffffffe4 err:4
>   hwrm_ring_free type 1 failed. rc:fffffff0 err:0    x44
>   Abandoning msg {0x51 0x3e35} len: 0 due to firmware status: 0x408100
>   nic open fail (rc: fffffffb)
>   DMAR: [DMA Write NO_PASID] Request device [47:00.0] fault addr
>   0xffffa07ef000 [fault reason 0x05] PTE Write access is not set
> 
> This case differs from the first two in a few ways, but this series would have
> still helped:
> 
>  - The ring frees fail on the close path and again on the error path of
>    the reopen (bnxt_init_chip()), and the device then writes to memory the
>    driver has already unmapped. The series stops DMA on both paths.
> 
>  - The interface came back up later, the watchdog fired again, and the
>    cycle started over. The host logged 79 DMAR write faults in about 20
>    hours. Patch 4 breaks this loop by refusing to reopen after DMA has
>    been stopped.
> 
>  - The firmware answers each RING_FREE about 5 seconds late, after the
>    driver has given up, and finally reports an error in its health
>    register. Patch 2 does not treat these late responses as success because
>    their sequence ids do not match.
> 
> In this most recent case, I suspect the hardware is faulty, but the driver
> shouldn't hand memory back to the system while the device could still write to
> it.

Sashiko's review of v6 raised a few questions that depend on how the firmware
behaves.

1. Patch 2: firmware ordering for RING_FREE

   When the firmware writes the RING_FREE response (valid byte set),
   has it already stopped all DMA for that TX/RX/AGG ring? Is the
   only thing still in flight the completions?

   Also, once the firmware answers RING_FREE for a completion ring, has
   it stopped writing to that ring?

   If the response can be written before the ring is quiesced, patch 2
   is wrong and I'll change it.

2. Patch 3: abandoned waits because of FW health

   hwrm_wait_must_abort() gives up when the health register reports
   not-healthy, and patch 3 counts that RING_FREE as stuck.

   I am going to guess no, but is there a health status that guarantees the
   firmware has discarded its ring state? If so, we could skip stopping
   DMA in that case.

   Sashiko suggests that an ifdown overlapping with a firmware reset would
   need a rebind. That might be extremely rare and fine as-is, though.

3. Patch 5: Drop ?

   Sashiko found a deadlock and RDMA restart races. I don't know what the
   simplest fix to all of this would be.

   Maybe it's better to drop patch 5 and let bnxt_re handle this in a
   separate series?

It would be really great to get the ring free failure path fixed so that FW
isn't TX-ing memory the driver has released.

If there's any guidance on the above that Broadcom can provide to help get
this applied that would be very helpful.

Thanks,
Joe

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2026-11-23 23:27 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-20 15:28 [PATCH net v6 0/5] bnxt_en: Make RING FREE more robust Joe Damato
2026-11-20 15:28 ` [PATCH net v6 1/5] bnxt_en: return the RING_FREE status to callers Joe Damato
2026-11-23 18:30   ` netdev-bot+sashiko
2026-11-23 21:18     ` Joe Damato
2026-11-20 15:28 ` [PATCH net v6 2/5] bnxt_en: check HWRM response if completion never arrives Joe Damato
2026-11-23 18:30   ` netdev-bot+sashiko
2026-11-23 22:43     ` Joe Damato
2026-11-20 15:28 ` [PATCH net v6 3/5] bnxt_en: stop DMA before releasing rings the firmware did not free Joe Damato
2026-11-23 18:31   ` netdev-bot+sashiko
2026-11-23 23:03     ` Joe Damato
2026-11-20 15:28 ` [PATCH net v6 4/5] bnxt_en: refuse to open a device with stopped DMA Joe Damato
2026-11-23 18:31   ` netdev-bot+sashiko
2026-11-23 23:10     ` Joe Damato
2026-11-20 15:28 ` [PATCH net v6 5/5] bnxt_en: stop the ULP around the reset task Joe Damato
2026-11-23 18:31   ` netdev-bot+sashiko
2026-11-23 23:16     ` Joe Damato
2026-11-23 23:27 ` [PATCH net v6 0/5] bnxt_en: Make RING FREE more robust Joe Damato

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox