Skip to content

Commit 76d21d1

Browse files
committed
csky: Fixup io-range page attribute for mmap("/dev/mem")
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>
1 parent 0f231dc commit 76d21d1

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

arch/csky/include/asm/pgtable.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,11 @@ static inline pte_t pte_mkyoung(pte_t pte)
241241

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

244+
#define __HAVE_PHYS_MEM_ACCESS_PROT
245+
struct file;
246+
extern pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
247+
unsigned long size, pgprot_t vma_prot);
248+
244249
/*
245250
* Macro to make mark a page protection value as "uncacheable". Note
246251
* that "protection" is really a misnomer here as the protection value

arch/csky/mm/ioremap.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,17 @@ void iounmap(void __iomem *addr)
4646
vunmap((void *)((unsigned long)addr & PAGE_MASK));
4747
}
4848
EXPORT_SYMBOL(iounmap);
49+
50+
pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
51+
unsigned long size, pgprot_t vma_prot)
52+
{
53+
if (!pfn_valid(pfn)) {
54+
vma_prot.pgprot |= _PAGE_SO;
55+
return pgprot_noncached(vma_prot);
56+
} else if (file->f_flags & O_SYNC) {
57+
return pgprot_noncached(vma_prot);
58+
}
59+
60+
return vma_prot;
61+
}
62+
EXPORT_SYMBOL(phys_mem_access_prot);

0 commit comments

Comments
 (0)