Commit 906e36c5 authored by Mike Travis's avatar Mike Travis Committed by Linus Torvalds

x86: use optimized ioresource lookup in ioremap function

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: default avatarMike Travis <travis@sgi.com>
Acked-by: default avatarAlex Thorlton <athorlton@sgi.com>
Reviewed-by: default avatarCliff Wickman <cpw@sgi.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Mark Salter <msalter@redhat.com>
Cc: Dave Young <dyoung@redhat.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Ingo Molnar <mingo@elte.hu>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 67cf13ce
...@@ -86,6 +86,7 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr, ...@@ -86,6 +86,7 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
pgprot_t prot; pgprot_t prot;
int retval; int retval;
void __iomem *ret_addr; void __iomem *ret_addr;
int ram_region;
/* Don't allow wraparound or zero size */ /* Don't allow wraparound or zero size */
last_addr = phys_addr + size - 1; last_addr = phys_addr + size - 1;
...@@ -108,12 +109,23 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr, ...@@ -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.. * Don't allow anybody to remap normal RAM that we're using..
*/ */
pfn = phys_addr >> PAGE_SHIFT; /* First check if whole region can be identified as RAM or not */
last_pfn = last_addr >> PAGE_SHIFT; ram_region = region_is_ram(phys_addr, size);
if (walk_system_ram_range(pfn, last_pfn - pfn + 1, NULL, if (ram_region > 0) {
__ioremap_check_ram) == 1) WARN_ONCE(1, "ioremap on RAM at 0x%lx - 0x%lx\n",
(unsigned long int)phys_addr,
(unsigned long int)last_addr);
return NULL; 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 * Mappings have to be page-aligned
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment