Commit a3e61d50 authored by Paul Mundt's avatar Paul Mundt

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: default avatarPaul Mundt <lethal@linux-sh.org>
parent 959f85f8
...@@ -195,7 +195,7 @@ void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen) ...@@ -195,7 +195,7 @@ void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
unsigned long len = pci_resource_len(dev, bar); unsigned long len = pci_resource_len(dev, bar);
unsigned long flags = pci_resource_flags(dev, bar); unsigned long flags = pci_resource_flags(dev, bar);
if (!len || !start) if (unlikely(!len || !start))
return NULL; return NULL;
if (maxlen && len > maxlen) if (maxlen && len > maxlen)
len = maxlen; len = maxlen;
...@@ -204,18 +204,16 @@ void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen) ...@@ -204,18 +204,16 @@ void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
* Presently the IORESOURCE_MEM case is a bit special, most * Presently the IORESOURCE_MEM case is a bit special, most
* SH7751 style PCI controllers have PCI memory at a fixed * SH7751 style PCI controllers have PCI memory at a fixed
* location in the address space where no remapping is desired * location in the address space where no remapping is desired
* (traditionally at 0xfd000000). Once this changes, the * (typically at 0xfd000000, but is_pci_memaddr() will know
* IORESOURCE_MEM case will have to switch to using ioremap() and * best). With the IORESOURCE_MEM case more care has to be taken
* more care will have to be taken to inhibit page table mapping * to inhibit page table mapping for legacy cores, but this is
* for legacy cores. * punted off to __ioremap().
*
* For now everything wraps to ioport_map(), since boards that
* have PCI will be able to check the address range properly on
* their own.
* -- PFM. * -- PFM.
*/ */
if (flags & (IORESOURCE_IO | IORESOURCE_MEM)) if (flags & IORESOURCE_IO)
return ioport_map(start, len); return ioport_map(start, len);
if (flags & IORESOURCE_MEM)
return ioremap(start, len);
return NULL; return NULL;
} }
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/pci.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/page.h> #include <asm/page.h>
#include <asm/pgalloc.h> #include <asm/pgalloc.h>
...@@ -134,6 +135,20 @@ void __iomem *__ioremap(unsigned long phys_addr, unsigned long size, ...@@ -134,6 +135,20 @@ void __iomem *__ioremap(unsigned long phys_addr, unsigned long size,
if (phys_addr >= 0xA0000 && last_addr < 0x100000) if (phys_addr >= 0xA0000 && last_addr < 0x100000)
return (void __iomem *)phys_to_virt(phys_addr); return (void __iomem *)phys_to_virt(phys_addr);
/*
* If we're on an SH7751 or SH7780 PCI controller, PCI memory is
* mapped at the end of the address space (typically 0xfd000000)
* in a non-translatable area, so mapping through page tables for
* this area is not only pointless, but also fundamentally
* broken. Just return the physical address instead.
*
* For boards that map a small PCI memory aperture somewhere in
* P1/P2 space, ioremap() will already do the right thing,
* and we'll never get this far.
*/
if (is_pci_memaddr(phys_addr) && is_pci_memaddr(last_addr))
return (void __iomem *)phys_addr;
/* /*
* Don't allow anybody to remap normal RAM that we're using.. * Don't allow anybody to remap normal RAM that we're using..
*/ */
...@@ -192,7 +207,7 @@ void __iounmap(void __iomem *addr) ...@@ -192,7 +207,7 @@ void __iounmap(void __iomem *addr)
unsigned long vaddr = (unsigned long __force)addr; unsigned long vaddr = (unsigned long __force)addr;
struct vm_struct *p; struct vm_struct *p;
if (PXSEG(vaddr) < P3SEG) if (PXSEG(vaddr) < P3SEG || is_pci_memaddr(vaddr))
return; return;
#ifdef CONFIG_32BIT #ifdef CONFIG_32BIT
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment