Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 161400
b: refs/heads/master
c: 637b86e
h: refs/heads/master
v: v3
  • Loading branch information
Venkatesh Pallipadi authored and H. Peter Anvin committed Aug 26, 2009
1 parent 001c35c commit 6173b83
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f58417409603d62f2eb23db4d2cf6853d84a1698
refs/heads/master: 637b86e75f4c255a4446bc0b67ce9d914b9d2d42
45 changes: 45 additions & 0 deletions trunk/arch/x86/mm/pat.c
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,51 @@ int free_memtype(u64 start, u64 end)
}


/**
* lookup_memtype - Looksup the memory type for a physical address
* @paddr: physical address of which memory type needs to be looked up
*
* Only to be called when PAT is enabled
*
* Returns _PAGE_CACHE_WB, _PAGE_CACHE_WC, _PAGE_CACHE_UC_MINUS or
* _PAGE_CACHE_UC
*/
static unsigned long lookup_memtype(u64 paddr)
{
int rettype = _PAGE_CACHE_WB;
struct memtype *entry;

if (is_ISA_range(paddr, paddr + PAGE_SIZE - 1))
return rettype;

if (pat_pagerange_is_ram(paddr, paddr + PAGE_SIZE)) {
struct page *page;
spin_lock(&memtype_lock);
page = pfn_to_page(paddr >> PAGE_SHIFT);
rettype = get_page_memtype(page);
spin_unlock(&memtype_lock);
/*
* -1 from get_page_memtype() implies RAM page is in its
* default state and not reserved, and hence of type WB
*/
if (rettype == -1)
rettype = _PAGE_CACHE_WB;

return rettype;
}

spin_lock(&memtype_lock);

entry = memtype_rb_search(&memtype_rbroot, paddr);
if (entry != NULL)
rettype = entry->type;
else
rettype = _PAGE_CACHE_UC_MINUS;

spin_unlock(&memtype_lock);
return rettype;
}

/**
* io_reserve_memtype - Request a memory type mapping for a region of memory
* @start: start (physical address) of the region
Expand Down

0 comments on commit 6173b83

Please sign in to comment.