diff options
author | Toshi Kani <toshi.kani@hp.com> | 2015-04-14 18:47:23 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-04-14 19:49:04 -0400 |
commit | e61ce6ade404ef17bd63d62bec78e29047a47b47 (patch) | |
tree | 4a3e14abad0216e51f781b2776562829febe2626 | |
parent | 0ddab1d2ed664c85c95488eef569786a84aedf37 (diff) |
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>
-rw-r--r-- | include/asm-generic/pgtable.h | 15 | ||||
-rw-r--r-- | lib/ioremap.c | 16 |
2 files changed, 31 insertions, 0 deletions
diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h index 1f9f5da6828f..9fb7dc7ca7f4 100644 --- a/include/asm-generic/pgtable.h +++ b/include/asm-generic/pgtable.h | |||
@@ -6,6 +6,7 @@ | |||
6 | 6 | ||
7 | #include <linux/mm_types.h> | 7 | #include <linux/mm_types.h> |
8 | #include <linux/bug.h> | 8 | #include <linux/bug.h> |
9 | #include <linux/errno.h> | ||
9 | 10 | ||
10 | #if 4 - defined(__PAGETABLE_PUD_FOLDED) - defined(__PAGETABLE_PMD_FOLDED) != \ | 11 | #if 4 - defined(__PAGETABLE_PUD_FOLDED) - defined(__PAGETABLE_PMD_FOLDED) != \ |
11 | CONFIG_PGTABLE_LEVELS | 12 | CONFIG_PGTABLE_LEVELS |
@@ -696,6 +697,20 @@ static inline int pmd_protnone(pmd_t pmd) | |||
696 | 697 | ||
697 | #endif /* CONFIG_MMU */ | 698 | #endif /* CONFIG_MMU */ |
698 | 699 | ||
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 | |||
699 | #endif /* !__ASSEMBLY__ */ | 714 | #endif /* !__ASSEMBLY__ */ |
700 | 715 | ||
701 | #ifndef io_remap_pfn_range | 716 | #ifndef io_remap_pfn_range |
diff --git a/lib/ioremap.c b/lib/ioremap.c index 2008652c9a1f..be249062ba6e 100644 --- a/lib/ioremap.c +++ b/lib/ioremap.c | |||
@@ -80,6 +80,14 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr, | |||
80 | return -ENOMEM; | 80 | return -ENOMEM; |
81 | do { | 81 | do { |
82 | next = pmd_addr_end(addr, end); | 82 | 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 | |||
83 | if (ioremap_pte_range(pmd, addr, next, phys_addr + addr, prot)) | 91 | if (ioremap_pte_range(pmd, addr, next, phys_addr + addr, prot)) |
84 | return -ENOMEM; | 92 | return -ENOMEM; |
85 | } while (pmd++, addr = next, addr != end); | 93 | } while (pmd++, addr = next, addr != end); |
@@ -98,6 +106,14 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr, | |||
98 | return -ENOMEM; | 106 | return -ENOMEM; |
99 | do { | 107 | do { |
100 | next = pud_addr_end(addr, end); | 108 | 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 | |||
101 | if (ioremap_pmd_range(pud, addr, next, phys_addr + addr, prot)) | 117 | if (ioremap_pmd_range(pud, addr, next, phys_addr + addr, prot)) |
102 | return -ENOMEM; | 118 | return -ENOMEM; |
103 | } while (pud++, addr = next, addr != end); | 119 | } while (pud++, addr = next, addr != end); |