kernel: add at803x fix for sgmii mode
[lede.git] / target / linux / generic / patches-3.18 / 132-mips_inline_dma_ops.patch
index f603db785414f4953657a0bc9aa60007053f3b05..8795bde0bd3accf10b35b808a8eb9aaafe8f20c5 100644 (file)
@@ -1,6 +1,33 @@
+From 2c58080407554e1bac8fd50d23cb02420524caed Mon Sep 17 00:00:00 2001
+From: Felix Fietkau <nbd@openwrt.org>
+Date: Mon, 12 Aug 2013 12:50:22 +0200
+Subject: [PATCH] MIPS: partially inline dma ops
+
+Several DMA ops are no-op on many platforms, and the indirection through
+the mips_dma_map_ops function table is causing the compiler to emit
+unnecessary code.
+
+Inlining visibly improves network performance in my tests (on a 24Kc
+based system), and also slightly reduces code size of a few drivers.
+
+Signed-off-by: Felix Fietkau <nbd@openwrt.org>
+---
+ arch/mips/Kconfig                   |   4 +
+ arch/mips/include/asm/dma-mapping.h | 360 +++++++++++++++++++++++++++++++++++-
+ arch/mips/mm/dma-default.c          | 163 ++--------------
+ 3 files changed, 373 insertions(+), 154 deletions(-)
+
 --- a/arch/mips/Kconfig
 +++ b/arch/mips/Kconfig
-@@ -1705,6 +1705,9 @@ config MIPS_MALTA_PM
+@@ -1450,6 +1450,7 @@ config CPU_CAVIUM_OCTEON
+       select CPU_SUPPORTS_HUGEPAGES
+       select USB_EHCI_BIG_ENDIAN_MMIO
+       select MIPS_L1_CACHE_SHIFT_7
++      select SYS_HAS_DMA_OPS
+       help
+         The Cavium Octeon processor is a highly integrated chip containing
+         many ethernet hardware widgets for networking tasks. The processor
+@@ -1705,6 +1706,9 @@ config MIPS_MALTA_PM
        bool
        default y
  
  }
  
  static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
-@@ -30,12 +73,312 @@ static inline bool dma_capable(struct de
+@@ -30,12 +73,304 @@ static inline bool dma_capable(struct de
  
  static inline void dma_mark_clean(void *addr, size_t size) {}
  
 +
 +#define dma_mmap_coherent(d, v, c, h, s) dma_mmap_attrs(d, v, c, h, s, NULL)
 +
-+static inline int dma_mmap_writecombine(struct device *dev, struct vm_area_struct *vma,
-+                    void *cpu_addr, dma_addr_t dma_addr, size_t size)
-+{
-+      DEFINE_DMA_ATTRS(attrs);
-+      dma_set_attr(DMA_ATTR_WRITE_COMBINE, &attrs);
-+      return dma_mmap_attrs(dev, vma, cpu_addr, dma_addr, size, &attrs);
-+}
-+
 +int
 +dma_common_get_sgtable(struct device *dev, struct sg_table *sgt,
 +                     void *cpu_addr, dma_addr_t dma_addr, size_t size);
  }
  
  static inline int dma_mapping_error(struct device *dev, u64 mask)
-@@ -43,7 +386,9 @@ static inline int dma_mapping_error(stru
+@@ -43,7 +378,9 @@ static inline int dma_mapping_error(stru
        struct dma_map_ops *ops = get_dma_ops(dev);
  
        debug_dma_mapping_error(dev, mask);
  }
  
  static inline int
-@@ -74,7 +419,11 @@ static inline void *dma_alloc_attrs(stru
+@@ -54,7 +391,7 @@ dma_set_mask(struct device *dev, u64 mas
+       if(!dev->dma_mask || !dma_supported(dev, mask))
+               return -EIO;
+-      if (ops->set_dma_mask)
++      if (ops && ops->set_dma_mask)
+               return ops->set_dma_mask(dev, mask);
+       *dev->dma_mask = mask;
+@@ -74,7 +411,11 @@ static inline void *dma_alloc_attrs(stru
        void *ret;
        struct dma_map_ops *ops = get_dma_ops(dev);
  
  
        debug_dma_alloc_coherent(dev, size, *dma_handle, ret);
  
-@@ -89,7 +438,10 @@ static inline void dma_free_attrs(struct
+@@ -89,7 +430,10 @@ static inline void dma_free_attrs(struct
  {
        struct dma_map_ops *ops = get_dma_ops(dev);