Skip to content

Commit 4f22ca7

Browse files
committed
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 <[email protected]>
1 parent 2da7559 commit 4f22ca7

File tree

2 files changed

+7
-38
lines changed

2 files changed

+7
-38
lines changed

arch/xtensa/mm/cache.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,8 @@ static inline void kmap_invalidate_coherent(struct page *page,
8181
static inline void *coherent_kvaddr(struct page *page, unsigned long base,
8282
unsigned long vaddr, unsigned long *paddr)
8383
{
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));
9186
}
9287

9388
void clear_user_highpage(struct page *page, unsigned long vaddr)

arch/xtensa/mm/misc.S

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -118,20 +118,13 @@ ENTRY(clear_page_alias)
118118

119119
abi_entry_default
120120

121-
/* Skip setting up a temporary DTLB if not aliased low page. */
122-
123121
movi a5, PAGE_OFFSET
124-
movi a6, 0
125-
beqz a3, 1f
126-
127-
/* Setup a temporary DTLB for the addr. */
128-
129122
addi a6, a3, (PAGE_KERNEL | _PAGE_HW_WRITE)
130123
mov a4, a2
131124
wdtlb a6, a2
132125
dsync
133126

134-
1: movi a3, 0
127+
movi a3, 0
135128
__loopi a2, a7, PAGE_SIZE, 32
136129
s32i a3, a2, 0
137130
s32i a3, a2, 4
@@ -143,12 +136,9 @@ ENTRY(clear_page_alias)
143136
s32i a3, a2, 28
144137
__endla a2, a7, 32
145138

146-
bnez a6, 1f
147-
abi_ret_default
148-
149-
/* We need to invalidate the temporary idtlb entry, if any. */
139+
/* We need to invalidate the temporary dtlb entry. */
150140

151-
1: idtlb a4
141+
idtlb a4
152142
dsync
153143

154144
abi_ret_default
@@ -166,22 +156,12 @@ ENTRY(copy_page_alias)
166156

167157
abi_entry_default
168158

169-
/* Skip setting up a temporary DTLB for destination if not aliased. */
170-
171-
movi a6, 0
172-
movi a7, 0
173-
beqz a4, 1f
174-
175159
/* Setup a temporary DTLB for destination. */
176160

177161
addi a6, a4, (PAGE_KERNEL | _PAGE_HW_WRITE)
178162
wdtlb a6, a2
179163
dsync
180164

181-
/* Skip setting up a temporary DTLB for source if not aliased. */
182-
183-
1: beqz a5, 1f
184-
185165
/* Setup a temporary DTLB for source. */
186166

187167
addi a7, a5, PAGE_KERNEL
@@ -219,17 +199,11 @@ ENTRY(copy_page_alias)
219199

220200
/* We need to invalidate any temporary mapping! */
221201

222-
bnez a6, 1f
223-
bnez a7, 2f
224-
abi_ret_default
225-
226-
1: addi a2, a2, -PAGE_SIZE
202+
addi a2, a2, -PAGE_SIZE
227203
idtlb a2
228204
dsync
229-
bnez a7, 2f
230-
abi_ret_default
231205

232-
2: addi a3, a3, -PAGE_SIZE+1
206+
addi a3, a3, -PAGE_SIZE+1
233207
idtlb a3
234208
dsync
235209

0 commit comments

Comments
 (0)