Linux MIPS Architecture development
 help / color / mirror / Atom feed
* [PATCH 1/2] MIPS: mm: remove mips_dma_mapping_error
@ 2017-12-05 11:50 Felix Fietkau
  2017-12-05 11:50 ` [PATCH 2/2] MIPS: mm: remove no-op dma_map_ops where possible Felix Fietkau
  2018-02-01 11:56 ` [PATCH 1/2] MIPS: mm: remove mips_dma_mapping_error James Hogan
  0 siblings, 2 replies; 3+ messages in thread
From: Felix Fietkau @ 2017-12-05 11:50 UTC (permalink / raw)
  To: linux-mips

dma_mapping_error() already checks if ops->mapping_error is a null
pointer

Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
 arch/mips/mm/dma-default.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/arch/mips/mm/dma-default.c b/arch/mips/mm/dma-default.c
index e3e94d05f0fd..1af0cd90cc34 100644
--- a/arch/mips/mm/dma-default.c
+++ b/arch/mips/mm/dma-default.c
@@ -373,11 +373,6 @@ static void mips_dma_sync_sg_for_device(struct device *dev,
 	}
 }
 
-static int mips_dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
-{
-	return 0;
-}
-
 static int mips_dma_supported(struct device *dev, u64 mask)
 {
 	return plat_dma_supported(dev, mask);
@@ -404,7 +399,6 @@ static const struct dma_map_ops mips_default_dma_map_ops = {
 	.sync_single_for_device = mips_dma_sync_single_for_device,
 	.sync_sg_for_cpu = mips_dma_sync_sg_for_cpu,
 	.sync_sg_for_device = mips_dma_sync_sg_for_device,
-	.mapping_error = mips_dma_mapping_error,
 	.dma_supported = mips_dma_supported,
 	.cache_sync = mips_dma_cache_sync,
 };
-- 
2.14.2

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] MIPS: mm: remove no-op dma_map_ops where possible
  2017-12-05 11:50 [PATCH 1/2] MIPS: mm: remove mips_dma_mapping_error Felix Fietkau
@ 2017-12-05 11:50 ` Felix Fietkau
  2018-02-01 11:56 ` [PATCH 1/2] MIPS: mm: remove mips_dma_mapping_error James Hogan
  1 sibling, 0 replies; 3+ messages in thread
From: Felix Fietkau @ 2017-12-05 11:50 UTC (permalink / raw)
  To: linux-mips

If no post-DMA flush is required, and the platform does not provide
plat_unmap_dma_mem(), there is no need to include unmap or sync_for_cpu
ops.

With this patch they are compiled out to improve icache footprint
on devices that handle lots of DMA traffic (especially network routers).

Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
 arch/mips/Kconfig          |  9 +++++++++
 arch/mips/mm/dma-default.c | 29 +++++++++++++++++------------
 2 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 350a990fc719..95e58d45a9c1 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -220,6 +220,7 @@ config BMIPS_GENERIC
 	select BRCMSTB_L2_IRQ
 	select IRQ_MIPS_CPU
 	select DMA_NONCOHERENT
+	select DMA_UNMAP_POST_FLUSH
 	select SYS_SUPPORTS_32BIT_KERNEL
 	select SYS_SUPPORTS_LITTLE_ENDIAN
 	select SYS_SUPPORTS_BIG_ENDIAN
@@ -347,6 +348,7 @@ config MACH_JAZZ
 	select CSRC_R4K
 	select DEFAULT_SGI_PARTITION if CPU_BIG_ENDIAN
 	select GENERIC_ISA_DMA
+	select DMA_UNMAP_POST_FLUSH
 	select HAVE_PCSPKR_PLATFORM
 	select IRQ_MIPS_CPU
 	select I8253
@@ -1109,6 +1111,9 @@ config DMA_NONCOHERENT
 	bool
 	select NEED_DMA_MAP_STATE
 
+config DMA_UNMAP_POST_FLUSH
+	bool
+
 config NEED_DMA_MAP_STATE
 	bool
 
@@ -1633,6 +1638,7 @@ config CPU_R10000
 	select CPU_SUPPORTS_64BIT_KERNEL
 	select CPU_SUPPORTS_HIGHMEM
 	select CPU_SUPPORTS_HUGEPAGES
+	select DMA_UNMAP_POST_FLUSH
 	help
 	  MIPS Technologies R10000-series processors.
 
@@ -1881,9 +1887,11 @@ config SYS_HAS_CPU_MIPS32_R3_5
 	bool
 
 config SYS_HAS_CPU_MIPS32_R5
+	select DMA_UNMAP_POST_FLUSH
 	bool
 
 config SYS_HAS_CPU_MIPS32_R6
+	select DMA_UNMAP_POST_FLUSH
 	bool
 
 config SYS_HAS_CPU_MIPS64_R1
@@ -1893,6 +1901,7 @@ config SYS_HAS_CPU_MIPS64_R2
 	bool
 
 config SYS_HAS_CPU_MIPS64_R6
+	select DMA_UNMAP_POST_FLUSH
 	bool
 
 config SYS_HAS_CPU_R3000
diff --git a/arch/mips/mm/dma-default.c b/arch/mips/mm/dma-default.c
index 1af0cd90cc34..ecca8782d6fb 100644
--- a/arch/mips/mm/dma-default.c
+++ b/arch/mips/mm/dma-default.c
@@ -267,8 +267,9 @@ static inline void __dma_sync(struct page *page,
 	} while (left);
 }
 
