xtensa: cope with ram beginning at higher addresses

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linux Kernel Mailing List
Date: Friday, April 3, 2009 - 6:01 pm

Gitweb:     http://git.kernel.org/linus/c947a585ab13f310c9223284dfd502790abd05f9
Commit:     c947a585ab13f310c9223284dfd502790abd05f9
Parent:     264da9f708b130122d881fa4570d1cd618440a73
Author:     Johannes Weiner <jw@emlix.com>
AuthorDate: Wed Mar 4 16:21:30 2009 +0100
Committer:  Chris Zankel <chris@zankel.net>
CommitDate: Thu Apr 2 23:41:08 2009 -0700

    xtensa: cope with ram beginning at higher addresses
    
    The current assumption of the memory code is that the first RAM PFN in
    the system is 0.
    
    Adjust the relevant code to play well with setups where memory starts
    at higher addresses, indicated by PLATFORM_DEFAULT_MEM_START.
    
    The new memory model looks like this:
    
    +----------+--+----------------------+----------------+
    |          |  |                      |                |
    |          |  |         RAM          |                |
    |          |  |                      |                |
    +----------+--+----------------------+----------------+
    |          |  |                      |                |
    +- PFN 0   |  +- min_low_pfn         +- max_low_pfn   +- max_pfn
               |
               +- ARCH_PFN_OFFSET
               +- PLATFORM_DEFAULT_MEM_START >> PAGE_SIZE
    
    The memory map contains pages starting from pfn ARCH_PFN_OFFSET up to
    max_low_pfn.  The only zone used right now will span exactly the same
    region.
    
    Usually, ARCH_PFN_OFFSET and min_low_pfn are the same value.  Handle
    them separately for robustness.  Gapping pages will be in the memory
    map but marked as reserved and won't be touched.
    
    Signed-off-by: Johannes Weiner <jw@emlix.com>
    Signed-off-by: Chris Zankel <chris@zankel.net>
---
 arch/xtensa/include/asm/page.h |    5 ++++-
 arch/xtensa/mm/init.c          |   10 +++++-----
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/arch/xtensa/include/asm/page.h b/arch/xtensa/include/asm/page.h
index 11f7dc2..a5a5d33 100644
--- a/arch/xtensa/include/asm/page.h
+++ b/arch/xtensa/include/asm/page.h
@@ -14,6 +14,7 @@
 #include <asm/processor.h>
 #include <asm/types.h>
 #include <asm/cache.h>
+#include <platform/hardware.h>
 
 /*
  * Fixed TLB translations in the processor.
@@ -150,9 +151,11 @@ extern void copy_user_page(void*, void*, unsigned long, struct page*);
  * addresses.
  */
 
+#define ARCH_PFN_OFFSET		(PLATFORM_DEFAULT_MEM_START >> PAGE_SHIFT)
+
 #define __pa(x)			((unsigned long) (x) - PAGE_OFFSET)
 #define __va(x)			((void *)((unsigned long) (x) + PAGE_OFFSET))
-#define pfn_valid(pfn)		((unsigned long)pfn < max_mapnr)
+#define pfn_valid(pfn)		((pfn) >= ARCH_PFN_OFFSET && ((pfn) - ARCH_PFN_OFFSET) < max_mapnr)
 #ifdef CONFIG_DISCONTIGMEM
 # error CONFIG_DISCONTIGMEM not supported
 #endif
diff --git a/arch/xtensa/mm/init.c b/arch/xtensa/mm/init.c
index a534d52..6190988 100644
--- a/arch/xtensa/mm/init.c
+++ b/arch/xtensa/mm/init.c
@@ -167,7 +167,7 @@ void __init paging_init(void)
 
 	/* All pages are DMA-able, so we put them all in the DMA zone. */
 
-	zones_size[ZONE_DMA] = max_low_pfn;
+	zones_size[ZONE_DMA] = max_low_pfn - ARCH_PFN_OFFSET;
 	for (i = 1; i < MAX_NR_ZONES; i++)
 		zones_size[i] = 0;
 
@@ -179,7 +179,7 @@ void __init paging_init(void)
 
 	memset(swapper_pg_dir, 0, PAGE_SIZE);
 
-	free_area_init(zones_size);
+	free_area_init_node(0, zones_size, ARCH_PFN_OFFSET, NULL);
 }
 
 /*
@@ -220,8 +220,8 @@ void __init mem_init(void)
 	unsigned long codesize, reservedpages, datasize, initsize;
 	unsigned long highmemsize, tmp, ram;
 
-	max_mapnr = num_physpages = max_low_pfn;
-	high_memory = (void *) __va(max_mapnr << PAGE_SHIFT);
+	max_mapnr = num_physpages = max_low_pfn - ARCH_PFN_OFFSET;
+	high_memory = (void *) __va(max_low_pfn << PAGE_SHIFT);
 	highmemsize = 0;
 
 #ifdef CONFIG_HIGHMEM
@@ -231,7 +231,7 @@ void __init mem_init(void)
 	totalram_pages += free_all_bootmem();
 
 	reservedpages = ram = 0;
-	for (tmp = 0; tmp < max_low_pfn; tmp++) {
+	for (tmp = 0; tmp < max_mapnr; tmp++) {
 		ram++;
 		if (PageReserved(mem_map+tmp))
 			reservedpages++;
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
xtensa: cope with ram beginning at higher addresses, Linux Kernel Mailing ..., (Fri Apr 3, 6:01 pm)