]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
ARM: 6379/1: Assume new page cache pages have dirty D-cache
authorCatalin Marinas <catalin.marinas@arm.com>
Mon, 13 Sep 2010 14:57:36 +0000 (15:57 +0100)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Sun, 19 Sep 2010 11:17:43 +0000 (12:17 +0100)
There are places in Linux where writes to newly allocated page cache
pages happen without a subsequent call to flush_dcache_page() (several
PIO drivers including USB HCD). This patch changes the meaning of
PG_arch_1 to be PG_dcache_clean and always flush the D-cache for a newly
mapped page in update_mmu_cache().

The patch also sets the PG_arch_1 bit in the DMA cache maintenance
function to avoid additional cache flushing in update_mmu_cache().

Tested-by: Rabin Vincent <rabin.vincent@stericsson.com>
Cc: Nicolas Pitre <nicolas.pitre@linaro.org>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
arch/arm/include/asm/cacheflush.h
arch/arm/include/asm/tlbflush.h
arch/arm/mm/copypage-v4mc.c
arch/arm/mm/copypage-v6.c
arch/arm/mm/copypage-xscale.c
arch/arm/mm/dma-mapping.c
arch/arm/mm/fault-armv.c
arch/arm/mm/flush.c

index 4656a24058d21f75d30097ae5b06a1b66863bdd9..d3730f0f4b503184eb2ad1b4546396a20b0a69cb 100644 (file)
 #endif
 
 /*
- * This flag is used to indicate that the page pointed to by a pte
- * is dirty and requires cleaning before returning it to the user.
+ * This flag is used to indicate that the page pointed to by a pte is clean
+ * and does not require cleaning before returning it to the user.
  */
-#define PG_dcache_dirty PG_arch_1
+#define PG_dcache_clean PG_arch_1
 
 /*
  *     MM Cache Management
index 33b546ae72d49c82545271372a1972283f7ddb5b..9ad329ad74586a4f09e20f9135cdbda94e4c839a 100644 (file)
@@ -560,7 +560,7 @@ extern void flush_tlb_kernel_range(unsigned long start, unsigned long end);
 #endif
 
 /*
- * if PG_dcache_dirty is set for the page, we need to ensure that any
+ * If PG_dcache_clean is not set for the page, we need to ensure that any
  * cache entries for the kernels virtual memory range are written
  * back to the page.
  */
index 598c51ad50717f28d00202a9f8fd185b6a58b6a8..b8061519ce776b7dbc049815c4fbff21daa073ef 100644 (file)
@@ -73,7 +73,7 @@ void v4_mc_copy_user_highpage(struct page *to, struct page *from,
 {
        void *kto = kmap_atomic(to, KM_USER1);
 
-       if (test_and_clear_bit(PG_dcache_dirty, &from->flags))
+       if (!test_and_set_bit(PG_dcache_clean, &from->flags))
                __flush_dcache_page(page_mapping(from), from);
 
        spin_lock(&minicache_lock);
index f55fa1044f72b829d0c307683f9ab12d768a4893..bdba6c65c901a1c682f1aaf0fce3875ad8fa448b 100644 (file)
@@ -79,7 +79,7 @@ static void v6_copy_user_highpage_aliasing(struct page *to,
        unsigned int offset = CACHE_COLOUR(vaddr);
        unsigned long kfrom, kto;
 
-       if (test_and_clear_bit(PG_dcache_dirty, &from->flags))
+       if (!test_and_set_bit(PG_dcache_clean, &from->flags))
                __flush_dcache_page(page_mapping(from), from);
 
        /* FIXME: not highmem safe */
index 9920c0ae2096cc2c6b8c9e535dc63ab5d400afb0..649bbcd325bffb27b263d0e43a484cc279c12a05 100644 (file)
@@ -95,7 +95,7 @@ void xscale_mc_copy_user_highpage(struct page *to, struct page *from,
 {
        void *kto = kmap_atomic(to, KM_USER1);
 
-       if (test_and_clear_bit(PG_dcache_dirty, &from->flags))
+       if (!test_and_set_bit(PG_dcache_clean, &from->flags))
                __flush_dcache_page(page_mapping(from), from);
 
        spin_lock(&minicache_lock);
index 4bc43e535d3baadc657df9af504078ff1ae00570..e4dd0646e85978b89a164c40100d0561bd1005f7 100644 (file)
@@ -523,6 +523,12 @@ void ___dma_page_dev_to_cpu(struct page *page, unsigned long off,
                outer_inv_range(paddr, paddr + size);
 
        dma_cache_maint_page(page, off, size, dir, dmac_unmap_area);
+
+       /*
+        * Mark the D-cache clean for this page to avoid extra flushing.
+        */
+       if (dir != DMA_TO_DEVICE && off == 0 && size >= PAGE_SIZE)
+               set_bit(PG_dcache_clean, &page->flags);
 }
 EXPORT_SYMBOL(___dma_page_dev_to_cpu);
 
index 9b906dec1ca1abc0ec308472dc39a7684c6c3b01..58846cbd0e0bed0903305ea35b2c769fd138c5f3 100644 (file)
@@ -141,7 +141,7 @@ make_coherent(struct address_space *mapping, struct vm_area_struct *vma,
  * a page table, or changing an existing PTE.  Basically, there are two
  * things that we need to take care of:
  *
- *  1. If PG_dcache_dirty is set for the page, we need to ensure
+ *  1. If PG_dcache_clean is not set for the page, we need to ensure
  *     that any cache entries for the kernels virtual memory
  *     range are written back to the page.
  *  2. If we have multiple shared mappings of the same space in
@@ -169,7 +169,7 @@ void update_mmu_cache(struct vm_area_struct *vma, unsigned long addr,
 
        mapping = page_mapping(page);
 #ifndef CONFIG_SMP
-       if (test_and_clear_bit(PG_dcache_dirty, &page->flags))
+       if (!test_and_set_bit(PG_dcache_clean, &page->flags))
                __flush_dcache_page(mapping, page);
 #endif
        if (mapping) {
index 87dd5ffdfa2dc95c9489ef427cf1809832f82b7f..b4efce9b798531865b12fc62c005949d13161160 100644 (file)
@@ -248,7 +248,7 @@ void flush_dcache_page(struct page *page)
 
 #ifndef CONFIG_SMP
        if (mapping && !mapping_mapped(mapping))
-               set_bit(PG_dcache_dirty, &page->flags);
+               clear_bit(PG_dcache_clean, &page->flags);
        else
 #endif
        {
@@ -257,6 +257,7 @@ void flush_dcache_page(struct page *page)
                        __flush_dcache_aliases(mapping, page);
                else if (mapping)
                        __flush_icache_all();
+               set_bit(PG_dcache_clean, &page->flags);
        }
 }
 EXPORT_SYMBOL(flush_dcache_page);