kernel: bump 5.4 to 5.4.24
[openwrt/staging/wigyori.git] / target / linux / ipq806x / patches-5.4 / 701-stmmac-fix-notifier-registration.patch
1 From 474a31e13a4e9749fb3ee55794d69d0f17ee0998 Mon Sep 17 00:00:00 2001
2 From: Aaro Koskinen <aaro.koskinen@nokia.com>
3 Date: Wed, 26 Feb 2020 18:49:01 +0200
4 Subject: net: stmmac: fix notifier registration
5
6 We cannot register the same netdev notifier multiple times when probing
7 stmmac devices. Register the notifier only once in module init, and also
8 make debugfs creation/deletion safe against simultaneous notifier call.
9
10 Fixes: 481a7d154cbb ("stmmac: debugfs entry name is not be changed when udev rename device name.")
11 Signed-off-by: Aaro Koskinen <aaro.koskinen@nokia.com>
12 Signed-off-by: David S. Miller <davem@davemloft.net>
13 ---
14 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 13 ++++++++-----
15 1 file changed, 8 insertions(+), 5 deletions(-)
16
17 (limited to 'drivers/net/ethernet/stmicro/stmmac')
18
19 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
20 +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
21 @@ -4208,6 +4208,8 @@ static void stmmac_init_fs(struct net_de
22 {
23 struct stmmac_priv *priv = netdev_priv(dev);
24
25 + rtnl_lock();
26 +
27 /* Create per netdev entries */
28 priv->dbgfs_dir = debugfs_create_dir(dev->name, stmmac_fs_dir);
29
30 @@ -4219,14 +4221,13 @@ static void stmmac_init_fs(struct net_de
31 debugfs_create_file("dma_cap", 0444, priv->dbgfs_dir, dev,
32 &stmmac_dma_cap_fops);
33
34 - register_netdevice_notifier(&stmmac_notifier);
35 + rtnl_unlock();
36 }
37
38 static void stmmac_exit_fs(struct net_device *dev)
39 {
40 struct stmmac_priv *priv = netdev_priv(dev);
41
42 - unregister_netdevice_notifier(&stmmac_notifier);
43 debugfs_remove_recursive(priv->dbgfs_dir);
44 }
45 #endif /* CONFIG_DEBUG_FS */
46 @@ -4728,14 +4729,14 @@ int stmmac_dvr_remove(struct device *dev
47
48 netdev_info(priv->dev, "%s: removing driver", __func__);
49
50 -#ifdef CONFIG_DEBUG_FS
51 - stmmac_exit_fs(ndev);
52 -#endif
53 stmmac_stop_all_dma(priv);
54
55 stmmac_mac_set(priv, priv->ioaddr, false);
56 netif_carrier_off(ndev);
57 unregister_netdev(ndev);
58 +#ifdef CONFIG_DEBUG_FS
59 + stmmac_exit_fs(ndev);
60 +#endif
61 phylink_destroy(priv->phylink);
62 if (priv->plat->stmmac_rst)
63 reset_control_assert(priv->plat->stmmac_rst);
64 @@ -4955,6 +4956,7 @@ static int __init stmmac_init(void)
65 /* Create debugfs main directory if it doesn't exist yet */
66 if (!stmmac_fs_dir)
67 stmmac_fs_dir = debugfs_create_dir(STMMAC_RESOURCE_NAME, NULL);
68 + register_netdevice_notifier(&stmmac_notifier);
69 #endif
70
71 return 0;
72 @@ -4963,6 +4965,7 @@ static int __init stmmac_init(void)
73 static void __exit stmmac_exit(void)
74 {
75 #ifdef CONFIG_DEBUG_FS
76 + unregister_netdevice_notifier(&stmmac_notifier);
77 debugfs_remove_recursive(stmmac_fs_dir);
78 #endif
79 }