Skip to content

Commit 01c4b78

Browse files
weiny2torvalds
authored andcommitted
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: Ira Weiny <ira.weiny@intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Reviewed-by: Dan Williams <dan.j.williams@intel.com> Reviewed-by: Christoph 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.com Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 73221d8 commit 01c4b78

11 files changed

Lines changed: 13 additions & 14 deletions

File tree

‎arch/arc/include/asm/highmem.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ static inline void flush_cache_kmaps(void)
4545

4646
static inline void kunmap(struct page *page)
4747
{
48-
BUG_ON(in_interrupt());
48+
might_sleep();
4949
if (!PageHighMem(page))
5050
return;
5151
kunmap_high(page);

‎arch/arc/mm/highmem.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ static pte_t * fixmap_page_table;
5151

5252
void *kmap(struct page *page)
5353
{
54-
BUG_ON(in_interrupt());
54+
might_sleep();
5555
if (!PageHighMem(page))
5656
return page_address(page);
5757

‎arch/arm/mm/highmem.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ EXPORT_SYMBOL(kmap);
4242

4343
void kunmap(struct page *page)
4444
{
45-
BUG_ON(in_interrupt());
45+
might_sleep();
4646
if (!PageHighMem(page))
4747
return;
4848
kunmap_high(page);

‎arch/csky/mm/highmem.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ EXPORT_SYMBOL(kmap);
2929

3030
void kunmap(struct page *page)
3131
{
32-
BUG_ON(in_interrupt());
32+
might_sleep();
3333
if (!PageHighMem(page))
3434
return;
3535
kunmap_high(page);

‎arch/microblaze/include/asm/highmem.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ static inline void *kmap(struct page *page)
6666

6767
static inline void kunmap(struct page *page)
6868
{
69-
BUG_ON(in_interrupt());
69+
might_sleep();
7070
if (!PageHighMem(page))
7171
return;
7272
kunmap_high(page);

‎arch/mips/mm/highmem.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ EXPORT_SYMBOL(kmap);
2828

2929
void kunmap(struct page *page)
3030
{
31-
BUG_ON(in_interrupt());
31+
might_sleep();
3232
if (!PageHighMem(page))
3333
return;
3434
kunmap_high(page);

‎arch/nds32/mm/highmem.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ EXPORT_SYMBOL(kmap);
2424

2525
void kunmap(struct page *page)
2626
{
27-
BUG_ON(in_interrupt());
27+
might_sleep();
2828
if (!PageHighMem(page))
2929
return;
3030
kunmap_high(page);

‎arch/powerpc/include/asm/highmem.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ static inline void *kmap(struct page *page)
7474

7575
static inline void kunmap(struct page *page)
7676
{
77-
BUG_ON(in_interrupt());
77+
might_sleep();
7878
if (!PageHighMem(page))
7979
return;
8080
kunmap_high(page);

‎arch/sparc/include/asm/highmem.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ void kunmap_high(struct page *page);
5555

5656
static inline void *kmap(struct page *page)
5757
{
58-
BUG_ON(in_interrupt());
58+
might_sleep();
5959
if (!PageHighMem(page))
6060
return page_address(page);
6161
return kmap_high(page);
6262
}
6363

6464
static inline void kunmap(struct page *page)
6565
{
66-
BUG_ON(in_interrupt());
66+
might_sleep();
6767
if (!PageHighMem(page))
6868
return;
6969
kunmap_high(page);

‎arch/x86/mm/highmem_32.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ EXPORT_SYMBOL(kmap);
1515

1616
void kunmap(struct page *page)
1717
{
18-
if (in_interrupt())
19-
BUG();
18+
might_sleep();
2019
if (!PageHighMem(page))
2120
return;
2221
kunmap_high(page);

0 commit comments

Comments
 (0)