MIPS: remove unnecessary platform dma helper functions
PATCH 1/2 MIPS: remove unnecessary platform dma helper functions
--- arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h | 12 ------------ arch/mips/include/asm/mach-generic/dma-coherence.h | 10 ---------- arch/mips/include/asm/mach-ip27/dma-coherence.h | 10 ---------- arch/mips/include/asm/mach-ip32/dma-coherence.h | 11 ----------- arch/mips/include/asm/mach-jazz/dma-coherence.h | 10 ---------- arch/mips/include/asm/mach-loongson/dma-coherence.h | 10 ---------- arch/mips/include/asm/mach-powertv/dma-coherence.h | 10 ---------- arch/mips/mm/dma-default.c | 4 +--- 8 files changed, 1 insertion(+), 76 deletions(-)
arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h +0 -12
@@ -52,23 +52,11 @@ static inline int plat_dma_supported(struct device *dev, u64 mask)return 0 ; } -static inline void plat_extra_sync_for_device (struct device *dev) -{ -BUG (); -} -static inline int plat_device_is_coherent (struct device *dev) {return 1 ; } -static inline int plat_dma_mapping_error (struct device *dev, -dma_addr_t dma_addr) -{ -BUG (); -return 0 ; -} -dma_addr_t phys_to_dma (struct device *dev,phys_addr_t paddr);phys_addr_t dma_to_phys (struct device *dev,dma_addr_t daddr);
arch/mips/include/asm/mach-generic/dma-coherence.h +0 -10
@@ -47,16 +47,6 @@ static inline int plat_dma_supported(struct device *dev, u64 mask)return 1 ; } -static inline void plat_extra_sync_for_device (struct device *dev) -{ -} - -static inline int plat_dma_mapping_error (struct device *dev, -dma_addr_t dma_addr) -{ -return 0 ; -} -static inline int plat_device_is_coherent (struct device *dev) {#ifdef CONFIG_DMA_COHERENT
arch/mips/include/asm/mach-ip27/dma-coherence.h +0 -10
@@ -58,16 +58,6 @@ static inline int plat_dma_supported(struct device *dev, u64 mask)return 1 ; } -static inline void plat_extra_sync_for_device (struct device *dev) -{ -} - -static inline int plat_dma_mapping_error (struct device *dev, -dma_addr_t dma_addr) -{ -return 0 ; -} -static inline int plat_device_is_coherent (struct device *dev) {return 1 ;/* IP27 non-cohernet mode is unsupported */
arch/mips/include/asm/mach-ip32/dma-coherence.h +0 -11
@@ -80,17 +80,6 @@ static inline int plat_dma_supported(struct device *dev, u64 mask)return 1 ; } -static inline void plat_extra_sync_for_device (struct device *dev) -{ -return ; -} - -static inline int plat_dma_mapping_error (struct device *dev, -dma_addr_t dma_addr) -{ -return 0 ; -} -static inline int plat_device_is_coherent (struct device *dev) {return 0 ;/* IP32 is non-cohernet */
arch/mips/include/asm/mach-jazz/dma-coherence.h +0 -10
@@ -48,16 +48,6 @@ static inline int plat_dma_supported(struct device *dev, u64 mask)return 1 ; } -static inline void plat_extra_sync_for_device (struct device *dev) -{ -} - -static inline int plat_dma_mapping_error (struct device *dev, -dma_addr_t dma_addr) -{ -return 0 ; -} -static inline int plat_device_is_coherent (struct device *dev) {return 0 ;
arch/mips/include/asm/mach-loongson/dma-coherence.h +0 -10
@@ -53,16 +53,6 @@ static inline int plat_dma_supported(struct device *dev, u64 mask)return 1 ; } -static inline void plat_extra_sync_for_device (struct device *dev) -{ -} - -static inline int plat_dma_mapping_error (struct device *dev, -dma_addr_t dma_addr) -{ -return 0 ; -} -static inline int plat_device_is_coherent (struct device *dev) {return 0 ;
arch/mips/include/asm/mach-powertv/dma-coherence.h +0 -10
@@ -99,16 +99,6 @@ static inline int plat_dma_supported(struct device *dev, u64 mask)return 1 ; } -static inline void plat_extra_sync_for_device (struct device *dev) -{ -} - -static inline int plat_dma_mapping_error (struct device *dev, -dma_addr_t dma_addr) -{ -return 0 ; -} -static inline int plat_device_is_coherent (struct device *dev) {return 0 ;
arch/mips/mm/dma-default.c +1 -3
@@ -292,7 +292,6 @@ static void mips_dma_sync_single_for_cpu(struct device *dev,static void mips_dma_sync_single_for_device (struct device *dev,dma_addr_t dma_handle,size_t size,enum dma_data_direction direction) { -plat_extra_sync_for_device (dev);if (!plat_device_is_coherent (dev))__dma_sync (dma_addr_to_page (dev, dma_handle), dma_handle & ~PAGE_MASK , size, direction);
@@ -326,7 +325,7 @@ static void mips_dma_sync_sg_for_device(struct device *dev,int mips_dma_mapping_error (struct device *dev,dma_addr_t dma_addr) { -return plat_dma_mapping_error (dev, dma_addr); +return 0 ; }int mips_dma_supported (struct device *dev,u64 mask)
@@ -339,7 +338,6 @@ void dma_cache_sync(struct device *dev, void *vaddr, size_t size, {BUG_ON (direction ==DMA_NONE ); -plat_extra_sync_for_device (dev);if (!plat_device_is_coherent (dev))__dma_sync_virtual (vaddr, size, direction); }
Signature · 1 line
1.8.0.2
PATCH 2/2 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.
--- arch/mips/Kconfig | 4 + arch/mips/include/asm/dma-mapping.h | 360 +++++++++++++++++++++++++++++++++++- arch/mips/mm/dma-default.c | 161 ++-------------- 3 files changed, 372 insertions(+), 153 deletions(-)
arch/mips/Kconfig +4 -0
@@ -1393,6 +1393,7 @@ config CPU_CAVIUM_OCTEON select LIBFDT select USE_OF select USB_EHCI_BIG_ENDIAN_MMIO + 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
@@ -1613,6 +1614,9 @@ config SYS_HAS_CPU_XLR config SYS_HAS_CPU_XLP bool +config SYS_HAS_DMA_OPS + bool + # # CPU may reorder R->R, R->W, W->R, W->W # Reordering beyond LL and SC is handled in WEAK_REORDERING_BEYOND_LLSC
arch/mips/include/asm/dma-mapping.h +355 -5
406 lines not on this page · raw message
arch/mips/mm/dma-default.c +13 -148
210 lines not on this page · raw message
Signature · 1 line
1.8.0.2
That's a mighty thin changelog there.
You are changing the semantics in the asm/mach-cavium-octeon/dma-coherence.h case.
Have you verified that all in-tree cases really are NOPs?
David Daney
Quoted 197 lines · Felix Fietkau
Signed-off-by Felix Fietkau <[email protected]>--- arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h | 12 ------------ arch/mips/include/asm/mach-generic/dma-coherence.h | 10 ---------- arch/mips/include/asm/mach-ip27/dma-coherence.h | 10 ---------- arch/mips/include/asm/mach-ip32/dma-coherence.h | 11 ----------- arch/mips/include/asm/mach-jazz/dma-coherence.h | 10 ---------- arch/mips/include/asm/mach-loongson/dma-coherence.h | 10 ---------- arch/mips/include/asm/mach-powertv/dma-coherence.h | 10 ---------- arch/mips/mm/dma-default.c | 4 +--- 8 files changed, 1 insertion(+), 76 deletions(-)arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h +0
-12@@ -52,23 +52,11 @@ static inline int plat_dma_supported(struct device *dev, u64 mask)return 0 ; } -static inline void plat_extra_sync_for_device (struct device *dev) -{ -BUG (); -} -static inline int plat_device_is_coherent (struct device *dev) {return 1 ; } -static inline int plat_dma_mapping_error (struct device *dev, -dma_addr_t dma_addr) -{ -BUG (); -return 0 ; -} -dma_addr_t phys_to_dma (struct device *dev,phys_addr_t paddr);phys_addr_t dma_to_phys (struct device *dev,dma_addr_t daddr);arch/mips/include/asm/mach-generic/dma-coherence.h +0
-10@@ -47,16 +47,6 @@ static inline int plat_dma_supported(struct device *dev, u64 mask)return 1 ; } -static inline void plat_extra_sync_for_device (struct device *dev) -{ -} - -static inline int plat_dma_mapping_error (struct device *dev, -dma_addr_t dma_addr) -{ -return 0 ; -} -static inline int plat_device_is_coherent (struct device *dev) {#ifdef CONFIG_DMA_COHERENT arch/mips/include/asm/mach-ip27/dma-coherence.h +0
-10@@ -58,16 +58,6 @@ static inline int plat_dma_supported(struct device *dev, u64 mask)return 1 ; } -static inline void plat_extra_sync_for_device (struct device *dev) -{ -} - -static inline int plat_dma_mapping_error (struct device *dev, -dma_addr_t dma_addr) -{ -return 0 ; -} -static inline int plat_device_is_coherent (struct device *dev) {return 1 ;/* IP27 non-cohernet mode is unsupported */ arch/mips/include/asm/mach-ip32/dma-coherence.h +0
-11@@ -80,17 +80,6 @@ static inline int plat_dma_supported(struct device *dev, u64 mask)return 1 ; } -static inline void plat_extra_sync_for_device (struct device *dev) -{ -return ; -} - -static inline int plat_dma_mapping_error (struct device *dev, -dma_addr_t dma_addr) -{ -return 0 ; -} -static inline int plat_device_is_coherent (struct device *dev) {return 0 ;/* IP32 is non-cohernet */ arch/mips/include/asm/mach-jazz/dma-coherence.h +0
-10@@ -48,16 +48,6 @@ static inline int plat_dma_supported(struct device *dev, u64 mask)return 1 ; } -static inline void plat_extra_sync_for_device (struct device *dev) -{ -} - -static inline int plat_dma_mapping_error (struct device *dev, -dma_addr_t dma_addr) -{ -return 0 ; -} -static inline int plat_device_is_coherent (struct device *dev) {return 0 ;arch/mips/include/asm/mach-loongson/dma-coherence.h +0
-10@@ -53,16 +53,6 @@ static inline int plat_dma_supported(struct device *dev, u64 mask)return 1 ; } -static inline void plat_extra_sync_for_device (struct device *dev) -{ -} - -static inline int plat_dma_mapping_error (struct device *dev, -dma_addr_t dma_addr) -{ -return 0 ; -} -static inline int plat_device_is_coherent (struct device *dev) {return 0 ;arch/mips/include/asm/mach-powertv/dma-coherence.h +0
-10@@ -99,16 +99,6 @@ static inline int plat_dma_supported(struct device *dev, u64 mask)return 1 ; } -static inline void plat_extra_sync_for_device (struct device *dev) -{ -} - -static inline int plat_dma_mapping_error (struct device *dev, -dma_addr_t dma_addr) -{ -return 0 ; -} -static inline int plat_device_is_coherent (struct device *dev) {return 0 ;arch/mips/mm/dma-default.c +1
-3@@ -292,7 +292,6 @@ static void mips_dma_sync_single_for_cpu(struct device *dev,static void mips_dma_sync_single_for_device (struct device *dev,dma_addr_t dma_handle,size_t size,enum dma_data_direction direction) { -plat_extra_sync_for_device (dev);if (!plat_device_is_coherent (dev))__dma_sync (dma_addr_to_page (dev, dma_handle), dma_handle & ~PAGE_MASK , size, direction);@@ -326,7 +325,7 @@ static void mips_dma_sync_sg_for_device(struct device *dev,int mips_dma_mapping_error (struct device *dev,dma_addr_t dma_addr) { -return plat_dma_mapping_error (dev, dma_addr); +return 0 ; }int mips_dma_supported (struct device *dev,u64 mask)@@ -339,7 +338,6 @@ void dma_cache_sync(struct device *dev, void *vaddr, size_t size, {BUG_ON (direction ==DMA_NONE ); -plat_extra_sync_for_device (dev);if (!plat_device_is_coherent (dev))__dma_sync_virtual (vaddr, size, direction); }
Re: [PATCH 2/2] MIPS: partially inline dma ops
In reply to Felix FietkauQuoted 7 lines · Felix Fietkau
Several DMA ops are no-op on many platforms, and the indirection through the
mips_dma_map_opsfunction 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.
Quoted 7 lines
Signed-off-by Felix Fietkau <[email protected]>--- arch/mips/Kconfig | 4 + arch/mips/include/asm/dma-mapping.h | 360 +++++++++++++++++++++++++++++++++++- arch/mips/mm/dma-default.c | 161 ++-------------- 3 files changed, 372 insertions(+), 153 deletions(-)
That is not a very pleasing diffstat.
David
Quoted 1 line · David Daney
That's a mighty thin changelog there.
I thought it was obvious that the lines I removed contain no useful code at all :)
Quoted 2 lines
You are changing the semantics in the
asm/mach-cavium-octeon/dma-coherence.hcase.
I'm just removing a fallback BUG() that could never be reached before my change either. As for the other platforms, I verified that there's no useful code in these functions anywhere in the tree.
Quoted 1 line
Have you verified that all in-tree cases really are NOPs?
Yes.
- Felix
Re: [PATCH 2/2] MIPS: partially inline dma ops
In reply to David DaneyQuoted 8 lines · David Daney
Quoted 7 lines · Felix Fietkau
Several DMA ops are no-op on many platforms, and the indirection through the
mips_dma_map_opsfunction 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.
Quoted 7 lines
Quoted 6 lines
Signed-off-by Felix Fietkau <[email protected]>--- arch/mips/Kconfig | 4 + arch/mips/include/asm/dma-mapping.h | 360 +++++++++++++++++++++++++++++++++++- arch/mips/mm/dma-default.c | 161 ++-------------- 3 files changed, 372 insertions(+), 153 deletions(-)That is not a very pleasing diffstat.
I know. But altering the generic include (of which I duplicated the inlined code here) would make things even worse. I believe the improvement in the generated code is worth it though.
I just did some fresh performance tests with an 400 MHz AR7242 system (MIPS 24Kc), bridging packets from one Ethernet port to another. I'm running TCP iperf through this device.
Without this patch, I get 710-760 MBit/s with heavy fluctuation. With this patch, I get 780-790 MBit/s with little fluctuation. Most other MIPS systems will probably see similar improvements in DMA heavy drivers.
For Octeon, I don't expect any visible performance change, and the change shouldn't make it any worse either.
- Felix