e0a47cfca00332f2c11c292f78a2dd460871f345
[openwrt/staging/blocktrron.git] /
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
5 dp_remove
6
7 Correctly unregister notifier on dp_remove to fix kernel panic on system
8 reboot.
9
10 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
11 ---
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(+)
16
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
20 */
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);
25 #endif
26
27 --- a/nss_dp_main.c
28 +++ b/nss_dp_main.c
29 @@ -913,6 +913,10 @@ static int nss_dp_remove(struct platform
30 if (!dp_priv)
31 continue;
32
33 + #ifdef CONFIG_NET_SWITCHDEV
34 + nss_dp_switchdev_remove(dp_priv->netdev);
35 + #endif
36 +
37 dp_ops = dp_priv->data_plane_ops;
38 hal_ops = dp_priv->gmac_hal_ops;
39
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
43
44 switch_init_done = true;
45 }
46 +
47 +void nss_dp_switchdev_remove(struct net_device *dev)
48 +{
49 + if (!switch_init_done)
50 + return;
51 +
52 + if (nss_dp_sw_ev_nb)
53 + unregister_switchdev_notifier(nss_dp_sw_ev_nb);
54 +
55 + unregister_switchdev_blocking_notifier(&nss_dp_switchdev_notifier);
56 +
57 + switch_init_done = false;
58 +}
59 #endif