From 079bfe441b274a8c06474be82e4ccc88599a5e0e Mon Sep 17 00:00:00 2001 From: Christian Marangi Date: Tue, 16 Apr 2024 16:08:46 +0200 Subject: [PATCH 2/6] nss_dp_switchdev: correctly unregister notifier on dp_remove Correctly unregister notifier on dp_remove to fix kernel panic on system reboot. Signed-off-by: Christian Marangi --- include/nss_dp_dev.h | 1 + nss_dp_main.c | 4 ++++ nss_dp_switchdev.c | 13 +++++++++++++ 3 files changed, 18 insertions(+) --- a/include/nss_dp_dev.h +++ b/include/nss_dp_dev.h @@ -349,6 +349,7 @@ void nss_dp_set_ethtool_ops(struct net_d */ #ifdef CONFIG_NET_SWITCHDEV void nss_dp_switchdev_setup(struct net_device *dev); +void nss_dp_switchdev_remove(struct net_device *dev); bool nss_dp_is_phy_dev(struct net_device *dev); #endif --- a/nss_dp_main.c +++ b/nss_dp_main.c @@ -972,6 +972,10 @@ static int nss_dp_remove(struct platform if (!dp_priv) continue; + #ifdef CONFIG_NET_SWITCHDEV + nss_dp_switchdev_remove(dp_priv->netdev); + #endif + dp_ops = dp_priv->data_plane_ops; hal_ops = dp_priv->gmac_hal_ops; --- a/nss_dp_switchdev.c +++ b/nss_dp_switchdev.c @@ -648,4 +648,17 @@ void nss_dp_switchdev_setup(struct net_d switch_init_done = true; } + +void nss_dp_switchdev_remove(struct net_device *dev) +{ + if (!switch_init_done) + return; + + if (nss_dp_sw_ev_nb) + unregister_switchdev_notifier(nss_dp_sw_ev_nb); + + unregister_switchdev_blocking_notifier(&nss_dp_switchdev_notifier); + + switch_init_done = false; +} #endif