1 From 4ff9304355036d4a00bdf0e47e869fc770ba1cc5 Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Wed, 20 Apr 2016 16:18:07 +0200
4 Subject: [PATCH 87/91] net-next: mediatek: add IRQ locking
6 The code that enables and disables IRQs is missing proper locking. After
7 adding the IRQ separation patch and routing the putting the RX and TX IRQs
8 on different cores we experienced IRQ stalls. Fix this by adding proper
9 locking. We use a dedicated lock to reduce the latency if the IRQ code.
10 Otherwise it might wait for bottom code to finish before reenabling or
13 Signed-off-by: John Crispin <blogic@openwrt.org>
15 drivers/net/ethernet/mediatek/mtk_eth_soc.c | 7 +++++++
16 drivers/net/ethernet/mediatek/mtk_eth_soc.h | 1 +
17 2 files changed, 8 insertions(+)
19 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
20 +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
21 @@ -316,22 +316,28 @@ static void mtk_mdio_cleanup(struct mtk_
23 static inline void mtk_irq_disable(struct mtk_eth *eth, u32 mask)
25 + unsigned long flags;
28 + spin_lock_irqsave(ð->irq_lock, flags);
29 val = mtk_r32(eth, MTK_QDMA_INT_MASK);
30 mtk_w32(eth, val & ~mask, MTK_QDMA_INT_MASK);
32 mtk_r32(eth, MTK_QDMA_INT_MASK);
33 + spin_unlock_irqrestore(ð->irq_lock, flags);
36 static inline void mtk_irq_enable(struct mtk_eth *eth, u32 mask)
38 + unsigned long flags;
41 + spin_lock_irqsave(ð->irq_lock, flags);
42 val = mtk_r32(eth, MTK_QDMA_INT_MASK);
43 mtk_w32(eth, val | mask, MTK_QDMA_INT_MASK);
45 mtk_r32(eth, MTK_QDMA_INT_MASK);
46 + spin_unlock_irqrestore(ð->irq_lock, flags);
49 static int mtk_set_mac_address(struct net_device *dev, void *p)
50 @@ -1752,6 +1758,7 @@ static int mtk_probe(struct platform_dev
51 return -EADDRNOTAVAIL;
53 spin_lock_init(ð->page_lock);
54 + spin_lock_init(ð->irq_lock);
56 eth->ethsys = syscon_regmap_lookup_by_phandle(pdev->dev.of_node,
58 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
59 +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
60 @@ -372,6 +372,7 @@ struct mtk_eth {
62 struct reset_control *rstc;
64 + spinlock_t irq_lock;
65 struct net_device dummy_dev;
66 struct net_device *netdev[MTK_MAX_DEVS];
67 struct mtk_mac *mac[MTK_MAX_DEVS];