aboutsummaryrefslogtreecommitdiffstats
path: root/docs/openwrt.tex
blob: 946387b4d650072c1ab504fd3dfe7be65d7798d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
\documentclass[a4paper]{book}

\usepackage{openwrt}

\begin{document}
\tableofcontents
\chapter{The Router}
  \section{Getting started}
    \subsection{Installation}
    \subsection{Initial configuration}
    \subsection{Failsafe mode}
  \section{Configuring OpenWrt}
    \subsection{Network}
      \input{network}
    \subsection{Wireless}
      \input{wireless}
  \section{Advanced configuration}
    \input{config}
    \subsection{Hotplug}
    \subsection{Init scripts}
      \input{init-scripts}
    \subsection{Network scripts}
      \input{network-scripts}
\chapter{Development issues}
  \section{The build system}
    \input{build}
  \section{Extra tools}
    \subsection{Image Builder}
    \subsection{SDK}
  \section{Working with OpenWrt}
    \input{working}
  \section{Adding platform support}
     \input{adding}
  \section{Debugging and debricking}
     \input{debugging}
   \section{Reporting bugs}
	\subsection{Using the Trac ticket system}
	\input{bugs}
   \section{Submitting patches}
    \input{submitting-patches}
\end{document}
/* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
From: Felix Fietkau <nbd@nbd.name>
Date: Tue, 5 Dec 2017 12:46:01 +0100
Subject: [PATCH] MIPS: mm: remove no-op dma_map_ops where possible

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>
---

--- 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
@@ -345,6 +346,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
@@ -1127,6 +1129,9 @@ config DMA_NONCOHERENT
 	bool
 	select NEED_DMA_MAP_STATE
 
+config DMA_UNMAP_POST_FLUSH
+	bool
+
 config NEED_DMA_MAP_STATE
 	bool
 
@@ -1651,6 +1656,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.
 
@@ -1899,9 +1905,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
@@ -1911,6 +1919,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
--- a/arch/mips/mm/dma-default.c
+++ b/arch/mips/mm/dma-default.c
@@ -267,8 +267,9 @@ static inline void __dma_sync(struct pag
 	} 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(stru
 	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 dev
 	}
 }
 
-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_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;
@@ -394,12 +397,14 @@ static const struct dma_map_ops mips_def
 	.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
 };