diff options
Diffstat (limited to 'lib/ioremap.c')
-rw-r--r-- | lib/ioremap.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/lib/ioremap.c b/lib/ioremap.c index 0c9216c48762..86c8911b0e3a 100644 --- a/lib/ioremap.c +++ b/lib/ioremap.c | |||
@@ -13,6 +13,43 @@ | |||
13 | #include <asm/cacheflush.h> | 13 | #include <asm/cacheflush.h> |
14 | #include <asm/pgtable.h> | 14 | #include <asm/pgtable.h> |
15 | 15 | ||
16 | #ifdef CONFIG_HAVE_ARCH_HUGE_VMAP | ||
17 | static int __read_mostly ioremap_pud_capable; | ||
18 | static int __read_mostly ioremap_pmd_capable; | ||
19 | static int __read_mostly ioremap_huge_disabled; | ||
20 | |||
21 | static int __init set_nohugeiomap(char *str) | ||
22 | { | ||
23 | ioremap_huge_disabled = 1; | ||
24 | return 0; | ||
25 | } | ||
26 | early_param("nohugeiomap", set_nohugeiomap); | ||
27 | |||
28 | void __init ioremap_huge_init(void) | ||
29 | { | ||
30 | if (!ioremap_huge_disabled) { | ||
31 | if (arch_ioremap_pud_supported()) | ||
32 | ioremap_pud_capable = 1; | ||
33 | if (arch_ioremap_pmd_supported()) | ||
34 | ioremap_pmd_capable = 1; | ||
35 | } | ||
36 | } | ||
37 | |||
38 | static inline int ioremap_pud_enabled(void) | ||
39 | { | ||
40 | return ioremap_pud_capable; | ||
41 | } | ||
42 | |||
43 | static inline int ioremap_pmd_enabled(void) | ||
44 | { | ||
45 | return ioremap_pmd_capable; | ||
46 | } | ||
47 | |||
48 | #else /* !CONFIG_HAVE_ARCH_HUGE_VMAP */ | ||
49 | static inline int ioremap_pud_enabled(void) { return 0; } | ||
50 | static inline int ioremap_pmd_enabled(void) { return 0; } | ||
51 | #endif /* CONFIG_HAVE_ARCH_HUGE_VMAP */ | ||
52 | |||
16 | static int ioremap_pte_range(pmd_t *pmd, unsigned long addr, | 53 | static int ioremap_pte_range(pmd_t *pmd, unsigned long addr, |
17 | unsigned long end, phys_addr_t phys_addr, pgprot_t prot) | 54 | unsigned long end, phys_addr_t phys_addr, pgprot_t prot) |
18 | { | 55 | { |
@@ -43,6 +80,14 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr, | |||
43 | return -ENOMEM; | 80 | return -ENOMEM; |
44 | do { | 81 | do { |
45 | 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 | |||
46 | if (ioremap_pte_range(pmd, addr, next, phys_addr + addr, prot)) | 91 | if (ioremap_pte_range(pmd, addr, next, phys_addr + addr, prot)) |
47 | return -ENOMEM; | 92 | return -ENOMEM; |
48 | } while (pmd++, addr = next, addr != end); | 93 | } while (pmd++, addr = next, addr != end); |
@@ -61,6 +106,14 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr, | |||
61 | return -ENOMEM; | 106 | return -ENOMEM; |
62 | do { | 107 | do { |
63 | 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 | |||
64 | if (ioremap_pmd_range(pud, addr, next, phys_addr + addr, prot)) | 117 | if (ioremap_pmd_range(pud, addr, next, phys_addr + addr, prot)) |
65 | return -ENOMEM; | 118 | return -ENOMEM; |
66 | } while (pud++, addr = next, addr != end); | 119 | } while (pud++, addr = next, addr != end); |