]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/x86/mm/pat.c
x86: section mismatch fix
[linux-2.6-omap-h63xx.git] / arch / x86 / mm / pat.c
index 60adbe22efa0d66e3885cbb39ed5f65c521a8fde..06b7a1c90fb89e43eadd396592cbf6625080020b 100644 (file)
 #ifdef CONFIG_X86_PAT
 int __read_mostly pat_wc_enabled = 1;
 
-void __init pat_disable(char *reason)
+void __cpuinit pat_disable(char *reason)
 {
        pat_wc_enabled = 0;
        printk(KERN_INFO "%s\n", reason);
 }
 
-static int nopat(char *str)
+static int __init nopat(char *str)
 {
        pat_disable("PAT support disabled.");
        return 0;
@@ -151,32 +151,33 @@ static int pat_x_mtrr_type(u64 start, u64 end, unsigned long prot,
        unsigned long pat_type;
        u8 mtrr_type;
 
-       mtrr_type = mtrr_type_lookup(start, end);
-       if (mtrr_type == 0xFF) {                /* MTRR not enabled */
-               *ret_prot = prot;
-               return 0;
-       }
-       if (mtrr_type == 0xFE) {                /* MTRR match error */
-               *ret_prot = _PAGE_CACHE_UC;
-               return -1;
-       }
-       if (mtrr_type != MTRR_TYPE_UNCACHABLE &&
-           mtrr_type != MTRR_TYPE_WRBACK &&
-           mtrr_type != MTRR_TYPE_WRCOMB) {    /* MTRR type unhandled */
-               *ret_prot = _PAGE_CACHE_UC;
-               return -1;
-       }
-
        pat_type = prot & _PAGE_CACHE_MASK;
        prot &= (~_PAGE_CACHE_MASK);
 
-       /* Currently doing intersection by hand. Optimize it later. */
+       /*
+        * We return the PAT request directly for types where PAT takes
+        * precedence with respect to MTRR and for UC_MINUS.
+        * Consistency checks with other PAT requests is done later
+        * while going through memtype list.
+        */
        if (pat_type == _PAGE_CACHE_WC) {
                *ret_prot = prot | _PAGE_CACHE_WC;
+               return 0;
        } else if (pat_type == _PAGE_CACHE_UC_MINUS) {
                *ret_prot = prot | _PAGE_CACHE_UC_MINUS;
-       } else if (pat_type == _PAGE_CACHE_UC ||
-                  mtrr_type == MTRR_TYPE_UNCACHABLE) {
+               return 0;
+       } else if (pat_type == _PAGE_CACHE_UC) {
+               *ret_prot = prot | _PAGE_CACHE_UC;
+               return 0;
+       }
+
+       /*
+        * Look for MTRR hint to get the effective type in case where PAT
+        * request is for WB.
+        */
+       mtrr_type = mtrr_type_lookup(start, end);
+
+       if (mtrr_type == MTRR_TYPE_UNCACHABLE) {
                *ret_prot = prot | _PAGE_CACHE_UC;
        } else if (mtrr_type == MTRR_TYPE_WRCOMB) {
                *ret_prot = prot | _PAGE_CACHE_WC;
@@ -233,14 +234,12 @@ int reserve_memtype(u64 start, u64 end, unsigned long req_type,
 
        if (req_type == -1) {
                /*
-                * Special case where caller wants to inherit from mtrr or
-                * existing pat mapping, defaulting to UC_MINUS in case of
-                * no match.
+                * Call mtrr_lookup to get the type hint. This is an
+                * optimization for /dev/mem mmap'ers into WB memory (BIOS
+                * tools and ACPI tools). Use WB request for WB memory and use
+                * UC_MINUS otherwise.
                 */
                u8 mtrr_type = mtrr_type_lookup(start, end);
-               if (mtrr_type == 0xFE) { /* MTRR match error */
-                       err = -1;
-               }
 
                if (mtrr_type == MTRR_TYPE_WRBACK) {
                        req_type = _PAGE_CACHE_WB;
@@ -555,7 +554,7 @@ int phys_mem_access_prot_allowed(struct file *file, unsigned long pfn,
                "%s:%d /dev/mem ioremap_change_attr failed %s for %Lx-%Lx\n",
                        current->comm, current->pid,
                        cattr_name(flags),
-                       offset, offset + size);
+                       offset, (unsigned long long)(offset + size));
                return 0;
        }
 
@@ -576,7 +575,7 @@ void map_devmem(unsigned long pfn, unsigned long size, pgprot_t vma_prot)
                "%s:%d /dev/mem expected mapping type %s for %Lx-%Lx, got %s\n",
                        current->comm, current->pid,
                        cattr_name(want_flags),
-                       addr, addr + size,
+                       addr, (unsigned long long)(addr + size),
                        cattr_name(flags));
        }
 }