Skip to content

Commit

Permalink
{x86,powerpc,microblaze}/kmap: move preempt disable
Browse files Browse the repository at this point in the history
During this kmap() conversion series we must maintain bisect-ability.  To
do this, kmap_atomic_prot() in x86, powerpc, and microblaze need to remain
functional.

Create a temporary inline version of kmap_atomic_prot within these
architectures so we can rework their kmap_atomic() calls and then lift
kmap_atomic_prot() to the core.

Suggested-by: Al Viro <[email protected]>
Signed-off-by: Ira Weiny <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
Cc: Andy Lutomirski <[email protected]>
Cc: Benjamin Herrenschmidt <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Christian König <[email protected]>
Cc: Chris Zankel <[email protected]>
Cc: Daniel Vetter <[email protected]>
Cc: Dan Williams <[email protected]>
Cc: Dave Hansen <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: Helge Deller <[email protected]>
Cc: "H. Peter Anvin" <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: "James E.J. Bottomley" <[email protected]>
Cc: Max Filippov <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Thomas Bogendoerfer <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
weiny2 authored and torvalds committed Jun 5, 2020
1 parent e23c459 commit ee9bc5f
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 26 deletions.
11 changes: 10 additions & 1 deletion arch/microblaze/include/asm/highmem.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,16 @@ extern pte_t *pkmap_page_table;
#define PKMAP_NR(virt) ((virt - PKMAP_BASE) >> PAGE_SHIFT)
#define PKMAP_ADDR(nr) (PKMAP_BASE + ((nr) << PAGE_SHIFT))

extern void *kmap_atomic_prot(struct page *page, pgprot_t prot);
extern void *kmap_atomic_high_prot(struct page *page, pgprot_t prot);
static inline void *kmap_atomic_prot(struct page *page, pgprot_t prot)
{
preempt_disable();
pagefault_disable();
if (!PageHighMem(page))
return page_address(page);

return kmap_atomic_high_prot(page, prot);
}
extern void __kunmap_atomic(void *kvaddr);

static inline void *kmap_atomic(struct page *page)
Expand Down
10 changes: 2 additions & 8 deletions arch/microblaze/mm/highmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,12 @@
*/
#include <asm/tlbflush.h>

void *kmap_atomic_prot(struct page *page, pgprot_t prot)
void *kmap_atomic_high_prot(struct page *page, pgprot_t prot)
{

unsigned long vaddr;
int idx, type;

preempt_disable();
pagefault_disable();
if (!PageHighMem(page))
return page_address(page);


type = kmap_atomic_idx_push();
idx = type + KM_TYPE_NR*smp_processor_id();
vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
Expand All @@ -55,7 +49,7 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)

return (void *) vaddr;
}
EXPORT_SYMBOL(kmap_atomic_prot);
EXPORT_SYMBOL(kmap_atomic_high_prot);

void __kunmap_atomic(void *kvaddr)
{
Expand Down
11 changes: 10 additions & 1 deletion arch/powerpc/include/asm/highmem.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,16 @@ extern pte_t *pkmap_page_table;
#define PKMAP_NR(virt) ((virt-PKMAP_BASE) >> PAGE_SHIFT)
#define PKMAP_ADDR(nr) (PKMAP_BASE + ((nr) << PAGE_SHIFT))

extern void *kmap_atomic_prot(struct page *page, pgprot_t prot);
extern void *kmap_atomic_high_prot(struct page *page, pgprot_t prot);
static inline void *kmap_atomic_prot(struct page *page, pgprot_t prot)
{
preempt_disable();
pagefault_disable();
if (!PageHighMem(page))
return page_address(page);

return kmap_atomic_high_prot(page, prot);
}
extern void __kunmap_atomic(void *kvaddr);

static inline void *kmap_atomic(struct page *page)
Expand Down
9 changes: 2 additions & 7 deletions arch/powerpc/mm/highmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,11 @@
* be used in IRQ contexts, so in some (very limited) cases we need
* it.
*/
void *kmap_atomic_prot(struct page *page, pgprot_t prot)
void *kmap_atomic_high_prot(struct page *page, pgprot_t prot)
{
unsigned long vaddr;
int idx, type;

preempt_disable();
pagefault_disable();
if (!PageHighMem(page))
return page_address(page);

type = kmap_atomic_idx_push();
idx = type + KM_TYPE_NR*smp_processor_id();
vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
Expand All @@ -49,7 +44,7 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)

return (void*) vaddr;
}
EXPORT_SYMBOL(kmap_atomic_prot);
EXPORT_SYMBOL(kmap_atomic_high_prot);

void __kunmap_atomic(void *kvaddr)
{
Expand Down
11 changes: 10 additions & 1 deletion arch/x86/include/asm/highmem.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,16 @@ extern unsigned long highstart_pfn, highend_pfn;
#define PKMAP_NR(virt) ((virt-PKMAP_BASE) >> PAGE_SHIFT)
#define PKMAP_ADDR(nr) (PKMAP_BASE + ((nr) << PAGE_SHIFT))

void *kmap_atomic_prot(struct page *page, pgprot_t prot);
extern void *kmap_atomic_high_prot(struct page *page, pgprot_t prot);
static inline void *kmap_atomic_prot(struct page *page, pgprot_t prot)
{
preempt_disable();
pagefault_disable();
if (!PageHighMem(page))
return page_address(page);

return kmap_atomic_high_prot(page, prot);
}
void *kmap_atomic(struct page *page);
void __kunmap_atomic(void *kvaddr);
void *kmap_atomic_pfn(unsigned long pfn);
Expand Down
10 changes: 2 additions & 8 deletions arch/x86/mm/highmem_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,11 @@
* However when holding an atomic kmap it is not legal to sleep, so atomic
* kmaps are appropriate for short, tight code paths only.
*/
void *kmap_atomic_prot(struct page *page, pgprot_t prot)
void *kmap_atomic_high_prot(struct page *page, pgprot_t prot)
{
unsigned long vaddr;
int idx, type;

preempt_disable();
pagefault_disable();

if (!PageHighMem(page))
return page_address(page);

type = kmap_atomic_idx_push();
idx = type + KM_TYPE_NR*smp_processor_id();
vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
Expand All @@ -32,7 +26,7 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)

return (void *)vaddr;
}
EXPORT_SYMBOL(kmap_atomic_prot);
EXPORT_SYMBOL(kmap_atomic_high_prot);

void *kmap_atomic(struct page *page)
{
Expand Down

0 comments on commit ee9bc5f

Please sign in to comment.