lkml.org 
[lkml]   [2020]   [May]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH V2 05/11] {x86,powerpc,microblaze}/kmap: Move preempt disable
    Date
    From: Ira Weiny <ira.weiny@intel.com>

    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.

    Signed-off-by: Ira Weiny <ira.weiny@intel.com>

    ---
    Changes from V1:
    New patch
    ---
    arch/microblaze/include/asm/highmem.h | 11 ++++++++++-
    arch/microblaze/mm/highmem.c | 10 ++--------
    arch/powerpc/include/asm/highmem.h | 11 ++++++++++-
    arch/powerpc/mm/highmem.c | 9 ++-------
    arch/x86/include/asm/highmem.h | 11 ++++++++++-
    arch/x86/mm/highmem_32.c | 10 ++--------
    6 files changed, 36 insertions(+), 26 deletions(-)

    diff --git a/arch/microblaze/include/asm/highmem.h b/arch/microblaze/include/asm/highmem.h
    index 0c94046f2d58..ec9954b091e1 100644
    --- a/arch/microblaze/include/asm/highmem.h
    +++ b/arch/microblaze/include/asm/highmem.h
    @@ -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);
    +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)
    diff --git a/arch/microblaze/mm/highmem.c b/arch/microblaze/mm/highmem.c
    index d7569f77fa15..0e3efaa8a004 100644
    --- a/arch/microblaze/mm/highmem.c
    +++ b/arch/microblaze/mm/highmem.c
    @@ -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);
    @@ -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)
    {
    diff --git a/arch/powerpc/include/asm/highmem.h b/arch/powerpc/include/asm/highmem.h
    index ba3371977d49..d049806a8354 100644
    --- a/arch/powerpc/include/asm/highmem.h
    +++ b/arch/powerpc/include/asm/highmem.h
    @@ -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)
    diff --git a/arch/powerpc/mm/highmem.c b/arch/powerpc/mm/highmem.c
    index 320c1672b2ae..f075cef6d663 100644
    --- a/arch/powerpc/mm/highmem.c
    +++ b/arch/powerpc/mm/highmem.c
    @@ -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);
    @@ -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)
    {
    diff --git a/arch/x86/include/asm/highmem.h b/arch/x86/include/asm/highmem.h
    index 90b96594d6c5..61f47fef40e5 100644
    --- a/arch/x86/include/asm/highmem.h
    +++ b/arch/x86/include/asm/highmem.h
    @@ -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);
    diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
    index c4ebfd0ae401..48b56b1af902 100644
    --- a/arch/x86/mm/highmem_32.c
    +++ b/arch/x86/mm/highmem_32.c
    @@ -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);
    @@ -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)
    {
    --
    2.25.1
    \
     
     \ /
      Last update: 2020-05-04 03:10    [W:4.441 / U:0.008 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site