Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MIPS: add kmap_noncoherent to wire a cached non-coherent TLB entry

This is identical to kmap_coherent apart from the cache coherency
attribute used for the TLB entry, so kmap_coherent is abstracted to
kmap_prot which is then called for both kmap_coherent &
kmap_noncoherent. This will be used by a subsequent patch.

Suggested-by: Leonid Yegoshin <leonid.yegoshin@imgtec.com>
Signed-off-by: Paul Burton <paul.burton@imgtec.com>

+20 -2
+6
arch/mips/include/asm/cacheflush.h
··· 113 113 114 114 extern void *kmap_coherent(struct page *page, unsigned long addr); 115 115 extern void kunmap_coherent(void); 116 + extern void *kmap_noncoherent(struct page *page, unsigned long addr); 117 + 118 + static inline void kunmap_noncoherent(void) 119 + { 120 + kunmap_coherent(); 121 + } 116 122 117 123 #define ARCH_HAS_FLUSH_KERNEL_DCACHE_PAGE 118 124 static inline void flush_kernel_dcache_page(struct page *page)
+2
arch/mips/include/asm/pgtable.h
··· 32 32 _page_cachable_default) 33 33 #define PAGE_KERNEL __pgprot(_PAGE_PRESENT | __READABLE | __WRITEABLE | \ 34 34 _PAGE_GLOBAL | _page_cachable_default) 35 + #define PAGE_KERNEL_NC __pgprot(_PAGE_PRESENT | __READABLE | __WRITEABLE | \ 36 + _PAGE_GLOBAL | _CACHE_CACHABLE_NONCOHERENT) 35 37 #define PAGE_USERIO __pgprot(_PAGE_PRESENT | (cpu_has_rixi ? 0 : _PAGE_READ) | _PAGE_WRITE | \ 36 38 _page_cachable_default) 37 39 #define PAGE_KERNEL_UNCACHED __pgprot(_PAGE_PRESENT | __READABLE | \
+12 -2
arch/mips/mm/init.c
··· 114 114 static inline void kmap_coherent_init(void) {} 115 115 #endif 116 116 117 - void *kmap_coherent(struct page *page, unsigned long addr) 117 + static void *__kmap_pgprot(struct page *page, unsigned long addr, pgprot_t prot) 118 118 { 119 119 enum fixed_addresses idx; 120 120 unsigned long vaddr, flags, entrylo; ··· 133 133 idx += in_interrupt() ? FIX_N_COLOURS : 0; 134 134 #endif 135 135 vaddr = __fix_to_virt(FIX_CMAP_END - idx); 136 - pte = mk_pte(page, PAGE_KERNEL); 136 + pte = mk_pte(page, prot); 137 137 #if defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32) 138 138 entrylo = pte.pte_high; 139 139 #else ··· 169 169 EXIT_CRITICAL(flags); 170 170 171 171 return (void*) vaddr; 172 + } 173 + 174 + void *kmap_coherent(struct page *page, unsigned long addr) 175 + { 176 + return __kmap_pgprot(page, addr, PAGE_KERNEL); 177 + } 178 + 179 + void *kmap_noncoherent(struct page *page, unsigned long addr) 180 + { 181 + return __kmap_pgprot(page, addr, PAGE_KERNEL_NC); 172 182 } 173 183 174 184 void kunmap_coherent(void)