MIPS: Add option to disable software I/O coherency.
PATCH v6 1/1 MIPS: Add option to disable software I/O coherency.
From: "Steven J. Hill" <[email protected]>
Some MIPS controllers have hardware I/O coherency. This patch detects those and turns off software coherency. A new kernel command line option also allows the user to manually turn software coherency on or off.
Signed-off-by Steven J. Hill <[email protected]>
--- arch/mips/include/asm/dma-mapping.h | 3 + arch/mips/include/asm/mach-generic/dma-coherence.h | 5 +- arch/mips/mm/c-r4k.c | 26 +++++--- arch/mips/mm/dma-default.c | 5 +- arch/mips/mti-malta/malta-setup.c | 63 ++++++++++++++++++++ arch/mips/mti-sead3/sead3-setup.c | 3 - 6 files changed, 89 insertions(+), 16 deletions(-)
arch/mips/include/asm/dma-mapping.h +3 -0
@@ -5,6 +5,9 @@#include <asm/cache.h> #include <asm-generic/dma-coherent.h> +extern int coherentio; +extern int hw_coherentio; +#ifndef CONFIG_SGI_IP27 /* Kludge to fix 2.6.39 build for IP27 */ #include <dma-coherence.h> #endif
arch/mips/include/asm/mach-generic/dma-coherence.h +2 -3
@@ -61,9 +61,8 @@ static inline int plat_device_is_coherent(struct device *dev) {#ifdef CONFIG_DMA_COHERENT return 1 ; -#endif -#ifdef CONFIG_DMA_NONCOHERENT -return 0 ; +#else +return coherentio;#endif }
arch/mips/mm/c-r4k.c +18 -8
@@ -1381,19 +1381,24 @@ static void __cpuinit coherency_setup(void) } } -#if defined(CONFIG_DMA_NONCOHERENT ) - -static int __cpuinitdata coherentio; +int coherentio =0 ;/* User defined DMA coherency from command line. */ +int hw_coherentio =0 ;/* Actual hardware supported DMA coherency setting. */ static int __init setcoherentio (char *str) { coherentio =1 ; - +pr_info ("Hardware DMA cache coherency (command line)\n" );return 0 ; } -early_param ("coherentio" , setcoherentio); -#endif + +static int __init setnocoherentio (char *str) +{ + coherentio =0 ; +pr_info ("Software DMA cache coherency (command line)\n" ); +return 0 ; +} +early_param ("nocoherentio" , setnocoherentio);static void __cpuinit r4k_cache_error_setup (void ) {
@@ -1476,9 +1481,14 @@ void __cpuinit r4k_cache_init(void)build_clear_page ();build_copy_page (); -#if !defined(CONFIG_MIPS_CMP ) + +/* +* We want to run CMP kernels on core with and without coherent +* caches. Therefore, do not use CONFIG_MIPS_CMP to decide whether +* or not to flush caches. +*/ local_r4k___flush_cache_all (NULL ); -#endif +coherency_setup (); board_cache_error_setup = r4k_cache_error_setup; }
arch/mips/mm/dma-default.c +3 -2
@@ -115,7 +115,8 @@ static void *mips_dma_alloc_coherent(struct device *dev, size_t size,if (!plat_device_is_coherent (dev)) {dma_cache_wback_inv ((unsigned long ) ret, size); - ret =UNCAC_ADDR (ret); +if (!hw_coherentio) + ret =UNCAC_ADDR (ret); } }
@@ -142,7 +143,7 @@ static void mips_dma_free_coherent(struct device *dev, size_t size, void *vaddr,plat_unmap_dma_mem (dev, dma_handle, size,DMA_BIDIRECTIONAL ); -if (!plat_device_is_coherent (dev)) +if (!plat_device_is_coherent (dev) && !hw_coherentio) addr =CAC_ADDR (addr);free_pages (addr,get_order (size));
arch/mips/mti-malta/malta-setup.c +63 -0
81 lines not on this page · raw message
arch/mips/mti-sead3/sead3-setup.c +0 -3
@@ -13,9 +13,6 @@#include <asm/mips-boards/generic.h> #include <asm/prom.h> -int coherentio;/* 0 => no DMA cache coherency (may be set by user) */ -int hw_coherentio;/* 0 => no HW DMA cache coherency (reflects real HW) */ -const char *get_system_type (void ) {return "MIPS SEAD3" ;
Signature · 1 line
1.7.9.5