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

io-mapping: Cleanup atomic iomap

Switch the atomic iomap implementation over to kmap_local and stick the
preempt/pagefault mechanics into the generic code similar to the
kmap_atomic variants.

Rename the x86 map function in preparation for a non-atomic variant.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linuxfoundation.org>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Link: https://lore.kernel.org/r/20201103095858.625310005@linutronix.de

+9 -14
+1 -8
arch/x86/include/asm/iomap.h
··· 13 13 #include <asm/cacheflush.h> 14 14 #include <asm/tlbflush.h> 15 15 16 - void __iomem *iomap_atomic_pfn_prot(unsigned long pfn, pgprot_t prot); 17 - 18 - static inline void iounmap_atomic(void __iomem *vaddr) 19 - { 20 - kunmap_local_indexed((void __force *)vaddr); 21 - pagefault_enable(); 22 - preempt_enable(); 23 - } 16 + void __iomem *__iomap_local_pfn_prot(unsigned long pfn, pgprot_t prot); 24 17 25 18 int iomap_create_wc(resource_size_t base, unsigned long size, pgprot_t *prot); 26 19
+2 -4
arch/x86/mm/iomap_32.c
··· 44 44 } 45 45 EXPORT_SYMBOL_GPL(iomap_free); 46 46 47 - void __iomem *iomap_atomic_pfn_prot(unsigned long pfn, pgprot_t prot) 47 + void __iomem *__iomap_local_pfn_prot(unsigned long pfn, pgprot_t prot) 48 48 { 49 49 /* 50 50 * For non-PAT systems, translate non-WB request to UC- just in ··· 60 60 /* Filter out unsupported __PAGE_KERNEL* bits: */ 61 61 pgprot_val(prot) &= __default_kernel_pte_mask; 62 62 63 - preempt_disable(); 64 - pagefault_disable(); 65 63 return (void __force __iomem *)__kmap_local_pfn_prot(pfn, prot); 66 64 } 67 - EXPORT_SYMBOL_GPL(iomap_atomic_pfn_prot); 65 + EXPORT_SYMBOL_GPL(__iomap_local_pfn_prot);
+6 -2
include/linux/io-mapping.h
··· 69 69 70 70 BUG_ON(offset >= mapping->size); 71 71 phys_addr = mapping->base + offset; 72 - return iomap_atomic_pfn_prot(PHYS_PFN(phys_addr), mapping->prot); 72 + preempt_disable(); 73 + pagefault_disable(); 74 + return __iomap_local_pfn_prot(PHYS_PFN(phys_addr), mapping->prot); 73 75 } 74 76 75 77 static inline void 76 78 io_mapping_unmap_atomic(void __iomem *vaddr) 77 79 { 78 - iounmap_atomic(vaddr); 80 + kunmap_local_indexed((void __force *)vaddr); 81 + pagefault_enable(); 82 + preempt_enable(); 79 83 } 80 84 81 85 static inline void __iomem *