Skip to content

Commit

Permalink
x86: use optimized ioresource lookup in ioremap function
Browse files Browse the repository at this point in the history
Use the optimized ioresource lookup, "region_is_ram", for the ioremap
function.  If the region is not found, it falls back to the "page_is_ram"
function.  If it is found and it is RAM, then the usual warning message is
issued, and the ioremap operation is aborted.  Otherwise, the ioremap
operation continues.

Signed-off-by: Mike Travis <[email protected]>
Acked-by: Alex Thorlton <[email protected]>
Reviewed-by: Cliff Wickman <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: H. Peter Anvin <[email protected]>
Cc: Mark Salter <[email protected]>
Cc: Dave Young <[email protected]>
Cc: Rik van Riel <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Mel Gorman <[email protected]>
Cc: Ingo Molnar <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
  • Loading branch information
Mike Travis authored and sfrothwell committed Oct 2, 2014
1 parent 6cd2f15 commit 6227ba5
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions arch/x86/mm/ioremap.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
pgprot_t prot;
int retval;
void __iomem *ret_addr;
int ram_region;

/* Don't allow wraparound or zero size */
last_addr = phys_addr + size - 1;
Expand All @@ -108,12 +109,23 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
/*
* Don't allow anybody to remap normal RAM that we're using..
*/
pfn = phys_addr >> PAGE_SHIFT;
last_pfn = last_addr >> PAGE_SHIFT;
if (walk_system_ram_range(pfn, last_pfn - pfn + 1, NULL,
__ioremap_check_ram) == 1)
/* First check if whole region can be identified as RAM or not */
ram_region = region_is_ram(phys_addr, size);
if (ram_region > 0) {
WARN_ONCE(1, "ioremap on RAM at 0x%lx - 0x%lx\n",
(unsigned long int)phys_addr,
(unsigned long int)last_addr);
return NULL;
}

/* If could not be identified(-1), check page by page */
if (ram_region < 0) {
pfn = phys_addr >> PAGE_SHIFT;
last_pfn = last_addr >> PAGE_SHIFT;
if (walk_system_ram_range(pfn, last_pfn - pfn + 1, NULL,
__ioremap_check_ram) == 1)
return NULL;
}
/*
* Mappings have to be page-aligned
*/
Expand Down

0 comments on commit 6227ba5

Please sign in to comment.