Commit 01c4b788 authored by Ira Weiny's avatar Ira Weiny Committed by Linus Torvalds

arch/kmap: remove BUG_ON()

Patch series "Remove duplicated kmap code", v3.

The kmap infrastructure has been copied almost verbatim to every
architecture.  This series consolidates obvious duplicated code by
defining core functions which call into the architectures only when
needed.

Some of the k[un]map_atomic() implementations have some similarities but
the similarities were not sufficient to warrant further changes.

In addition we remove a duplicate implementation of kmap() in DRM.

This patch (of 15):

Replace the use of BUG_ON(in_interrupt()) in the kmap() and kunmap() in
favor of might_sleep().

Besides the benefits of might_sleep(), this normalizes the implementations
such that they can be made generic in subsequent patches.
Signed-off-by: default avatarIra Weiny <ira.weiny@intel.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Reviewed-by: default avatarDan Williams <dan.j.williams@intel.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Christian König <christian.koenig@amd.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
Cc: Helge Deller <deller@gmx.de>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Chris Zankel <chris@zankel.net>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Link: http://lkml.kernel.org/r/20200507150004.1423069-1-ira.weiny@intel.com
Link: http://lkml.kernel.org/r/20200507150004.1423069-2-ira.weiny@intel.comSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 73221d88
...@@ -45,7 +45,7 @@ static inline void flush_cache_kmaps(void) ...@@ -45,7 +45,7 @@ static inline void flush_cache_kmaps(void)
static inline void kunmap(struct page *page) static inline void kunmap(struct page *page)
{ {
BUG_ON(in_interrupt()); might_sleep();
if (!PageHighMem(page)) if (!PageHighMem(page))
return; return;
kunmap_high(page); kunmap_high(page);
......
...@@ -51,7 +51,7 @@ static pte_t * fixmap_page_table; ...@@ -51,7 +51,7 @@ static pte_t * fixmap_page_table;
void *kmap(struct page *page) void *kmap(struct page *page)
{ {
BUG_ON(in_interrupt()); might_sleep();
if (!PageHighMem(page)) if (!PageHighMem(page))
return page_address(page); return page_address(page);
......
...@@ -42,7 +42,7 @@ EXPORT_SYMBOL(kmap); ...@@ -42,7 +42,7 @@ EXPORT_SYMBOL(kmap);
void kunmap(struct page *page) void kunmap(struct page *page)
{ {
BUG_ON(in_interrupt()); might_sleep();
if (!PageHighMem(page)) if (!PageHighMem(page))
return; return;
kunmap_high(page); kunmap_high(page);
......
...@@ -29,7 +29,7 @@ EXPORT_SYMBOL(kmap); ...@@ -29,7 +29,7 @@ EXPORT_SYMBOL(kmap);
void kunmap(struct page *page) void kunmap(struct page *page)
{ {
BUG_ON(in_interrupt()); might_sleep();
if (!PageHighMem(page)) if (!PageHighMem(page))
return; return;
kunmap_high(page); kunmap_high(page);
......
...@@ -66,7 +66,7 @@ static inline void *kmap(struct page *page) ...@@ -66,7 +66,7 @@ static inline void *kmap(struct page *page)
static inline void kunmap(struct page *page) static inline void kunmap(struct page *page)
{ {
BUG_ON(in_interrupt()); might_sleep();
if (!PageHighMem(page)) if (!PageHighMem(page))
return; return;
kunmap_high(page); kunmap_high(page);
......
...@@ -28,7 +28,7 @@ EXPORT_SYMBOL(kmap); ...@@ -28,7 +28,7 @@ EXPORT_SYMBOL(kmap);
void kunmap(struct page *page) void kunmap(struct page *page)
{ {
BUG_ON(in_interrupt()); might_sleep();
if (!PageHighMem(page)) if (!PageHighMem(page))
return; return;
kunmap_high(page); kunmap_high(page);
......
...@@ -24,7 +24,7 @@ EXPORT_SYMBOL(kmap); ...@@ -24,7 +24,7 @@ EXPORT_SYMBOL(kmap);
void kunmap(struct page *page) void kunmap(struct page *page)
{ {
BUG_ON(in_interrupt()); might_sleep();
if (!PageHighMem(page)) if (!PageHighMem(page))
return; return;
kunmap_high(page); kunmap_high(page);
......
...@@ -74,7 +74,7 @@ static inline void *kmap(struct page *page) ...@@ -74,7 +74,7 @@ static inline void *kmap(struct page *page)
static inline void kunmap(struct page *page) static inline void kunmap(struct page *page)
{ {
BUG_ON(in_interrupt()); might_sleep();
if (!PageHighMem(page)) if (!PageHighMem(page))
return; return;
kunmap_high(page); kunmap_high(page);
......
...@@ -55,7 +55,7 @@ void kunmap_high(struct page *page); ...@@ -55,7 +55,7 @@ void kunmap_high(struct page *page);
static inline void *kmap(struct page *page) static inline void *kmap(struct page *page)
{ {
BUG_ON(in_interrupt()); might_sleep();
if (!PageHighMem(page)) if (!PageHighMem(page))
return page_address(page); return page_address(page);
return kmap_high(page); return kmap_high(page);
...@@ -63,7 +63,7 @@ static inline void *kmap(struct page *page) ...@@ -63,7 +63,7 @@ static inline void *kmap(struct page *page)
static inline void kunmap(struct page *page) static inline void kunmap(struct page *page)
{ {
BUG_ON(in_interrupt()); might_sleep();
if (!PageHighMem(page)) if (!PageHighMem(page))
return; return;
kunmap_high(page); kunmap_high(page);
......
...@@ -15,8 +15,7 @@ EXPORT_SYMBOL(kmap); ...@@ -15,8 +15,7 @@ EXPORT_SYMBOL(kmap);
void kunmap(struct page *page) void kunmap(struct page *page)
{ {
if (in_interrupt()) might_sleep();
BUG();
if (!PageHighMem(page)) if (!PageHighMem(page))
return; return;
kunmap_high(page); kunmap_high(page);
......
...@@ -73,7 +73,7 @@ static inline void *kmap(struct page *page) ...@@ -73,7 +73,7 @@ static inline void *kmap(struct page *page)
*/ */
BUILD_BUG_ON(PKMAP_BASE < BUILD_BUG_ON(PKMAP_BASE <
TLBTEMP_BASE_1 + TLBTEMP_SIZE); TLBTEMP_BASE_1 + TLBTEMP_SIZE);
BUG_ON(in_interrupt()); might_sleep();
if (!PageHighMem(page)) if (!PageHighMem(page))
return page_address(page); return page_address(page);
return kmap_high(page); return kmap_high(page);
...@@ -81,7 +81,7 @@ static inline void *kmap(struct page *page) ...@@ -81,7 +81,7 @@ static inline void *kmap(struct page *page)
static inline void kunmap(struct page *page) static inline void kunmap(struct page *page)
{ {
BUG_ON(in_interrupt()); might_sleep();
if (!PageHighMem(page)) if (!PageHighMem(page))
return; return;
kunmap_high(page); kunmap_high(page);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment