Skip to contentSkip to conversation

MIPS: remove unnecessary platform dma helper functions

PATCH In review Felix Fietkau 2 participants 4 messages Aug 15, 2013 – Sep 19, 2013 MIPS

lore
Share & tools
lore
#1 lore raw

PATCH v3 2/3 MIPS: improve checks for noncoherent DMA

In reply to Felix Fietkau

Only one MIPS development board actually supports enabling/disabling DMA coherency at runtime, so it's not a good idea to push the overhead of checking that configuration setting onto every other supported target as well.

---
 arch/mips/Kconfig                                  | 6 +++++-
 arch/mips/include/asm/dma-coherence.h              | 9 +++++++++
 arch/mips/include/asm/mach-generic/dma-coherence.h | 4 ----
 arch/mips/mm/dma-default.c                         | 2 ++
 4 files changed, 16 insertions(+), 5 deletions(-)
arch/mips/Kconfig +5 -1
index e12764c..9b258f5 100644
@@ -300,7 +300,7 @@ config MIPS_MALTA
 	select CEVT_R4K
 	select CSRC_R4K
 	select CSRC_GIC
-	select DMA_NONCOHERENT
+	select DMA_MAYBE_COHERENT
 	select GENERIC_ISA_DMA
 	select HAVE_PCSPKR_PLATFORM
 	select IRQ_CPU
@@ -915,6 +915,10 @@ config FW_CFE
 config ARCH_DMA_ADDR_T_64BIT
 	def_bool (HIGHMEM && 64BIT_PHYS_ADDR) || 64BIT
 
+config DMA_MAYBE_COHERENT
+	select DMA_NONCOHERENT
+	bool
+
 config DMA_COHERENT
 	bool
 
arch/mips/include/asm/dma-coherence.h +9 -0
index 242cbb3..bc5e85d 100644
@@ -9,7 +9,16 @@
 #ifndef __ASM_DMA_COHERENCE_H
 #define __ASM_DMA_COHERENCE_H
 
+#ifdef CONFIG_DMA_MAYBE_COHERENT
 extern int coherentio;
 extern int hw_coherentio;
+#else
+#ifdef CONFIG_DMA_COHERENT
+#define coherentio	1
+#else
+#define coherentio	0
+#endif
+#define hw_coherentio	0
+#endif /* CONFIG_DMA_MAYBE_COHERENT */
 
 #endif
arch/mips/include/asm/mach-generic/dma-coherence.h +0 -4
index a9e8f6b..7629c35 100644
@@ -49,11 +49,7 @@ static inline int plat_dma_supported(struct device *dev, u64 mask)
 
 static inline int plat_device_is_coherent(struct device *dev)
 {
-#ifdef CONFIG_DMA_COHERENT
-	return 1;
-#else
 	return coherentio;
-#endif
 }
 
 #ifdef CONFIG_SWIOTLB
arch/mips/mm/dma-default.c +2 -0
index 63e45d6..87a98d5 100644
@@ -22,6 +22,7 @@
 
 #include <dma-coherence.h>
 
+#ifdef CONFIG_DMA_MAYBE_COHERENT
 int coherentio = 0;	/* User defined DMA coherency from command line. */
 EXPORT_SYMBOL_GPL(coherentio);
 int hw_coherentio = 0;	/* Actual hardware supported DMA coherency setting. */
@@ -41,6 +42,7 @@ static int __init setnocoherentio(char *str)
 	return 0;
 }
 early_param("nocoherentio", setnocoherentio);
+#endif
 
 static inline struct page *dma_addr_to_page(struct device *dev,
 	dma_addr_t dma_addr)
Signature · 1 line
1.8.0.2
#2 lore raw

PATCH v3 3/3 MIPS: partially inline dma ops

In reply to Felix Fietkau

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.

coherentio is changed from EXPORT_SYMBOL_GPL to EXPORT_SYMBOL, because it is now potentially being accessed by any driver using the DMA mapping API.

---
 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(-)
arch/mips/Kconfig +4 -0
index 9b258f5..5a3007c 100644
@@ -1397,6 +1397,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
@@ -1617,6 +1618,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 +14 -149

218 lines not on this page · raw message

Signature · 1 line
1.8.0.2
#0 lore raw

PATCH v3 1/3 MIPS: remove unnecessary platform dma helper functions

The semantics stay the same - on Cavium Octeon the functions were dead code (it overrides the MIPS DMA ops) - on other platforms they contained no code at all.

---
 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
index 47fb247..f9f4486 100644
@@ -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
index 74cb992..a9e8f6b 100644
@@ -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
index 06c4419..4ffddfd 100644
@@ -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
index 073f0c4..104cfbc 100644
@@ -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
index 9fc1e9a..949003e 100644
@@ -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
index e143305..aeb2c05 100644
@@ -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
index f831672..5d4c3fe 100644
@@ -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
index aaccf1c..63e45d6 100644
@@ -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
#3 lore raw
Quoted 9 lines · Felix Fietkau

Date: Thu, 15 Aug 2013 11:28:30 +0200
From: Felix Fietkau <[email protected]>
To: [email protected]
Subject: [PATCH v3 1/3] MIPS: remove unnecessary platform dma helper
functions

The semantics stay the same - on Cavium Octeon the functions were dead code (it overrides the MIPS DMA ops) - on other platforms they contained no code at all.

Queued for 3.13.

Thanks,

Ralf