aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/mm/dma-default.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/mips/mm/dma-default.c')
-rw-r--r--arch/mips/mm/dma-default.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/arch/mips/mm/dma-default.c b/arch/mips/mm/dma-default.c
index aaccf1c10699..664e523653d0 100644
--- a/arch/mips/mm/dma-default.c
+++ b/arch/mips/mm/dma-default.c
@@ -50,16 +50,20 @@ static inline struct page *dma_addr_to_page(struct device *dev,
50} 50}
51 51
52/* 52/*
53 * The affected CPUs below in 'cpu_needs_post_dma_flush()' can
54 * speculatively fill random cachelines with stale data at any time,
55 * requiring an extra flush post-DMA.
56 *
53 * Warning on the terminology - Linux calls an uncached area coherent; 57 * Warning on the terminology - Linux calls an uncached area coherent;
54 * MIPS terminology calls memory areas with hardware maintained coherency 58 * MIPS terminology calls memory areas with hardware maintained coherency
55 * coherent. 59 * coherent.
56 */ 60 */
57 61static inline int cpu_needs_post_dma_flush(struct device *dev)
58static inline int cpu_is_noncoherent_r10000(struct device *dev)
59{ 62{
60 return !plat_device_is_coherent(dev) && 63 return !plat_device_is_coherent(dev) &&
61 (current_cpu_type() == CPU_R10000 || 64 (boot_cpu_type() == CPU_R10000 ||
62 current_cpu_type() == CPU_R12000); 65 boot_cpu_type() == CPU_R12000 ||
66 boot_cpu_type() == CPU_BMIPS5000);
63} 67}
64 68
65static gfp_t massage_gfp_flags(const struct device *dev, gfp_t gfp) 69static gfp_t massage_gfp_flags(const struct device *dev, gfp_t gfp)
@@ -230,7 +234,7 @@ static inline void __dma_sync(struct page *page,
230static void mips_dma_unmap_page(struct device *dev, dma_addr_t dma_addr, 234static void mips_dma_unmap_page(struct device *dev, dma_addr_t dma_addr,
231 size_t size, enum dma_data_direction direction, struct dma_attrs *attrs) 235 size_t size, enum dma_data_direction direction, struct dma_attrs *attrs)
232{ 236{
233 if (cpu_is_noncoherent_r10000(dev)) 237 if (cpu_needs_post_dma_flush(dev))
234 __dma_sync(dma_addr_to_page(dev, dma_addr), 238 __dma_sync(dma_addr_to_page(dev, dma_addr),
235 dma_addr & ~PAGE_MASK, size, direction); 239 dma_addr & ~PAGE_MASK, size, direction);
236 240
@@ -284,7 +288,7 @@ static void mips_dma_unmap_sg(struct device *dev, struct scatterlist *sg,
284static void mips_dma_sync_single_for_cpu(struct device *dev, 288static void mips_dma_sync_single_for_cpu(struct device *dev,
285 dma_addr_t dma_handle, size_t size, enum dma_data_direction direction) 289 dma_addr_t dma_handle, size_t size, enum dma_data_direction direction)
286{ 290{
287 if (cpu_is_noncoherent_r10000(dev)) 291 if (cpu_needs_post_dma_flush(dev))
288 __dma_sync(dma_addr_to_page(dev, dma_handle), 292 __dma_sync(dma_addr_to_page(dev, dma_handle),
289 dma_handle & ~PAGE_MASK, size, direction); 293 dma_handle & ~PAGE_MASK, size, direction);
290} 294}
@@ -305,7 +309,7 @@ static void mips_dma_sync_sg_for_cpu(struct device *dev,
305 309
306 /* Make sure that gcc doesn't leave the empty loop body. */ 310 /* Make sure that gcc doesn't leave the empty loop body. */
307 for (i = 0; i < nelems; i++, sg++) { 311 for (i = 0; i < nelems; i++, sg++) {
308 if (cpu_is_noncoherent_r10000(dev)) 312 if (cpu_needs_post_dma_flush(dev))
309 __dma_sync(sg_page(sg), sg->offset, sg->length, 313 __dma_sync(sg_page(sg), sg->offset, sg->length,
310 direction); 314 direction);
311 } 315 }