x86: ioremap_nocache fix
[pandora-kernel.git] / arch / x86 / mm / ioremap_64.c
index 6cac90a..0a05f02 100644 (file)
@@ -19,6 +19,7 @@
 #include <asm/tlbflush.h>
 #include <asm/cacheflush.h>
 #include <asm/proto.h>
+#include <asm/e820.h>
 
 unsigned long __phys_addr(unsigned long x)
 {
@@ -28,9 +29,6 @@ unsigned long __phys_addr(unsigned long x)
 }
 EXPORT_SYMBOL(__phys_addr);
 
-#define ISA_START_ADDRESS      0xa0000
-#define ISA_END_ADDRESS                0x100000
-
 /*
  * Fix up the linear direct mapping of the kernel to avoid cache attribute
  * conflicts.
@@ -43,7 +41,14 @@ ioremap_change_attr(unsigned long phys_addr, unsigned long size,
        if (phys_addr + size - 1 < (end_pfn_map << PAGE_SHIFT)) {
                unsigned long npages = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
                unsigned long vaddr = (unsigned long) __va(phys_addr);
+               int level;
 
+               /*
+                * If there is no identity map for this address,
+                * change_page_attr_addr is unnecessary
+                */
+               if (!lookup_address(vaddr, &level))
+                       return err;
                /*
                 * Must use a address here and not struct page because the phys addr
                 * can be a in hole between nodes and not have an memmap entry.
@@ -86,25 +91,7 @@ void __iomem * __ioremap(unsigned long phys_addr, unsigned long size, unsigned l
        if (phys_addr >= ISA_START_ADDRESS && last_addr < ISA_END_ADDRESS)
                return (__force void __iomem *)phys_to_virt(phys_addr);
 
-#ifdef CONFIG_FLATMEM
-       /*
-        * Don't allow anybody to remap normal RAM that we're using..
-        */
-       if (last_addr < virt_to_phys(high_memory)) {
-               char *t_addr, *t_end;
-               struct page *page;
-
-               t_addr = __va(phys_addr);
-               t_end = t_addr + (size - 1);
-          
-               for(page = virt_to_page(t_addr); page <= virt_to_page(t_end); page++)
-                       if(!PageReserved(page))
-                               return NULL;
-       }
-#endif
-
-       pgprot = __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_GLOBAL
-                         | _PAGE_DIRTY | _PAGE_ACCESSED | flags);
+       pgprot = __pgprot(__PAGE_KERNEL_EXEC | _PAGE_GLOBAL | flags);
        /*
         * Mappings have to be page-aligned
         */
@@ -158,7 +145,7 @@ EXPORT_SYMBOL(__ioremap);
 
 void __iomem *ioremap_nocache (unsigned long phys_addr, unsigned long size)
 {
-       return __ioremap(phys_addr, size, _PAGE_PCD);
+       return __ioremap(phys_addr, size, _PAGE_PCD | _PAGE_PWT);
 }
 EXPORT_SYMBOL(ioremap_nocache);