1 From: Jeff Hansen <jhansen@cardaccess-inc.com>
2 Subject: [PATCH] kmap_coherent
4 On ASUS WL-500gP there are some "Data bus error"s when executing simple
5 commands liks "ps" or "cat /proc/1/cmdline".
7 This fixes OpenWrt ticket #1485: https://dev.openwrt.org/ticket/1485
9 --- a/arch/mips/include/asm/cpu-features.h
10 +++ b/arch/mips/include/asm/cpu-features.h
12 #ifndef cpu_has_pindexed_dcache
13 #define cpu_has_pindexed_dcache (cpu_data[0].dcache.flags & MIPS_CACHE_PINDEX)
15 +#ifndef cpu_use_kmap_coherent
16 +#define cpu_use_kmap_coherent 1
20 * I-Cache snoops remote store. This only matters on SMP. Some multiprocessors
21 --- a/arch/mips/include/asm/mach-bcm47xx/cpu-feature-overrides.h
22 +++ b/arch/mips/include/asm/mach-bcm47xx/cpu-feature-overrides.h
24 #define cpu_scache_line_size() 0
27 +#define cpu_use_kmap_coherent 0
29 #endif /* __ASM_MACH_BCM47XX_CPU_FEATURE_OVERRIDES_H */
30 --- a/arch/mips/mm/c-r4k.c
31 +++ b/arch/mips/mm/c-r4k.c
32 @@ -699,7 +699,7 @@ static inline void local_r4k_flush_cache
33 map_coherent = (cpu_has_dc_aliases &&
34 page_mapcount(page) &&
35 !Page_dcache_dirty(page));
37 + if (map_coherent && cpu_use_kmap_coherent)
38 vaddr = kmap_coherent(page, addr);
40 vaddr = kmap_atomic(page);
41 @@ -721,7 +721,7 @@ static inline void local_r4k_flush_cache
46 + if (map_coherent && cpu_use_kmap_coherent)
50 --- a/arch/mips/mm/init.c
51 +++ b/arch/mips/mm/init.c
52 @@ -173,7 +173,7 @@ void copy_user_highpage(struct page *to,
55 vto = kmap_atomic(to);
56 - if (cpu_has_dc_aliases &&
57 + if (cpu_has_dc_aliases && cpu_use_kmap_coherent &&
58 page_mapcount(from) && !Page_dcache_dirty(from)) {
59 vfrom = kmap_coherent(from, vaddr);
60 copy_page(vto, vfrom);
61 @@ -195,7 +195,7 @@ void copy_to_user_page(struct vm_area_st
62 struct page *page, unsigned long vaddr, void *dst, const void *src,
65 - if (cpu_has_dc_aliases &&
66 + if (cpu_has_dc_aliases && cpu_use_kmap_coherent &&
67 page_mapcount(page) && !Page_dcache_dirty(page)) {
68 void *vto = kmap_coherent(page, vaddr) + (vaddr & ~PAGE_MASK);
69 memcpy(vto, src, len);
70 @@ -213,7 +213,7 @@ void copy_from_user_page(struct vm_area_
71 struct page *page, unsigned long vaddr, void *dst, const void *src,
74 - if (cpu_has_dc_aliases &&
75 + if (cpu_has_dc_aliases && cpu_use_kmap_coherent &&
76 page_mapcount(page) && !Page_dcache_dirty(page)) {
77 void *vfrom = kmap_coherent(page, vaddr) + (vaddr & ~PAGE_MASK);
78 memcpy(dst, vfrom, len);