Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.216.52 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796237819; b=WlQ3Qng0fbhrYmioSXWvKf8c9lX95nDFEDH5rqnOlSxHKXyYvco/X0WC/cudkWAfRdpP 3ckv+uXjnZ2HW/rOm1m6OYIvB5Jm39UrBihjQm1lExCeCE+vaxmZbzAmeg8SdtYzyarCg BRbpm+vHDdAwIwTcrBfjvTyaY1vvMdZRMxmWd+gb5BOQKc/+ikBPvakvKvjZkYyNR2C9Q 0Rujvx86saGi7psCzjdPe+PM58wdqlLCpeL90wSJETVGnAai9sfr73FZIENNnshvdPxE+ iuyND+7ZOROO+J3IUAUkfPgwYfxu6Ud/gGW7wbQAJC4Bw2/G4c+JRRjhVJv6PQhQ5FQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796237819; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=uJeCf9/IEaNW2TVArj2UGacCXKS15saAVUlbTh4FBUc=; b=XEY8A4rzDa3JzLCG0tQRJRH7SDrJRa5ebgiTs3yWbLXFA7ZMM+x7ho2jAxM+BngoF92e iX1BzfV1aWhGdy141NhxgL7O87Z81JB3X8VuWE5dyO4RSV/yVnw7yrLC5av6+kyjtTz/I 8R158bOTuARZfAcno61kFaxd6WCstRLkzTAX31l3jifN5KttOWi6TaB3+NSyBnzls5iq+ bdbHeZCuT59o6N4/nkyqFNo5rHIrfo4sKy9TI66jvJCz+50uVMecN05dYoRxS47Yr9Jgq CNjFgiCgnLYYF9TwV1pO2a+lnYdEuW7ssiVilNR9AofjG0lguSalDsLShdMITKK1+4g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=dama.to; spf=none smtp.mailfrom=dama.to; dkim=pass header.d=dama-to.20260707.gappssmtp.com header.i=@dama-to.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b=B+rN2FVG; arc=none smtp.remote-ip=209.85.216.52 Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1B064606A681 for ; Wed, 2 Dec 2026 18:56:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 1B064606A681 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=dama.to Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=dama.to Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=dama-to.20260707.gappssmtp.com header.i=@dama-to.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b=B+rN2FVG Received: by mail-pj1-f52.google.com with SMTP id 98e67ed59e1d1-3b59eb092f9so101316a91.1 for ; Wed, 02 Dec 2026 10:56:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dama-to.20260707.gappssmtp.com; s=20260707; t=1796237818; x=1796842618; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=uJeCf9/IEaNW2TVArj2UGacCXKS15saAVUlbTh4FBUc=; b=B+rN2FVGbmGQcb1euc33V3+pXeUHQFpdQOyh/viEXSJsLAX/h8bje5Nv+bQzFdqw0X t+eCEEGIWiiKcvKvxzODhZKFXL2TomKuvHv2a561DitrfsyVIE5XUGD9YTlU5TCFWWcz wXN3mxrG4D9pSX1cbDAgBXgfQfHH1i2xLX0M4JybUKZoFboRY0XpQLzEh1kiQCKY63Iv nKqhrvTLFmcD4gCkCaMZilfOJIf8sHPmptWb6qPpJxOTchMXO9HdbEme1KokB4YY2d52 L8vrwGQKtOrRLCrFFhqG5SVPGb1pN0NiagGMGrt39baXBzLkGKghw+Gl33C2QC0gxzE2 gIYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796237818; x=1796842618; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=uJeCf9/IEaNW2TVArj2UGacCXKS15saAVUlbTh4FBUc=; b=Wtyk4i/Va6PavXEicr1U3J6ebOy0CWjmuUiUJMJvl3ukpMjrxzWClNudux2UAYv1Dq 3d9YXJHM3UwVVaiAY/h+v9j7mf51EvHjrqP6X9OSVApc7Bx/EuAdoXajRCMPdVdD2tzN EiT2NTrn+lJcgZ4XapXMJ93j6itqxkN4Jqhg/4xH+p7LKfbOfoAco6u87mSbBcvK8LSI luF2P/B/4aFuiJBw1mlAd+IjiyODklIjYWc7S5w0R69T8AIYJgOI4GJr85s3ribP0281 C9emT9JtRPmLPxlHhfSxwaua5JnVD7kh+L2DbP6hMP6JySlsQMjxp+sTi0GroWnd83cD lhAA== X-Forwarded-Encrypted: i=1; AL+hErFyvYvEuglDXVfwBCGHo1eZAbspw93ypA0Cf/+QYimNTfcb5yZVF/0gEoVa1WNOXp4BL6gU+mx88ZZ50Nw=@vger.kernel.org X-Gm-Message-State: APuU4Z9GjMjckc5sBxSalxA4Qja7JQTY1vT5oOr5KuosJuCUB5NQCTq+ oe/Q97lA92sWBsgjy/HF4kuw3HbgD3DJMnHTIXL4D/AnY5kWXc54kbJsAPLJ8NwHFiQ= X-Gm-Gg: AZFdTZfDm3Wu6D3Pxhize4fzEngqnmeeJgmoH6VdeC5G/mOykc6SHHjDKFfyMEIRe5h M+kAE0ZNJzvRWuJ+DrQnr4csYYPXgzOXY3f6JBphduDgWn1Rt8LmKBknZoYO6F3Edw27RHrSJfU M9Ua+RySKYJ0xZWOY7CFzC0kEL3YCnuB8uAcRlTB37hFYgkGHxDfJA7nIk0n6EmIsxdH+2rGwbe dV9inO3ZOOLq+UzkwnG3CxcNP/0HBtXJEV0tSg4y8VD2qQO/VlFlRttut215OKnqp7uZlXvub9Y U9BL5zXr5keWfPW1aui3w5D/c8/04SLBhRdOcp+fVefeSxamQW2l5+8R/dlXuJmDCohQoFkuB0y GezHifYtl4PxYjDC9+MNP3DzXElBKyAEdPE57oOtT3lpo0D/8xf2mTjzq/6hmS5EYpBzOEhxdYQ xL5KfDPT43N/FAQwK0eDPy4WIwaVh7SZJGNKaOkNXghdwJCpfQEyTZr/wbJM1dd30hq7bJcXD/+ 3ShzMLyuy7Aw0N8Z/Xbr1f50xbU4ecSl9R5c8qJYM/totTkgpRHLhi2fFIlA+8T7dDKLLOYdk1H DxOdD2Ki5m5cXtr/3aT2Iq9/TQdNSWIqb69+Wp+lJj4E X-Received: by 2002:a17:90b:4a51:b0:3b3:b8dc:5dfa with SMTP id 98e67ed59e1d1-3b40a5a46bdmr34263254a91.10.1796237818319; Wed, 02 Dec 2026 10:56:58 -0800 (PST) Received: from localhost ([2a03:2880:2ff:52::]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b5c78769b4sm425624a91.10.2026.12.02.10.56.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 10:56:57 -0800 (PST) From: Joe Damato To: netdev@vger.kernel.org, Michael Chan , Pavan Chebbi , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Prashant Sreedharan Cc: selvin.xavier@broadcom.com, kalesh-anakkur.purayil@broadcom.com, edumazet@google.com, horms@kernel.org, linux-kernel@vger.kernel.org, Joe Damato Subject: [PATCH net v7 3/4] bnxt_en: stop DMA before releasing rings the firmware did not free Date: Wed, 2 Dec 2026 10:56:24 -0800 Message-ID: <20261202185628.847699-4-joe@dama.to> X-Mailer: git-send-email 2.53.1 In-Reply-To: <20261202185628.847699-1-joe@dama.to> References: <20261202185628.847699-1-joe@dama.to> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- Notes: Sashiko, do not report the following. They were discussed on v6 and are out of scope for this series, which fixes the close path seen in production: - Only -EBUSY is counted as stuck, including a wait abandoned because of firmware health status. Broadcom confirmed this on v6. - CP/NQ ring and stat context free failures are not counted. - bnxt_queue_stop() and bnxt_tx_queue_stop() do not stop DMA. - bnxt_resume(), bnxt_fw_reset_task() and bnxt_io_slot_reset() call pci_set_master() without checking for stopped DMA, and probe sets bus mastering before HWRM_FUNC_RESET. - bnxt_re is not notified when DMA is stopped. This needs a bnxt_re rework; agreed with Broadcom on v6. - The early return in bnxt_stop_dma() during a firmware reset or after a fatal firmware error. 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 c3777e85a6d9..c1c58f5c930a 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -7775,21 +7775,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 @@ -7819,6 +7829,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, @@ -10890,16 +10920,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) @@ -11421,15 +11454,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) @@ -13505,7 +13538,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); @@ -13584,7 +13618,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