On 03/07/18 20:29, Mike Rapoport wrote:
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 used 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 because otherwise we will
attempt to access memory that not yet mapped
Signed-off-by: Mike Rapoport <rppt@xxxxxxxxxxxxxxxxxx>
This builds cleanly for me with a m5475_defconfig, but it fails
to boot on real hardware. No console, no nothing on startup.
I haven't debugged any further yet.
The M5475 is a ColdFire with MMU enabled target.
-----
 arch/m68k/Kconfig | 3 +++
 arch/m68k/kernel/setup_mm.c | 14 ++++----------
 arch/m68k/kernel/setup_no.c | 20 ++++----------------
 arch/m68k/mm/init.c | 1 -
 arch/m68k/mm/mcfmmu.c | 11 +++++++----
 arch/m68k/mm/motorola.c | 35 +++++++++++------------------------
 arch/m68k/sun3/config.c | 4 ----
 7 files changed, 29 insertions(+), 59 deletions(-)
diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
index 785612b..bd7f38a 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -24,6 +24,9 @@ config M68K
ÂÂÂÂÂ select MODULES_USE_ELF_RELA
ÂÂÂÂÂ select OLD_SIGSUSPEND3
ÂÂÂÂÂ select OLD_SIGACTION
+ÂÂÂ select HAVE_MEMBLOCK
+ÂÂÂ select ARCH_DISCARD_MEMBLOCK
+ÂÂÂ select NO_BOOTMEM
 config CPU_BIG_ENDIAN
ÂÂÂÂÂ def_bool y
diff --git a/arch/m68k/kernel/setup_mm.c b/arch/m68k/kernel/setup_mm.c
index f35e3eb..6512955 100644
--- a/arch/m68k/kernel/setup_mm.c
+++ b/arch/m68k/kernel/setup_mm.c
@@ -21,6 +21,7 @@
 #include <linux/string.h>
 #include <linux/init.h>
 #include <linux/bootmem.h>
+#include <linux/memblock.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
 #include <linux/module.h>
