aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Mundt <lethal@linux-sh.org>2006-09-27 03:45:22 -0400
committerPaul Mundt <lethal@linux-sh.org>2006-09-27 03:45:22 -0400
commita3e61d50dc82475ebca3ff8b18c174c02c5ff511 (patch)
treed7a39867983b0bca5619cfe7493358e6bde6f3ba
parent959f85f8a3223c116bbe95dd8a9b207790b5d4d3 (diff)
sh: Inhibit mapping PCI apertures through page tables.
Inhibit mapping through page tables in __ioremap() for PCI memory apertures on SH7751 and SH7780-style PCI controllers, translation is not possible for these areas. For other users that map a small window in P1/P2 space, ioremap() traps that already, and should never make it to __ioremap(). Signed-off-by: Paul Mundt <lethal@linux-sh.org>
-rw-r--r--arch/sh/drivers/pci/pci.c20
-rw-r--r--arch/sh/mm/ioremap.c17
2 files changed, 25 insertions, 12 deletions
diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
index 7377a8a8e161..d439336d2e18 100644
--- a/arch/sh/drivers/pci/pci.c
+++ b/arch/sh/drivers/pci/pci.c
@@ -195,7 +195,7 @@ void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
195 unsigned long len = pci_resource_len(dev, bar); 195 unsigned long len = pci_resource_len(dev, bar);
196 unsigned long flags = pci_resource_flags(dev, bar); 196 unsigned long flags = pci_resource_flags(dev, bar);
197 197
198 if (!len || !start) 198 if (unlikely(!len || !start))
199 return NULL; 199 return NULL;
200 if (maxlen && len > maxlen) 200 if (maxlen && len > maxlen)
201 len = maxlen; 201 len = maxlen;
@@ -204,18 +204,16 @@ void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
204 * Presently the IORESOURCE_MEM case is a bit special, most 204 * Presently the IORESOURCE_MEM case is a bit special, most
205 * SH7751 style PCI controllers have PCI memory at a fixed 205 * SH7751 style PCI controllers have PCI memory at a fixed
206 * location in the address space where no remapping is desired 206 * location in the address space where no remapping is desired
207 * (traditionally at 0xfd000000). Once this changes, the 207 * (typically at 0xfd000000, but is_pci_memaddr() will know
208 * IORESOURCE_MEM case will have to switch to using ioremap() and 208 * best). With the IORESOURCE_MEM case more care has to be taken
209 * more care will have to be taken to inhibit page table mapping 209 * to inhibit page table mapping for legacy cores, but this is
210 * for legacy cores. 210 * punted off to __ioremap().
211 * 211 * -- PFM.
212 * For now everything wraps to ioport_map(), since boards that
213 * have PCI will be able to check the address range properly on
214 * their own.
215 * -- PFM.
216 */ 212 */
217 if (flags & (IORESOURCE_IO | IORESOURCE_MEM)) 213 if (flags & IORESOURCE_IO)
218 return ioport_map(start, len); 214 return ioport_map(start, len);
215 if (flags & IORESOURCE_MEM)
216 return ioremap(start, len);
219 217
220 return NULL; 218 return NULL;
221} 219}
diff --git a/arch/sh/mm/ioremap.c b/arch/sh/mm/ioremap.c
index 96fa4a999e2a..a9fe80cfc233 100644
--- a/arch/sh/mm/ioremap.c
+++ b/arch/sh/mm/ioremap.c
@@ -15,6 +15,7 @@
15#include <linux/vmalloc.h> 15#include <linux/vmalloc.h>
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/mm.h> 17#include <linux/mm.h>
18#include <linux/pci.h>
18#include <asm/io.h> 19#include <asm/io.h>
19#include <asm/page.h> 20#include <asm/page.h>
20#include <asm/pgalloc.h> 21#include <asm/pgalloc.h>
@@ -135,6 +136,20 @@ void __iomem *__ioremap(unsigned long phys_addr, unsigned long size,
135 return (void __iomem *)phys_to_virt(phys_addr); 136 return (void __iomem *)phys_to_virt(phys_addr);
136 137
137 /* 138 /*
139 * If we're on an SH7751 or SH7780 PCI controller, PCI memory is
140 * mapped at the end of the address space (typically 0xfd000000)
141 * in a non-translatable area, so mapping through page tables for
142 * this area is not only pointless, but also fundamentally
143 * broken. Just return the physical address instead.
144 *
145 * For boards that map a small PCI memory aperture somewhere in
146 * P1/P2 space, ioremap() will already do the right thing,
147 * and we'll never get this far.
148 */
149 if (is_pci_memaddr(phys_addr) && is_pci_memaddr(last_addr))
150 return (void __iomem *)phys_addr;
151
152 /*
138 * Don't allow anybody to remap normal RAM that we're using.. 153 * Don't allow anybody to remap normal RAM that we're using..
139 */ 154 */
140 if (phys_addr < virt_to_phys(high_memory)) 155 if (phys_addr < virt_to_phys(high_memory))
@@ -192,7 +207,7 @@ void __iounmap(void __iomem *addr)
192 unsigned long vaddr = (unsigned long __force)addr; 207 unsigned long vaddr = (unsigned long __force)addr;
193 struct vm_struct *p; 208 struct vm_struct *p;
194 209
195 if (PXSEG(vaddr) < P3SEG) 210 if (PXSEG(vaddr) < P3SEG || is_pci_memaddr(vaddr))
196 return; 211 return;
197 212
198#ifdef CONFIG_32BIT 213#ifdef CONFIG_32BIT