To: linus, alan Cc: lkml Subject: [PATCH] M68k: Make bootmem use virtually mapped pages From: Roman Zippel M68k: Make bootmem use virtually mapped pages. Many m68k machines don't have the kernel in the memory chunk with the lowest address Signed-off-by: Roman Zippel Signed-off-by: Geert Uytterhoeven --- include/linux/bootmem.h | 4 ++-- mm/bootmem.c | 14 ++++++-------- 2 files changed, 8 insertions(+), 10 deletions(-) --- linux-2.6.19-rc1/include/linux/bootmem.h 2006-10-05 11:17:03.000000000 +0200 +++ linux-m68k-2.6.19-rc1/include/linux/bootmem.h 2006-10-05 17:39:21.000000000 +0200 @@ -65,11 +65,11 @@ extern void reserve_bootmem(unsigned lon #define alloc_bootmem(x) \ __alloc_bootmem(x, SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS)) #define alloc_bootmem_low(x) \ - __alloc_bootmem_low(x, SMP_CACHE_BYTES, 0) + __alloc_bootmem_low(x, SMP_CACHE_BYTES, __pa(PAGE_OFFSET)) #define alloc_bootmem_pages(x) \ __alloc_bootmem(x, PAGE_SIZE, __pa(MAX_DMA_ADDRESS)) #define alloc_bootmem_low_pages(x) \ - __alloc_bootmem_low(x, PAGE_SIZE, 0) + __alloc_bootmem_low(x, PAGE_SIZE, __pa(PAGE_OFFSET)) #endif /* !CONFIG_HAVE_ARCH_BOOTMEM_NODE */ extern unsigned long free_all_bootmem(void); --- linux-2.6.19-rc1/mm/bootmem.c 2006-10-05 11:17:06.000000000 +0200 +++ linux-m68k-2.6.19-rc1/mm/bootmem.c 2006-10-05 17:39:23.000000000 +0200 @@ -301,7 +301,6 @@ found: static unsigned long __init free_all_bootmem_core(pg_data_t *pgdat) { struct page *page; - unsigned long pfn; bootmem_data_t *bdata = pgdat->bdata; unsigned long i, count, total = 0; unsigned long idx; @@ -312,8 +311,7 @@ static unsigned long __init free_all_boo count = 0; /* first extant page of the node */ - pfn = PFN_DOWN(bdata->node_boot_start); - idx = bdata->node_low_pfn - pfn; + idx = bdata->node_low_pfn - PFN_DOWN(bdata->node_boot_start); map = bdata->node_bootmem_map; /* Check physaddr is O(LOG2(BITS_PER_LONG)) page aligned */ if (bdata->node_boot_start == 0 || @@ -325,18 +323,18 @@ static unsigned long __init free_all_boo if (gofast && v == ~0UL) { int order; - page = pfn_to_page(pfn); + page = virt_to_page(phys_to_virt((i << PAGE_SHIFT) + + bdata->node_boot_start)); count += BITS_PER_LONG; order = ffs(BITS_PER_LONG) - 1; __free_pages_bootmem(page, order); i += BITS_PER_LONG; - page += BITS_PER_LONG; } else if (v) { unsigned long m; - - page = pfn_to_page(pfn); - for (m = 1; m && i < idx; m<<=1, page++, i++) { + for (m = 1; m && i < idx; m<<=1, i++) { if (v & m) { + page = virt_to_page(phys_to_virt((i << PAGE_SHIFT) + + bdata->node_boot_start)); count++; __free_pages_bootmem(page, 0); } @@ -344,7 +342,6 @@ static unsigned long __init free_all_boo } else { i += BITS_PER_LONG; } - pfn += BITS_PER_LONG; } total += count;