Commit 1008a115 authored by Mike Rapoport's avatar Mike Rapoport Committed by Geert Uytterhoeven

m68k: switch to MEMBLOCK + NO_BOOTMEM

In m68k the physical memory is described by [memory_start, memory_end] for
!MMU variant and by m68k_memory array of memory ranges for the MMU version.
This information is directly use to register the physical memory with
memblock.

The reserve_bootmem() calls are replaced with memblock_reserve() and the
bootmap bitmap allocation is simply dropped.

Since the MMU variant creates early mappings only for the small part of the
memory we force bottom-up allocations in memblock.
Signed-off-by: default avatarMike Rapoport <rppt@linux.vnet.ibm.com>
Acked-by: default avatarGreg Ungerer <gerg@linux-m68k.org>
Signed-off-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
parent 9e092219
...@@ -26,6 +26,9 @@ config M68K ...@@ -26,6 +26,9 @@ config M68K
select OLD_SIGSUSPEND3 select OLD_SIGSUSPEND3
select OLD_SIGACTION select OLD_SIGACTION
select DMA_NONCOHERENT_OPS if HAS_DMA select DMA_NONCOHERENT_OPS if HAS_DMA
select HAVE_MEMBLOCK
select ARCH_DISCARD_MEMBLOCK
select NO_BOOTMEM
config CPU_BIG_ENDIAN config CPU_BIG_ENDIAN
def_bool y def_bool y
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <linux/string.h> #include <linux/string.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/bootmem.h> #include <linux/bootmem.h>
#include <linux/memblock.h>
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <linux/module.h> #include <linux/module.h>
...@@ -164,6 +165,8 @@ static void __init m68k_parse_bootinfo(const struct bi_record *record) ...@@ -164,6 +165,8 @@ static void __init m68k_parse_bootinfo(const struct bi_record *record)
be32_to_cpu(m->addr); be32_to_cpu(m->addr);
m68k_memory[m68k_num_memory].size = m68k_memory[m68k_num_memory].size =
be32_to_cpu(m->size); be32_to_cpu(m->size);
memblock_add(m68k_memory[m68k_num_memory].addr,
m68k_memory[m68k_num_memory].size);
m68k_num_memory++; m68k_num_memory++;
} else } else
pr_warn("%s: too many memory chunks\n", pr_warn("%s: too many memory chunks\n",
...@@ -223,10 +226,6 @@ static void __init m68k_parse_bootinfo(const struct bi_record *record) ...@@ -223,10 +226,6 @@ static void __init m68k_parse_bootinfo(const struct bi_record *record)
void __init setup_arch(char **cmdline_p) void __init setup_arch(char **cmdline_p)
{ {
#ifndef CONFIG_SUN3
int i;
#endif
/* The bootinfo is located right after the kernel */ /* The bootinfo is located right after the kernel */
if (!CPU_IS_COLDFIRE) if (!CPU_IS_COLDFIRE)
m68k_parse_bootinfo((const struct bi_record *)_end); m68k_parse_bootinfo((const struct bi_record *)_end);
...@@ -355,14 +354,9 @@ void __init setup_arch(char **cmdline_p) ...@@ -355,14 +354,9 @@ void __init setup_arch(char **cmdline_p)
#endif #endif
#ifndef CONFIG_SUN3 #ifndef CONFIG_SUN3
for (i = 1; i < m68k_num_memory; i++)
free_bootmem_node(NODE_DATA(i), m68k_memory[i].addr,
m68k_memory[i].size);
#ifdef CONFIG_BLK_DEV_INITRD #ifdef CONFIG_BLK_DEV_INITRD
if (m68k_ramdisk.size) { if (m68k_ramdisk.size) {
reserve_bootmem_node(__virt_to_node(phys_to_virt(m68k_ramdisk.addr)), memblock_reserve(m68k_ramdisk.addr, m68k_ramdisk.size);
m68k_ramdisk.addr, m68k_ramdisk.size,
BOOTMEM_DEFAULT);
initrd_start = (unsigned long)phys_to_virt(m68k_ramdisk.addr); initrd_start = (unsigned long)phys_to_virt(m68k_ramdisk.addr);
initrd_end = initrd_start + m68k_ramdisk.size; initrd_end = initrd_start + m68k_ramdisk.size;
pr_info("initrd: %08lx - %08lx\n", initrd_start, initrd_end); pr_info("initrd: %08lx - %08lx\n", initrd_start, initrd_end);
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/bootmem.h> #include <linux/bootmem.h>
#include <linux/memblock.h>
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/initrd.h> #include <linux/initrd.h>
...@@ -85,8 +86,6 @@ void (*mach_power_off)(void); ...@@ -85,8 +86,6 @@ void (*mach_power_off)(void);
void __init setup_arch(char **cmdline_p) void __init setup_arch(char **cmdline_p)
{ {
int bootmap_size;
memory_start = PAGE_ALIGN(_ramstart); memory_start = PAGE_ALIGN(_ramstart);
memory_end = _ramend; memory_end = _ramend;
...@@ -141,6 +140,8 @@ void __init setup_arch(char **cmdline_p) ...@@ -141,6 +140,8 @@ void __init setup_arch(char **cmdline_p)
pr_debug("MEMORY -> ROMFS=0x%p-0x%06lx MEM=0x%06lx-0x%06lx\n ", pr_debug("MEMORY -> ROMFS=0x%p-0x%06lx MEM=0x%06lx-0x%06lx\n ",
__bss_stop, memory_start, memory_start, memory_end); __bss_stop, memory_start, memory_start, memory_end);
memblock_add(memory_start, memory_end - memory_start);
/* Keep a copy of command line */ /* Keep a copy of command line */
*cmdline_p = &command_line[0]; *cmdline_p = &command_line[0];
memcpy(boot_command_line, command_line, COMMAND_LINE_SIZE); memcpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
...@@ -157,23 +158,10 @@ void __init setup_arch(char **cmdline_p) ...@@ -157,23 +158,10 @@ void __init setup_arch(char **cmdline_p)
min_low_pfn = PFN_DOWN(memory_start); min_low_pfn = PFN_DOWN(memory_start);
max_pfn = max_low_pfn = PFN_DOWN(memory_end); max_pfn = max_low_pfn = PFN_DOWN(memory_end);
bootmap_size = init_bootmem_node(
NODE_DATA(0),
min_low_pfn, /* map goes here */
PFN_DOWN(PAGE_OFFSET),
max_pfn);
/*
* Free the usable memory, we have to make sure we do not free
* the bootmem bitmap so we then reserve it after freeing it :-)
*/
free_bootmem(memory_start, memory_end - memory_start);
reserve_bootmem(memory_start, bootmap_size, BOOTMEM_DEFAULT);
#if defined(CONFIG_UBOOT) && defined(CONFIG_BLK_DEV_INITRD) #if defined(CONFIG_UBOOT) && defined(CONFIG_BLK_DEV_INITRD)
if ((initrd_start > 0) && (initrd_start < initrd_end) && if ((initrd_start > 0) && (initrd_start < initrd_end) &&
(initrd_end < memory_end)) (initrd_end < memory_end))
reserve_bootmem(initrd_start, initrd_end - initrd_start, memblock_reserve(initrd_start, initrd_end - initrd_start);
BOOTMEM_DEFAULT);
#endif /* if defined(CONFIG_BLK_DEV_INITRD) */ #endif /* if defined(CONFIG_BLK_DEV_INITRD) */
/* /*
......
...@@ -71,7 +71,6 @@ void __init m68k_setup_node(int node) ...@@ -71,7 +71,6 @@ void __init m68k_setup_node(int node)
pg_data_table[i] = pg_data_map + node; pg_data_table[i] = pg_data_map + node;
} }
#endif #endif
pg_data_map[node].bdata = bootmem_node_data + node;
node_set_online(node); node_set_online(node);
} }
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/bootmem.h> #include <linux/bootmem.h>
#include <linux/memblock.h>
#include <asm/setup.h> #include <asm/setup.h>
#include <asm/page.h> #include <asm/page.h>
...@@ -153,31 +154,31 @@ int cf_tlb_miss(struct pt_regs *regs, int write, int dtlb, int extension_word) ...@@ -153,31 +154,31 @@ int cf_tlb_miss(struct pt_regs *regs, int write, int dtlb, int extension_word)
void __init cf_bootmem_alloc(void) void __init cf_bootmem_alloc(void)
{ {
unsigned long start_pfn;
unsigned long memstart; unsigned long memstart;
/* _rambase and _ramend will be naturally page aligned */ /* _rambase and _ramend will be naturally page aligned */
m68k_memory[0].addr = _rambase; m68k_memory[0].addr = _rambase;
m68k_memory[0].size = _ramend - _rambase; m68k_memory[0].size = _ramend - _rambase;
memblock_add(m68k_memory[0].addr, m68k_memory[0].size);
/* compute total pages in system */ /* compute total pages in system */
num_pages = PFN_DOWN(_ramend - _rambase); num_pages = PFN_DOWN(_ramend - _rambase);
/* page numbers */ /* page numbers */
memstart = PAGE_ALIGN(_ramstart); memstart = PAGE_ALIGN(_ramstart);
min_low_pfn = PFN_DOWN(_rambase); min_low_pfn = PFN_DOWN(_rambase);
start_pfn = PFN_DOWN(memstart);
max_pfn = max_low_pfn = PFN_DOWN(_ramend); max_pfn = max_low_pfn = PFN_DOWN(_ramend);
high_memory = (void *)_ramend; high_memory = (void *)_ramend;
/* Reserve kernel text/data/bss */
memblock_reserve(memstart, memstart - _rambase);
m68k_virt_to_node_shift = fls(_ramend - 1) - 6; m68k_virt_to_node_shift = fls(_ramend - 1) - 6;
module_fixup(NULL, __start_fixup, __stop_fixup); module_fixup(NULL, __start_fixup, __stop_fixup);
/* setup bootmem data */ /* setup node data */
m68k_setup_node(0); m68k_setup_node(0);
memstart += init_bootmem_node(NODE_DATA(0), start_pfn,
min_low_pfn, max_low_pfn);
free_bootmem_node(NODE_DATA(0), memstart, _ramend - memstart);
} }
/* /*
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/bootmem.h> #include <linux/bootmem.h>
#include <linux/memblock.h>
#include <linux/gfp.h> #include <linux/gfp.h>
#include <asm/setup.h> #include <asm/setup.h>
...@@ -208,7 +209,7 @@ void __init paging_init(void) ...@@ -208,7 +209,7 @@ void __init paging_init(void)
{ {
unsigned long zones_size[MAX_NR_ZONES] = { 0, }; unsigned long zones_size[MAX_NR_ZONES] = { 0, };
unsigned long min_addr, max_addr; unsigned long min_addr, max_addr;
unsigned long addr, size, end; unsigned long addr;
int i; int i;
#ifdef DEBUG #ifdef DEBUG
...@@ -253,34 +254,20 @@ void __init paging_init(void) ...@@ -253,34 +254,20 @@ void __init paging_init(void)
min_low_pfn = availmem >> PAGE_SHIFT; min_low_pfn = availmem >> PAGE_SHIFT;
max_pfn = max_low_pfn = max_addr >> PAGE_SHIFT; max_pfn = max_low_pfn = max_addr >> PAGE_SHIFT;
for (i = 0; i < m68k_num_memory; i++) { /* Reserve kernel text/data/bss and the memory allocated in head.S */
addr = m68k_memory[i].addr; memblock_reserve(m68k_memory[0].addr, availmem - m68k_memory[0].addr);
end = addr + m68k_memory[i].size;
m68k_setup_node(i);
availmem = PAGE_ALIGN(availmem);
availmem += init_bootmem_node(NODE_DATA(i),
availmem >> PAGE_SHIFT,
addr >> PAGE_SHIFT,
end >> PAGE_SHIFT);
}
/* /*
* Map the physical memory available into the kernel virtual * Map the physical memory available into the kernel virtual
* address space. First initialize the bootmem allocator with * address space. Make sure memblock will not try to allocate
* the memory we already mapped, so map_node() has something * pages beyond the memory we already mapped in head.S
* to allocate.
*/ */
addr = m68k_memory[0].addr; memblock_set_bottom_up(true);
size = m68k_memory[0].size;
free_bootmem_node(NODE_DATA(0), availmem, for (i = 0; i < m68k_num_memory; i++) {
min(m68k_init_mapped_size, size) - (availmem - addr)); m68k_setup_node(i);
map_node(0);
if (size > m68k_init_mapped_size)
free_bootmem_node(NODE_DATA(0), addr + m68k_init_mapped_size,
size - m68k_init_mapped_size);
for (i = 1; i < m68k_num_memory; i++)
map_node(i); map_node(i);
}
flush_tlb_all(); flush_tlb_all();
......
...@@ -123,10 +123,6 @@ static void __init sun3_bootmem_alloc(unsigned long memory_start, ...@@ -123,10 +123,6 @@ static void __init sun3_bootmem_alloc(unsigned long memory_start,
availmem = memory_start; availmem = memory_start;
m68k_setup_node(0); m68k_setup_node(0);
availmem += init_bootmem(start_page, num_pages);
availmem = (availmem + (PAGE_SIZE-1)) & PAGE_MASK;
free_bootmem(__pa(availmem), memory_end - (availmem));
} }
......
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