Commit 11ab3f3d3c2474d3ed6912443de74c3972bd6f23

Authored by Chen Liqin
1 parent 718deb6b61

score: add flush_dcahce_page and PG_dcache_dirty define

Signed-off-by: Cui Bixiong <bixiong@sunnorth.com.cn>
Signed-off-by: Chen Liqin <liqin.chen@sunplusct.com>

	modified:   arch/score/include/asm/cacheflush.h
	modified:   arch/score/mm/cache.c

Showing 2 changed files with 27 additions and 3 deletions Side-by-side Diff

arch/score/include/asm/cacheflush.h
... ... @@ -14,10 +14,12 @@
14 14 extern void flush_icache_all(void);
15 15 extern void flush_icache_range(unsigned long start, unsigned long end);
16 16 extern void flush_dcache_range(unsigned long start, unsigned long end);
  17 +extern void flush_dcache_page(struct page *page);
17 18  
  19 +#define PG_dcache_dirty PG_arch_1
  20 +
18 21 #define flush_cache_dup_mm(mm) do {} while (0)
19 22 #define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0
20   -#define flush_dcache_page(page) do {} while (0)
21 23 #define flush_dcache_mmap_lock(mapping) do {} while (0)
22 24 #define flush_dcache_mmap_unlock(mapping) do {} while (0)
23 25 #define flush_cache_vmap(start, end) do {} while (0)
arch/score/mm/cache.c
... ... @@ -29,6 +29,7 @@
29 29 #include <linux/mm.h>
30 30 #include <linux/module.h>
31 31 #include <linux/sched.h>
  32 +#include <linux/fs.h>
32 33  
33 34 #include <asm/mmu_context.h>
34 35  
... ... @@ -51,6 +52,27 @@
51 52 }
52 53 }
53 54  
  55 +void flush_dcache_page(struct page *page)
  56 +{
  57 + struct address_space *mapping = page_mapping(page);
  58 + unsigned long addr;
  59 +
  60 + if (PageHighMem(page))
  61 + return;
  62 + if (mapping && !mapping_mapped(mapping)) {
  63 + set_bit(PG_dcache_dirty, &(page)->flags);
  64 + return;
  65 + }
  66 +
  67 + /*
  68 + * We could delay the flush for the !page_mapping case too. But that
  69 + * case is for exec env/arg pages and those are %99 certainly going to
  70 + * get faulted into the tlb (and thus flushed) anyways.
  71 + */
  72 + addr = (unsigned long) page_address(page);
  73 + flush_data_cache_page(addr);
  74 +}
  75 +
54 76 /* called by update_mmu_cache. */
55 77 void __update_cache(struct vm_area_struct *vma, unsigned long address,
56 78 pte_t pte)
57 79  
... ... @@ -63,11 +85,11 @@
63 85 if (unlikely(!pfn_valid(pfn)))
64 86 return;
65 87 page = pfn_to_page(pfn);
66   - if (page_mapping(page) && test_bit(PG_arch_1, &page->flags)) {
  88 + if (page_mapping(page) && test_bit(PG_dcache_dirty, &(page)->flags)) {
67 89 addr = (unsigned long) page_address(page);
68 90 if (exec)
69 91 flush_data_cache_page(addr);
70   - clear_bit(PG_arch_1, &page->flags);
  92 + clear_bit(PG_dcache_dirty, &(page)->flags);
71 93 }
72 94 }
73 95