Skip to content

Commit e61ce6a

Browse files
Toshi Kanitorvalds
authored andcommitted
mm: change ioremap to set up huge I/O mappings
ioremap_pud_range() and ioremap_pmd_range() are changed to create huge I/O mappings when their capability is enabled, and a request meets required conditions -- both virtual & physical addresses are aligned by their huge page size, and a requested range fufills their huge page size. When pud_set_huge() or pmd_set_huge() returns zero, i.e. no-operation is performed, the code simply falls back to the next level. The changes are only enabled when CONFIG_HAVE_ARCH_HUGE_VMAP is defined on the architecture. Signed-off-by: Toshi Kani <toshi.kani@hp.com> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Ingo Molnar <mingo@redhat.com> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Dave Hansen <dave.hansen@intel.com> Cc: Robert Elliott <Elliott@hp.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 0ddab1d commit e61ce6a

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

include/asm-generic/pgtable.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <linux/mm_types.h>
88
#include <linux/bug.h>
9+
#include <linux/errno.h>
910

1011
#if 4 - defined(__PAGETABLE_PUD_FOLDED) - defined(__PAGETABLE_PMD_FOLDED) != \
1112
CONFIG_PGTABLE_LEVELS
@@ -696,6 +697,20 @@ static inline int pmd_protnone(pmd_t pmd)
696697

697698
#endif /* CONFIG_MMU */
698699

700+
#ifdef CONFIG_HAVE_ARCH_HUGE_VMAP
701+
int pud_set_huge(pud_t *pud, phys_addr_t addr, pgprot_t prot);
702+
int pmd_set_huge(pmd_t *pmd, phys_addr_t addr, pgprot_t prot);
703+
#else /* !CONFIG_HAVE_ARCH_HUGE_VMAP */
704+
static inline int pud_set_huge(pud_t *pud, phys_addr_t addr, pgprot_t prot)
705+
{
706+
return 0;
707+
}
708+
static inline int pmd_set_huge(pmd_t *pmd, phys_addr_t addr, pgprot_t prot)
709+
{
710+
return 0;
711+
}
712+
#endif /* CONFIG_HAVE_ARCH_HUGE_VMAP */
713+
699714
#endif /* !__ASSEMBLY__ */
700715

701716
#ifndef io_remap_pfn_range

lib/ioremap.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,14 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
8080
return -ENOMEM;
8181
do {
8282
next = pmd_addr_end(addr, end);
83+
84+
if (ioremap_pmd_enabled() &&
85+
((next - addr) == PMD_SIZE) &&
86+
IS_ALIGNED(phys_addr + addr, PMD_SIZE)) {
87+
if (pmd_set_huge(pmd, phys_addr + addr, prot))
88+
continue;
89+
}
90+
8391
if (ioremap_pte_range(pmd, addr, next, phys_addr + addr, prot))
8492
return -ENOMEM;
8593
} while (pmd++, addr = next, addr != end);
@@ -98,6 +106,14 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
98106
return -ENOMEM;
99107
do {
100108
next = pud_addr_end(addr, end);
109+
110+
if (ioremap_pud_enabled() &&
111+
((next - addr) == PUD_SIZE) &&
112+
IS_ALIGNED(phys_addr + addr, PUD_SIZE)) {
113+
if (pud_set_huge(pud, phys_addr + addr, prot))
114+
continue;
115+
}
116+
101117
if (ioremap_pmd_range(pud, addr, next, phys_addr + addr, prot))
102118
return -ENOMEM;
103119
} while (pud++, addr = next, addr != end);

0 commit comments

Comments
 (0)