@@ -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>
@@ -131,6 +132,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 */
@@ -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);
@@ -383,6 +405,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;
@@ -447,6 +480,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));
@@ -498,6 +535,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;
}
@@ -508,6 +546,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);
}
BugLink: https://bugs.launchpad.net/bugs/2172611 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(+)