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=1795620880; b=4SUE5xdTIozsJFJ8lJQB3bnLcuoxqBpzI1mdueBpVnPS5NLByUMG3yrwUUyC0uk3ysvL 1u3KRaKDpDqr6qZXvZl3a/D9gIMJlLfkOOQrdfOID9LMfcuMUFXToYG0KATMKmH5jB54k Ve9raYWYQQEqw7JU+CulvLnOZ4YPaj0CT5pE2FpnW7Hl9KbbqwXzUXlx2J8sqMxHJu6mC jargskgeV+oUJ/fjidh2Q9lDurtaU6N6THrciezdtfbHAVbKCpEBg4QdGJAXV2IHGOPLv clnx5v5EQe8EbSb+T70gqC7ir42IonxyLInJqWR/fHZidxyEx/TPNfHLaVT6oFO+ZyA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795620880; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=1s5o4XK23CrRAEfjNzoDzFHv3EdSFU7A8jVXgtBCPm8=; b=4eAWUh4XrzMllakKUes4KTjBmDWGDyYLO/FPvk4dNsh7u2lungKwY+lhnODUhOvCelrZ qG5HiUwJi2Mi7yCUniSzOUk0DrbtNuFeAX9Di7rHbHFvnYZhkoklon7fKxpcI85Xi2L6W rqluIOToB8opr5XMQkp6mvTiqFqasRMZ77wCb4X4CgfpZlS5SkTpT5CfM+/WTIcvwqANR WL8QooNLj864/dEWS1v0ILlR8V4wR1Z8eU1vOMvyLgpdJ/WiX6uu5fJDTsj79L+nnqlEV K6CFN+XA1jItjW9SDkP6wzBPBUXhpisb8Hqy/Y+4NtGqyfEKE63SVw++EtHNm3cXVPQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=LQe9Oxr8; 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 41259606A31E; Wed, 25 Nov 2026 15:34:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=LQe9Oxr8 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 85EFD1F000C6; Wed, 25 Nov 2026 15:34:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795620880; bh=1s5o4XK23CrRAEfjNzoDzFHv3EdSFU7A8jVXgtBCPm8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=LQe9Oxr8v3Z7uvGMQhjgnPaSRdIB8rIMuRVPSRsrjpJPXp/F0zLo9M5oBK6ujNYR6 IgvxNYsQuFLc8VfEE8hKg5SfsU/o0RiI88zyEoxUj84dxZ1MogrVfoYrrE8mKRMPt2 RmgOSmf3syxwimV7U01Q/n5VNQp5nfNIVgXyscxk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Bryan Cochrane , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.18 051/990] bnxt_en: Take RTNL before netif_close() when aborting FW reset Date: Wed, 25 Nov 2026 15:23:38 +0100 Message-ID: <20261125143823.285026277@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261125143822.072087159@linuxfoundation.org> References: <20261125143822.072087159@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@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 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Bryan Cochrane commit bf83b257423bb557b970df3d7ece32fbd85f3bd4 upstream. netif_close() must be called with RTNL held in addition to the netdev instance lock: __dev_close_many() asserts it, and the NETDEV_GOING_DOWN and NETDEV_DOWN notifier chains it runs rely on it for serialization. Commit 004b5008016a ("eth: bnxt: remove most dependencies on RTNL") replaced rtnl_lock() with netdev_lock() in bnxt_fw_reset_task() and bnxt_fw_reset(). That is sufficient for the paths that only tear the NIC down internally with __bnxt_close_nic(), but the abort paths close the netdev via bnxt_fw_reset_abort() -> netif_close(), and the error path in bnxt_fw_reset() calls netif_close() directly. Those now run without RTNL and trigger a WARN_ONCE() cascade when a firmware reset is aborted: RTNL: assertion failed at net/core/dev.c (1740) WARNING: net/core/dev.c:1740 at __dev_close_many+0x1be/0x1f0 Workqueue: bnxt_pf_wq bnxt_fw_reset_task [bnxt_en] Call Trace: netif_close_many+0xb5/0x190 netif_close+0xa2/0xd0 bnxt_fw_reset_task.cold+0x8d/0x213 [bnxt_en] process_one_work+0x19d/0x3a0 worker_thread+0x1af/0x320 kthread+0xe3/0x120 followed by the same assertion from call_netdevice_notifiers_info(), fib_rules_event(), inetdev_event(), rtnl_fill_ifinfo(), devlink_compat_phys_port_name_get() and ip_mc_down(). This was observed on a machine in real use with a BCM57504 (4 PFs, FW 236.1.153.0) running v7.1.6: the firmware crashed, announced a "Fatal firmware reset event" and then failed to come back within the advertised max wait, so bnxt_fw_reset_task() aborted the reset on all ports: bnxt_en 0000:c1:00.1 eno16905np1: Firmware reset aborted bnxt_en 0000:c1:00.1 eno16905np1: fw_health_status 0x448100 Take RTNL (before the netdev instance lock, matching the OPENING state which already uses rtnl_trylock()) in the fw_reset_abort path of bnxt_fw_reset_task() and route the POLL_VF abort through that same path. In bnxt_fw_reset(), only a PF can reach the bnxt_get_registered_vfs() error path that calls netif_close(), so take RTNL up front via bnxt_rtnl_lock_sp() when BNXT_PF(bp) is true and keep bnxt_lock_sp() on VFs. That avoids dropping the instance lock mid-reset (which would expose a transient BNXT_STATE_IN_FW_RESET and let a concurrent devlink health recover set BNXT_STATE_IN_SP_TASK), avoids racing with bnxt_sriov_configure() updating active_vfs outside RTNL, and keeps VFs from contending on RTNL during recovery while PFs already run on the single-threaded bnxt_pf_wq. The bug was found by inspecting the kernel log of the affected machine and the driver source; the fix was prepared with the help of an AI coding assistant (Gemini based) and reviewed by the submitter. It is build tested (allmodconfig with W=1, plus the same change on top of v7.1.6 built as a module for the affected BCM57504 host). The aborted reset path itself only runs when the firmware fails to return from a reset, which could not be reproduced on demand. Fixes: 004b5008016a ("eth: bnxt: remove most dependencies on RTNL") Cc: stable@vger.kernel.org Signed-off-by: Bryan Cochrane Link: https://patch.msgid.link/20261110044235.204386-1-bcochrane@google.com Signed-off-by: Jakub Kicinski [ bcochrane: backport to 6.18.y: 6.18 lacks bnxt_lock_sp() and bnxt_unlock_sp(), so keep the existing inline BNXT_STATE_IN_SP_TASK + netdev_lock()/netdev_unlock() on the VF branch of bnxt_fw_reset() while using the existing bnxt_rtnl_lock_sp() / bnxt_rtnl_unlock_sp() on PFs. ] Signed-off-by: Bryan Cochrane Signed-off-by: Sasha Levin --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 414da981a3e5b..51c144584d240 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -14567,8 +14567,12 @@ static int bnxt_get_registered_vfs(struct bnxt *bp) void bnxt_fw_reset(struct bnxt *bp) { bnxt_ulp_stop(bp); - clear_bit(BNXT_STATE_IN_SP_TASK, &bp->state); - netdev_lock(bp->dev); + if (BNXT_PF(bp)) { + bnxt_rtnl_lock_sp(bp); + } else { + clear_bit(BNXT_STATE_IN_SP_TASK, &bp->state); + netdev_lock(bp->dev); + } if (test_bit(BNXT_STATE_OPEN, &bp->state) && !test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) { struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; @@ -14614,8 +14618,12 @@ void bnxt_fw_reset(struct bnxt *bp) bnxt_queue_fw_reset_work(bp, tmo); } fw_reset_exit: - set_bit(BNXT_STATE_IN_SP_TASK, &bp->state); - netdev_unlock(bp->dev); + if (BNXT_PF(bp)) { + bnxt_rtnl_unlock_sp(bp); + } else { + set_bit(BNXT_STATE_IN_SP_TASK, &bp->state); + netdev_unlock(bp->dev); + } } static void bnxt_chk_missed_irq(struct bnxt *bp) @@ -15268,9 +15276,8 @@ static void bnxt_fw_reset_task(struct work_struct *work) bp->fw_reset_timestamp = jiffies; netdev_lock(bp->dev); if (test_bit(BNXT_STATE_ABORT_ERR, &bp->state)) { - bnxt_fw_reset_abort(bp, rc); netdev_unlock(bp->dev); - goto ulp_start; + goto fw_reset_abort; } bnxt_fw_reset_close(bp); if (bp->fw_cap & BNXT_FW_CAP_ERR_RECOVER_RELOAD) { @@ -15403,9 +15410,11 @@ static void bnxt_fw_reset_task(struct work_struct *work) netdev_err(bp->dev, "fw_health_status 0x%x\n", sts); } fw_reset_abort: + rtnl_lock(); netdev_lock(bp->dev); bnxt_fw_reset_abort(bp, rc); netdev_unlock(bp->dev); + rtnl_unlock(); ulp_start: if (!rc) bnxt_ulp_start(bp); -- 2.53.0