Skip to contentSkip to conversation

MIPS: Add option to disable software I/O coherency.

PATCH Superseded Steven J. Hill 2 participants 2 messages Dec 7, 2012 MIPS

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

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

---
 arch/mips/include/asm/mach-generic/dma-coherence.h |    4 +-
 arch/mips/mm/c-r4k.c                               |   21 +---
 arch/mips/mm/dma-default.c                         |    8 +-
 arch/mips/mti-malta/malta-setup.c                  |  102 ++++++++++++++++++++
 4 files changed, 116 insertions(+), 19 deletions(-)
arch/mips/include/asm/mach-generic/dma-coherence.h +3 -1
index 9c95177..9f1cd31 100644
@@ -63,7 +63,9 @@ static inline int plat_device_is_coherent(struct device *dev)
 	return 1;
 #endif
 #ifdef CONFIG_DMA_NONCOHERENT
-	return 0;
+	extern int coherentio;
+
+	return coherentio;
 #endif
 }
 
arch/mips/mm/c-r4k.c +5 -16
index c0f27c8..7f13f24 100644
@@ -1383,20 +1383,6 @@ static void __cpuinit coherency_setup(void)
 	}
 }
 
-#if defined(CONFIG_DMA_NONCOHERENT)
-
-static int __cpuinitdata coherentio;
-
-static int __init setcoherentio(char *str)
-{
-	coherentio = 1;
-
-	return 1;
-}
-
-__setup("coherentio", setcoherentio);
-#endif
-
 static void __cpuinit r4k_cache_error_setup(void)
 {
 	extern char __weak except_vec2_generic;
@@ -1419,6 +1405,7 @@ void __cpuinit r4k_cache_init(void)
 {
 	extern void build_clear_page(void);
 	extern void build_copy_page(void);
+	extern int coherentio;
 	struct cpuinfo_mips *c = &current_cpu_data;
 
 	probe_pcache();
@@ -1478,9 +1465,11 @@ 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(s) with and without coherent caches */
+	/* Therefore can't use CONFIG_MIPS_CMP to decide to flush cache */
 	local_r4k___flush_cache_all(NULL);
-#endif
+
 	coherency_setup();
 	board_cache_error_setup = r4k_cache_error_setup;
 }
arch/mips/mm/dma-default.c +6 -2
index 3fab204..058c2ca 100644
@@ -100,6 +100,7 @@ EXPORT_SYMBOL(dma_alloc_noncoherent);
 static void *mips_dma_alloc_coherent(struct device *dev, size_t size,
 	dma_addr_t * dma_handle, gfp_t gfp, struct dma_attrs *attrs)
 {
+	extern int hw_coherentio;
 	void *ret;
 
 	if (dma_alloc_from_coherent(dev, size, dma_handle, &ret))
@@ -115,7 +116,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);
 		}
 	}
 
@@ -134,6 +136,7 @@ EXPORT_SYMBOL(dma_free_noncoherent);
 static void mips_dma_free_coherent(struct device *dev, size_t size, void *vaddr,
 	dma_addr_t dma_handle, struct dma_attrs *attrs)
 {
+	extern int hw_coherentio;
 	unsigned long addr = (unsigned long) vaddr;
 	int order = get_order(size);
 
@@ -143,7 +146,8 @@ 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))
-		addr = CAC_ADDR(addr);
+		if (!hw_coherentio)
+			addr = CAC_ADDR(addr);
 
 	free_pages(addr, get_order(size));
 }
arch/mips/mti-malta/malta-setup.c +102 -0

120 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 8 lines · Steven J. Hill

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.

This patch conflicts with commit b5b64f2ba4 "MIPS: Move processing of coherency kernel parameters earlier" in the linux-next tree.

Shane McDonald