kernel: update 4.9 to 4.9.47
[openwrt/openwrt.git] / target / linux / mediatek / patches-4.9 / 0061-eth-up_down_lock.patch
1 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
2 +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
3 @@ -1904,12 +1904,16 @@ static int mtk_open(struct net_device *d
4 struct mtk_mac *mac = netdev_priv(dev);
5 struct mtk_eth *eth = mac->hw;
6
7 + spin_lock(&eth->iface_lock);
8 +
9 /* we run 2 netdevs on the same dma ring so we only bring it up once */
10 if (!atomic_read(&eth->dma_refcnt)) {
11 int err = mtk_start_dma(eth);
12
13 - if (err)
14 + if (err) {
15 + spin_unlock(&eth->iface_lock);
16 return err;
17 + }
18
19 napi_enable(&eth->tx_napi);
20 napi_enable(&eth->rx_napi);
21 @@ -1923,6 +1927,7 @@ static int mtk_open(struct net_device *d
22
23 phy_start(dev->phydev);
24 netif_start_queue(dev);
25 + spin_unlock(&eth->iface_lock);
26
27 return 0;
28 }
29 @@ -1955,12 +1960,15 @@ static int mtk_stop(struct net_device *d
30 struct mtk_mac *mac = netdev_priv(dev);
31 struct mtk_eth *eth = mac->hw;
32
33 + spin_lock(&eth->iface_lock);
34 netif_tx_disable(dev);
35 phy_stop(dev->phydev);
36
37 /* only shutdown DMA if this is the last user */
38 - if (!atomic_dec_and_test(&eth->dma_refcnt))
39 + if (!atomic_dec_and_test(&eth->dma_refcnt)) {
40 + spin_unlock(&eth->iface_lock);
41 return 0;
42 + }
43
44 del_timer(&eth->napi_timer);
45
46 @@ -1974,6 +1982,8 @@ static int mtk_stop(struct net_device *d
47
48 mtk_dma_free(eth);
49
50 + spin_unlock(&eth->iface_lock);
51 +
52 return 0;
53 }
54
55 @@ -2623,6 +2633,7 @@ static int mtk_probe(struct platform_dev
56 if (IS_ERR(eth->base))
57 return PTR_ERR(eth->base);
58
59 + spin_lock_init(&eth->iface_lock);
60 spin_lock_init(&eth->page_lock);
61 spin_lock_init(&eth->tx_irq_lock);
62 spin_lock_init(&eth->rx_irq_lock);
63 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
64 +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
65 @@ -573,6 +573,7 @@ struct mtk_rx_ring {
66 struct mtk_eth {
67 struct device *dev;
68 void __iomem *base;
69 + spinlock_t iface_lock;
70 spinlock_t page_lock;
71 spinlock_t tx_irq_lock;
72 spinlock_t rx_irq_lock;