ramips: fix HiWiFi HC5761A switch settings
[oweals/openwrt.git] / target / linux / brcm47xx / patches-4.19 / 160-kmap_coherent.patch
1 From: Jeff Hansen <jhansen@cardaccess-inc.com>
2 Subject: [PATCH] kmap_coherent
3
4 On ASUS WL-500gP there are some "Data bus error"s when executing simple
5 commands liks "ps" or "cat /proc/1/cmdline".
6
7 This fixes OpenWrt ticket #1485: https://dev.openwrt.org/ticket/1485
8 ---
9 --- a/arch/mips/include/asm/cpu-features.h
10 +++ b/arch/mips/include/asm/cpu-features.h
11 @@ -226,6 +226,9 @@
12  #ifndef cpu_has_local_ebase
13  #define cpu_has_local_ebase    1
14  #endif
15 +#ifndef cpu_use_kmap_coherent
16 +#define cpu_use_kmap_coherent 1
17 +#endif
18  
19  /*
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
23 @@ -80,4 +80,6 @@
24  #define cpu_scache_line_size()         0
25  #define cpu_has_vz                     0
26  
27 +#define cpu_use_kmap_coherent          0
28 +
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 @@ -694,7 +694,7 @@ static inline void local_r4k_flush_cache
33                 map_coherent = (cpu_has_dc_aliases &&
34                                 page_mapcount(page) &&
35                                 !Page_dcache_dirty(page));
36 -               if (map_coherent)
37 +               if (map_coherent && cpu_use_kmap_coherent)
38                         vaddr = kmap_coherent(page, addr);
39                 else
40                         vaddr = kmap_atomic(page);
41 @@ -719,7 +719,7 @@ static inline void local_r4k_flush_cache
42         }
43  
44         if (vaddr) {
45 -               if (map_coherent)
46 +               if (map_coherent && cpu_use_kmap_coherent)
47                         kunmap_coherent();
48                 else
49                         kunmap_atomic(vaddr);
50 --- a/arch/mips/mm/init.c
51 +++ b/arch/mips/mm/init.c
52 @@ -168,7 +168,7 @@ void copy_user_highpage(struct page *to,
53         void *vfrom, *vto;
54  
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 @@ -190,7 +190,7 @@ void copy_to_user_page(struct vm_area_st
62         struct page *page, unsigned long vaddr, void *dst, const void *src,
63         unsigned long len)
64  {
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 @@ -208,7 +208,7 @@ void copy_from_user_page(struct vm_area_
71         struct page *page, unsigned long vaddr, void *dst, const void *src,
72         unsigned long len)
73  {
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);