--- arch/x86/mm/pat.c | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) Index: linux-2.6/arch/x86/mm/pat.c =================================================================== --- linux-2.6.orig/arch/x86/mm/pat.c +++ linux-2.6/arch/x86/mm/pat.c @@ -31,7 +31,7 @@ #ifdef CONFIG_X86_PAT int __read_mostly pat_enabled = 1; -void __cpuinit pat_disable(const char *reason) +static void __cpuinit pat_disable(const char *reason) { pat_enabled = 0; printk(KERN_INFO "%s\n", reason); @@ -176,9 +176,9 @@ static unsigned long pat_x_mtrr_type(u64 { /* * Look for MTRR hint to get the effective type in case where PAT - * request is for WB. + * request is for WB or WC. */ - if (req_type == _PAGE_CACHE_WB) { + if (req_type == _PAGE_CACHE_WB || req_type == _PAGE_CACHE_WC) { u8 mtrr_type; mtrr_type = mtrr_type_lookup(start, end); @@ -191,10 +191,15 @@ static unsigned long pat_x_mtrr_type(u64 return req_type; } +static unsigned long real_type(struct memtype *entry) +{ + return pat_x_mtrr_type(entry->start, entry->end, entry->type); +} + static int chk_conflict(struct memtype *new, struct memtype *entry, unsigned long *type) { - if (new->type != entry->type) { + if (real_type(new) != real_type(entry)) { if (type) { new->type = entry->type; *type = entry->type; @@ -206,15 +211,16 @@ chk_conflict(struct memtype *new, struct list_for_each_entry_continue(entry, &memtype_list, nd) { if (new->end <= entry->start) break; - else if (new->type != entry->type) + else if (real_type(new) != real_type(entry)) goto conflict; } return 0; conflict: printk(KERN_INFO "%s:%d conflicting memory types " - "%Lx-%Lx %s<->%s\n", current->comm, current->pid, new->start, - new->end, cattr_name(new->type), cattr_name(entry->type)); + "%Lx-%Lx %s <-> %Lx-%Lx%s\n", current->comm, current->pid, + new->start, new->end, cattr_name(new->type), + entry->start, entry->end, cattr_name(entry->type)); return -EBUSY; } @@ -353,18 +359,7 @@ int reserve_memtype(u64 start, u64 end, } if (req_type == -1) { - /* - * 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 == MTRR_TYPE_WRBACK) - actual_type = _PAGE_CACHE_WB; - else - actual_type = _PAGE_CACHE_UC_MINUS; + actual_type = pat_x_mtrr_type(start, end, _PAGE_CACHE_WB); } else { actual_type = pat_x_mtrr_type(start, end, req_type & _PAGE_CACHE_MASK); @@ -386,7 +381,7 @@ int reserve_memtype(u64 start, u64 end, new->start = start; new->end = end; - new->type = actual_type; + new->type = req_type & _PAGE_CACHE_MASK; spin_lock(&memtype_lock);