From: Jeff Hansen Subject: [PATCH] kmap_coherent On ASUS WL-500gP there are some "Data bus error"s when executing simple commands liks "ps" or "cat /proc/1/cmdline". This fixes OpenWrt ticket #1485: https://dev.openwrt.org/ticket/1485 --- --- a/arch/mips/include/asm/cpu-features.h +++ b/arch/mips/include/asm/cpu-features.h @@ -257,6 +257,9 @@ #ifndef cpu_has_pindexed_dcache #define cpu_has_pindexed_dcache (cpu_data[0].dcache.flags & MIPS_CACHE_PINDEX) #endif +#ifndef cpu_use_kmap_coherent +#define cpu_use_kmap_coherent 1 +#endif /* * I-Cache snoops remote store. This only matters on SMP. Some multiprocessors --- a/arch/mips/include/asm/mach-bcm47xx/cpu-feature-overrides.h +++ b/arch/mips/include/asm/mach-bcm47xx/cpu-feature-overrides.h @@ -79,4 +79,6 @@ #define cpu_scache_line_size() 0 #define cpu_has_vz 0 +#define cpu_use_kmap_coherent 0 + #endif /* __ASM_MACH_BCM47XX_CPU_FEATURE_OVERRIDES_H */ --- a/arch/mips/mm/c-r4k.c +++ b/arch/mips/mm/c-r4k.c @@ -701,7 +701,7 @@ static inline void local_r4k_flush_cache map_coherent = (cpu_has_dc_aliases && page_mapcount(page) && !Page_dcache_dirty(page)); - if (map_coherent) + if (map_coherent && cpu_use_kmap_coherent) vaddr = kmap_coherent(page, addr); else vaddr = kmap_atomic(page); @@ -728,7 +728,7 @@ static inline void local_r4k_flush_cache } if (vaddr) { - if (map_coherent) + if (map_coherent && cpu_use_kmap_coherent) kunmap_coherent(); else kunmap_atomic(vaddr); --- a/arch/mips/mm/init.c +++ b/arch/mips/mm/init.c @@ -172,7 +172,7 @@ void copy_user_highpage(struct page *to, void *vfrom, *vto; vto = kmap_atomic(to); - if (cpu_has_dc_aliases && + if (cpu_has_dc_aliases && cpu_use_kmap_coherent && page_mapcount(from) && !Page_dcache_dirty(from)) { vfrom = kmap_coherent(from, vaddr); copy_page(vto, vfrom); @@ -194,7 +194,7 @@ void copy_to_user_page(struct vm_area_st struct page *page, unsigned long vaddr, void *dst, const void *src, unsigned long len) { - if (cpu_has_dc_aliases && + if (cpu_has_dc_aliases && cpu_use_kmap_coherent && page_mapcount(page) && !Page_dcache_dirty(page)) { void *vto = kmap_coherent(page, vaddr) + (vaddr & ~PAGE_MASK); memcpy(vto, src, len); @@ -212,7 +212,7 @@ void copy_from_user_page(struct vm_area_ struct page *page, unsigned long vaddr, void *dst, const void *src, unsigned long len) { - if (cpu_has_dc_aliases && + if (cpu_has_dc_aliases && cpu_use_kmap_coherent && page_mapcount(page) && !Page_dcache_dirty(page)) { void *vfrom = kmap_coherent(page, vaddr) + (vaddr & ~PAGE_MASK); memcpy(dst, vfrom, len);