brcm47xx: fix parts of the cache code that were not covered by the kmap_coherent...
[openwrt.git] / target / linux / brcm47xx-2.6 / patches-2.6.22 / 160-kmap_coherent.patch
1 Index: linux-2.6.22-rc5/arch/mips/mm/init.c
2 ===================================================================
3 --- linux-2.6.22-rc5.orig/arch/mips/mm/init.c   2007-06-27 23:40:06.406545264 +0200
4 +++ linux-2.6.22-rc5/arch/mips/mm/init.c        2007-06-27 23:40:08.920163136 +0200
5 @@ -207,7 +207,7 @@
6         void *vfrom, *vto;
7  
8         vto = kmap_atomic(to, KM_USER1);
9 -       if (cpu_has_dc_aliases) {
10 +       if (cpu_has_dc_aliases && cpu_use_kmap_coherent) {
11                 vfrom = kmap_coherent(from, vaddr);
12                 copy_page(vto, vfrom);
13                 kunmap_coherent();
14 @@ -230,7 +230,7 @@
15         struct page *page, unsigned long vaddr, void *dst, const void *src,
16         unsigned long len)
17  {
18 -       if (cpu_has_dc_aliases) {
19 +       if (cpu_has_dc_aliases && cpu_use_kmap_coherent) {
20                 void *vto = kmap_coherent(page, vaddr) + (vaddr & ~PAGE_MASK);
21                 memcpy(vto, src, len);
22                 kunmap_coherent();
23 @@ -246,7 +246,7 @@
24         struct page *page, unsigned long vaddr, void *dst, const void *src,
25         unsigned long len)
26  {
27 -       if (cpu_has_dc_aliases) {
28 +       if (cpu_has_dc_aliases && cpu_use_kmap_coherent) {
29                 void *vfrom =
30                         kmap_coherent(page, vaddr) + (vaddr & ~PAGE_MASK);
31                 memcpy(dst, vfrom, len);
32 Index: linux-2.6.22-rc5/include/asm-mips/mach-bcm947xx/cpu-feature-overrides.h
33 ===================================================================
34 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
35 +++ linux-2.6.22-rc5/include/asm-mips/mach-bcm947xx/cpu-feature-overrides.h     2007-06-27 23:40:08.921162984 +0200
36 @@ -0,0 +1,13 @@
37 +/*
38 + * This file is subject to the terms and conditions of the GNU General Public
39 + * License.  See the file "COPYING" in the main directory of this archive
40 + * for more details.
41 + *
42 + * Copyright (C) 2005 Ralf Baechle (ralf@linux-mips.org)
43 + */
44 +#ifndef __ASM_MACH_BCM947XX_CPU_FEATURE_OVERRIDES_H
45 +#define __ASM_MACH_BCM947XX_CPU_FEATURE_OVERRIDES_H
46 +
47 +#define cpu_use_kmap_coherent  0
48 +
49 +#endif /* __ASM_MACH_BCM947XX_CPU_FEATURE_OVERRIDES_H */
50 Index: linux-2.6.22-rc5/include/asm-mips/cpu-features.h
51 ===================================================================
52 --- linux-2.6.22-rc5.orig/include/asm-mips/cpu-features.h       2007-06-27 23:40:06.419543288 +0200
53 +++ linux-2.6.22-rc5/include/asm-mips/cpu-features.h    2007-06-27 23:40:08.921162984 +0200
54 @@ -101,6 +101,9 @@
55  #ifndef cpu_has_pindexed_dcache
56  #define cpu_has_pindexed_dcache        (cpu_data[0].dcache.flags & MIPS_CACHE_PINDEX)
57  #endif
58 +#ifndef cpu_use_kmap_coherent
59 +#define cpu_use_kmap_coherent 1
60 +#endif
61  
62  /*
63   * I-Cache snoops remote store.  This only matters on SMP.  Some multiprocessors
64 Index: linux-2.6.22-rc5/arch/mips/mm/c-r4k.c
65 ===================================================================
66 --- linux-2.6.22-rc5.orig/arch/mips/mm/c-r4k.c  2007-06-27 23:40:45.883543848 +0200
67 +++ linux-2.6.22-rc5/arch/mips/mm/c-r4k.c       2007-06-27 23:42:06.682260576 +0200
68 @@ -339,7 +339,7 @@
69  
70  static void r4k_flush_cache_all(void)
71  {
72 -       if (!cpu_has_dc_aliases)
73 +       if (!cpu_has_dc_aliases || !cpu_use_kmap_coherent)
74                 return;
75  
76         r4k_on_each_cpu(local_r4k_flush_cache_all, NULL, 1, 1);
77 @@ -380,7 +380,7 @@
78  static void r4k_flush_cache_range(struct vm_area_struct *vma,
79         unsigned long start, unsigned long end)
80  {
81 -       if (!cpu_has_dc_aliases)
82 +       if (!cpu_has_dc_aliases || !cpu_use_kmap_coherent)
83                 return;
84  
85         r4k_on_each_cpu(local_r4k_flush_cache_range, vma, 1, 1);
86 @@ -412,7 +412,7 @@
87  
88  static void r4k_flush_cache_mm(struct mm_struct *mm)
89  {
90 -       if (!cpu_has_dc_aliases)
91 +       if (!cpu_has_dc_aliases || !cpu_use_kmap_coherent)
92                 return;
93  
94         r4k_on_each_cpu(local_r4k_flush_cache_mm, mm, 1, 1);