2 * linux/arch/arm/lib/copypage-xscale.S
4 * Copyright (C) 1995-2005 Russell King
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 * This handles the mini data cache, as found on SA11x0 and XScale
11 * processors. When we copy a user page page, we map it in such a way
12 * that accesses to this page will not touch the main data cache, but
13 * will be cached in the mini data cache. This prevents us thrashing
14 * the main data cache on page faults.
16 #include <linux/init.h>
18 #include <linux/highmem.h>
20 #include <asm/pgtable.h>
21 #include <asm/tlbflush.h>
22 #include <asm/cacheflush.h>
27 * 0xffff8000 to 0xffffffff is reserved for any ARM architecture
28 * specific hacks for copying pages efficiently.
30 #define COPYPAGE_MINICACHE 0xffff8000
32 #define minicache_pgprot __pgprot(L_PTE_PRESENT | L_PTE_YOUNG | \
35 static DEFINE_RAW_SPINLOCK(minicache_lock
);
38 * XScale mini-dcache optimised copy_user_highpage
40 * We flush the destination cache lines just before we write the data into the
41 * corresponding address. Since the Dcache is read-allocate, this removes the
42 * Dcache aliasing issue. The writes will be forwarded to the write buffer,
43 * and merged as appropriate.
46 mc_copy_user_page(void *from
, void *to
)
49 * Strangely enough, best performance is achieved
50 * when prefetching destination as well. (NP)
53 "stmfd sp!, {r4, r5, lr} \n\
63 2: ldrd r2, [r0], #8 \n\
72 mcr p15, 0, ip, c7, c10, 1 @ clean D line\n\
74 mcr p15, 0, ip, c7, c6, 1 @ invalidate D line\n\
83 mcr p15, 0, ip, c7, c10, 1 @ clean D line\n\
85 mcr p15, 0, ip, c7, c6, 1 @ invalidate D line\n\
88 ldmfd sp!, {r4, r5, pc} "
90 : "r" (from
), "r" (to
), "I" (PAGE_SIZE
/ 64 - 1));
93 void xscale_mc_copy_user_highpage(struct page
*to
, struct page
*from
,
94 unsigned long vaddr
, struct vm_area_struct
*vma
)
96 void *kto
= kmap_atomic(to
, KM_USER1
);
98 if (!test_and_set_bit(PG_dcache_clean
, &from
->flags
))
99 __flush_dcache_page(page_mapping(from
), from
);
101 raw_spin_lock(&minicache_lock
);
103 set_pte_ext(TOP_PTE(COPYPAGE_MINICACHE
), pfn_pte(page_to_pfn(from
), minicache_pgprot
), 0);
104 flush_tlb_kernel_page(COPYPAGE_MINICACHE
);
106 mc_copy_user_page((void *)COPYPAGE_MINICACHE
, kto
);
108 raw_spin_unlock(&minicache_lock
);
110 kunmap_atomic(kto
, KM_USER1
);
114 * XScale optimised clear_user_page
117 xscale_mc_clear_user_highpage(struct page
*page
, unsigned long vaddr
)
119 void *ptr
, *kaddr
= kmap_atomic(page
, KM_USER0
);
125 strd r2, [%0], #8 \n\
126 strd r2, [%0], #8 \n\
127 strd r2, [%0], #8 \n\
128 strd r2, [%0], #8 \n\
129 mcr p15, 0, ip, c7, c10, 1 @ clean D line\n\
131 mcr p15, 0, ip, c7, c6, 1 @ invalidate D line\n\
134 : "0" (kaddr
), "I" (PAGE_SIZE
/ 32)
135 : "r1", "r2", "r3", "ip");
136 kunmap_atomic(kaddr
, KM_USER0
);
139 struct cpu_user_fns xscale_mc_user_fns __initdata
= {
140 .cpu_clear_user_highpage
= xscale_mc_clear_user_highpage
,
141 .cpu_copy_user_highpage
= xscale_mc_copy_user_highpage
,