blob: 03a2042aced5f88b54e224396720c95d5fc3acce [file] [log] [blame]
Russell Kingd73e60b2008-10-31 13:08:02 +00001/*
2 * linux/arch/arm/mm/copypage-xsc3.S
3 *
4 * Copyright (C) 2004 Intel Corp.
5 *
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.
9 *
10 * Adapted for 3rd gen XScale core, no more mini-dcache
11 * Author: Matt Gilbert (matthew.m.gilbert@intel.com)
12 */
13#include <linux/init.h>
Russell King063b0a42008-10-31 15:08:35 +000014#include <linux/highmem.h>
Russell Kingd73e60b2008-10-31 13:08:02 +000015
16/*
17 * General note:
18 * We don't really want write-allocate cache behaviour for these functions
19 * since that will just eat through 8K of the cache.
20 */
21
22/*
Russell King063b0a42008-10-31 15:08:35 +000023 * XSC3 optimised copy_user_highpage
Russell Kingd73e60b2008-10-31 13:08:02 +000024 * r0 = destination
25 * r1 = source
Russell Kingd73e60b2008-10-31 13:08:02 +000026 *
27 * The source page may have some clean entries in the cache already, but we
28 * can safely ignore them - break_cow() will flush them out of the cache
29 * if we eventually end up using our copied page.
30 *
31 */
Uwe Kleine-König446c92b2009-03-12 18:03:16 +010032static void __naked
Russell King063b0a42008-10-31 15:08:35 +000033xsc3_mc_copy_user_page(void *kto, const void *kfrom)
Russell Kingd73e60b2008-10-31 13:08:02 +000034{
35 asm("\
36 stmfd sp!, {r4, r5, lr} \n\
Khem Raj9a40ac862010-06-04 04:05:15 +010037 mov lr, %2 \n\
Russell Kingd73e60b2008-10-31 13:08:02 +000038 \n\
39 pld [r1, #0] \n\
40 pld [r1, #32] \n\
411: pld [r1, #64] \n\
42 pld [r1, #96] \n\
43 \n\
442: ldrd r2, [r1], #8 \n\
45 mov ip, r0 \n\
46 ldrd r4, [r1], #8 \n\
47 mcr p15, 0, ip, c7, c6, 1 @ invalidate\n\
48 strd r2, [r0], #8 \n\
49 ldrd r2, [r1], #8 \n\
50 strd r4, [r0], #8 \n\
51 ldrd r4, [r1], #8 \n\
52 strd r2, [r0], #8 \n\
53 strd r4, [r0], #8 \n\
54 ldrd r2, [r1], #8 \n\
55 mov ip, r0 \n\
56 ldrd r4, [r1], #8 \n\
57 mcr p15, 0, ip, c7, c6, 1 @ invalidate\n\
58 strd r2, [r0], #8 \n\
59 ldrd r2, [r1], #8 \n\
60 subs lr, lr, #1 \n\
61 strd r4, [r0], #8 \n\
62 ldrd r4, [r1], #8 \n\
63 strd r2, [r0], #8 \n\
64 strd r4, [r0], #8 \n\
65 bgt 1b \n\
66 beq 2b \n\
67 \n\
68 ldmfd sp!, {r4, r5, pc}"
69 :
Khem Raj9a40ac862010-06-04 04:05:15 +010070 : "r" (kto), "r" (kfrom), "I" (PAGE_SIZE / 64 - 1));
Russell Kingd73e60b2008-10-31 13:08:02 +000071}
72
Russell King063b0a42008-10-31 15:08:35 +000073void xsc3_mc_copy_user_highpage(struct page *to, struct page *from,
Russell Kingf00a75c2009-10-05 15:17:45 +010074 unsigned long vaddr, struct vm_area_struct *vma)
Russell King063b0a42008-10-31 15:08:35 +000075{
76 void *kto, *kfrom;
77
Cong Wang5472e862011-11-25 23:14:15 +080078 kto = kmap_atomic(to);
79 kfrom = kmap_atomic(from);
Russell King27258982009-10-05 15:34:22 +010080 flush_cache_page(vma, vaddr, page_to_pfn(from));
Russell King063b0a42008-10-31 15:08:35 +000081 xsc3_mc_copy_user_page(kto, kfrom);
Cong Wang5472e862011-11-25 23:14:15 +080082 kunmap_atomic(kfrom);
83 kunmap_atomic(kto);
Russell King063b0a42008-10-31 15:08:35 +000084}
85
Russell Kingd73e60b2008-10-31 13:08:02 +000086/*
87 * XScale optimised clear_user_page
88 * r0 = destination
89 * r1 = virtual user address of ultimate destination page
90 */
Russell King303c6442008-10-31 16:32:19 +000091void xsc3_mc_clear_user_highpage(struct page *page, unsigned long vaddr)
Russell Kingd73e60b2008-10-31 13:08:02 +000092{
Cong Wang5472e862011-11-25 23:14:15 +080093 void *ptr, *kaddr = kmap_atomic(page);
Nicolas Pitre43ae2862008-11-04 02:42:27 -050094 asm volatile ("\
95 mov r1, %2 \n\
Russell Kingd73e60b2008-10-31 13:08:02 +000096 mov r2, #0 \n\
97 mov r3, #0 \n\
Russell King303c6442008-10-31 16:32:19 +0000981: mcr p15, 0, %0, c7, c6, 1 @ invalidate line\n\
99 strd r2, [%0], #8 \n\
100 strd r2, [%0], #8 \n\
101 strd r2, [%0], #8 \n\
102 strd r2, [%0], #8 \n\
Russell Kingd73e60b2008-10-31 13:08:02 +0000103 subs r1, r1, #1 \n\
Russell King303c6442008-10-31 16:32:19 +0000104 bne 1b"
Nicolas Pitre43ae2862008-11-04 02:42:27 -0500105 : "=r" (ptr)
106 : "0" (kaddr), "I" (PAGE_SIZE / 32)
Russell King303c6442008-10-31 16:32:19 +0000107 : "r1", "r2", "r3");
Cong Wang5472e862011-11-25 23:14:15 +0800108 kunmap_atomic(kaddr);
Russell Kingd73e60b2008-10-31 13:08:02 +0000109}
110
111struct cpu_user_fns xsc3_mc_user_fns __initdata = {
Russell King303c6442008-10-31 16:32:19 +0000112 .cpu_clear_user_highpage = xsc3_mc_clear_user_highpage,
Russell King063b0a42008-10-31 15:08:35 +0000113 .cpu_copy_user_highpage = xsc3_mc_copy_user_highpage,
Russell Kingd73e60b2008-10-31 13:08:02 +0000114};