Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

xtensa: simplify coherent_kvaddr logic

Functions coherent_kvaddr, clear_page_alias and copy_page_alias use
physical address 0 as a special value that means 'this page is in the
KSEG mapping and its existing virtual address has the same color as the
virtual address of its future mapping, so don't map it to the
TLBTEMP_BASE area'.

Simplify this logic and drop special handling of low memory pages/pages
with coherent mapping and always use TLBTEMP_BASE area.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>

+7 -38
+2 -7
arch/xtensa/mm/cache.c
··· 81 81 static inline void *coherent_kvaddr(struct page *page, unsigned long base, 82 82 unsigned long vaddr, unsigned long *paddr) 83 83 { 84 - if (PageHighMem(page) || !DCACHE_ALIAS_EQ(page_to_phys(page), vaddr)) { 85 - *paddr = page_to_phys(page); 86 - return (void *)(base + (vaddr & DCACHE_ALIAS_MASK)); 87 - } else { 88 - *paddr = 0; 89 - return page_to_virt(page); 90 - } 84 + *paddr = page_to_phys(page); 85 + return (void *)(base + (vaddr & DCACHE_ALIAS_MASK)); 91 86 } 92 87 93 88 void clear_user_highpage(struct page *page, unsigned long vaddr)
+5 -31
arch/xtensa/mm/misc.S
··· 118 118 119 119 abi_entry_default 120 120 121 - /* Skip setting up a temporary DTLB if not aliased low page. */ 122 - 123 121 movi a5, PAGE_OFFSET 124 - movi a6, 0 125 - beqz a3, 1f 126 - 127 - /* Setup a temporary DTLB for the addr. */ 128 - 129 122 addi a6, a3, (PAGE_KERNEL | _PAGE_HW_WRITE) 130 123 mov a4, a2 131 124 wdtlb a6, a2 132 125 dsync 133 126 134 - 1: movi a3, 0 127 + movi a3, 0 135 128 __loopi a2, a7, PAGE_SIZE, 32 136 129 s32i a3, a2, 0 137 130 s32i a3, a2, 4 ··· 136 143 s32i a3, a2, 28 137 144 __endla a2, a7, 32 138 145 139 - bnez a6, 1f 140 - abi_ret_default 146 + /* We need to invalidate the temporary dtlb entry. */ 141 147 142 - /* We need to invalidate the temporary idtlb entry, if any. */ 143 - 144 - 1: idtlb a4 148 + idtlb a4 145 149 dsync 146 150 147 151 abi_ret_default ··· 156 166 157 167 abi_entry_default 158 168 159 - /* Skip setting up a temporary DTLB for destination if not aliased. */ 160 - 161 - movi a6, 0 162 - movi a7, 0 163 - beqz a4, 1f 164 - 165 169 /* Setup a temporary DTLB for destination. */ 166 170 167 171 addi a6, a4, (PAGE_KERNEL | _PAGE_HW_WRITE) 168 172 wdtlb a6, a2 169 173 dsync 170 - 171 - /* Skip setting up a temporary DTLB for source if not aliased. */ 172 - 173 - 1: beqz a5, 1f 174 174 175 175 /* Setup a temporary DTLB for source. */ 176 176 ··· 199 219 200 220 /* We need to invalidate any temporary mapping! */ 201 221 202 - bnez a6, 1f 203 - bnez a7, 2f 204 - abi_ret_default 205 - 206 - 1: addi a2, a2, -PAGE_SIZE 222 + addi a2, a2, -PAGE_SIZE 207 223 idtlb a2 208 224 dsync 209 - bnez a7, 2f 210 - abi_ret_default 211 225 212 - 2: addi a3, a3, -PAGE_SIZE+1 226 + addi a3, a3, -PAGE_SIZE+1 213 227 idtlb a3 214 228 dsync 215 229