Skip to content

Commit

Permalink
MIPS: Fix I-cache flushing for kmap'd pages.
Browse files Browse the repository at this point in the history
Make the I-cache flush pages while taking into account the
address color by using kmap_coherent() when there is
I-cache aliasing present.

Signed-off-by: Leonid Yegoshin <[email protected]>
Signed-off-by: Steven J. Hill <[email protected]>
  • Loading branch information
Leonid Yegoshin authored and Zubair Lutfullah Kakakhel committed Mar 13, 2015
1 parent d9d27a2 commit 8ef5089
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
3 changes: 3 additions & 0 deletions arch/mips/include/asm/cpu-features.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@
#ifndef cpu_has_vtag_dcache
#define cpu_has_vtag_dcache (cpu_data[0].dcache.flags & MIPS_CACHE_VTAG)
#endif
#ifndef cpu_has_ic_aliases
#define cpu_has_ic_aliases (cpu_data[0].icache.flags & MIPS_CACHE_ALIASES)
#endif
#ifndef cpu_has_dc_aliases
#define cpu_has_dc_aliases (cpu_data[0].dcache.flags & MIPS_CACHE_ALIASES)
#endif
Expand Down
17 changes: 14 additions & 3 deletions arch/mips/mm/c-r4k.c
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,7 @@ static inline void local_r4k_flush_cache_page(void *args)
pmd_t *pmdp;
pte_t *ptep;
void *vaddr;
int noflush = 0;

/*
* If ownes no valid ASID yet, cannot possibly have gotten
Expand Down Expand Up @@ -611,6 +612,7 @@ static inline void local_r4k_flush_cache_page(void *args)

if (cpu_context(cpu, mm) != 0)
drop_mmu_context(mm, cpu);
noflush = 1;
} else
vaddr ? r4k_blast_icache_page(addr) :
r4k_blast_icache_user_page(addr);
Expand All @@ -622,6 +624,13 @@ static inline void local_r4k_flush_cache_page(void *args)
else
kunmap_atomic(vaddr);
}

/* If we have I-cache aliasing, then blast it via coherent page. */
if (exec && cpu_has_ic_aliases && !noflush && !map_coherent) {
vaddr = kmap_coherent(page, addr);
r4k_blast_icache_page((unsigned long)vaddr);
kunmap_coherent();
}
}

static void r4k_flush_cache_page(struct vm_area_struct *vma,
Expand Down Expand Up @@ -1305,10 +1314,12 @@ static void probe_pcache(void)
c->icache.ways = 1;
}

printk("Primary instruction cache %ldkB, %s, %s, linesize %d bytes.\n",
icache_size >> 10,
printk("Primary instruction cache %ldkB, %s, %s, %slinesize %d bytes.\n",
icache_size >> 10, way_string[c->icache.ways],
c->icache.flags & MIPS_CACHE_VTAG ? "VIVT" : "VIPT",
way_string[c->icache.ways], c->icache.linesz);
(c->icache.flags & MIPS_CACHE_ALIASES) ?
"I-cache aliases, " : "",
c->icache.linesz);

printk("Primary data cache %ldkB, %s, %s, %s, linesize %d bytes\n",
dcache_size >> 10, way_string[c->dcache.ways],
Expand Down
2 changes: 0 additions & 2 deletions arch/mips/mm/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ static void *__kmap_pgprot(struct page *page, unsigned long addr, pgprot_t prot)
pte_t pte;
int tlbidx;

BUG_ON(Page_dcache_dirty(page));

pagefault_disable();
idx = (addr >> PAGE_SHIFT) & (FIX_N_COLOURS - 1);
idx += in_interrupt() ? FIX_N_COLOURS : 0;
Expand Down

0 comments on commit 8ef5089

Please sign in to comment.