aboutsummaryrefslogtreecommitdiff
path: root/package/kernel/qca-nss-dp/patches/0011-02-nss_dp_switchdev-correctly-unregister-notifier-on-dp.patch
blob: 8379fcf20cc1afaf3ff577f7d95da2287d257321 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
From 079bfe441b274a8c06474be82e4ccc88599a5e0e Mon Sep 17 00:00:00 2001
From: Christian Marangi <ansuelsmth@gmail.com>
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 <ansuelsmth@gmail.com>
---
 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