aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/mm/mem.c
diff options
context:
space:
mode:
authorKumar Gala <galak@kernel.crashing.org>2008-04-15 15:52:22 -0400
committerPaul Mackerras <paulus@samba.org>2008-04-16 17:46:13 -0400
commitd7917ba7051e3fd12ebe2d5a09b29fb3a2b38190 (patch)
tree339d273aee5eb2cb83e226945f0319b51f4bdf3c /arch/powerpc/mm/mem.c
parent99c62dd773797b68f3b1ca6bb3274725d1852fa2 (diff)
[POWERPC] Introduce lowmem_end_addr to distinguish from total_lowmem
total_lowmem represents the amount of low memory, not the physical address that low memory ends at. If the start of memory is at 0 it happens that total_lowmem can be used as both the size and the address that lowmem ends at (or more specifically one byte beyond the end). To make the code a bit more clear and deal with the case when the start of memory isn't at physical 0, we introduce lowmem_end_addr that represents one byte beyond the last physical address in the lowmem region. Signed-off-by: Kumar Gala <galak@kernel.crashing.org> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc/mm/mem.c')
-rw-r--r--arch/powerpc/mm/mem.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index e3349ead3959..16def4dcff6d 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -216,9 +216,11 @@ void __init do_init_bootmem(void)
216 unsigned long total_pages; 216 unsigned long total_pages;
217 int boot_mapsize; 217 int boot_mapsize;
218 218
219 max_pfn = total_pages = lmb_end_of_DRAM() >> PAGE_SHIFT; 219 max_pfn = lmb_end_of_DRAM() >> PAGE_SHIFT;
220 total_pages = (lmb_end_of_DRAM() - memstart_addr) >> PAGE_SHIFT;
220#ifdef CONFIG_HIGHMEM 221#ifdef CONFIG_HIGHMEM
221 total_pages = total_lowmem >> PAGE_SHIFT; 222 total_pages = total_lowmem >> PAGE_SHIFT;
223 max_low_pfn = lowmem_end_addr >> PAGE_SHIFT;
222#endif 224#endif
223 225
224 /* 226 /*
@@ -244,18 +246,18 @@ void __init do_init_bootmem(void)
244 * present. 246 * present.
245 */ 247 */
246#ifdef CONFIG_HIGHMEM 248#ifdef CONFIG_HIGHMEM
247 free_bootmem_with_active_regions(0, total_lowmem >> PAGE_SHIFT); 249 free_bootmem_with_active_regions(0, lowmem_end_addr >> PAGE_SHIFT);
248 250
249 /* reserve the sections we're already using */ 251 /* reserve the sections we're already using */
250 for (i = 0; i < lmb.reserved.cnt; i++) { 252 for (i = 0; i < lmb.reserved.cnt; i++) {
251 unsigned long addr = lmb.reserved.region[i].base + 253 unsigned long addr = lmb.reserved.region[i].base +
252 lmb_size_bytes(&lmb.reserved, i) - 1; 254 lmb_size_bytes(&lmb.reserved, i) - 1;
253 if (addr < total_lowmem) 255 if (addr < lowmem_end_addr)
254 reserve_bootmem(lmb.reserved.region[i].base, 256 reserve_bootmem(lmb.reserved.region[i].base,
255 lmb_size_bytes(&lmb.reserved, i), 257 lmb_size_bytes(&lmb.reserved, i),
256 BOOTMEM_DEFAULT); 258 BOOTMEM_DEFAULT);
257 else if (lmb.reserved.region[i].base < total_lowmem) { 259 else if (lmb.reserved.region[i].base < lowmem_end_addr) {
258 unsigned long adjusted_size = total_lowmem - 260 unsigned long adjusted_size = lowmem_end_addr -
259 lmb.reserved.region[i].base; 261 lmb.reserved.region[i].base;
260 reserve_bootmem(lmb.reserved.region[i].base, 262 reserve_bootmem(lmb.reserved.region[i].base,
261 adjusted_size, BOOTMEM_DEFAULT); 263 adjusted_size, BOOTMEM_DEFAULT);
@@ -325,7 +327,7 @@ void __init paging_init(void)
325 (top_of_ram - total_ram) >> 20); 327 (top_of_ram - total_ram) >> 20);
326 memset(max_zone_pfns, 0, sizeof(max_zone_pfns)); 328 memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
327#ifdef CONFIG_HIGHMEM 329#ifdef CONFIG_HIGHMEM
328 max_zone_pfns[ZONE_DMA] = total_lowmem >> PAGE_SHIFT; 330 max_zone_pfns[ZONE_DMA] = lowmem_end_addr >> PAGE_SHIFT;
329 max_zone_pfns[ZONE_HIGHMEM] = top_of_ram >> PAGE_SHIFT; 331 max_zone_pfns[ZONE_HIGHMEM] = top_of_ram >> PAGE_SHIFT;
330#else 332#else
331 max_zone_pfns[ZONE_DMA] = top_of_ram >> PAGE_SHIFT; 333 max_zone_pfns[ZONE_DMA] = top_of_ram >> PAGE_SHIFT;
@@ -380,7 +382,7 @@ void __init mem_init(void)
380 { 382 {
381 unsigned long pfn, highmem_mapnr; 383 unsigned long pfn, highmem_mapnr;
382 384
383 highmem_mapnr = total_lowmem >> PAGE_SHIFT; 385 highmem_mapnr = lowmem_end_addr >> PAGE_SHIFT;
384 for (pfn = highmem_mapnr; pfn < max_mapnr; ++pfn) { 386 for (pfn = highmem_mapnr; pfn < max_mapnr; ++pfn) {
385 struct page *page = pfn_to_page(pfn); 387 struct page *page = pfn_to_page(pfn);
386 if (lmb_is_reserved(pfn << PAGE_SHIFT)) 388 if (lmb_is_reserved(pfn << PAGE_SHIFT))