blob: 6f0909dda2f991f5210fbdd0d24743e95c41a05f [file] [log] [blame]
Thomas Gleixnerd2912cb2019-06-04 10:11:33 +02001// SPDX-License-Identifier: GPL-2.0-only
Russell Kingd73e60b2008-10-31 13:08:02 +00002/*
3 * linux/arch/arm/mm/copypage-xsc3.S
4 *
5 * Copyright (C) 2004 Intel Corp.
6 *
Russell Kingd73e60b2008-10-31 13:08:02 +00007 * Adapted for 3rd gen XScale core, no more mini-dcache
8 * Author: Matt Gilbert (matthew.m.gilbert@intel.com)
9 */
10#include <linux/init.h>
Russell King063b0a42008-10-31 15:08:35 +000011#include <linux/highmem.h>
Russell Kingd73e60b2008-10-31 13:08:02 +000012
13/*
14 * General note:
15 * We don't really want write-allocate cache behaviour for these functions
16 * since that will just eat through 8K of the cache.
17 */
18
19/*
Russell King063b0a42008-10-31 15:08:35 +000020 * XSC3 optimised copy_user_highpage
Russell Kingd73e60b2008-10-31 13:08:02 +000021 *
22 * The source page may have some clean entries in the cache already, but we
23 * can safely ignore them - break_cow() will flush them out of the cache
24 * if we eventually end up using our copied page.
25 *
26 */
Nicolas Pitreb99afae2018-11-07 17:49:00 +010027static void xsc3_mc_copy_user_page(void *kto, const void *kfrom)
Russell Kingd73e60b2008-10-31 13:08:02 +000028{
Nicolas Pitreb99afae2018-11-07 17:49:00 +010029 int tmp;
30
31 asm volatile ("\
32 pld [%1, #0] \n\
33 pld [%1, #32] \n\
341: pld [%1, #64] \n\
35 pld [%1, #96] \n\
Russell Kingd73e60b2008-10-31 13:08:02 +000036 \n\
Nicolas Pitrebc2eca92018-11-09 04:26:39 +0100372: ldrd r2, r3, [%1], #8 \n\
38 ldrd r4, r5, [%1], #8 \n\
Nicolas Pitreb99afae2018-11-07 17:49:00 +010039 mcr p15, 0, %0, c7, c6, 1 @ invalidate\n\
Nicolas Pitrebc2eca92018-11-09 04:26:39 +010040 strd r2, r3, [%0], #8 \n\
41 ldrd r2, r3, [%1], #8 \n\
42 strd r4, r5, [%0], #8 \n\
43 ldrd r4, r5, [%1], #8 \n\
44 strd r2, r3, [%0], #8 \n\
45 strd r4, r5, [%0], #8 \n\
46 ldrd r2, r3, [%1], #8 \n\
47 ldrd r4, r5, [%1], #8 \n\
Nicolas Pitreb99afae2018-11-07 17:49:00 +010048 mcr p15, 0, %0, c7, c6, 1 @ invalidate\n\
Nicolas Pitrebc2eca92018-11-09 04:26:39 +010049 strd r2, r3, [%0], #8 \n\
50 ldrd r2, r3, [%1], #8 \n\
Nicolas Pitreb99afae2018-11-07 17:49:00 +010051 subs %2, %2, #1 \n\
Nicolas Pitrebc2eca92018-11-09 04:26:39 +010052 strd r4, r5, [%0], #8 \n\
53 ldrd r4, r5, [%1], #8 \n\
54 strd r2, r3, [%0], #8 \n\
55 strd r4, r5, [%0], #8 \n\
Russell Kingd73e60b2008-10-31 13:08:02 +000056 bgt 1b \n\
Nicolas Pitreb99afae2018-11-07 17:49:00 +010057 beq 2b "
58 : "+&r" (kto), "+&r" (kfrom), "=&r" (tmp)
59 : "2" (PAGE_SIZE / 64 - 1)
60 : "r2", "r3", "r4", "r5");
Russell Kingd73e60b2008-10-31 13:08:02 +000061}
62
Russell King063b0a42008-10-31 15:08:35 +000063void xsc3_mc_copy_user_highpage(struct page *to, struct page *from,
Russell Kingf00a75c2009-10-05 15:17:45 +010064 unsigned long vaddr, struct vm_area_struct *vma)
Russell King063b0a42008-10-31 15:08:35 +000065{
66 void *kto, *kfrom;
67
Cong Wang5472e862011-11-25 23:14:15 +080068 kto = kmap_atomic(to);
69 kfrom = kmap_atomic(from);
Russell King27258982009-10-05 15:34:22 +010070 flush_cache_page(vma, vaddr, page_to_pfn(from));
Russell King063b0a42008-10-31 15:08:35 +000071 xsc3_mc_copy_user_page(kto, kfrom);
Cong Wang5472e862011-11-25 23:14:15 +080072 kunmap_atomic(kfrom);
73 kunmap_atomic(kto);
Russell King063b0a42008-10-31 15:08:35 +000074}
75
Russell Kingd73e60b2008-10-31 13:08:02 +000076/*
77 * XScale optimised clear_user_page
Russell Kingd73e60b2008-10-31 13:08:02 +000078 */
Russell King303c6442008-10-31 16:32:19 +000079void xsc3_mc_clear_user_highpage(struct page *page, unsigned long vaddr)
Russell Kingd73e60b2008-10-31 13:08:02 +000080{
Cong Wang5472e862011-11-25 23:14:15 +080081 void *ptr, *kaddr = kmap_atomic(page);
Nicolas Pitre43ae2862008-11-04 02:42:27 -050082 asm volatile ("\
83 mov r1, %2 \n\
Russell Kingd73e60b2008-10-31 13:08:02 +000084 mov r2, #0 \n\
85 mov r3, #0 \n\
Russell King303c6442008-10-31 16:32:19 +0000861: mcr p15, 0, %0, c7, c6, 1 @ invalidate line\n\
Nicolas Pitrebc2eca92018-11-09 04:26:39 +010087 strd r2, r3, [%0], #8 \n\
88 strd r2, r3, [%0], #8 \n\
89 strd r2, r3, [%0], #8 \n\
90 strd r2, r3, [%0], #8 \n\
Russell Kingd73e60b2008-10-31 13:08:02 +000091 subs r1, r1, #1 \n\
Russell King303c6442008-10-31 16:32:19 +000092 bne 1b"
Nicolas Pitre43ae2862008-11-04 02:42:27 -050093 : "=r" (ptr)
94 : "0" (kaddr), "I" (PAGE_SIZE / 32)
Russell King303c6442008-10-31 16:32:19 +000095 : "r1", "r2", "r3");
Cong Wang5472e862011-11-25 23:14:15 +080096 kunmap_atomic(kaddr);
Russell Kingd73e60b2008-10-31 13:08:02 +000097}
98
99struct cpu_user_fns xsc3_mc_user_fns __initdata = {
Russell King303c6442008-10-31 16:32:19 +0000100 .cpu_clear_user_highpage = xsc3_mc_clear_user_highpage,
Russell King063b0a42008-10-31 15:08:35 +0000101 .cpu_copy_user_highpage = xsc3_mc_copy_user_highpage,
Russell Kingd73e60b2008-10-31 13:08:02 +0000102};