kernel/3.1[02]: add Winbond W25X05 SPI flash support
[openwrt.git] / target / linux / generic / patches-3.12 / 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 @@ -299,7 +299,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 @@ -912,6 +912,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,16 @@
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 +#else
51 +#ifdef CONFIG_DMA_COHERENT
52 +#define coherentio     1
53 +#else
54 +#define coherentio     0
55 +#endif
56 +#define hw_coherentio  0
57 +#endif /* CONFIG_DMA_MAYBE_COHERENT */
58  
59  #endif
60 --- a/arch/mips/include/asm/mach-generic/dma-coherence.h
61 +++ b/arch/mips/include/asm/mach-generic/dma-coherence.h
62 @@ -49,11 +49,7 @@ static inline int plat_dma_supported(str
63  
64  static inline int plat_device_is_coherent(struct device *dev)
65  {
66 -#ifdef CONFIG_DMA_COHERENT
67 -       return 1;
68 -#else
69         return coherentio;
70 -#endif
71  }
72  
73  #ifdef CONFIG_SWIOTLB
74 --- a/arch/mips/mm/dma-default.c
75 +++ b/arch/mips/mm/dma-default.c
76 @@ -23,6 +23,7 @@
77  
78  #include <dma-coherence.h>
79  
80 +#ifdef CONFIG_DMA_MAYBE_COHERENT
81  int coherentio = 0;    /* User defined DMA coherency from command line. */
82  EXPORT_SYMBOL_GPL(coherentio);
83  int hw_coherentio = 0; /* Actual hardware supported DMA coherency setting. */
84 @@ -42,6 +43,7 @@ static int __init setnocoherentio(char *
85         return 0;
86  }
87  early_param("nocoherentio", setnocoherentio);
88 +#endif
89  
90  static inline struct page *dma_addr_to_page(struct device *dev,
91         dma_addr_t dma_addr)