Skip to content

Commit

Permalink
csky: Fixup io-range page attribute for mmap("/dev/mem")
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Guo Ren committed Feb 13, 2019
1 parent 0f231dc commit 76d21d1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions arch/csky/include/asm/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions arch/csky/mm/ioremap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

0 comments on commit 76d21d1

Please sign in to comment.