Hi Mike,

On 13/5/19 3:20 pm, Mike Rapoport wrote:
On Mon, May 13, 2019 at 02:59:52PM +1000, Greg Ungerer wrote:
Hi Mike,

On 8/5/19 8:09 pm, Mike Rapoport wrote:
Enable SPARSEMEM support for systems with !SINGLE_MEMORY_CHUNK.
With SPARSEMEM there is a single node for the entire physical memory and to
cope with holes in the physical address space it is divided to sections of
up to 16M.

Each section has it's own memory map which size depends on actual populated
memory.

The DISCONTIGMEM is marked BROKEN and will be removed in a couple of
releases.

Signed-off-by: Mike Rapoport <r...@linux.ibm.com>

This worked for me on no-MMU ColdFire targets, but failed to
boot on an MMU enabled M5475 target. I got no console output
at all. I haven't debugged any further yet.

The ColdFire configs do not seem to enable SINGLE_MEMORY_CHUNK:

config SINGLE_MEMORY_CHUNK
        bool "Use one physical chunk of memory only" if ADVANCED && !SUN3
        depends on MMU
        default y if SUN3

When SINGLE_MEMORY_CHUNK=n, Kconfig enables SPARSEMEM as the only memory
model.

Is it possible for ColdFile to have more than a single memory bank?

I don't know of any that do. Theoretically you could have a DRAM
bank and a bank for the internal SRAM - but in practice I don't
think anybody ever did that.


If not, the patch below should fix ColdFire boot:

Yep, that does fix it.

Regards
Greg


diff --git a/arch/m68k/Kconfig.cpu b/arch/m68k/Kconfig.cpu
index 1b056d24c554..2a547c927578 100644
--- a/arch/m68k/Kconfig.cpu
+++ b/arch/m68k/Kconfig.cpu
@@ -375,7 +375,7 @@ config RMW_INSNS
  config SINGLE_MEMORY_CHUNK
         bool "Use one physical chunk of memory only" if ADVANCED && !SUN3
         depends on MMU
-       default y if SUN3
+       default y if SUN3 || MMU_COLDFIRE
         help
           Ignore all but the first contiguous chunk of physical memory for VM
           purposes.  This will save a few bytes kernel size and may speed up

Regards
Greg


---
  arch/m68k/Kconfig.cpu             |  8 +++++
  arch/m68k/include/asm/sparsemem.h |  8 +++++
  arch/m68k/mm/motorola.c           | 64 ++++++++++++++++++++++++++++++++-------
  3 files changed, 69 insertions(+), 11 deletions(-)
  create mode 100644 arch/m68k/include/asm/sparsemem.h

diff --git a/arch/m68k/Kconfig.cpu b/arch/m68k/Kconfig.cpu
index 6542e7a5997b..1b056d24c554 100644
--- a/arch/m68k/Kconfig.cpu
+++ b/arch/m68k/Kconfig.cpu
@@ -21,6 +21,7 @@ choice
  config M68KCLASSIC
        bool "Classic M68K CPU family support"
        select NEED_MULTIPLE_NODES if DISCONTIGMEM
+       select SPARSEMEM_STATIC if SPARSEMEM
  config COLDFIRE
        bool "Coldfire CPU family support"
@@ -381,8 +382,15 @@ config SINGLE_MEMORY_CHUNK
          some operations.  Say N if not sure.
  config ARCH_DISCONTIGMEM_ENABLE
+       def_bool no
+       depends on BROKEN && MMU && !SINGLE_MEMORY_CHUNK
+
+config ARCH_SPARSEMEM_ENABLE
        def_bool MMU && !SINGLE_MEMORY_CHUNK
+config HAVE_ARCH_PFN_VALID
+       def_bool SPARSEMEM
+
  config 060_WRITETHROUGH
        bool "Use write-through caching for 68060 supervisor accesses"
        depends on ADVANCED && M68060
