Skip to contentSkip to conversation

m68k: coldfire MMU fixes

PATCH In review Greg Ungerer 2 participants 6 messages Sep 8, 2017 – Sep 11, 2017

Subsystems (2)
lore
Share & tools
lore

Greg Ungerer

author maintainer
#0 lore raw

cover m68k: coldfire MMU fixes

The following patch series fixes some issues with the initialization phase of the ColdFire MMU system startup. With these fixes applied we can also enable and run the ColdFire 5441x family of parts with their MMU enabled.

 arch/m68k/Kconfig.cpu               |    2 +-
 arch/m68k/coldfire/m54xx.c          |    4 ----
 arch/m68k/include/asm/mcfmmu.h      |    1 +
 arch/m68k/include/asm/mmu_context.h |    1 -
 arch/m68k/kernel/setup_mm.c         |    2 ++
 arch/m68k/mm/mcfmmu.c               |    4 ++--
 6 files changed, 6 insertions(+), 8 deletions(-)
author maintainer
#1 lore raw

PATCH 1/3 m68k: move coldfire MMU initialization code

The M54[78]x ColdFire parts are not the only members of the ColdFire family that have an MMU. But currently some of the early MMU initialization code is inside the startup code specific to only the ColdFire M54[78]x parts. Move that early ColdFire MMU init code so that it is run for other ColdFire parts running with MMU enabled.

Specifically this means that the MMU initialization code will now also be run for the ColdFire M5441x parts when running with MMU enabled.

The code move meant that the extern definition for the mmu_context_init() function had to be moved as well. To make it clear that is ColdFire specific I have renamed that with a "cf_" in front of it and put its extern definition in the mcfmmu.h (which is already included by the setup code).

---
 arch/m68k/coldfire/m54xx.c          | 4 ----
 arch/m68k/include/asm/mcfmmu.h      | 1 +
 arch/m68k/include/asm/mmu_context.h | 1 -
 arch/m68k/kernel/setup_mm.c         | 2 ++
 arch/m68k/mm/mcfmmu.c               | 2 +-
 5 files changed, 4 insertions(+), 6 deletions(-)
arch/m68k/coldfire/m54xx.c +0 -4
index c552851..704efea 100644
@@ -95,10 +95,6 @@ static void mcf54xx_reset(void)
 
 void __init config_BSP(char *commandp, int size)
 {
-#ifdef CONFIG_MMU
-	cf_bootmem_alloc();
-	mmu_context_init();
-#endif
 	mach_reset = mcf54xx_reset;
 	mach_sched_init = hw_timer_init;
 	m54xx_uarts_init();
arch/m68k/include/asm/mcfmmu.h +1 -0
index 10f9930..283352a 100644
@@ -106,6 +106,7 @@ static inline void mmu_write(u32 a, u32 v)
 }
 
 void cf_bootmem_alloc(void);
+void cf_mmu_context_init(void);
 int cf_tlb_miss(struct pt_regs *regs, int write, int dtlb, int extension_word);
 
 #endif
