Skip to content

Commit efcc4ea

Browse files
Vincent ChenGreentime Hu
authored andcommitted
nds32: Correct flush_dcache_page function
1. Disable local irq before d-cache write-back and invalidate. The cpu_dcache_wbinval_page function is composed of d-cache write-back and invalidate. If the local irq is enabled when calling cpu_dcache_wbinval_page, the content of d-cache is possibly updated between write-back and invalidate. In this case, the updated data will be dropped due to the following d-cache invalidation. Therefore, we disable the local irq before calling cpu_dcache_wbinval_page. 2. Correct the data write-back for page aliasing case. Only the page whose (page->index << PAGE_SHIFT) is located at the same page color as page_address(page) needs to execute data write-back in flush_dcache_page function. Signed-off-by: Vincent Chen <[email protected]> Reviewed-by: Greentime Hu <[email protected]> Signed-off-by: Greentime Hu <[email protected]>
1 parent 1613de8 commit efcc4ea

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

arch/nds32/mm/cacheflush.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -217,17 +217,20 @@ void flush_dcache_page(struct page *page)
217217
if (mapping && !mapping_mapped(mapping))
218218
set_bit(PG_dcache_dirty, &page->flags);
219219
else {
220-
int i, pc;
221-
unsigned long vto, kaddr, flags;
220+
unsigned long kaddr, flags;
221+
222222
kaddr = (unsigned long)page_address(page);
223-
cpu_dcache_wbinval_page(kaddr);
224-
pc = CACHE_SET(DCACHE) * CACHE_LINE_SIZE(DCACHE) / PAGE_SIZE;
225223
local_irq_save(flags);
226-
for (i = 0; i < pc; i++) {
227-
vto =
228-
kremap0(kaddr + i * PAGE_SIZE, page_to_phys(page));
229-
cpu_dcache_wbinval_page(vto);
230-
kunmap01(vto);
224+
cpu_dcache_wbinval_page(kaddr);
225+
if (mapping) {
226+
unsigned long vaddr, kto;
227+
228+
vaddr = page->index << PAGE_SHIFT;
229+
if (aliasing(vaddr, kaddr)) {
230+
kto = kremap0(vaddr, page_to_phys(page));
231+
cpu_dcache_wbinval_page(kto);
232+
kunmap01(kto);
233+
}
231234
}
232235
local_irq_restore(flags);
233236
}

0 commit comments

Comments
 (0)