Commit db84dc61 authored by Franck Bui-Huu's avatar Franck Bui-Huu Committed by Ralf Baechle

[MIPS] Setup min_low_pfn/max_low_pfn correctly

This patch makes a better usage of these two globals.
'min_low_pfn' is now correctly setup for all configs, which
allow us to rely on it in boot memory code init.
Signed-off-by: default avatarFranck Bui-Huu <fbuihuu@gmail.com>
Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
parent a583158c
...@@ -271,8 +271,7 @@ static void __init bootmem_init(void) ...@@ -271,8 +271,7 @@ static void __init bootmem_init(void)
static void __init bootmem_init(void) static void __init bootmem_init(void)
{ {
unsigned long reserved_end; unsigned long reserved_end;
unsigned long highest = 0; unsigned long mapstart = ~0UL;
unsigned long mapstart = -1UL;
unsigned long bootmap_size; unsigned long bootmap_size;
int i; int i;
...@@ -283,6 +282,13 @@ static void __init bootmem_init(void) ...@@ -283,6 +282,13 @@ static void __init bootmem_init(void)
*/ */
reserved_end = max(init_initrd(), PFN_UP(__pa_symbol(&_end))); reserved_end = max(init_initrd(), PFN_UP(__pa_symbol(&_end)));
/*
* max_low_pfn is not a number of pages. The number of pages
* of the system is given by 'max_low_pfn - min_low_pfn'.
*/
min_low_pfn = ~0UL;
max_low_pfn = 0;
/* /*
* Find the highest page frame number we have available. * Find the highest page frame number we have available.
*/ */
...@@ -296,8 +302,10 @@ static void __init bootmem_init(void) ...@@ -296,8 +302,10 @@ static void __init bootmem_init(void)
end = PFN_DOWN(boot_mem_map.map[i].addr end = PFN_DOWN(boot_mem_map.map[i].addr
+ boot_mem_map.map[i].size); + boot_mem_map.map[i].size);
if (end > highest) if (end > max_low_pfn)
highest = end; max_low_pfn = end;
if (start < min_low_pfn)
min_low_pfn = start;
if (end <= reserved_end) if (end <= reserved_end)
continue; continue;
if (start >= mapstart) if (start >= mapstart)
...@@ -305,22 +313,32 @@ static void __init bootmem_init(void) ...@@ -305,22 +313,32 @@ static void __init bootmem_init(void)
mapstart = max(reserved_end, start); mapstart = max(reserved_end, start);
} }
if (min_low_pfn >= max_low_pfn)
panic("Incorrect memory mapping !!!");
if (min_low_pfn > 0) {
printk(KERN_INFO
"Wasting %lu bytes for tracking %lu unused pages\n",
min_low_pfn * sizeof(struct page),
min_low_pfn);
min_low_pfn = 0;
}
/* /*
* Determine low and high memory ranges * Determine low and high memory ranges
*/ */
if (highest > PFN_DOWN(HIGHMEM_START)) { if (max_low_pfn > PFN_DOWN(HIGHMEM_START)) {
#ifdef CONFIG_HIGHMEM #ifdef CONFIG_HIGHMEM
highstart_pfn = PFN_DOWN(HIGHMEM_START); highstart_pfn = PFN_DOWN(HIGHMEM_START);
highend_pfn = highest; highend_pfn = max_low_pfn;
#endif #endif
highest = PFN_DOWN(HIGHMEM_START); max_low_pfn = PFN_DOWN(HIGHMEM_START);
} }
/* /*
* Initialize the boot-time allocator with low memory only. * Initialize the boot-time allocator with low memory only.
*/ */
bootmap_size = init_bootmem(mapstart, highest); bootmap_size = init_bootmem_node(NODE_DATA(0), mapstart,
min_low_pfn, max_low_pfn);
/* /*
* Register fully available low RAM pages with the bootmem allocator. * Register fully available low RAM pages with the bootmem allocator.
*/ */
......
...@@ -341,7 +341,6 @@ static int __init page_is_ram(unsigned long pagenr) ...@@ -341,7 +341,6 @@ static int __init page_is_ram(unsigned long pagenr)
void __init paging_init(void) void __init paging_init(void)
{ {
unsigned long zones_size[MAX_NR_ZONES] = { 0, }; unsigned long zones_size[MAX_NR_ZONES] = { 0, };
unsigned long max_dma, low;
#ifndef CONFIG_FLATMEM #ifndef CONFIG_FLATMEM
unsigned long zholes_size[MAX_NR_ZONES] = { 0, }; unsigned long zholes_size[MAX_NR_ZONES] = { 0, };
unsigned long i, j, pfn; unsigned long i, j, pfn;
...@@ -354,19 +353,19 @@ void __init paging_init(void) ...@@ -354,19 +353,19 @@ void __init paging_init(void)
#endif #endif
kmap_coherent_init(); kmap_coherent_init();
max_dma = virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT;
low = max_low_pfn;
#ifdef CONFIG_ISA #ifdef CONFIG_ISA
if (low < max_dma) if (max_low_pfn >= MAX_DMA_PFN)
zones_size[ZONE_DMA] = low; if (min_low_pfn >= MAX_DMA_PFN) {
else { zones_size[ZONE_DMA] = 0;
zones_size[ZONE_DMA] = max_dma; zones_size[ZONE_NORMAL] = max_low_pfn - min_low_pfn;
zones_size[ZONE_NORMAL] = low - max_dma; } else {
zones_size[ZONE_DMA] = MAX_DMA_PFN - min_low_pfn;
zones_size[ZONE_NORMAL] = max_low_pfn - MAX_DMA_PFN;
} }
#else else
zones_size[ZONE_DMA] = low;
#endif #endif
zones_size[ZONE_DMA] = max_low_pfn - min_low_pfn;
#ifdef CONFIG_HIGHMEM #ifdef CONFIG_HIGHMEM
zones_size[ZONE_HIGHMEM] = highend_pfn - highstart_pfn; zones_size[ZONE_HIGHMEM] = highend_pfn - highstart_pfn;
......
...@@ -91,6 +91,7 @@ ...@@ -91,6 +91,7 @@
#else #else
#define MAX_DMA_ADDRESS (PAGE_OFFSET + 0x01000000) #define MAX_DMA_ADDRESS (PAGE_OFFSET + 0x01000000)
#endif #endif
#define MAX_DMA_PFN PFN_DOWN(virt_to_phys((void *)MAX_DMA_ADDRESS))
/* 8237 DMA controllers */ /* 8237 DMA controllers */
#define IO_DMA1_BASE 0x00 /* 8 bit slave DMA, channels 0..3 */ #define IO_DMA1_BASE 0x00 /* 8 bit slave DMA, channels 0..3 */
......
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