arch/m68k/include/asm/mmu_context.h +0 -1
index 4a6ae6d..00c28b1 100644
@@ -91,7 +91,6 @@ static inline void activate_mm(struct mm_struct *active_mm,
 
 #define deactivate_mm(tsk, mm) do { } while (0)
 
-extern void mmu_context_init(void);
 #define prepare_arch_switch(next) load_ksp_mmu(next)
 
 static inline void load_ksp_mmu(struct task_struct *task)
arch/m68k/kernel/setup_mm.c +2 -0
index 7a2c212..e79b068 100644
@@ -343,6 +343,8 @@ void __init setup_arch(char **cmdline_p)
 #ifdef CONFIG_COLDFIRE
 	case MACH_M54XX:
 	case MACH_M5441X:
+		cf_bootmem_alloc();
+		cf_mmu_context_init();
 		config_BSP(NULL, 0);
 		break;
 #endif
arch/m68k/mm/mcfmmu.c +1 -1
index 87131cd..12fe55b 100644
@@ -183,7 +183,7 @@ void __init cf_bootmem_alloc(void)
  * Initialize the context management stuff.
  * The following was taken from arch/ppc/mmu_context.c
  */
-void __init mmu_context_init(void)
+void __init cf_mmu_context_init(void)
 {
 	/*
 	 * Some processors have too few contexts to reserve one for
Signature · 1 line
1.9.1
author maintainer
#2 lore raw

PATCH 2/3 m68k: fix ColdFire node shift size calculation

In reply to Greg Ungerer

The m68k pg_data_table is a fix size array defined in arch/m68k/mm/init.c. Index numbers within it are defined based on memory size. But for Coldfire these don't take into account a non-zero physical RAM base address, and this causes us to access past the end of this array at system start time.

Change the node shift calculation so that we keep the index inside its range.

---
 arch/m68k/mm/mcfmmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/m68k/mm/mcfmmu.c +1 -1
index 12fe55b..61e148e 100644
@@ -169,7 +169,7 @@ void __init cf_bootmem_alloc(void)
 	max_pfn = max_low_pfn = PFN_DOWN(_ramend);
 	high_memory = (void *)_ramend;
 
-	m68k_virt_to_node_shift = fls(_ramend - _rambase - 1) - 6;
+	m68k_virt_to_node_shift = fls(_ramend - 1) - 6;
 	module_fixup(NULL, __start_fixup, __stop_fixup);
 
 	/* setup bootmem data */
Signature · 1 line
1.9.1
author maintainer
#3 lore raw

PATCH 3/3 m68k: allow ColdFire m5441x parts to run with MMU enabled

In reply to Greg Ungerer

The Freescale ColdFire M5441x system-on-chip parts have full paged MMU hardware support. So far though we have only allowed them to be configured for use in non-MMU mode.

All required kernel changes to support operation of the M5441x parts with MMU enabled have been pushed into the kernel, so now we can allow it to be configured and used with the MMU enabled.

I don't actually have any M5441x based hardware so I can't do any real testing on this. The changes up to now were based on Yannick Gicquel initial patches to support this. Is anybody out there able to test this properly? I won't push this any further until we have some confirmation that it all works as expected.

---
 arch/m68k/Kconfig.cpu | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/m68k/Kconfig.cpu +1 -1
index d2219f30..4dc51c0 100644
@@ -283,7 +283,7 @@ config M548x
 
 config M5441x
 	bool "MCF5441x"
-	depends on !MMU
+	select MMU_COLDFIRE if MMU
 	select GENERIC_CLOCKEVENTS
 	select HAVE_CACHE_CB
 	help
Signature · 1 line
1.9.1
Tested-by on the v1 series
#4 lore raw
In reply to Greg Ungerer

Dear Greg,

Quoted 4 lines · Greg Ungerer

The following patch series fixes some issues with the initialization phase of the ColdFire MMU system startup. With these fixes applied we can also enable and run the ColdFire 5441x family of parts with their MMU enabled.

Quoted 8 lines
  arch/m68k/Kconfig.cpu               |    2 +-
  arch/m68k/coldfire/m54xx.c          |    4 ----
  arch/m68k/include/asm/mcfmmu.h      |    1 +
  arch/m68k/include/asm/mmu_context.h |    1 -
  arch/m68k/kernel/setup_mm.c         |    2 ++
  arch/m68k/mm/mcfmmu.c               |    4 ++--
  6 files changed, 6 insertions(+), 8 deletions(-)

I just applied this patchset to fresh master and re-verified that enabling MMU works on my mcf54415 based board.

Regards,
Angelo Dureghello

Quoted 5 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-m68k" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

author maintainer
#5 lore raw

Hi Angelo,

Quoted 16 lines · Angelo Dureghello

Dear Greg,

Quoted 4 lines · Greg Ungerer

The following patch series fixes some issues with the initialization phase of the ColdFire MMU system startup. With these fixes applied we can also enable and run the ColdFire 5441x family of parts with their MMU enabled.

Quoted 8 lines
  arch/m68k/Kconfig.cpu               |    2 +-
  arch/m68k/coldfire/m54xx.c          |    4 ----
  arch/m68k/include/asm/mcfmmu.h      |    1 +
  arch/m68k/include/asm/mmu_context.h |    1 -
  arch/m68k/kernel/setup_mm.c         |    2 ++
  arch/m68k/mm/mcfmmu.c               |    4 ++--
  6 files changed, 6 insertions(+), 8 deletions(-)
Quoted 4 lines

I just applied this patchset to fresh master and re-verified that enabling MMU works on my mcf54415 based board.

Thats great, thanks Angelo. I will add your tested-by tags to the commits.

Regards
Greg