From 9a74b3eb22f2d67a5681301f52aca5b7703382c8 Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Sat, 16 Feb 2008 22:34:25 +0000 Subject: [MIPS] Fix buggy invocations of kmap_coherent() kmap_coherent will only work correctly if the page it is called on is not marked dirty. If it's dirty the kernel address of the page should be used instead of a temporary mapping. Signed-off-by: Ralf Baechle --- arch/mips/mm/cache.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'arch/mips/mm/cache.c') diff --git a/arch/mips/mm/cache.c b/arch/mips/mm/cache.c index 81f30ac2bff..6a24651971d 100644 --- a/arch/mips/mm/cache.c +++ b/arch/mips/mm/cache.c @@ -92,12 +92,17 @@ EXPORT_SYMBOL(__flush_dcache_page); void __flush_anon_page(struct page *page, unsigned long vmaddr) { - if (pages_do_alias((unsigned long)page_address(page), vmaddr)) { - void *kaddr; + unsigned long addr = (unsigned long) page_address(page); - kaddr = kmap_coherent(page, vmaddr); - flush_data_cache_page((unsigned long)kaddr); - kunmap_coherent(); + if (pages_do_alias(addr, vmaddr)) { + if (page_mapped(page) && !Page_dcache_dirty(page)) { + void *kaddr; + + kaddr = kmap_coherent(page, vmaddr); + flush_data_cache_page((unsigned long)kaddr); + kunmap_coherent(); + } else + flush_data_cache_page(addr); } } -- cgit v1.2.3-70-g09d2