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

mips/mm/highmem: Switch to generic kmap atomic

No reason having the same code in every architecture

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20201103095857.885321106@linutronix.de

+6 -99
+1
arch/mips/Kconfig
··· 2719 2719 config HIGHMEM 2720 2720 bool "High Memory Support" 2721 2721 depends on 32BIT && CPU_SUPPORTS_HIGHMEM && SYS_SUPPORTS_HIGHMEM && !CPU_MIPS32_3_5_EVA 2722 + select KMAP_LOCAL 2722 2723 2723 2724 config CPU_SUPPORTS_HIGHMEM 2724 2725 bool
+2 -2
arch/mips/include/asm/fixmap.h
··· 17 17 #include <spaces.h> 18 18 #ifdef CONFIG_HIGHMEM 19 19 #include <linux/threads.h> 20 - #include <asm/kmap_types.h> 20 + #include <asm/kmap_size.h> 21 21 #endif 22 22 23 23 /* ··· 52 52 #ifdef CONFIG_HIGHMEM 53 53 /* reserved pte's for temporary kernel mappings */ 54 54 FIX_KMAP_BEGIN = FIX_CMAP_END + 1, 55 - FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1, 55 + FIX_KMAP_END = FIX_KMAP_BEGIN + (KM_MAX_IDX * NR_CPUS) - 1, 56 56 #endif 57 57 __end_of_fixed_addresses 58 58 };
+3 -3
arch/mips/include/asm/highmem.h
··· 24 24 #include <linux/interrupt.h> 25 25 #include <linux/uaccess.h> 26 26 #include <asm/cpu-features.h> 27 - #include <asm/kmap_types.h> 27 + #include <asm/kmap_size.h> 28 28 29 29 /* declarations for highmem.c */ 30 30 extern unsigned long highstart_pfn, highend_pfn; ··· 48 48 49 49 #define ARCH_HAS_KMAP_FLUSH_TLB 50 50 extern void kmap_flush_tlb(unsigned long addr); 51 - extern void *kmap_atomic_pfn(unsigned long pfn); 52 51 53 52 #define flush_cache_kmaps() BUG_ON(cpu_has_dc_aliases) 54 53 55 - extern void kmap_init(void); 54 + #define arch_kmap_local_post_map(vaddr, pteval) local_flush_tlb_one(vaddr) 55 + #define arch_kmap_local_post_unmap(vaddr) local_flush_tlb_one(vaddr) 56 56 57 57 #endif /* __KERNEL__ */ 58 58
-13
arch/mips/include/asm/kmap_types.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - #ifndef _ASM_KMAP_TYPES_H 3 - #define _ASM_KMAP_TYPES_H 4 - 5 - #ifdef CONFIG_DEBUG_HIGHMEM 6 - #define __WITH_KM_FENCE 7 - #endif 8 - 9 - #include <asm-generic/kmap_types.h> 10 - 11 - #undef __WITH_KM_FENCE 12 - 13 - #endif
-77
arch/mips/mm/highmem.c
··· 8 8 #include <asm/fixmap.h> 9 9 #include <asm/tlbflush.h> 10 10 11 - static pte_t *kmap_pte; 12 - 13 11 unsigned long highstart_pfn, highend_pfn; 14 12 15 13 void kmap_flush_tlb(unsigned long addr) ··· 15 17 flush_tlb_one(addr); 16 18 } 17 19 EXPORT_SYMBOL(kmap_flush_tlb); 18 - 19 - void *kmap_atomic_high_prot(struct page *page, pgprot_t prot) 20 - { 21 - unsigned long vaddr; 22 - int idx, type; 23 - 24 - type = kmap_atomic_idx_push(); 25 - idx = type + KM_TYPE_NR*smp_processor_id(); 26 - vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx); 27 - #ifdef CONFIG_DEBUG_HIGHMEM 28 - BUG_ON(!pte_none(*(kmap_pte - idx))); 29 - #endif 30 - set_pte(kmap_pte-idx, mk_pte(page, prot)); 31 - local_flush_tlb_one((unsigned long)vaddr); 32 - 33 - return (void*) vaddr; 34 - } 35 - EXPORT_SYMBOL(kmap_atomic_high_prot); 36 - 37 - void kunmap_atomic_high(void *kvaddr) 38 - { 39 - unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK; 40 - int type __maybe_unused; 41 - 42 - if (vaddr < FIXADDR_START) 43 - return; 44 - 45 - type = kmap_atomic_idx(); 46 - #ifdef CONFIG_DEBUG_HIGHMEM 47 - { 48 - int idx = type + KM_TYPE_NR * smp_processor_id(); 49 - 50 - BUG_ON(vaddr != __fix_to_virt(FIX_KMAP_BEGIN + idx)); 51 - 52 - /* 53 - * force other mappings to Oops if they'll try to access 54 - * this pte without first remap it 55 - */ 56 - pte_clear(&init_mm, vaddr, kmap_pte-idx); 57 - local_flush_tlb_one(vaddr); 58 - } 59 - #endif 60 - kmap_atomic_idx_pop(); 61 - } 62 - EXPORT_SYMBOL(kunmap_atomic_high); 63 - 64 - /* 65 - * This is the same as kmap_atomic() but can map memory that doesn't 66 - * have a struct page associated with it. 67 - */ 68 - void *kmap_atomic_pfn(unsigned long pfn) 69 - { 70 - unsigned long vaddr; 71 - int idx, type; 72 - 73 - preempt_disable(); 74 - pagefault_disable(); 75 - 76 - type = kmap_atomic_idx_push(); 77 - idx = type + KM_TYPE_NR*smp_processor_id(); 78 - vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx); 79 - set_pte(kmap_pte-idx, pfn_pte(pfn, PAGE_KERNEL)); 80 - flush_tlb_one(vaddr); 81 - 82 - return (void*) vaddr; 83 - } 84 - 85 - void __init kmap_init(void) 86 - { 87 - unsigned long kmap_vstart; 88 - 89 - /* cache the first kmap pte */ 90 - kmap_vstart = __fix_to_virt(FIX_KMAP_BEGIN); 91 - kmap_pte = virt_to_kpte(kmap_vstart); 92 - }
-4
arch/mips/mm/init.c
··· 36 36 #include <asm/cachectl.h> 37 37 #include <asm/cpu.h> 38 38 #include <asm/dma.h> 39 - #include <asm/kmap_types.h> 40 39 #include <asm/maar.h> 41 40 #include <asm/mmu_context.h> 42 41 #include <asm/sections.h> ··· 401 402 402 403 pagetable_init(); 403 404 404 - #ifdef CONFIG_HIGHMEM 405 - kmap_init(); 406 - #endif 407 405 #ifdef CONFIG_ZONE_DMA 408 406 max_zone_pfns[ZONE_DMA] = MAX_DMA_PFN; 409 407 #endif