Skip to content

Commit

Permalink
x86 PAT: consolidate old memtype new memtype check into a function
Browse files Browse the repository at this point in the history
Impact: cleanup

Move the new memtype old memtype allowed check to header so that is can be
shared by other users. Subsequent patch uses this in pat.c in remap_pfn_range()
code path. No functionality change in this patch.

Signed-off-by: Venkatesh Pallipadi <[email protected]>
Signed-off-by: Suresh Siddha <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
  • Loading branch information
[email protected] authored and Ingo Molnar committed Jan 13, 2009
1 parent a367061 commit afc7d20
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
19 changes: 19 additions & 0 deletions arch/x86/include/asm/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,25 @@ static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)

#define canon_pgprot(p) __pgprot(pgprot_val(p) & __supported_pte_mask)

static inline int is_new_memtype_allowed(unsigned long flags,
unsigned long new_flags)
{
/*
* Certain new memtypes are not allowed with certain
* requested memtype:
* - request is uncached, return cannot be write-back
* - request is write-combine, return cannot be write-back
*/
if ((flags == _PAGE_CACHE_UC_MINUS &&
new_flags == _PAGE_CACHE_WB) ||
(flags == _PAGE_CACHE_WC &&
new_flags == _PAGE_CACHE_WB)) {
return 0;
}

return 1;
}

#ifndef __ASSEMBLY__
/* Indicate that x86 has its own track and untrack pfn vma functions */
#define __HAVE_PFNMAP_TRACKING
Expand Down
12 changes: 1 addition & 11 deletions arch/x86/pci/i386.c
Original file line number Diff line number Diff line change
Expand Up @@ -314,17 +314,7 @@ int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
return retval;

if (flags != new_flags) {
/*
* Do not fallback to certain memory types with certain
* requested type:
* - request is uncached, return cannot be write-back
* - request is uncached, return cannot be write-combine
* - request is write-combine, return cannot be write-back
*/
if ((flags == _PAGE_CACHE_UC_MINUS &&
(new_flags == _PAGE_CACHE_WB)) ||
(flags == _PAGE_CACHE_WC &&
new_flags == _PAGE_CACHE_WB)) {
if (!is_new_memtype_allowed(flags, new_flags)) {
free_memtype(addr, addr+len);
return -EINVAL;
}
Expand Down

0 comments on commit afc7d20

Please sign in to comment.