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

parisc/kmap: remove duplicate kmap code

parisc reimplements the kmap calls except to flush its dcache. This is
arguably an abuse of kmap but regardless it is messy and confusing.

Remove the duplicate code and have parisc define ARCH_HAS_FLUSH_ON_KUNMAP
for a kunmap_flush_on_unmap() architecture specific call to flush the
cache.

Suggested-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Christian König <christian.koenig@amd.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Chris Zankel <chris@zankel.net>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Helge Deller <deller@gmx.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20200507150004.1423069-14-ira.weiny@intel.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Ira Weiny and committed by
Linus Torvalds
7438f363 8bfb1a10

+9 -29
+2 -26
arch/parisc/include/asm/cacheflush.h
··· 100 100 } 101 101 } 102 102 103 - #include <asm/kmap_types.h> 104 - 105 - #define ARCH_HAS_KMAP 106 - 107 - static inline void *kmap(struct page *page) 108 - { 109 - might_sleep(); 110 - return page_address(page); 111 - } 112 - 113 - static inline void kunmap(struct page *page) 114 - { 115 - flush_kernel_dcache_page_addr(page_address(page)); 116 - } 117 - 118 - static inline void *kmap_atomic(struct page *page) 119 - { 120 - preempt_disable(); 121 - pagefault_disable(); 122 - return page_address(page); 123 - } 124 - 125 - static inline void kunmap_atomic_high(void *addr) 103 + #define ARCH_HAS_FLUSH_ON_KUNMAP 104 + static inline void kunmap_flush_on_unmap(void *addr) 126 105 { 127 106 flush_kernel_dcache_page_addr(addr); 128 107 } 129 - 130 - #define kmap_atomic_prot(page, prot) kmap_atomic(page) 131 - #define kmap_atomic_pfn(pfn) kmap_atomic(pfn_to_page(pfn)) 132 108 133 109 #endif /* _PARISC_CACHEFLUSH_H */ 134 110
+7 -3
include/linux/highmem.h
··· 130 130 131 131 static inline unsigned long totalhigh_pages(void) { return 0UL; } 132 132 133 - #ifndef ARCH_HAS_KMAP 134 133 static inline void *kmap(struct page *page) 135 134 { 136 135 might_sleep(); ··· 142 143 143 144 static inline void kunmap(struct page *page) 144 145 { 146 + #ifdef ARCH_HAS_FLUSH_ON_KUNMAP 147 + kunmap_flush_on_unmap(page_address(page)); 148 + #endif 145 149 } 146 150 147 151 static inline void *kmap_atomic(struct page *page) ··· 158 156 static inline void kunmap_atomic_high(void *addr) 159 157 { 160 158 /* 161 - * Nothing to do in the CONFIG_HIGHMEM=n case as kunmap_atomic() 159 + * Mostly nothing to do in the CONFIG_HIGHMEM=n case as kunmap_atomic() 162 160 * handles re-enabling faults + preemption 163 161 */ 162 + #ifdef ARCH_HAS_FLUSH_ON_KUNMAP 163 + kunmap_flush_on_unmap(addr); 164 + #endif 164 165 } 165 166 166 167 #define kmap_atomic_pfn(pfn) kmap_atomic(pfn_to_page(pfn)) 167 168 168 169 #define kmap_flush_unused() do {} while(0) 169 - #endif 170 170 171 171 #endif /* CONFIG_HIGHMEM */ 172 172