kernel: improve dma ops inlining patches
[openwrt/staging/chunkeey.git] / target / linux / generic / patches-3.10 / 131-improve_noncoherent_dma_checks.patch
1 From d593f8fc627f8cdaee9c14e4d22b0770a09baaf1 Mon Sep 17 00:00:00 2001
2 From: Felix Fietkau <nbd@openwrt.org>
3 Date: Thu, 15 Aug 2013 10:47:47 +0200
4 Subject: [PATCH] MIPS: improve checks for noncoherent DMA
5
6 Only one MIPS development board actually supports enabling/disabling DMA
7 coherency at runtime, so it's not a good idea to push the overhead of
8 checking that configuration setting onto every other supported target as
9 well.
10
11 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
12 ---
13 arch/mips/Kconfig | 6 +++++-
14 arch/mips/include/asm/dma-coherence.h | 7 +++++++
15 arch/mips/include/asm/mach-generic/dma-coherence.h | 4 ----
16 arch/mips/mm/dma-default.c | 2 ++
17 4 files changed, 14 insertions(+), 5 deletions(-)
18
19 --- a/arch/mips/Kconfig
20 +++ b/arch/mips/Kconfig
21 @@ -296,7 +296,7 @@ config MIPS_MALTA
22 select CEVT_R4K
23 select CSRC_R4K
24 select CSRC_GIC
25 - select DMA_NONCOHERENT
26 + select DMA_MAYBE_COHERENT
27 select GENERIC_ISA_DMA
28 select HAVE_PCSPKR_PLATFORM
29 select IRQ_CPU
30 @@ -947,6 +947,10 @@ config FW_CFE
31 config ARCH_DMA_ADDR_T_64BIT
32 def_bool (HIGHMEM && 64BIT_PHYS_ADDR) || 64BIT
33
34 +config DMA_MAYBE_COHERENT
35 + select DMA_NONCOHERENT
36 + bool
37 +
38 config DMA_COHERENT
39 bool
40
41 --- a/arch/mips/include/asm/dma-coherence.h
42 +++ b/arch/mips/include/asm/dma-coherence.h
43 @@ -9,7 +9,14 @@
44 #ifndef __ASM_DMA_COHERENCE_H
45 #define __ASM_DMA_COHERENCE_H
46
47 +#ifdef CONFIG_DMA_MAYBE_COHERENT
48 extern int coherentio;
49 extern int hw_coherentio;
50 +#elif defined(CONFIG_DMA_COHERENT)
51 +#define coherentio 1
52 +#else
53 +#define coherentio 0
54 +#endif
55 +#define hw_coherentio 0
56
57 #endif
58 --- a/arch/mips/include/asm/mach-generic/dma-coherence.h
59 +++ b/arch/mips/include/asm/mach-generic/dma-coherence.h
60 @@ -49,11 +49,7 @@ static inline int plat_dma_supported(str
61
62 static inline int plat_device_is_coherent(struct device *dev)
63 {
64 -#ifdef CONFIG_DMA_COHERENT
65 - return 1;
66 -#else
67 return coherentio;
68 -#endif
69 }
70
71 #endif /* __ASM_MACH_GENERIC_DMA_COHERENCE_H */
72 --- a/arch/mips/mm/dma-default.c
73 +++ b/arch/mips/mm/dma-default.c
74 @@ -22,6 +22,7 @@
75
76 #include <dma-coherence.h>
77
78 +#ifdef CONFIG_DMA_MAYBE_COHERENT
79 int coherentio = 0; /* User defined DMA coherency from command line. */
80 EXPORT_SYMBOL_GPL(coherentio);
81 int hw_coherentio = 0; /* Actual hardware supported DMA coherency setting. */
82 @@ -41,6 +42,7 @@ static int __init setnocoherentio(char *
83 return 0;
84 }
85 early_param("nocoherentio", setnocoherentio);
86 +#endif
87
88 static inline struct page *dma_addr_to_page(struct device *dev,
89 dma_addr_t dma_addr)