From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796325435; b=pZu1aPCSp9BH+YfyXzrqTWBPDREP/kd30tORFU9c2Nl/3E/Kar0CraLTClozG44NYyB6 uBtlSKiUbrjtBDnxhcG04QUdNtERWTGomm1n4/89M10hfIRf3JcdIlivlzXJ9i4VJPTga bu2UT+B4ELDY2YMaLf07nh2jXpEV0egCkSK6zFsOP7CjCRqizJgulDmp81aJWe/ep2ki+ JN0RMC/+THubBl+ir8kSjRs82pNLdE8Sh9wxBr/DHzojpa8XsHs3sD+kMajteXPd4bj1J DCDzlHvVvHHwFrZ520YBchNPeppp1jLJpSQlJ7X4ujTy6wDbEc1e+q42DIZIOgQefqw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796325435; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=Lomg7NKmvKMaKTNuhaQmiL+xxhD6kqSwiGMcDjVy/rc=; b=XX0L/YwoupEIf/dxM6Dca7Eqho1wJLkcF3k19fs33OJsGcedTMLbdnVrXPVX3HqN1C+a OehZMhK4dFkUOa6Qx84iRrjzOrvaLdzPKNPXV2sjGBLSVOG2AVDlRctHzFtGNnIuWNZnA 1j8L8xV/rttQ5OVmKa/jgQh/c6Tb9toc1EhZriyez8dFPcLjXKfFURV8eZfw74OXTozb9 GB1ZvKUmd5TIH7cf/ogsHyW+3EIF5vGiLHNL0S0yAiyZyyUu1u+1PMNTnGHkvb6amiH2E X9swMNHdnzQhvFfq5FdjbRB+dmu8TdMq65S/kfO9VTDrfbeFoTU4UeMf3WGaIRj8v/w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ZlTt8BcG; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A2D81606A6A9; Thu, 3 Dec 2026 19:17:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ZlTt8BcG Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8BB011F000C2; Thu, 3 Dec 2026 19:17:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796325435; bh=Lomg7NKmvKMaKTNuhaQmiL+xxhD6kqSwiGMcDjVy/rc=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=ZlTt8BcGImslmFyy6ZRztyH+5cBBLOX7rTOb/Zct1jJmvlYbAYSVK0zD2x7MV/apd XaA2X06zVGVI7cqao95qQM1wTskf51dNHMbYYlhxPpJHKcmt7xLIZrdEblgdagwJkG vHaPgYXJia2ebiJ3LI0Orb1gWu4LmKSYRtFpFc1zpt+rnKSKFFb99btX1Xttby1KUt hq3owqax8K08U7C2Hn0mZajP19GnSO0u/+JLck7xd005zJj2fx3UFrRE+fprU9WFem JxExdtkoPZfWDX4sxInU+qKiKgryi/0zfdaftsVT0/B826kC7UR4Krt46hZq4zeYhn 9a/OrEEil5htQ== Subject: Re: [PATCH net v7 4/4] bnxt_en: refuse to open a device with stopped DMA From: netdev-bot+sashiko@kernel.org To: joe@dama.to Cc: netdev@vger.kernel.org, michael.chan@broadcom.com, pavan.chebbi@broadcom.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, prashant@broadcom.com, selvin.xavier@broadcom.com, kalesh-anakkur.purayil@broadcom.com, edumazet@google.com, horms@kernel.org, linux-kernel@vger.kernel.org Date: Thu, 03 Dec 2026 19:17:14 +0000 Message-ID: <179632543413.3146.13728964654428418135@kernel.org> In-Reply-To: <20261202185628.847699-5-joe@dama.to> References: <20261202185628.847699-5-joe@dama.to> X-sashiko-severity: High Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider. Critical: 0 · High: 1 · Medium: 2 · Low: 0 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [High] bnxt_stop_dma() (bnxt.c:7845) returns without clearing Bus Master Enable and without setting BNXT_STATE_DMA_STOPPED whenever… - [Medium] This series makes 'rebind the driver' the only recovery after bnxt_stop_dma() has run. - [Medium] bnxt_en: pci_set_master() called when BNXT_STATE_DMA_STOPPED is set -- bnxt_en: refuse to open a device with stopped DMA This commit adds BNXT_STATE_DMA_STOPPED, sets it in bnxt_stop_dma(), and refuses to open the device while the bit is set. It also adds the bit to BNXT_NO_FW_ACCESS(), so most HWRM commands fail right away after DMA has been stopped. Rebinding the driver is the only way to recover. > diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c > index c1c58f5c930a0..1f40914610bb8 100644 > --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c > +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c > @@ -7848,9 +7848,20 @@ static void bnxt_stop_dma(struct bnxt *bp) > > netdev_err(bp->dev, > "Disabling DMA before releasing ring memory, the driver must be rebound to recover\n"); > + set_bit(BNXT_STATE_DMA_STOPPED, &bp->state); > pci_clear_master(bp->pdev); > } [Severity: Medium] bnxt_stop_dma() clears bus mastering so the device cannot DMA into the ring and RX buffer memory that __bnxt_close_nic() frees next. The new bit is supposed to keep it that way until the driver is rebound. bnxt_resume(), bnxt_fw_reset_task() and bnxt_io_slot_reset() still call pci_set_master() without looking at BNXT_STATE_DMA_STOPPED. The notes defer those callers to net-next. However, with BNXT_STATE_DMA_STOPPED in BNXT_NO_FW_ACCESS(), these paths now turn bus mastering back on and then fail part way through. The device is left enabled as a bus master with nobody driving it. Suspend looks like the easiest way to get there. bnxt_suspend() calls bnxt_close(), which returns 0 even when bnxt_shutdown_nic() hits the HWRM_RING_FREE timeout and calls bnxt_stop_dma(). On resume: bnxt_resume() pci_set_master(bp->pdev) bnxt_hwrm_ver_get() bnxt_hwrm_func_reset() bnxt_hwrm_func_qcaps() <- -EBUSY from BNXT_NO_FW_ACCESS() goto resume_exit <- bus mastering left on The firmware ring state may survive suspend (s2idle, or D3hot without a soft reset). In that case, can the device write into the freed buffers between pci_set_master() and HWRM_FUNC_RESET? That includes the VF bnxt_hwrm_poll() retry loop. If HWRM_VER_GET or HWRM_FUNC_RESET fails on an unresponsive firmware, that window never closes. bnxt_fw_reset_task() is similar: BNXT_FW_RESET_STATE_ENABLE_DEV calls pci_set_master(), then bnxt_open() refuses with -ENODEV. In bnxt_io_slot_reset(), pci_set_master() runs and bnxt_io_resume() then fails in bnxt_hwrm_func_qcaps(). Could these paths check BNXT_STATE_DMA_STOPPED before pci_set_master() and bail out? Or could they clear bus mastering again on their error exits? This patch is what makes them fail with bus mastering on, so it seems worth handling here rather than in net-next. [Severity: High] bnxt_stop_dma() returns early before it reaches this point: /* A firmware reset resets the device, and the fatal error path * already disables it. */ if (test_bit(BNXT_STATE_IN_FW_RESET, &bp->state) || test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state)) return; When IN_FW_RESET is set, neither pci_clear_master() nor the new set_bit() runs. Is a reset guaranteed to happen before the device can reach the freed ring memory? One path where it doesn't seem to: bnxt_fw_reset() with active VFs sets IN_FW_RESET and moves to BNXT_FW_RESET_STATE_POLL_VF, and the device stays open. If the user then closes the device: bnxt_close() bnxt_close_nic() set_bit(BNXT_STATE_ABORT_ERR, &bp->state); __bnxt_close_nic() HWRM_RING_FREE gets no answer (-EBUSY) bnxt_stop_dma() <- returns early, bus mastering stays on bnxt_free_mem() Then the POLL_VF case in bnxt_fw_reset_task() does: netdev_lock(bp->dev); if (test_bit(BNXT_STATE_ABORT_ERR, &bp->state)) { netdev_unlock(bp->dev); goto fw_reset_abort; } bnxt_fw_reset_abort() clears IN_FW_RESET and closes the device. It never issues a reset or calls pci_disable_device(). The VF timeout branch in POLL_VF also clears IN_FW_RESET without a reset. Wouldn't the firmware then still own rings that point at freed memory, with bus mastering on? BNXT_STATE_DMA_STOPPED would also never get set, so the new open-time check would not fire. The normal non-fatal reset path seems to have a smaller window too. bnxt_fw_reset_close() frees ring memory before bus mastering is cleared: __bnxt_close_nic(bp, true, false); bnxt_vf_reps_free(bp); bnxt_clear_int_mode(bp); bnxt_hwrm_func_drv_unrgtr(bp); if (pci_is_enabled(bp->pdev)) pci_disable_device(bp->pdev); bnxt_hwrm_func_drv_unrgtr() can wait for a full HWRM timeout if the firmware does not respond. Later, a failed bnxt_reset_all() only logs "Unable to reset FW rc=%d". BNXT_FW_RESET_STATE_ENABLE_DEV then calls pci_set_master() anyway. Could the IN_FW_RESET skip depend on a reset or pci_disable_device() actually happening? Alternatively, could bus mastering be cleared on these paths as well? [ ... ] > diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h > index 41d05efd6307a..50c024dd3c6c4 100644 > --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h > +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h > @@ -2474,9 +2474,11 @@ struct bnxt { [ ... ] > +#define BNXT_STATE_DMA_STOPPED 16 > > #define BNXT_NO_FW_ACCESS(bp) \ > (test_bit(BNXT_STATE_FW_FATAL_COND, &(bp)->state) || \ > + test_bit(BNXT_STATE_DMA_STOPPED, &(bp)->state) || \ > pci_channel_offline((bp)->pdev)) [Severity: Medium] Rebinding is now the only recovery. What clears the firmware's ring state before bus mastering is turned back on at the next probe? With DMA_STOPPED in BNXT_NO_FW_ACCESS(), bnxt_remove_one() now skips its bnxt_hwrm_func_drv_unrgtr() call right away. The return value is ignored and no FLR follows. bnxt_shutdown() handles the same failure with an FLR: if (bnxt_hwrm_func_drv_unrgtr(bp)) { pcie_flr(pdev); goto shutdown_exit; } On rebind, the order is: bnxt_init_one() bnxt_init_board() pci_set_master(pdev); ... bnxt_fw_init_one_p1() bnxt_hwrm_ver_get() (on failure: msleep(100), bnxt_try_recover_fw(), ver_get again) bnxt_hwrm_func_reset() bnxt_hwrm_ring_free() says: /* -EBUSY means the firmware never answered, so it may still own * the ring. */ Between pci_set_master() and HWRM_FUNC_RESET, could DMA engines that still hold the previous binding's rings read descriptors from, or write packets, completions or stats into, memory the previous instance freed? bnxt_kdump_reset() already clears bus mastering and runs pcie_flr() before probe to clear pending DMA from a previous instance, but only in the kdump case. Would either of these close the window: a pcie_flr() in bnxt_remove_one() when BNXT_STATE_DMA_STOPPED is set, or a reset before pci_set_master() at probe? -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202185628.847699-1-joe%40dama.to