mediatek: enable ramdisk support by default
[openwrt/openwrt.git] / target / linux / mvebu / patches-4.4 / 047-net-mvneta-Fix-spinlock-usage.patch
1 From: Gregory CLEMENT <gregory.clement@free-electrons.com>
2 Date: Sat, 12 Mar 2016 18:44:17 +0100
3 Subject: [PATCH] net: mvneta: Fix spinlock usage
4
5 In the previous patch, the spinlock was not initialized. While it didn't
6 cause any trouble yet it could be a problem to use it uninitialized.
7
8 The most annoying part was the critical section protected by the spinlock
9 in mvneta_stop(). Some of the functions could sleep as pointed when
10 activated CONFIG_DEBUG_ATOMIC_SLEEP. Actually, in mvneta_stop() we only
11 need to protect the is_stopped flagged, indeed the code of the notifier
12 for CPU online is protected by the same spinlock, so when we get the
13 lock, the notifer work is done.
14
15 Reported-by: Patrick Uiterwijk <patrick@puiterwijk.org>
16 Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
17 Signed-off-by: David S. Miller <davem@davemloft.net>
18 ---
19
20 --- a/drivers/net/ethernet/marvell/mvneta.c
21 +++ b/drivers/net/ethernet/marvell/mvneta.c
22 @@ -3488,17 +3488,17 @@ static int mvneta_stop(struct net_device
23 struct mvneta_port *pp = netdev_priv(dev);
24
25 /* Inform that we are stopping so we don't want to setup the
26 - * driver for new CPUs in the notifiers
27 + * driver for new CPUs in the notifiers. The code of the
28 + * notifier for CPU online is protected by the same spinlock,
29 + * so when we get the lock, the notifer work is done.
30 */
31 spin_lock(&pp->lock);
32 pp->is_stopped = true;
33 + spin_unlock(&pp->lock);
34 +
35 mvneta_stop_dev(pp);
36 mvneta_mdio_remove(pp);
37 unregister_cpu_notifier(&pp->cpu_notifier);
38 - /* Now that the notifier are unregistered, we can release le
39 - * lock
40 - */
41 - spin_unlock(&pp->lock);
42 on_each_cpu(mvneta_percpu_disable, pp, true);
43 free_percpu_irq(dev->irq, pp->ports);
44 mvneta_cleanup_rxqs(pp);
45 @@ -4031,6 +4031,7 @@ static int mvneta_probe(struct platform_
46 dev->ethtool_ops = &mvneta_eth_tool_ops;
47
48 pp = netdev_priv(dev);
49 + spin_lock_init(&pp->lock);
50 pp->phy_node = phy_node;
51 pp->phy_interface = phy_mode;
52