-static void mips_dma_unmap_page(struct device *dev, dma_addr_t dma_addr,
-	size_t size, enum dma_data_direction direction, unsigned long attrs)
+static void __maybe_unused
+mips_dma_unmap_page(struct device *dev, dma_addr_t dma_addr, size_t size,
+		    enum dma_data_direction direction, unsigned long attrs)
 {
 	if (cpu_needs_post_dma_flush(dev) && !(attrs & DMA_ATTR_SKIP_CPU_SYNC))
 		__dma_sync(dma_addr_to_page(dev, dma_addr),
@@ -308,9 +309,10 @@ static dma_addr_t mips_dma_map_page(struct device *dev, struct page *page,
 	return plat_map_dma_mem_page(dev, page) + offset;
 }
 
-static void mips_dma_unmap_sg(struct device *dev, struct scatterlist *sglist,
-	int nhwentries, enum dma_data_direction direction,
-	unsigned long attrs)
+static void __maybe_unused
+mips_dma_unmap_sg(struct device *dev, struct scatterlist *sglist,
+		  int nhwentries, enum dma_data_direction direction,
+		  unsigned long attrs)
 {
 	int i;
 	struct scatterlist *sg;
@@ -325,8 +327,9 @@ static void mips_dma_unmap_sg(struct device *dev, struct scatterlist *sglist,
 	}
 }
 
-static void mips_dma_sync_single_for_cpu(struct device *dev,
-	dma_addr_t dma_handle, size_t size, enum dma_data_direction direction)
+static void __maybe_unused
+mips_dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle,
+			     size_t size, enum dma_data_direction direction)
 {
 	if (cpu_needs_post_dma_flush(dev))
 		__dma_sync(dma_addr_to_page(dev, dma_handle),
@@ -342,9 +345,9 @@ static void mips_dma_sync_single_for_device(struct device *dev,
 			   dma_handle & ~PAGE_MASK, size, direction);
 }
 
-static void mips_dma_sync_sg_for_cpu(struct device *dev,
-	struct scatterlist *sglist, int nelems,
-	enum dma_data_direction direction)
+static void __maybe_unused
+mips_dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sglist,
+			 int nelems, enum dma_data_direction direction)
 {
 	int i;
 	struct scatterlist *sg;
@@ -392,12 +395,14 @@ static const struct dma_map_ops mips_default_dma_map_ops = {
 	.free = mips_dma_free_coherent,
 	.mmap = mips_dma_mmap,
 	.map_page = mips_dma_map_page,
-	.unmap_page = mips_dma_unmap_page,
 	.map_sg = mips_dma_map_sg,
+#ifdef CONFIG_DMA_UNMAP_POST_FLUSH
+	.unmap_page = mips_dma_unmap_page,
 	.unmap_sg = mips_dma_unmap_sg,
 	.sync_single_for_cpu = mips_dma_sync_single_for_cpu,
-	.sync_single_for_device = mips_dma_sync_single_for_device,
 	.sync_sg_for_cpu = mips_dma_sync_sg_for_cpu,
+#endif
+	.sync_single_for_device = mips_dma_sync_single_for_device,
 	.sync_sg_for_device = mips_dma_sync_sg_for_device,
 	.dma_supported = mips_dma_supported,
 	.cache_sync = mips_dma_cache_sync,
-- 
2.14.2

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] MIPS: mm: remove mips_dma_mapping_error
  2017-12-05 11:50 [PATCH 1/2] MIPS: mm: remove mips_dma_mapping_error Felix Fietkau
  2017-12-05 11:50 ` [PATCH 2/2] MIPS: mm: remove no-op dma_map_ops where possible Felix Fietkau
@ 2018-02-01 11:56 ` James Hogan
  1 sibling, 0 replies; 3+ messages in thread
From: James Hogan @ 2018-02-01 11:56 UTC (permalink / raw)
  To: Felix Fietkau; +Cc: linux-mips

[-- Attachment #1: Type: text/plain, Size: 1286 bytes --]

On Tue, Dec 05, 2017 at 12:50:33PM +0100, Felix Fietkau wrote:
> dma_mapping_error() already checks if ops->mapping_error is a null
> pointer
> 
> Signed-off-by: Felix Fietkau <nbd@nbd.name>

Thanks, I've already applied this to my 4.16 branch.

Cheers
James

> ---
>  arch/mips/mm/dma-default.c | 6 ------
>  1 file changed, 6 deletions(-)
> 
> diff --git a/arch/mips/mm/dma-default.c b/arch/mips/mm/dma-default.c
> index e3e94d05f0fd..1af0cd90cc34 100644
> --- a/arch/mips/mm/dma-default.c
> +++ b/arch/mips/mm/dma-default.c
> @@ -373,11 +373,6 @@ static void mips_dma_sync_sg_for_device(struct device *dev,
>  	}
>  }
>  
> -static int mips_dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
> -{
> -	return 0;
> -}
> -
>  static int mips_dma_supported(struct device *dev, u64 mask)
>  {
>  	return plat_dma_supported(dev, mask);
> @@ -404,7 +399,6 @@ static const struct dma_map_ops mips_default_dma_map_ops = {
>  	.sync_single_for_device = mips_dma_sync_single_for_device,
>  	.sync_sg_for_cpu = mips_dma_sync_sg_for_cpu,
>  	.sync_sg_for_device = mips_dma_sync_sg_for_device,
> -	.mapping_error = mips_dma_mapping_error,
>  	.dma_supported = mips_dma_supported,
>  	.cache_sync = mips_dma_cache_sync,
>  };
> -- 
> 2.14.2
> 
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-02-01 11:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-05 11:50 [PATCH 1/2] MIPS: mm: remove mips_dma_mapping_error Felix Fietkau
2017-12-05 11:50 ` [PATCH 2/2] MIPS: mm: remove no-op dma_map_ops where possible Felix Fietkau
2018-02-01 11:56 ` [PATCH 1/2] MIPS: mm: remove mips_dma_mapping_error James Hogan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox