diff options
author | Christophe Leroy <christophe.leroy@c-s.fr> | 2018-10-09 09:51:43 -0400 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2018-10-14 03:04:09 -0400 |
commit | 56f3c1413f5cce0c8f4d6f1ab79d790da5aa61af (patch) | |
tree | a1ec8ea4a338d63d56353383ae49caad7b5b23dc | |
parent | aa91796ec46339f2ed53da311bd3ea77a3e4dfe1 (diff) |
powerpc/mm: properly set PAGE_KERNEL flags in ioremap()
Set PAGE_KERNEL directly in the caller and do not rely on a
hack adding PAGE_KERNEL flags when _PAGE_PRESENT is not set.
As already done for PPC64, use pgprot_cache() helpers instead of
_PAGE_XXX flags in PPC32 ioremap() derived functions.
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
-rw-r--r-- | arch/powerpc/include/asm/nohash/pgtable.h | 2 | ||||
-rw-r--r-- | arch/powerpc/kernel/isa-bridge.c | 6 | ||||
-rw-r--r-- | arch/powerpc/kernel/pci_64.c | 2 | ||||
-rw-r--r-- | arch/powerpc/mm/pgtable_32.c | 28 | ||||
-rw-r--r-- | arch/powerpc/mm/pgtable_64.c | 10 | ||||
-rw-r--r-- | arch/powerpc/platforms/4xx/ocm.c | 7 | ||||
-rw-r--r-- | drivers/pcmcia/electra_cf.c | 2 |
7 files changed, 24 insertions, 33 deletions
diff --git a/arch/powerpc/include/asm/nohash/pgtable.h b/arch/powerpc/include/asm/nohash/pgtable.h index b321c82b3624..5b82e44c4231 100644 --- a/arch/powerpc/include/asm/nohash/pgtable.h +++ b/arch/powerpc/include/asm/nohash/pgtable.h | |||
@@ -197,6 +197,8 @@ extern int ptep_set_access_flags(struct vm_area_struct *vma, unsigned long addre | |||
197 | #if _PAGE_WRITETHRU != 0 | 197 | #if _PAGE_WRITETHRU != 0 |
198 | #define pgprot_cached_wthru(prot) (__pgprot((pgprot_val(prot) & ~_PAGE_CACHE_CTL) | \ | 198 | #define pgprot_cached_wthru(prot) (__pgprot((pgprot_val(prot) & ~_PAGE_CACHE_CTL) | \ |
199 | _PAGE_COHERENT | _PAGE_WRITETHRU)) | 199 | _PAGE_COHERENT | _PAGE_WRITETHRU)) |
200 | #else | ||
201 | #define pgprot_cached_wthru(prot) pgprot_noncached(prot) | ||
200 | #endif | 202 | #endif |
201 | 203 | ||
202 | #define pgprot_cached_noncoherent(prot) \ | 204 | #define pgprot_cached_noncoherent(prot) \ |
diff --git a/arch/powerpc/kernel/isa-bridge.c b/arch/powerpc/kernel/isa-bridge.c index 1df6c74aa731..072e384f8c86 100644 --- a/arch/powerpc/kernel/isa-bridge.c +++ b/arch/powerpc/kernel/isa-bridge.c | |||
@@ -110,14 +110,14 @@ static void pci_process_ISA_OF_ranges(struct device_node *isa_node, | |||
110 | size = 0x10000; | 110 | size = 0x10000; |
111 | 111 | ||
112 | __ioremap_at(phb_io_base_phys, (void *)ISA_IO_BASE, | 112 | __ioremap_at(phb_io_base_phys, (void *)ISA_IO_BASE, |
113 | size, pgprot_val(pgprot_noncached(__pgprot(0)))); | 113 | size, pgprot_val(pgprot_noncached(PAGE_KERNEL))); |
114 | return; | 114 | return; |
115 | 115 | ||
116 | inval_range: | 116 | inval_range: |
117 | printk(KERN_ERR "no ISA IO ranges or unexpected isa range, " | 117 | printk(KERN_ERR "no ISA IO ranges or unexpected isa range, " |
118 | "mapping 64k\n"); | 118 | "mapping 64k\n"); |
119 | __ioremap_at(phb_io_base_phys, (void *)ISA_IO_BASE, | 119 | __ioremap_at(phb_io_base_phys, (void *)ISA_IO_BASE, |
120 | 0x10000, pgprot_val(pgprot_noncached(__pgprot(0)))); | 120 | 0x10000, pgprot_val(pgprot_noncached(PAGE_KERNEL))); |
121 | } | 121 | } |
122 | 122 | ||
123 | 123 | ||
@@ -253,7 +253,7 @@ void __init isa_bridge_init_non_pci(struct device_node *np) | |||
253 | */ | 253 | */ |
254 | isa_io_base = ISA_IO_BASE; | 254 | isa_io_base = ISA_IO_BASE; |
255 | __ioremap_at(pbase, (void *)ISA_IO_BASE, | 255 | __ioremap_at(pbase, (void *)ISA_IO_BASE, |
256 | size, pgprot_val(pgprot_noncached(__pgprot(0)))); | 256 | size, pgprot_val(pgprot_noncached(PAGE_KERNEL))); |
257 | 257 | ||
258 | pr_debug("ISA: Non-PCI bridge is %pOF\n", np); | 258 | pr_debug("ISA: Non-PCI bridge is %pOF\n", np); |
259 | } | 259 | } |
diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c index dff28f903512..64bb4dd2b8f1 100644 --- a/arch/powerpc/kernel/pci_64.c +++ b/arch/powerpc/kernel/pci_64.c | |||
@@ -159,7 +159,7 @@ static int pcibios_map_phb_io_space(struct pci_controller *hose) | |||
159 | 159 | ||
160 | /* Establish the mapping */ | 160 | /* Establish the mapping */ |
161 | if (__ioremap_at(phys_page, area->addr, size_page, | 161 | if (__ioremap_at(phys_page, area->addr, size_page, |
162 | pgprot_val(pgprot_noncached(__pgprot(0)))) == NULL) | 162 | pgprot_val(pgprot_noncached(PAGE_KERNEL))) == NULL) |
163 | return -ENOMEM; | 163 | return -ENOMEM; |
164 | 164 | ||
165 | /* Fixup hose IO resource */ | 165 | /* Fixup hose IO resource */ |
diff --git a/arch/powerpc/mm/pgtable_32.c b/arch/powerpc/mm/pgtable_32.c index 4c3adde09d95..6a81a2446c47 100644 --- a/arch/powerpc/mm/pgtable_32.c +++ b/arch/powerpc/mm/pgtable_32.c | |||
@@ -76,32 +76,36 @@ pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long address) | |||
76 | void __iomem * | 76 | void __iomem * |
77 | ioremap(phys_addr_t addr, unsigned long size) | 77 | ioremap(phys_addr_t addr, unsigned long size) |
78 | { | 78 | { |
79 | return __ioremap_caller(addr, size, _PAGE_NO_CACHE | _PAGE_GUARDED, | 79 | unsigned long flags = pgprot_val(pgprot_noncached(PAGE_KERNEL)); |
80 | __builtin_return_address(0)); | 80 | |
81 | return __ioremap_caller(addr, size, flags, __builtin_return_address(0)); | ||
81 | } | 82 | } |
82 | EXPORT_SYMBOL(ioremap); | 83 | EXPORT_SYMBOL(ioremap); |
83 | 84 | ||
84 | void __iomem * | 85 | void __iomem * |
85 | ioremap_wc(phys_addr_t addr, unsigned long size) | 86 | ioremap_wc(phys_addr_t addr, unsigned long size) |
86 | { | 87 | { |
87 | return __ioremap_caller(addr, size, _PAGE_NO_CACHE, | 88 | unsigned long flags = pgprot_val(pgprot_noncached_wc(PAGE_KERNEL)); |
88 | __builtin_return_address(0)); | 89 | |
90 | return __ioremap_caller(addr, size, flags, __builtin_return_address(0)); | ||
89 | } | 91 | } |
90 | EXPORT_SYMBOL(ioremap_wc); | 92 | EXPORT_SYMBOL(ioremap_wc); |
91 | 93 | ||
92 | void __iomem * | 94 | void __iomem * |
93 | ioremap_wt(phys_addr_t addr, unsigned long size) | 95 | ioremap_wt(phys_addr_t addr, unsigned long size) |
94 | { | 96 | { |
95 | return __ioremap_caller(addr, size, _PAGE_WRITETHRU, | 97 | unsigned long flags = pgprot_val(pgprot_cached_wthru(PAGE_KERNEL)); |
96 | __builtin_return_address(0)); | 98 | |
99 | return __ioremap_caller(addr, size, flags, __builtin_return_address(0)); | ||
97 | } | 100 | } |
98 | EXPORT_SYMBOL(ioremap_wt); | 101 | EXPORT_SYMBOL(ioremap_wt); |
99 | 102 | ||
100 | void __iomem * | 103 | void __iomem * |
101 | ioremap_coherent(phys_addr_t addr, unsigned long size) | 104 | ioremap_coherent(phys_addr_t addr, unsigned long size) |
102 | { | 105 | { |
103 | return __ioremap_caller(addr, size, _PAGE_COHERENT, | 106 | unsigned long flags = pgprot_val(pgprot_cached(PAGE_KERNEL)); |
104 | __builtin_return_address(0)); | 107 | |
108 | return __ioremap_caller(addr, size, flags, __builtin_return_address(0)); | ||
105 | } | 109 | } |
106 | EXPORT_SYMBOL(ioremap_coherent); | 110 | EXPORT_SYMBOL(ioremap_coherent); |
107 | 111 | ||
@@ -134,14 +138,6 @@ __ioremap_caller(phys_addr_t addr, unsigned long size, unsigned long flags, | |||
134 | phys_addr_t p; | 138 | phys_addr_t p; |
135 | int err; | 139 | int err; |
136 | 140 | ||
137 | /* Make sure we have the base flags */ | ||
138 | if ((flags & _PAGE_PRESENT) == 0) | ||
139 | flags |= pgprot_val(PAGE_KERNEL); | ||
140 | |||
141 | /* Non-cacheable page cannot be coherent */ | ||
142 | if (flags & _PAGE_NO_CACHE) | ||
143 | flags &= ~_PAGE_COHERENT; | ||
144 | |||
145 | /* | 141 | /* |
146 | * Choose an address to map it to. | 142 | * Choose an address to map it to. |
147 | * Once the vmalloc system is running, we use it. | 143 | * Once the vmalloc system is running, we use it. |
diff --git a/arch/powerpc/mm/pgtable_64.c b/arch/powerpc/mm/pgtable_64.c index c0f356d9b135..1f1bb40555a8 100644 --- a/arch/powerpc/mm/pgtable_64.c +++ b/arch/powerpc/mm/pgtable_64.c | |||
@@ -118,10 +118,6 @@ void __iomem * __ioremap_at(phys_addr_t pa, void *ea, unsigned long size, | |||
118 | { | 118 | { |
119 | unsigned long i; | 119 | unsigned long i; |
120 | 120 | ||
121 | /* Make sure we have the base flags */ | ||
122 | if ((flags & _PAGE_PRESENT) == 0) | ||
123 | flags |= pgprot_val(PAGE_KERNEL); | ||
124 | |||
125 | /* We don't support the 4K PFN hack with ioremap */ | 121 | /* We don't support the 4K PFN hack with ioremap */ |
126 | if (flags & H_PAGE_4K_PFN) | 122 | if (flags & H_PAGE_4K_PFN) |
127 | return NULL; | 123 | return NULL; |
@@ -204,7 +200,7 @@ void __iomem * __ioremap(phys_addr_t addr, unsigned long size, | |||
204 | 200 | ||
205 | void __iomem * ioremap(phys_addr_t addr, unsigned long size) | 201 | void __iomem * ioremap(phys_addr_t addr, unsigned long size) |
206 | { | 202 | { |
207 | unsigned long flags = pgprot_val(pgprot_noncached(__pgprot(0))); | 203 | unsigned long flags = pgprot_val(pgprot_noncached(PAGE_KERNEL)); |
208 | void *caller = __builtin_return_address(0); | 204 | void *caller = __builtin_return_address(0); |
209 | 205 | ||
210 | if (ppc_md.ioremap) | 206 | if (ppc_md.ioremap) |
@@ -214,7 +210,7 @@ void __iomem * ioremap(phys_addr_t addr, unsigned long size) | |||
214 | 210 | ||
215 | void __iomem * ioremap_wc(phys_addr_t addr, unsigned long size) | 211 | void __iomem * ioremap_wc(phys_addr_t addr, unsigned long size) |
216 | { | 212 | { |
217 | unsigned long flags = pgprot_val(pgprot_noncached_wc(__pgprot(0))); | 213 | unsigned long flags = pgprot_val(pgprot_noncached_wc(PAGE_KERNEL)); |
218 | void *caller = __builtin_return_address(0); | 214 | void *caller = __builtin_return_address(0); |
219 | 215 | ||
220 | if (ppc_md.ioremap) | 216 | if (ppc_md.ioremap) |
@@ -224,7 +220,7 @@ void __iomem * ioremap_wc(phys_addr_t addr, unsigned long size) | |||
224 | 220 | ||
225 | void __iomem *ioremap_coherent(phys_addr_t addr, unsigned long size) | 221 | void __iomem *ioremap_coherent(phys_addr_t addr, unsigned long size) |
226 | { | 222 | { |
227 | unsigned long flags = pgprot_val(pgprot_cached(__pgprot(0))); | 223 | unsigned long flags = pgprot_val(pgprot_cached(PAGE_KERNEL)); |
228 | void *caller = __builtin_return_address(0); | 224 | void *caller = __builtin_return_address(0); |
229 | 225 | ||
230 | if (ppc_md.ioremap) | 226 | if (ppc_md.ioremap) |
diff --git a/arch/powerpc/platforms/4xx/ocm.c b/arch/powerpc/platforms/4xx/ocm.c index 69d9f60d9fe5..f5bbd4563342 100644 --- a/arch/powerpc/platforms/4xx/ocm.c +++ b/arch/powerpc/platforms/4xx/ocm.c | |||
@@ -113,7 +113,6 @@ static void __init ocm_init_node(int count, struct device_node *node) | |||
113 | int len; | 113 | int len; |
114 | 114 | ||
115 | struct resource rsrc; | 115 | struct resource rsrc; |
116 | int ioflags; | ||
117 | 116 | ||
118 | ocm = ocm_get_node(count); | 117 | ocm = ocm_get_node(count); |
119 | 118 | ||
@@ -179,9 +178,8 @@ static void __init ocm_init_node(int count, struct device_node *node) | |||
179 | 178 | ||
180 | /* ioremap the non-cached region */ | 179 | /* ioremap the non-cached region */ |
181 | if (ocm->nc.memtotal) { | 180 | if (ocm->nc.memtotal) { |
182 | ioflags = _PAGE_NO_CACHE | _PAGE_GUARDED | _PAGE_EXEC; | ||
183 | ocm->nc.virt = __ioremap(ocm->nc.phys, ocm->nc.memtotal, | 181 | ocm->nc.virt = __ioremap(ocm->nc.phys, ocm->nc.memtotal, |
184 | ioflags); | 182 | _PAGE_EXEC | PAGE_KERNEL_NCG); |
185 | 183 | ||
186 | if (!ocm->nc.virt) { | 184 | if (!ocm->nc.virt) { |
187 | printk(KERN_ERR | 185 | printk(KERN_ERR |
@@ -195,9 +193,8 @@ static void __init ocm_init_node(int count, struct device_node *node) | |||
195 | /* ioremap the cached region */ | 193 | /* ioremap the cached region */ |
196 | 194 | ||
197 | if (ocm->c.memtotal) { | 195 | if (ocm->c.memtotal) { |
198 | ioflags = _PAGE_EXEC; | ||
199 | ocm->c.virt = __ioremap(ocm->c.phys, ocm->c.memtotal, | 196 | ocm->c.virt = __ioremap(ocm->c.phys, ocm->c.memtotal, |
200 | ioflags); | 197 | _PAGE_EXEC | PAGE_KERNEL); |
201 | 198 | ||
202 | if (!ocm->c.virt) { | 199 | if (!ocm->c.virt) { |
203 | printk(KERN_ERR | 200 | printk(KERN_ERR |
diff --git a/drivers/pcmcia/electra_cf.c b/drivers/pcmcia/electra_cf.c index 9671ded549f0..34d6c1a0971e 100644 --- a/drivers/pcmcia/electra_cf.c +++ b/drivers/pcmcia/electra_cf.c | |||
@@ -230,7 +230,7 @@ static int electra_cf_probe(struct platform_device *ofdev) | |||
230 | 230 | ||
231 | if (!cf->mem_base || !cf->io_virt || !cf->gpio_base || | 231 | if (!cf->mem_base || !cf->io_virt || !cf->gpio_base || |
232 | (__ioremap_at(io.start, cf->io_virt, cf->io_size, | 232 | (__ioremap_at(io.start, cf->io_virt, cf->io_size, |
233 | pgprot_val(pgprot_noncached(__pgprot(0)))) == NULL)) { | 233 | pgprot_val(pgprot_noncached(PAGE_KERNEL))) == NULL)) { |
234 | dev_err(device, "can't ioremap ranges\n"); | 234 | dev_err(device, "can't ioremap ranges\n"); |
235 | status = -ENOMEM; | 235 | status = -ENOMEM; |
236 | goto fail1; | 236 | goto fail1; |