1 From 079bfe441b274a8c06474be82e4ccc88599a5e0e Mon Sep 17 00:00:00 2001
2 From: Christian Marangi <ansuelsmth@gmail.com>
3 Date: Tue, 16 Apr 2024 16:08:46 +0200
4 Subject: [PATCH 2/6] nss_dp_switchdev: correctly unregister notifier on
7 Correctly unregister notifier on dp_remove to fix kernel panic on system
10 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
12 include/nss_dp_dev.h | 1 +
13 nss_dp_main.c | 4 ++++
14 nss_dp_switchdev.c | 13 +++++++++++++
15 3 files changed, 18 insertions(+)
17 --- a/include/nss_dp_dev.h
18 +++ b/include/nss_dp_dev.h
19 @@ -312,6 +312,7 @@ void nss_dp_set_ethtool_ops(struct net_d
21 #ifdef CONFIG_NET_SWITCHDEV
22 void nss_dp_switchdev_setup(struct net_device *dev);
23 +void nss_dp_switchdev_remove(struct net_device *dev);
24 bool nss_dp_is_phy_dev(struct net_device *dev);
29 @@ -913,6 +913,10 @@ static int nss_dp_remove(struct platform
33 + #ifdef CONFIG_NET_SWITCHDEV
34 + nss_dp_switchdev_remove(dp_priv->netdev);
37 dp_ops = dp_priv->data_plane_ops;
38 hal_ops = dp_priv->gmac_hal_ops;
40 --- a/nss_dp_switchdev.c
41 +++ b/nss_dp_switchdev.c
42 @@ -635,4 +635,17 @@ void nss_dp_switchdev_setup(struct net_d
44 switch_init_done = true;
47 +void nss_dp_switchdev_remove(struct net_device *dev)
49 + if (!switch_init_done)
52 + if (nss_dp_sw_ev_nb)
53 + unregister_switchdev_notifier(nss_dp_sw_ev_nb);
55 + unregister_switchdev_blocking_notifier(&nss_dp_switchdev_notifier);
57 + switch_init_done = false;