diff --git a/arch/m68k/include/asm/sparsemem.h 
b/arch/m68k/include/asm/sparsemem.h
new file mode 100644
index 000000000000..6645a6420af9
--- /dev/null
+++ b/arch/m68k/include/asm/sparsemem.h
@@ -0,0 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _ASM_M68K_SPARSEMEM_H_
+#define _ASM_M68K_SPARSEMEM_H_
+
+#define MAX_PHYSMEM_BITS       32
+#define SECTION_SIZE_BITS      24
+
+#endif /* _ASM_M68K_SPARSEMEM_H_ */
diff --git a/arch/m68k/mm/motorola.c b/arch/m68k/mm/motorola.c
index 356601bf96d9..87d09942be5c 100644
--- a/arch/m68k/mm/motorola.c
+++ b/arch/m68k/mm/motorola.c
@@ -207,13 +207,63 @@ static void __init map_node(int node)
  #endif
  }
+#ifdef CONFIG_SPARSEMEM
+static void m68k_free_area_init(unsigned long max_addr)
+{
+       unsigned long zones_size[MAX_NR_ZONES] = { 0, };
+       unsigned long zholes_size[MAX_NR_ZONES] = { 0, };
+       unsigned long holes_size;
+
+       m68k_setup_node(0);
+
+       /*
+        * Make sure the memory map is allocated from top of the
+        * memory.
+        * Otherwise for systems with both ST-RAM and FastRam, ST-RAM
+        * gets filled with the memory map leaving no space for
+        * framebuffer
+        */
+       memblock_set_bottom_up(false);
+       memblocks_present();
+       sparse_init();
+       memblock_set_bottom_up(true);
+
+       zones_size[ZONE_DMA] = max_addr >> PAGE_SHIFT;
+       if (m68k_num_memory > 1) {
+               holes_size = max_addr - memblock_phys_mem_size();
+               zholes_size[ZONE_DMA] = holes_size >> PAGE_SHIFT;
+       }
+
+       free_area_init_node(0, zones_size,
+                           m68k_memory[0].addr >> PAGE_SHIFT, zholes_size);
+
+       if (node_present_pages(0))
+               node_set_state(0, N_NORMAL_MEMORY);
+}
+
+#else
+static void m68k_free_area_init(unsigned long max_addr)
+{
+       unsigned long zones_size[MAX_NR_ZONES] = { 0, };
+       int i;
+
+       for (i = 0; i < m68k_num_memory; i++) {
+               m68k_setup_node(i);
+               zones_size[ZONE_DMA] = m68k_memory[i].size >> PAGE_SHIFT;
+               free_area_init_node(i, zones_size,
+                                   m68k_memory[i].addr >> PAGE_SHIFT, NULL);
+               if (node_present_pages(i))
+                       node_set_state(i, N_NORMAL_MEMORY);
+       }
+}
+#endif
+
  /*
   * paging_init() continues the virtual memory environment setup which
   * was begun by the code in arch/head.S.
   */
  void __init paging_init(void)
  {
-       unsigned long zones_size[MAX_NR_ZONES] = { 0, };
        unsigned long min_addr, max_addr;
        unsigned long addr;
        int i;
@@ -272,10 +322,8 @@ void __init paging_init(void)
         */
        memblock_set_bottom_up(true);
-       for (i = 0; i < m68k_num_memory; i++) {
-               m68k_setup_node(i);
+       for (i = 0; i < m68k_num_memory; i++)
                map_node(i);
-       }
        flush_tlb_all();
@@ -296,12 +344,6 @@ void __init paging_init(void)
  #ifdef DEBUG
        printk ("before free_area_init\n");
  #endif
-       for (i = 0; i < m68k_num_memory; i++) {
-               zones_size[ZONE_DMA] = m68k_memory[i].size >> PAGE_SHIFT;
-               free_area_init_node(i, zones_size,
-                                   m68k_memory[i].addr >> PAGE_SHIFT, NULL);
-               if (node_present_pages(i))
-                       node_set_state(i, N_NORMAL_MEMORY);
-       }
+       m68k_free_area_init(max_addr);
  }



Reply via email to