Thomas Gleixner | d2912cb | 2019-06-04 10:11:33 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Russell King | d73e60b | 2008-10-31 13:08:02 +0000 | [diff] [blame] | 2 | /* |
| 3 | * linux/arch/arm/mm/copypage-xsc3.S |
| 4 | * |
| 5 | * Copyright (C) 2004 Intel Corp. |
| 6 | * |
Russell King | d73e60b | 2008-10-31 13:08:02 +0000 | [diff] [blame] | 7 | * 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 King | 063b0a4 | 2008-10-31 15:08:35 +0000 | [diff] [blame] | 11 | #include <linux/highmem.h> |
Russell King | d73e60b | 2008-10-31 13:08:02 +0000 | [diff] [blame] | 12 | |
| 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 King | 063b0a4 | 2008-10-31 15:08:35 +0000 | [diff] [blame] | 20 | * XSC3 optimised copy_user_highpage |
Russell King | d73e60b | 2008-10-31 13:08:02 +0000 | [diff] [blame] | 21 | * |
| 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 Pitre | b99afae | 2018-11-07 17:49:00 +0100 | [diff] [blame] | 27 | static void xsc3_mc_copy_user_page(void *kto, const void *kfrom) |
Russell King | d73e60b | 2008-10-31 13:08:02 +0000 | [diff] [blame] | 28 | { |
Nicolas Pitre | b99afae | 2018-11-07 17:49:00 +0100 | [diff] [blame] | 29 | int tmp; |
| 30 | |
| 31 | asm volatile ("\ |
| 32 | pld [%1, #0] \n\ |
| 33 | pld [%1, #32] \n\ |
| 34 | 1: pld [%1, #64] \n\ |
| 35 | pld [%1, #96] \n\ |
Russell King | d73e60b | 2008-10-31 13:08:02 +0000 | [diff] [blame] | 36 | \n\ |
Nicolas Pitre | bc2eca9 | 2018-11-09 04:26:39 +0100 | [diff] [blame] | 37 | 2: ldrd r2, r3, [%1], #8 \n\ |
| 38 | ldrd r4, r5, [%1], #8 \n\ |
Nicolas Pitre | b99afae | 2018-11-07 17:49:00 +0100 | [diff] [blame] | 39 | mcr p15, 0, %0, c7, c6, 1 @ invalidate\n\ |
Nicolas Pitre | bc2eca9 | 2018-11-09 04:26:39 +0100 | [diff] [blame] | 40 | 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 Pitre | b99afae | 2018-11-07 17:49:00 +0100 | [diff] [blame] | 48 | mcr p15, 0, %0, c7, c6, 1 @ invalidate\n\ |
Nicolas Pitre | bc2eca9 | 2018-11-09 04:26:39 +0100 | [diff] [blame] | 49 | strd r2, r3, [%0], #8 \n\ |
| 50 | ldrd r2, r3, [%1], #8 \n\ |
Nicolas Pitre | b99afae | 2018-11-07 17:49:00 +0100 | [diff] [blame] | 51 | subs %2, %2, #1 \n\ |
Nicolas Pitre | bc2eca9 | 2018-11-09 04:26:39 +0100 | [diff] [blame] | 52 | 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 King | d73e60b | 2008-10-31 13:08:02 +0000 | [diff] [blame] | 56 | bgt 1b \n\ |
Nicolas Pitre | b99afae | 2018-11-07 17:49:00 +0100 | [diff] [blame] | 57 | beq 2b " |
| 58 | : "+&r" (kto), "+&r" (kfrom), "=&r" (tmp) |
| 59 | : "2" (PAGE_SIZE / 64 - 1) |
| 60 | : "r2", "r3", "r4", "r5"); |
Russell King | d73e60b | 2008-10-31 13:08:02 +0000 | [diff] [blame] | 61 | } |
| 62 | |
Russell King | 063b0a4 | 2008-10-31 15:08:35 +0000 | [diff] [blame] | 63 | void xsc3_mc_copy_user_highpage(struct page *to, struct page *from, |
Russell King | f00a75c | 2009-10-05 15:17:45 +0100 | [diff] [blame] | 64 | unsigned long vaddr, struct vm_area_struct *vma) |
Russell King | 063b0a4 | 2008-10-31 15:08:35 +0000 | [diff] [blame] | 65 | { |
| 66 | void *kto, *kfrom; |
| 67 | |
Cong Wang | 5472e86 | 2011-11-25 23:14:15 +0800 | [diff] [blame] | 68 | kto = kmap_atomic(to); |
| 69 | kfrom = kmap_atomic(from); |
Russell King | 2725898 | 2009-10-05 15:34:22 +0100 | [diff] [blame] | 70 | flush_cache_page(vma, vaddr, page_to_pfn(from)); |
Russell King | 063b0a4 | 2008-10-31 15:08:35 +0000 | [diff] [blame] | 71 | xsc3_mc_copy_user_page(kto, kfrom); |
Cong Wang | 5472e86 | 2011-11-25 23:14:15 +0800 | [diff] [blame] | 72 | kunmap_atomic(kfrom); |
| 73 | kunmap_atomic(kto); |
Russell King | 063b0a4 | 2008-10-31 15:08:35 +0000 | [diff] [blame] | 74 | } |
| 75 | |
Russell King | d73e60b | 2008-10-31 13:08:02 +0000 | [diff] [blame] | 76 | /* |
| 77 | * XScale optimised clear_user_page |
Russell King | d73e60b | 2008-10-31 13:08:02 +0000 | [diff] [blame] | 78 | */ |
Russell King | 303c644 | 2008-10-31 16:32:19 +0000 | [diff] [blame] | 79 | void xsc3_mc_clear_user_highpage(struct page *page, unsigned long vaddr) |
Russell King | d73e60b | 2008-10-31 13:08:02 +0000 | [diff] [blame] | 80 | { |
Cong Wang | 5472e86 | 2011-11-25 23:14:15 +0800 | [diff] [blame] | 81 | void *ptr, *kaddr = kmap_atomic(page); |
Nicolas Pitre | 43ae286 | 2008-11-04 02:42:27 -0500 | [diff] [blame] | 82 | asm volatile ("\ |
| 83 | mov r1, %2 \n\ |
Russell King | d73e60b | 2008-10-31 13:08:02 +0000 | [diff] [blame] | 84 | mov r2, #0 \n\ |
| 85 | mov r3, #0 \n\ |
Russell King | 303c644 | 2008-10-31 16:32:19 +0000 | [diff] [blame] | 86 | 1: mcr p15, 0, %0, c7, c6, 1 @ invalidate line\n\ |
Nicolas Pitre | bc2eca9 | 2018-11-09 04:26:39 +0100 | [diff] [blame] | 87 | 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 King | d73e60b | 2008-10-31 13:08:02 +0000 | [diff] [blame] | 91 | subs r1, r1, #1 \n\ |
Russell King | 303c644 | 2008-10-31 16:32:19 +0000 | [diff] [blame] | 92 | bne 1b" |
Nicolas Pitre | 43ae286 | 2008-11-04 02:42:27 -0500 | [diff] [blame] | 93 | : "=r" (ptr) |
| 94 | : "0" (kaddr), "I" (PAGE_SIZE / 32) |
Russell King | 303c644 | 2008-10-31 16:32:19 +0000 | [diff] [blame] | 95 | : "r1", "r2", "r3"); |
Cong Wang | 5472e86 | 2011-11-25 23:14:15 +0800 | [diff] [blame] | 96 | kunmap_atomic(kaddr); |
Russell King | d73e60b | 2008-10-31 13:08:02 +0000 | [diff] [blame] | 97 | } |
| 98 | |
| 99 | struct cpu_user_fns xsc3_mc_user_fns __initdata = { |
Russell King | 303c644 | 2008-10-31 16:32:19 +0000 | [diff] [blame] | 100 | .cpu_clear_user_highpage = xsc3_mc_clear_user_highpage, |
Russell King | 063b0a4 | 2008-10-31 15:08:35 +0000 | [diff] [blame] | 101 | .cpu_copy_user_highpage = xsc3_mc_copy_user_highpage, |
Russell King | d73e60b | 2008-10-31 13:08:02 +0000 | [diff] [blame] | 102 | }; |