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 <vincentc@andestech.com>
Reviewed-by: Greentime Hu <greentime@andestech.com>
Signed-off-by: Greentime Hu <greentime@andestech.com>
This commit is contained in:
Vincent Chen 2018-04-24 15:08:46 +08:00 коммит произвёл Greentime Hu
Родитель 1613de8a78
Коммит efcc4ea872
1 изменённых файлов: 12 добавлений и 9 удалений

Просмотреть файл

@ -217,17 +217,20 @@ void flush_dcache_page(struct page *page)
if (mapping && !mapping_mapped(mapping)) if (mapping && !mapping_mapped(mapping))
set_bit(PG_dcache_dirty, &page->flags); set_bit(PG_dcache_dirty, &page->flags);
else { else {
int i, pc; unsigned long kaddr, flags;
unsigned long vto, kaddr, flags;
kaddr = (unsigned long)page_address(page); kaddr = (unsigned long)page_address(page);
cpu_dcache_wbinval_page(kaddr);
pc = CACHE_SET(DCACHE) * CACHE_LINE_SIZE(DCACHE) / PAGE_SIZE;
local_irq_save(flags); local_irq_save(flags);
for (i = 0; i < pc; i++) { cpu_dcache_wbinval_page(kaddr);
vto = if (mapping) {
kremap0(kaddr + i * PAGE_SIZE, page_to_phys(page)); unsigned long vaddr, kto;
cpu_dcache_wbinval_page(vto);
kunmap01(vto); vaddr = page->index << PAGE_SHIFT;
if (aliasing(vaddr, kaddr)) {
kto = kremap0(vaddr, page_to_phys(page));
cpu_dcache_wbinval_page(kto);
kunmap01(kto);
}
} }
local_irq_restore(flags); local_irq_restore(flags);
} }