Merge master.kernel.org:/pub/scm/linux/kernel/git/steve/gfs2-2.6-nmw
[pandora-kernel.git] / arch / sh / mm / ioremap.c
index 96fa4a9..11d54c1 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/vmalloc.h>
 #include <linux/module.h>
 #include <linux/mm.h>
+#include <linux/pci.h>
 #include <asm/io.h>
 #include <asm/page.h>
 #include <asm/pgalloc.h>
@@ -27,9 +28,7 @@ static inline void remap_area_pte(pte_t * pte, unsigned long address,
 {
        unsigned long end;
        unsigned long pfn;
-       pgprot_t pgprot = __pgprot(_PAGE_PRESENT | _PAGE_RW |
-                                  _PAGE_DIRTY | _PAGE_ACCESSED |
-                                  _PAGE_HW_SHARED | _PAGE_FLAGS_HARD | flags);
+       pgprot_t pgprot = __pgprot(pgprot_val(PAGE_KERNEL_NOCACHE) | flags);
 
        address &= ~PMD_MASK;
        end = address + size;
@@ -134,6 +133,20 @@ void __iomem *__ioremap(unsigned long phys_addr, unsigned long size,
        if (phys_addr >= 0xA0000 && last_addr < 0x100000)
                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..
         */
@@ -192,7 +205,7 @@ void __iounmap(void __iomem *addr)
        unsigned long vaddr = (unsigned long __force)addr;
        struct vm_struct *p;
 
-       if (PXSEG(vaddr) < P3SEG)
+       if (PXSEG(vaddr) < P3SEG || is_pci_memaddr(vaddr))
                return;
 
 #ifdef CONFIG_32BIT