Fix kmap_coherent use on 2.6.25 kernels
[librecmc/librecmc.git] / target / linux / brcm47xx / patches-2.6.25 / 160-kmap_coherent.patch
1 Index: linux-2.6.25.1/arch/mips/mm/init.c
2 ===================================================================
3 --- linux-2.6.25.1.orig/arch/mips/mm/init.c     2008-05-18 11:32:33.000000000 +0100
4 +++ linux-2.6.25.1/arch/mips/mm/init.c  2008-05-18 21:05:57.000000000 +0100
5 @@ -211,7 +211,7 @@ void copy_user_highpage(struct page *to,
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             page_mapped(from) && !Page_dcache_dirty(from)) {
12                 vfrom = kmap_coherent(from, vaddr);
13                 copy_page(vto, vfrom);
14 @@ -235,7 +235,7 @@ void copy_to_user_page(struct vm_area_st
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             page_mapped(page) && !Page_dcache_dirty(page)) {
21                 void *vto = kmap_coherent(page, vaddr) + (vaddr & ~PAGE_MASK);
22                 memcpy(vto, src, len);
23 @@ -255,7 +255,7 @@ void copy_from_user_page(struct vm_area_
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             page_mapped(page) && !Page_dcache_dirty(page)) {
30                 void *vfrom = kmap_coherent(page, vaddr) + (vaddr & ~PAGE_MASK);
31                 memcpy(dst, vfrom, len);
32 Index: linux-2.6.25.1/include/asm-mips/mach-bcm47xx/cpu-feature-overrides.h
33 ===================================================================
34 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
35 +++ linux-2.6.25.1/include/asm-mips/mach-bcm47xx/cpu-feature-overrides.h        2008-05-18 11:32:40.000000000 +0100
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_BCM47XX_CPU_FEATURE_OVERRIDES_H
45 +#define __ASM_MACH_BCM47XX_CPU_FEATURE_OVERRIDES_H
46 +
47 +#define cpu_use_kmap_coherent  0
48 +
49 +#endif /* __ASM_MACH_BCM47XX_CPU_FEATURE_OVERRIDES_H */
50 Index: linux-2.6.25.1/include/asm-mips/cpu-features.h
51 ===================================================================
52 --- linux-2.6.25.1.orig/include/asm-mips/cpu-features.h 2008-05-18 11:32:33.000000000 +0100
53 +++ linux-2.6.25.1/include/asm-mips/cpu-features.h      2008-05-18 11:32:40.000000000 +0100
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.25.1/arch/mips/mm/c-r4k.c
65 ===================================================================
66 --- linux-2.6.25.1.orig/arch/mips/mm/c-r4k.c    2008-05-18 21:06:36.000000000 +0100
67 +++ linux-2.6.25.1/arch/mips/mm/c-r4k.c 2008-05-18 21:09:28.000000000 +0100
68 @@ -484,7 +484,7 @@ static inline void local_r4k_flush_cache
69                  * Use kmap_coherent or kmap_atomic to do flushes for
70                  * another ASID than the current one.
71                  */
72 -               if (cpu_has_dc_aliases)
73 +               if (cpu_has_dc_aliases && cpu_use_kmap_coherent)
74                         vaddr = kmap_coherent(page, addr);
75                 else
76                         vaddr = kmap_atomic(page, KM_USER0);
77 @@ -505,7 +505,7 @@ static inline void local_r4k_flush_cache
78         }
79  
80         if (vaddr) {
81 -               if (cpu_has_dc_aliases)
82 +               if (cpu_has_dc_aliases && cpu_use_kmap_coherent)
83                         kunmap_coherent();
84                 else
85                         kunmap_atomic(vaddr, KM_USER0);