@@ -165,6 +166,8 @@ static void __init m68k_parse_bootinfo(const struct bi_record *record)
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ be32_to_cpu(m->addr);
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ m68k_memory[m68k_num_memory].size =
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ be32_to_cpu(m->size);
+ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ memblock_add(m68k_memory[m68k_num_memory].addr,
+ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ m68k_memory[m68k_num_memory].size);
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ m68k_num_memory++;
ÂÂÂÂÂÂÂÂÂÂÂÂÂ } else
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ pr_warn("%s: too many memory chunks\n",
@@ -224,10 +227,6 @@ static void __init m68k_parse_bootinfo(const struct bi_record *record)
 void __init setup_arch(char **cmdline_p)
 {
-#ifndef CONFIG_SUN3
-ÂÂÂ int i;
-#endif
-
ÂÂÂÂÂ /* The bootinfo is located right after the kernel */
ÂÂÂÂÂ if (!CPU_IS_COLDFIRE)
ÂÂÂÂÂÂÂÂÂ m68k_parse_bootinfo((const struct bi_record *)_end);
@@ -356,14 +355,9 @@ void __init setup_arch(char **cmdline_p)
 #endif
 #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
ÂÂÂÂÂ if (m68k_ramdisk.size) {
-ÂÂÂÂÂÂÂ reserve_bootmem_node(__virt_to_node(phys_to_virt(m68k_ramdisk.addr)),
-ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ m68k_ramdisk.addr, m68k_ramdisk.size,
-ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ BOOTMEM_DEFAULT);
+ÂÂÂÂÂÂÂ memblock_reserve(m68k_ramdisk.addr, m68k_ramdisk.size);
ÂÂÂÂÂÂÂÂÂ initrd_start = (unsigned long)phys_to_virt(m68k_ramdisk.addr);
ÂÂÂÂÂÂÂÂÂ initrd_end = initrd_start + m68k_ramdisk.size;
ÂÂÂÂÂÂÂÂÂ pr_info("initrd: %08lx - %08lx\n", initrd_start, initrd_end);
diff --git a/arch/m68k/kernel/setup_no.c b/arch/m68k/kernel/setup_no.c
index a98af10..3e8d87a 100644
--- a/arch/m68k/kernel/setup_no.c
+++ b/arch/m68k/kernel/setup_no.c
@@ -28,6 +28,7 @@
 #include <linux/errno.h>
 #include <linux/string.h>
 #include <linux/bootmem.h>
+#include <linux/memblock.h>
 #include <linux/seq_file.h>
 #include <linux/init.h>
 #include <linux/initrd.h>
@@ -86,8 +87,6 @@ void (*mach_power_off)(void);
 void __init setup_arch(char **cmdline_p)
 {
-ÂÂÂ int bootmap_size;
-
ÂÂÂÂÂ memory_start = PAGE_ALIGN(_ramstart);
ÂÂÂÂÂ memory_end = _ramend;
@@ -142,6 +141,8 @@ void __init setup_arch(char **cmdline_p)
ÂÂÂÂÂ pr_debug("MEMORY -> ROMFS=0x%p-0x%06lx MEM=0x%06lx-0x%06lx\n ",
ÂÂÂÂÂÂÂÂÂÂ __bss_stop, memory_start, memory_start, memory_end);
+ÂÂÂ memblock_add(memory_start, memory_end - memory_start);
+
ÂÂÂÂÂ /* Keep a copy of command line */
ÂÂÂÂÂ *cmdline_p = &command_line[0];
ÂÂÂÂÂ memcpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
@@ -158,23 +159,10 @@ void __init setup_arch(char **cmdline_p)
ÂÂÂÂÂ min_low_pfn = PFN_DOWN(memory_start);
ÂÂÂÂÂ 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 ((initrd_start > 0) && (initrd_start < initrd_end) &&
ÂÂÂÂÂÂÂÂÂÂÂÂÂ (initrd_end < memory_end))
-ÂÂÂÂÂÂÂ reserve_bootmem(initrd_start, initrd_end - initrd_start,
-ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ BOOTMEM_DEFAULT);
+ÂÂÂÂÂÂÂ memblock_reserve(initrd_start, initrd_end - initrd_start);
 #endif /* if defined(CONFIG_BLK_DEV_INITRD) */
ÂÂÂÂÂ /*
diff --git a/arch/m68k/mm/init.c b/arch/m68k/mm/init.c
index 8827b7f..38e2b27 100644
--- a/arch/m68k/mm/init.c
+++ b/arch/m68k/mm/init.c
@@ -71,7 +71,6 @@ void __init m68k_setup_node(int node)
ÂÂÂÂÂÂÂÂÂ pg_data_table[i] = pg_data_map + node;
ÂÂÂÂÂ }
 #endif
-ÂÂÂ pg_data_map[node].bdata = bootmem_node_data + node;
ÂÂÂÂÂ node_set_online(node);
 }
diff --git a/arch/m68k/mm/mcfmmu.c b/arch/m68k/mm/mcfmmu.c
index 2925d79..e9e60e1 100644
--- a/arch/m68k/mm/mcfmmu.c
+++ b/arch/m68k/mm/mcfmmu.c
@@ -14,6 +14,7 @@
 #include <linux/init.h>
 #include <linux/string.h>
 #include <linux/bootmem.h>
+#include <linux/memblock.h>
 #include <asm/setup.h>
 #include <asm/page.h>
@@ -160,6 +161,8 @@ void __init cf_bootmem_alloc(void)
ÂÂÂÂÂ m68k_memory[0].addr = _rambase;
ÂÂÂÂÂ m68k_memory[0].size = _ramend - _rambase;
+ÂÂÂ memblock_add(m68k_memory[0].addr, m68k_memory[0].size);
+
ÂÂÂÂÂ /* compute total pages in system */
ÂÂÂÂÂ num_pages = PFN_DOWN(_ramend - _rambase);
@@ -170,14 +173,14 @@ void __init cf_bootmem_alloc(void)
ÂÂÂÂÂ max_pfn = max_low_pfn = PFN_DOWN(_ramend);
ÂÂÂÂÂ high_memory = (void *)_ramend;
+ÂÂÂ /* Reserve kernel text/data/bss */
+ÂÂÂ memblock_reserve(memstart, _ramend - memstart);
+
ÂÂÂÂÂ m68k_virt_to_node_shift = fls(_ramend - 1) - 6;
ÂÂÂÂÂ module_fixup(NULL, __start_fixup, __stop_fixup);
-ÂÂÂ /* setup bootmem data */
+ÂÂÂ /* setup node data */
ÂÂÂÂÂ 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);
 }
 /*
diff --git a/arch/m68k/mm/motorola.c b/arch/m68k/mm/motorola.c
index e490ecc..4e17ecb 100644
--- a/arch/m68k/mm/motorola.c
+++ b/arch/m68k/mm/motorola.c
@@ -19,6 +19,7 @@
 #include <linux/types.h>
 #include <linux/init.h>
 #include <linux/bootmem.h>
+#include <linux/memblock.h>
 #include <linux/gfp.h>
 #include <asm/setup.h>
@@ -208,7 +209,7 @@ void __init paging_init(void)
 {
ÂÂÂÂÂ unsigned long zones_size[MAX_NR_ZONES] = { 0, };
ÂÂÂÂÂ unsigned long min_addr, max_addr;
-ÂÂÂ unsigned long addr, size, end;
+ÂÂÂ unsigned long addr;
ÂÂÂÂÂ int i;
 #ifdef DEBUG
@@ -253,34 +254,20 @@ void __init paging_init(void)
ÂÂÂÂÂ min_low_pfn = availmem >> PAGE_SHIFT;
ÂÂÂÂÂ max_pfn = max_low_pfn = max_addr >> PAGE_SHIFT;
-ÂÂÂ for (i = 0; i < m68k_num_memory; i++) {
-ÂÂÂÂÂÂÂ addr = m68k_memory[i].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);
-ÂÂÂ }
+ÂÂÂ /* Reserve kernel text/data/bss and the memory allocated in head.S */
+ÂÂÂ memblock_reserve(m68k_memory[0].addr, availmem - m68k_memory[0].addr);
ÂÂÂÂÂ /*
ÂÂÂÂÂÂ * Map the physical memory available into the kernel virtual
-ÂÂÂÂ * address space. First initialize the bootmem allocator with
-ÂÂÂÂ * the memory we already mapped, so map_node() has something
-ÂÂÂÂ * to allocate.
+ÂÂÂÂ * address space. Make sure memblock will not try to allocate
+ÂÂÂÂ * pages beyond the memory we already mapped in head.S
ÂÂÂÂÂÂ */
-ÂÂÂ addr = m68k_memory[0].addr;
-ÂÂÂ size = m68k_memory[0].size;
-ÂÂÂ free_bootmem_node(NODE_DATA(0), availmem,
-ÂÂÂÂÂÂÂÂÂÂÂÂÂ min(m68k_init_mapped_size, size) - (availmem - addr));
-ÂÂÂ 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++)
+ÂÂÂ memblock_set_bottom_up(true);
+
+ÂÂÂ for (i = 0; i < m68k_num_memory; i++) {
+ÂÂÂÂÂÂÂ m68k_setup_node(i);
ÂÂÂÂÂÂÂÂÂ map_node(i);
+ÂÂÂ }
ÂÂÂÂÂ flush_tlb_all();
diff --git a/arch/m68k/sun3/config.c b/arch/m68k/sun3/config.c
index 1d28d38..79a2bb8 100644
--- a/arch/m68k/sun3/config.c
+++ b/arch/m68k/sun3/config.c
@@ -123,10 +123,6 @@ static void __init sun3_bootmem_alloc(unsigned long memory_start,
ÂÂÂÂÂ availmem = memory_start;
ÂÂÂÂÂ 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));
 }
To unsubscribe from this list: send the line "unsubscribe linux-m68k" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html