lkml.org 
[lkml]   [2019]   [Mar]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH AUTOSEL 4.20 41/52] csky: Fixup io-range page attribute for mmap("/dev/mem")
    Date
    From: Guo Ren <ren_guo@c-sky.com>

    [ Upstream commit 76d21d186a65523b08ea5f70302e2c29ee8f6a8d ]

    Some user space drivers need accessing IO address and IO remap need
    SO(strong order) page-attribute to make IO operation correct. So we
    need add SO-page-attr for all non-memory address.

    Signed-off-by: Guo Ren <ren_guo@c-sky.com>
    Reported-by: Fan Xiaodong <xiaodong.fan@boyahualu.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    arch/csky/include/asm/pgtable.h | 5 +++++
    arch/csky/mm/ioremap.c | 14 ++++++++++++++
    2 files changed, 19 insertions(+)

    diff --git a/arch/csky/include/asm/pgtable.h b/arch/csky/include/asm/pgtable.h
    index af7a7faa1010..dcea277c09ae 100644
    --- a/arch/csky/include/asm/pgtable.h
    +++ b/arch/csky/include/asm/pgtable.h
    @@ -241,6 +241,11 @@ static inline pte_t pte_mkyoung(pte_t pte)

    #define pgd_index(address) ((address) >> PGDIR_SHIFT)

    +#define __HAVE_PHYS_MEM_ACCESS_PROT
    +struct file;
    +extern pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
    + unsigned long size, pgprot_t vma_prot);
    +
    /*
    * Macro to make mark a page protection value as "uncacheable". Note
    * that "protection" is really a misnomer here as the protection value
    diff --git a/arch/csky/mm/ioremap.c b/arch/csky/mm/ioremap.c
    index 7ad3ff103f4a..02025a2a9ec0 100644
    --- a/arch/csky/mm/ioremap.c
    +++ b/arch/csky/mm/ioremap.c
    @@ -46,3 +46,17 @@ void iounmap(void __iomem *addr)
    vunmap((void *)((unsigned long)addr & PAGE_MASK));
    }
    EXPORT_SYMBOL(iounmap);
    +
    +pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
    + unsigned long size, pgprot_t vma_prot)
    +{
    + if (!pfn_valid(pfn)) {
    + vma_prot.pgprot |= _PAGE_SO;
    + return pgprot_noncached(vma_prot);
    + } else if (file->f_flags & O_SYNC) {
    + return pgprot_noncached(vma_prot);
    + }
    +
    + return vma_prot;
    +}
    +EXPORT_SYMBOL(phys_mem_access_prot);
    --
    2.19.1
    \
     
     \ /
      Last update: 2019-03-11 21:10    [W:5.582 / U:0.056 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site