0095-net-next-mediatek-add-IRQ-locking.patch 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. From dd08d1ac4cfc86fbea5ee207b9615922ede88ec6 Mon Sep 17 00:00:00 2001
  2. From: John Crispin <john@phrozen.org>
  3. Date: Tue, 17 May 2016 06:01:45 +0200
  4. Subject: [PATCH 095/102] net-next: mediatek: add IRQ locking
  5. The code that enables and disables IRQs is missing proper locking. After
  6. adding the IRQ separation patch and routing the putting the RX and TX IRQs
  7. on different cores we experienced IRQ stalls. Fix this by adding proper
  8. locking. We use a dedicated lock to reduce the latency if the IRQ code.
  9. Otherwise it might wait for bottom code to finish before reenabling or
  10. disabling IRQs.
  11. Signed-off-by: Sean Wang <keyhaede@gmail.com>
  12. Signed-off-by: John Crispin <john@phrozen.org>
  13. ---
  14. drivers/net/ethernet/mediatek/mtk_eth_soc.c | 7 +++++++
  15. drivers/net/ethernet/mediatek/mtk_eth_soc.h | 1 +
  16. 2 files changed, 8 insertions(+)
  17. --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
  18. +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
  19. @@ -331,18 +331,24 @@ static void mtk_mdio_cleanup(struct mtk_
  20. static inline void mtk_irq_disable(struct mtk_eth *eth, u32 mask)
  21. {
  22. + unsigned long flags;
  23. u32 val;
  24. + spin_lock_irqsave(&eth->irq_lock, flags);
  25. val = mtk_r32(eth, MTK_QDMA_INT_MASK);
  26. mtk_w32(eth, val & ~mask, MTK_QDMA_INT_MASK);
  27. + spin_unlock_irqrestore(&eth->irq_lock, flags);
  28. }
  29. static inline void mtk_irq_enable(struct mtk_eth *eth, u32 mask)
  30. {
  31. + unsigned long flags;
  32. u32 val;
  33. + spin_lock_irqsave(&eth->irq_lock, flags);
  34. val = mtk_r32(eth, MTK_QDMA_INT_MASK);
  35. mtk_w32(eth, val | mask, MTK_QDMA_INT_MASK);
  36. + spin_unlock_irqrestore(&eth->irq_lock, flags);
  37. }
  38. static int mtk_set_mac_address(struct net_device *dev, void *p)
  39. @@ -1771,6 +1777,7 @@ static int mtk_probe(struct platform_dev
  40. return -EADDRNOTAVAIL;
  41. spin_lock_init(&eth->page_lock);
  42. + spin_lock_init(&eth->irq_lock);
  43. eth->ethsys = syscon_regmap_lookup_by_phandle(pdev->dev.of_node,
  44. "mediatek,ethsys");
  45. --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
  46. +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
  47. @@ -373,6 +373,7 @@ struct mtk_eth {
  48. void __iomem *base;
  49. struct reset_control *rstc;
  50. spinlock_t page_lock;
  51. + spinlock_t irq_lock;
  52. struct net_device dummy_dev;
  53. struct net_device *netdev[MTK_MAX_DEVS];
  54. struct mtk_mac *mac[MTK_MAX_DEVS];