mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chris Babroski <cbabroski@nvidia.com>
To: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Cc: <andrew+netdev@lunn.ch>, <davem@davemloft.net>,
	<edumazet@kernel.org>, <kuba@kernel.org>, <pabeni@redhat.com>,
	<davthompson@nvidia.com>, <cbabroski@nvidia.com>
Subject: [PATCH net-next v1 2/2] mlxbf_gige: disable MAC after kernel panic
Date: Fri, 20 Nov 2026 15:24:03 -0500	[thread overview]
Message-ID: <8fa3f8fcbdc45e58b815261d6c2c1decd884f5d1.1795206150.git.cbabroski@nvidia.com> (raw)
In-Reply-To: <cover.1795206150.git.cbabroski@nvidia.com>

After a kernel panic the MAC continues to receive packets into the RX
FIFO even though the driver can no longer process them. By default, the
MAC HW is designed to repeatedly send pause frames to its link partner
when the RX FIFO is full. The internal Ethernet switch on BlueField that
is connected to this port is also designed to stop traffic on all ports
when it receives a high number of continuous pause frames from one of
the ports.

What this means is that when the kernel panics on BlueField, it is
possible to reproduce a scenario under steady and high network load
where the network becomes inaccessible for other devices connected to
the 3-port switch, namely the OOB host and DPU-BMC.

Register a panic notifier at highest priority that disables MAC RX and
clears the RX FIFO to ensure that the MAC can no longer receive packets
or send pause frames.

Signed-off-by: Chris Babroski <cbabroski@nvidia.com>
---
 .../ethernet/mellanox/mlxbf_gige/mlxbf_gige.h |  2 +
 .../mellanox/mlxbf_gige/mlxbf_gige_main.c     | 39 +++++++++++++++++++
 2 files changed, 41 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige.h b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige.h
index e7777700ee18..c63bdfae4344 100644
--- a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige.h
+++ b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige.h
@@ -13,6 +13,7 @@
 #include <linux/io-64-nonatomic-lo-hi.h>
 #include <linux/irqreturn.h>
 #include <linux/netdevice.h>
+#include <linux/notifier.h>
 #include <linux/irq.h>
 #include <linux/phy.h>
 
@@ -130,6 +131,7 @@ struct mlxbf_gige {
 	u8 hw_version;
 	struct mlxbf_gige_mdio_gw *mdio_gw;
 	int prev_speed;
+	struct notifier_block panic_nb;
 };
 
 /* Rx Work Queue Element definitions */
diff --git a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c
index d1f8a72cae53..76da71108345 100644
--- a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c
+++ b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c
@@ -12,6 +12,7 @@
 #include <linux/interrupt.h>
 #include <linux/iopoll.h>
 #include <linux/module.h>
+#include <linux/panic_notifier.h>
 #include <linux/phy.h>
 #include <linux/platform_device.h>
 #include <linux/rtnetlink.h>
@@ -127,6 +128,27 @@ static int mlxbf_gige_clean_port(struct mlxbf_gige *priv)
 	return err;
 }
 
+static void mlxbf_gige_disable_port(struct mlxbf_gige *priv)
+{
+	u64 control;
+
+	/* Disable RX DMA */
+	control = readq(priv->base + MLXBF_GIGE_RX_DMA);
+	control &= ~MLXBF_GIGE_RX_DMA_EN;
+	writeq(control, priv->base + MLXBF_GIGE_RX_DMA);
+
+	/* Disable port */
+	control = readq(priv->base + MLXBF_GIGE_CONTROL);
+	control &= ~MLXBF_GIGE_CONTROL_PORT_EN;
+	writeq(control, priv->base + MLXBF_GIGE_CONTROL);
+
+	/* Disable interrupts */
+	writeq(0, priv->base + MLXBF_GIGE_INT_EN);
+
+	/* Ensure completion of disable writes before cleaning the port */
+	mb();
+}
+
 static int mlxbf_gige_open(struct net_device *netdev)
 {
 	struct mlxbf_gige *priv = netdev_priv(netdev);
@@ -382,6 +404,17 @@ static struct mlxbf_gige_link_cfg mlxbf_gige_link_cfgs[] = {
 	}
 };
 
+static int mlxbf_gige_on_panic(struct notifier_block *nb,
+			       unsigned long action, void *data)
+{
+	struct mlxbf_gige *priv;
+
+	priv = container_of(nb, struct mlxbf_gige, panic_nb);
+	mlxbf_gige_disable_port(priv);
+	mlxbf_gige_clean_port(priv);
+	return NOTIFY_DONE;
+}
+
 static int mlxbf_gige_probe(struct platform_device *pdev)
 {
 	struct phy_device *phydev;
@@ -446,6 +479,10 @@ static int mlxbf_gige_probe(struct platform_device *pdev)
 	/* Write initial MAC address to hardware */
 	mlxbf_gige_initial_mac(priv);
 
+	priv->panic_nb.priority = INT_MAX;
+	priv->panic_nb.notifier_call = mlxbf_gige_on_panic;
+	atomic_notifier_chain_register(&panic_notifier_list, &priv->panic_nb);
+
 	err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
 	if (err) {
 		dev_err(&pdev->dev, "DMA configuration failed: %pe\n", ERR_PTR(err));
@@ -497,6 +534,7 @@ static int mlxbf_gige_probe(struct platform_device *pdev)
 	return 0;
 
 out:
+	atomic_notifier_chain_unregister(&panic_notifier_list, &priv->panic_nb);
 	mlxbf_gige_mdio_remove(priv);
 	return err;
 }
@@ -507,6 +545,7 @@ static void mlxbf_gige_remove(struct platform_device *pdev)
 
 	unregister_netdev(priv->netdev);
 	phy_disconnect(priv->netdev->phydev);
+	atomic_notifier_chain_unregister(&panic_notifier_list, &priv->panic_nb);
 	mlxbf_gige_mdio_remove(priv);
 	platform_set_drvdata(pdev, NULL);
 }
-- 
2.34.1


  parent reply	other threads:[~2026-11-20 20:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20 20:24 [PATCH net-next v1 0/2] mlxbf_gige: disable MAC after panic Chris Babroski
2026-11-20 20:24 ` [PATCH net-next v1 1/2] mlxbf_gige: protect against MAC disable during TX Chris Babroski
2026-11-20 20:24 ` Chris Babroski [this message]
2026-11-20 20:27 ` [PATCH net-next v1 0/2] mlxbf_gige: disable MAC after panic netdev-bot+sinfo
2026-11-20 20:43   ` Chris Babroski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8fa3f8fcbdc45e58b815261d6c2c1decd884f5d1.1795206150.git.cbabroski@nvidia.com \
    --to=cbabroski@nvidia.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=davthompson@nvidia.com \
    --cc=edumazet@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®