Skip to content

Commit 8ef5089

Browse files
Leonid YegoshinZubair Lutfullah Kakakhel
authored andcommitted
MIPS: Fix I-cache flushing for kmap'd pages.
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]>
1 parent d9d27a2 commit 8ef5089

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

arch/mips/include/asm/cpu-features.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@
142142
#ifndef cpu_has_vtag_dcache
143143
#define cpu_has_vtag_dcache (cpu_data[0].dcache.flags & MIPS_CACHE_VTAG)
144144
#endif
145+
#ifndef cpu_has_ic_aliases
146+
#define cpu_has_ic_aliases (cpu_data[0].icache.flags & MIPS_CACHE_ALIASES)
147+
#endif
145148
#ifndef cpu_has_dc_aliases
146149
#define cpu_has_dc_aliases (cpu_data[0].dcache.flags & MIPS_CACHE_ALIASES)
147150
#endif

arch/mips/mm/c-r4k.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,7 @@ static inline void local_r4k_flush_cache_page(void *args)
552552
pmd_t *pmdp;
553553
pte_t *ptep;
554554
void *vaddr;
555+
int noflush = 0;
555556

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

612613
if (cpu_context(cpu, mm) != 0)
613614
drop_mmu_context(mm, cpu);
615+
noflush = 1;
614616
} else
615617
vaddr ? r4k_blast_icache_page(addr) :
616618
r4k_blast_icache_user_page(addr);
@@ -622,6 +624,13 @@ static inline void local_r4k_flush_cache_page(void *args)
622624
else
623625
kunmap_atomic(vaddr);
624626
}
627+
628+
/* If we have I-cache aliasing, then blast it via coherent page. */
629+
if (exec && cpu_has_ic_aliases && !noflush && !map_coherent) {
630+
vaddr = kmap_coherent(page, addr);
631+
r4k_blast_icache_page((unsigned long)vaddr);
632+
kunmap_coherent();
633+
}
625634
}
626635

627636
static void r4k_flush_cache_page(struct vm_area_struct *vma,
@@ -1305,10 +1314,12 @@ static void probe_pcache(void)
13051314
c->icache.ways = 1;
13061315
}
13071316

1308-
printk("Primary instruction cache %ldkB, %s, %s, linesize %d bytes.\n",
1309-
icache_size >> 10,
1317+
printk("Primary instruction cache %ldkB, %s, %s, %slinesize %d bytes.\n",
1318+
icache_size >> 10, way_string[c->icache.ways],
13101319
c->icache.flags & MIPS_CACHE_VTAG ? "VIVT" : "VIPT",
1311-
way_string[c->icache.ways], c->icache.linesz);
1320+
(c->icache.flags & MIPS_CACHE_ALIASES) ?
1321+
"I-cache aliases, " : "",
1322+
c->icache.linesz);
13121323

13131324
printk("Primary data cache %ldkB, %s, %s, %s, linesize %d bytes\n",
13141325
dcache_size >> 10, way_string[c->dcache.ways],

arch/mips/mm/init.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ static void *__kmap_pgprot(struct page *page, unsigned long addr, pgprot_t prot)
8888
pte_t pte;
8989
int tlbidx;
9090

91-
BUG_ON(Page_dcache_dirty(page));
92-
9391
pagefault_disable();
9492
idx = (addr >> PAGE_SHIFT) & (FIX_N_COLOURS - 1);
9593
idx += in_interrupt() ? FIX_N_COLOURS : 0;

0 commit comments

Comments
 (0)