Skip to contentSkip to conversation

m68k: prepare to support ColdFire M5441x MMU enabled

PATCH In review Greg Ungerer 2 participants 13 messages Aug 29, 2016 – Aug 30, 2016

Subsystems (2)
lore
Share & tools
lore

Greg Ungerer

author maintainer
#0 lore raw

cover m68k: prepare to support ColdFire M5441x MMU enabled

The following changes are in preparation for supporting the ColdFire M5441x SoC with its MMU enabled. (It is already supported in the no-MMU mode).

Quite a few relate to the ability to run with no FPU hardware (and no software emulation of FP). I have taken CONFIG_FPU to mean that we expect a hardware FPU to be present - and we generate code to support that in the kernel. If CONFIG_FPU is not defined we generate no support code (so no use of FPU specific instructions). That is mostly what the code already did, but not comepletely.

I don't actually enable the M5441x to run with MMU enabled in this series. I don't have that hardware, so I can't verify that it actually works. But these changes don't break the m547x, so I expect all is ok. With the extra MMU enabling configuration line added you can cleanly build for the M5441x with MMU enabled after this series though.

These patches are based on the ideas from Yannick Gicquel's <[email protected]> patches from some time back.

Regards
Greg

 arch/m68k/Kconfig                     |    1
 arch/m68k/Kconfig.cpu                 |    6 +++++
 arch/m68k/coldfire/head.S             |    8 +++---
 arch/m68k/coldfire/m54xx.c            |   40 ----------------------------------
 arch/m68k/include/asm/m5441xsim.h     |    4 +++
 arch/m68k/include/asm/m54xxacr.h      |    2 -
 arch/m68k/include/asm/m54xxsim.h      |    4 +++
 arch/m68k/include/asm/mcfmmu.h        |    1
 arch/m68k/include/uapi/asm/bootinfo.h |    1
 arch/m68k/kernel/process.c            |    4 +--
 arch/m68k/kernel/setup_mm.c           |    5 ++--
 arch/m68k/mm/mcfmmu.c                 |   31 +++++++++++++++++++++++++-
 12 files changed, 57 insertions(+), 50 deletions(-)
author maintainer
#1 lore raw

PATCH 1/8 m68k: move CONFIG_FPU set to per-CPU configuration

Move the selection of CONFIG_FPU to each CPU type configuration.

Currently for m68k we have a global set of CONFIG_FPU based on if CONFIG_MMU is enabled or not. There is at least one CPU family we support (m5441x) that has an MMU but has no FPU hardware. So we need to be able to have CONFIG_MMU set and CONFIG_FPU not set.

Whether we build for a CPU with MMU enabled or not doesn't change the fact that it has FPU hardware support. Our current non-MMU builds have never had CONIG_FPU enabled - and in fact the kernel will not compile with that set and CONFIG_MMU not set at the moment. It is easy enough to fix this - but it would involve a structure change to sigcontext.h, and that is a user space exported header (so ABI change).

This change makes no configuration visible changes, and all configs end up with the same configuration settings as before.

This change based on changes and discussion from Yannick Gicquel <[email protected]>.

---
 arch/m68k/Kconfig     | 1 -
 arch/m68k/Kconfig.cpu | 6 ++++++
 2 files changed, 6 insertions(+), 1 deletion(-)
arch/m68k/Kconfig +0 -1
index 498b567..d140206 100644
@@ -14,7 +14,6 @@ config M68K
 	select GENERIC_IOMAP
 	select GENERIC_STRNCPY_FROM_USER if MMU
 	select GENERIC_STRNLEN_USER if MMU
-	select FPU if MMU
 	select ARCH_WANT_IPC_PARSE_VERSION
 	select ARCH_USES_GETTIMEOFFSET if MMU && !COLDFIRE
 	select HAVE_FUTEX_CMPXCHG if MMU && FUTEX
arch/m68k/Kconfig.cpu +6 -0
index 967260f..d2219f30 100644
@@ -62,6 +62,7 @@ config MCPU32
 config M68020
 	bool "68020 support"
 	depends on MMU
+	select FPU
 	select CPU_HAS_ADDRESS_SPACES
 	help
 	  If you anticipate running this kernel on a computer with a MC68020
@@ -72,6 +73,7 @@ config M68020
 config M68030
 	bool "68030 support"
 	depends on MMU && !MMU_SUN3
+	select FPU
 	select CPU_HAS_ADDRESS_SPACES
 	help
 	  If you anticipate running this kernel on a computer with a MC68030
@@ -81,6 +83,7 @@ config M68030
 config M68040
 	bool "68040 support"
 	depends on MMU && !MMU_SUN3
+	select FPU
 	select CPU_HAS_ADDRESS_SPACES
 	help
 	  If you anticipate running this kernel on a computer with a MC68LC040
@@ -91,6 +94,7 @@ config M68040
 config M68060
 	bool "68060 support"
 	depends on MMU && !MMU_SUN3
+	select FPU
 	select CPU_HAS_ADDRESS_SPACES
 	help
 	  If you anticipate running this kernel on a computer with a MC68060
@@ -259,6 +263,7 @@ config M547x
 	bool "MCF547x"
 	select M54xx
 	select MMU_COLDFIRE if MMU
+	select FPU if MMU
 	select HAVE_CACHE_CB
 	select HAVE_MBAR
 	select CPU_NO_EFFICIENT_FFS
@@ -268,6 +273,7 @@ config M547x
 config M548x
 	bool "MCF548x"
 	select MMU_COLDFIRE if MMU
+	select FPU if MMU
 	select M54xx
 	select HAVE_CACHE_CB
 	select HAVE_MBAR
Signature · 1 line
1.9.1
author maintainer
#2 lore raw

PATCH 2/8 m68k: set appropriate machine type for m5411x SoC platforms

In reply to Greg Ungerer

Create a new machine type for platforms based around the ColdFire 5441x SoC family. Set that machine type on startup when building for this platform type.

Currently the ColdFire head.S hard codes a M54xx machine type at startup - since that is the only platform type currently supported with MMU enabled. The m5441x has an MMU and this change forms part of the support required to run it with the MMU enabled.

---
 arch/m68k/coldfire/head.S             | 4 ++--
 arch/m68k/include/asm/m5441xsim.h     | 1 +
 arch/m68k/include/asm/m54xxsim.h      | 1 +
 arch/m68k/include/uapi/asm/bootinfo.h | 1 +
 arch/m68k/kernel/setup_mm.c           | 1 +
 5 files changed, 6 insertions(+), 2 deletions(-)
arch/m68k/coldfire/head.S +2 -2
index 73d92ea..4ba5d562 100644
@@ -282,8 +282,8 @@ _clear_bss:
 	movel	%d0,m68k_mmutype
 	movel	#FPU_COLDFIRE,%d0
 	movel	%d0,m68k_fputype
-	movel	#MACH_M54XX,%d0
-	movel	%d0,m68k_machtype		/* Mark us as a 54xx machine */
+	movel	#MACHINE,%d0
+	movel	%d0,m68k_machtype		/* Mark machine type */
 	lea	init_task,%a2			/* Set "current" init task */
 #endif
 
arch/m68k/include/asm/m5441xsim.h +1 -0
index cc798ab..60768b5 100644
@@ -10,6 +10,7 @@
 #define CPU_NAME		"COLDFIRE(m5441x)"
 #define CPU_INSTR_PER_JIFFY	2
 #define MCF_BUSCLK		(MCF_CLK / 2)
+#define MACHINE			MACH_M5441X
 
 #include <asm/m54xxacr.h>
 
arch/m68k/include/asm/m54xxsim.h +1 -0
index a5fbd17..cde0390 100644
@@ -8,6 +8,7 @@
 #define	CPU_NAME		"COLDFIRE(m54xx)"
 #define	CPU_INSTR_PER_JIFFY	2
 #define	MCF_BUSCLK		(MCF_CLK / 2)
+#define	MACHINE			MACH_M54XX
 
 #include <asm/m54xxacr.h>
 
arch/m68k/include/uapi/asm/bootinfo.h +1 -0
index cdeb26a0..a48cf54 100644
@@ -81,6 +81,7 @@ struct mem_info {
 #define MACH_Q40		10
 #define MACH_SUN3X		11
 #define MACH_M54XX		12
+#define MACH_M5441X		13
 
 
     /*
arch/m68k/kernel/setup_mm.c +1 -0
index 5b8ec4d..13f4640 100644
@@ -341,6 +341,7 @@ void __init setup_arch(char **cmdline_p)
 #endif
 #ifdef CONFIG_COLDFIRE
 	case MACH_M54XX:
+	case MACH_M5441X:
 		config_BSP(NULL, 0);
 		break;
 #endif
Signature · 1 line
1.9.1
author maintainer
#3 lore raw

PATCH 3/8 m68k: report correct FPU type on ColdFire MMU platforms

In reply to Greg Ungerer

Not all ColdFire SoC parts that have an MMU also have an FPU - so set an FPU type (via m68k_fputype) appropriate for the configured platform.

With this set correctly /proc/cpuinfo will report FPU "none" on devices that don't have one. And kernel code paths that initialize FPU hardware will now only execute if an FPU is actually present.

---
 arch/m68k/coldfire/head.S         | 4 ++--
 arch/m68k/include/asm/m5441xsim.h | 1 +
 arch/m68k/include/asm/m54xxsim.h  | 1 +
 3 files changed, 4 insertions(+), 2 deletions(-)
arch/m68k/coldfire/head.S +2 -2
index 4ba5d562..bdb472c 100644
@@ -280,8 +280,8 @@ _clear_bss:
 	movel	%d0,m68k_cputype		/* Mark us as a ColdFire */
 	movel	#MMU_COLDFIRE,%d0
 	movel	%d0,m68k_mmutype
-	movel	#FPU_COLDFIRE,%d0
-	movel	%d0,m68k_fputype
+	movel	#FPUTYPE,%d0
+	movel	%d0,m68k_fputype		/* Mark FPU type */
 	movel	#MACHINE,%d0
 	movel	%d0,m68k_machtype		/* Mark machine type */
 	lea	init_task,%a2			/* Set "current" init task */
arch/m68k/include/asm/m5441xsim.h +1 -0
index 60768b5..4279c0d 100644
@@ -11,6 +11,7 @@
 #define CPU_INSTR_PER_JIFFY	2
 #define MCF_BUSCLK		(MCF_CLK / 2)
 #define MACHINE			MACH_M5441X
+#define FPUTYPE			0
 
 #include <asm/m54xxacr.h>
 
arch/m68k/include/asm/m54xxsim.h +1 -0
index cde0390..7dd6cc4 100644
@@ -9,6 +9,7 @@
 #define	CPU_INSTR_PER_JIFFY	2
 #define	MCF_BUSCLK		(MCF_CLK / 2)
 #define	MACHINE			MACH_M54XX
+#define	FPUTYPE			FPU_COLDFIRE
 
 #include <asm/m54xxacr.h>
 
Signature · 1 line
1.9.1
author maintainer
#4 lore raw

PATCH 4/8 m68k: move ColdFire _bootmem_alloc code

In reply to Greg Ungerer

The early ColdFire bootmem_alloc() code is currently only included in the board support for the Coldire 54xx platforms. It will be used on all ColdFire MMU enabled platforms as others are supported. So move the mcf54xx_bootmem_alloc() function to be generally available to all MMU enabled ColdFire parts (and use a more generic name for it).

---
 arch/m68k/coldfire/m54xx.c     | 40 +---------------------------------------
 arch/m68k/include/asm/mcfmmu.h |  1 +
 arch/m68k/mm/mcfmmu.c          | 31 ++++++++++++++++++++++++++++++-
 3 files changed, 32 insertions(+), 40 deletions(-)
arch/m68k/coldfire/m54xx.c +1 -39
index c32f767..386df3b 100644
@@ -25,7 +25,6 @@
 #include <asm/m54xxgpt.h>
 #ifdef CONFIG_MMU
 #include <asm/mmu_context.h>
-#include <linux/pfn.h>
 #endif
 
 /***************************************************************************/
@@ -78,47 +77,10 @@ static void mcf54xx_reset(void)
 
 /***************************************************************************/
 
-#ifdef CONFIG_MMU
-
-unsigned long num_pages;
-
-static void __init mcf54xx_bootmem_alloc(void)
-{
-	unsigned long start_pfn;
-	unsigned long memstart;
-
-	/* _rambase and _ramend will be naturally page aligned */
-	m68k_memory[0].addr = _rambase;
-	m68k_memory[0].size = _ramend - _rambase;
-
-	/* compute total pages in system */
-	num_pages = PFN_DOWN(_ramend - _rambase);
-
-	/* page numbers */
-	memstart = PAGE_ALIGN(_ramstart);
-	min_low_pfn = PFN_DOWN(_rambase);
-	start_pfn = PFN_DOWN(memstart);
-	max_pfn = max_low_pfn = PFN_DOWN(_ramend);
-	high_memory = (void *)_ramend;
-
-	m68k_virt_to_node_shift = fls(_ramend - _rambase - 1) - 6;
-	module_fixup(NULL, __start_fixup, __stop_fixup);
-
-	/* setup bootmem 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);
-}
-
-#endif /* CONFIG_MMU */
-
-/***************************************************************************/
-
 void __init config_BSP(char *commandp, int size)
 {
 #ifdef CONFIG_MMU
-	mcf54xx_bootmem_alloc();
+	cf_bootmem_alloc();
 	mmu_context_init();
 #endif
 	mach_reset = mcf54xx_reset;
arch/m68k/include/asm/mcfmmu.h +1 -0
index 8824236..10f9930 100644
@@ -105,6 +105,7 @@ static inline void mmu_write(u32 a, u32 v)
 	__asm__ __volatile__ ("nop");
 }
 
+void cf_bootmem_alloc(void);
 int cf_tlb_miss(struct pt_regs *regs, int write, int dtlb, int extension_word);
 
 #endif
arch/m68k/mm/mcfmmu.c +30 -1
index f58fafe..87131cd 100644
@@ -27,7 +27,7 @@ mm_context_t next_mmu_context;
 unsigned long context_map[LAST_CONTEXT / BITS_PER_LONG + 1];
 atomic_t nr_free_contexts;
 struct mm_struct *context_mm[LAST_CONTEXT+1];
-extern unsigned long num_pages;
+unsigned long num_pages;
 
 /*
  * ColdFire paging_init derived from sun3.
@@ -150,6 +150,35 @@ int cf_tlb_miss(struct pt_regs *regs, int write, int dtlb, int extension_word)
 	return 0;
 }
 
+void __init cf_bootmem_alloc(void)
+{
+	unsigned long start_pfn;
+	unsigned long memstart;
+
+	/* _rambase and _ramend will be naturally page aligned */
+	m68k_memory[0].addr = _rambase;
+	m68k_memory[0].size = _ramend - _rambase;
+
+	/* compute total pages in system */
+	num_pages = PFN_DOWN(_ramend - _rambase);
+
+	/* page numbers */
+	memstart = PAGE_ALIGN(_ramstart);
+	min_low_pfn = PFN_DOWN(_rambase);
+	start_pfn = PFN_DOWN(memstart);
+	max_pfn = max_low_pfn = PFN_DOWN(_ramend);
+	high_memory = (void *)_ramend;
+
+	m68k_virt_to_node_shift = fls(_ramend - _rambase - 1) - 6;
+	module_fixup(NULL, __start_fixup, __stop_fixup);
+
+	/* setup bootmem 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);
+}
+
 /*
  * Initialize the context management stuff.
  * The following was taken from arch/ppc/mmu_context.c
Signature · 1 line
1.9.1
author maintainer
#5 lore raw

PATCH 5/8 m68k: generalize io memory region setup for ColdFire ACR registers

In reply to Greg Ungerer

The ACR registers of the ColdFire define at a macro level what regions of the addresses space should have caching or other attribute types applied.

Currently for the MMU enabled setups we map the interal IO peripheral addres space as uncachable based on the define for the MBAR address (CONFIG_MBAR). Not all ColdFire SoC use a programmable MBAR register address. Some parts have fixed addressing for their internal peripheral registers.

Generalize the way we get the internal peripheral base address so all types can be accomodated in the ACR definitions. Each ColdFire SoC type now sets its IO memory base and size definitions (which may be based on MBAR) which are then used in the ACR definitions.

---
 arch/m68k/include/asm/m5441xsim.h | 2 ++
 arch/m68k/include/asm/m54xxacr.h  | 2 +-
 arch/m68k/include/asm/m54xxsim.h  | 2 ++
 3 files changed, 5 insertions(+), 1 deletion(-)
arch/m68k/include/asm/m5441xsim.h +2 -0
index 4279c0d..64f60be 100644
@@ -12,6 +12,8 @@
 #define MCF_BUSCLK		(MCF_CLK / 2)
 #define MACHINE			MACH_M5441X
 #define FPUTYPE			0
+#define IOMEMBASE		0xe0000000
+#define IOMEMSIZE		0x20000000
 
 #include <asm/m54xxacr.h>
 
arch/m68k/include/asm/m54xxacr.h +1 -1
index 59e1710..c6ac05c 100644
@@ -94,7 +94,7 @@
  *	register region as non-cacheable. And then we map all our RAM as
  *	cacheable and supervisor access only.
  */
-#define ACR0_MODE	(ACR_BA(CONFIG_MBAR)+ACR_ADMSK(0x1000000)+ \
+#define ACR0_MODE	(ACR_BA(IOMEMBASE)+ACR_ADMSK(IOMEMSIZE)+ \
 			 ACR_ENABLE+ACR_SUPER+ACR_CM_OFF_PRE+ACR_SP)
 #if defined(CONFIG_CACHE_COPYBACK)
 #define ACR1_MODE	(ACR_BA(CONFIG_RAMBASE)+ACR_ADMSK(CONFIG_RAMSIZE)+ \
arch/m68k/include/asm/m54xxsim.h +2 -0
index 7dd6cc4..73d937f 100644
@@ -10,6 +10,8 @@
 #define	MCF_BUSCLK		(MCF_CLK / 2)
 #define	MACHINE			MACH_M54XX
 #define	FPUTYPE			FPU_COLDFIRE
+#define	IOMEMBASE		MCF_MBAR
+#define	IOMEMSIZE		0x01000000
 
 #include <asm/m54xxacr.h>
 
Signature · 1 line
1.9.1
author maintainer
#6 lore raw

PATCH 6/8 m68k: always make available dump_fpu()

In reply to Greg Ungerer

Our local m68k architecture dump_fpu() is conditionally compiled in on CONFIG_FPU. That is OK for all existing MMU enabled CPU types, but won't handle the case for some ColdFire SoC CPU parts that we want to support that have no FPU hardware.

dump_fpu() is expected to be present by the ELF loader, so we must always have it available and exported.

Modify the position of the conditional to allow supporting the case where CONFIG_FPU is not defined.

This change based on changes and discussion from Yannick Gicquel <[email protected]>.

---
 arch/m68k/kernel/process.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/m68k/kernel/process.c +2 -2
index c55ff71..44ec789 100644
@@ -203,7 +203,6 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
 }
 
 /* Fill in the fpu structure for a core dump.  */
-#ifdef CONFIG_FPU
 int dump_fpu (struct pt_regs *regs, struct user_m68kfp_struct *fpu)
 {
 	char fpustate[216];
@@ -222,6 +221,7 @@ int dump_fpu (struct pt_regs *regs, struct user_m68kfp_struct *fpu)
 		return 1;
 	}
 
+#ifdef CONFIG_FPU
 	/* First dump the fpu context to avoid protocol violation.  */
 	asm volatile ("fsave %0" :: "m" (fpustate[0]) : "memory");
 	if (!CPU_IS_060 ? !fpustate[0] : !fpustate[2])
@@ -248,11 +248,11 @@ int dump_fpu (struct pt_regs *regs, struct user_m68kfp_struct *fpu)
 			      : "m" (fpu->fpregs[0])
 			      : "memory");
 	}
+#endif /* CONFIG_FPU */
 
 	return 1;
 }
 EXPORT_SYMBOL(dump_fpu);
-#endif /* CONFIG_FPU */
 
 unsigned long get_wchan(struct task_struct *p)
 {
Signature · 1 line
1.9.1
author maintainer
#7 lore raw

PATCH 7/8 m68k: only generate FPU instructions of CONFIG_FPU

In reply to Greg Ungerer

Most of the m68k code that supports a hardware FPU is surrounded by CONFIG_FPU. Except this setup code in setup_mm.c. Be consistent and surround these hardware FPU instructions with CONFIG_FPU instead of a check based on CONFIG_M68KFPU_EMU_ONLY.

The side effect of this is that we can now compile a kernel with no m68k/ColdFire hardware support FPU instructions at all (if we do not define CONFIG_FPU).

---
 arch/m68k/kernel/setup_mm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/m68k/kernel/setup_mm.c +1 -1
index 13f4640..00290c4 100644
@@ -245,7 +245,7 @@ void __init setup_arch(char **cmdline_p)
 	 * We should really do our own FPU check at startup.
 	 * [what do we do with buggy 68LC040s? if we have problems
 	 *  with them, we should add a test to check_bugs() below] */
-#ifndef CONFIG_M68KFPU_EMU_ONLY
+#ifdef CONFIG_FPU
 	/* clear the fpu if we have one */
 	if (m68k_fputype & (FPU_68881|FPU_68882|FPU_68040|FPU_68060|FPU_COLDFIRE)) {
 		volatile int zero = 0;
Signature · 1 line
1.9.1
author maintainer
#12 lore raw

PATCH 8/8 m68k: don't panic if no hardware FPU defined

In reply to Greg Ungerer

If we boot up and find no hardware FPU we panic and die.

Change this behavior to be that if we boot up and we _expect_ a hardware FPU to be present then panic. Don't panic if we don't actually expect to have any hardware FPU.

This lets us compile a kernel without FPU if we really choose too.

---
 arch/m68k/kernel/setup_mm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/m68k/kernel/setup_mm.c +1 -1
index 00290c4..a01d4a0 100644
@@ -549,7 +549,7 @@ module_init(proc_hardware_init);
 
 void check_bugs(void)
 {
-#ifndef CONFIG_M68KFPU_EMU
+#if defined(CONFIG_FPU) && !defined(CONFIG_M68KFPU_EMU)
 	if (m68k_fputype == 0) {
 		pr_emerg("*** YOU DO NOT HAVE A FLOATING POINT UNIT, "
 			"WHICH IS REQUIRED BY LINUX/M68K ***\n");
Signature · 1 line
1.9.1
#8 lore raw

Re: [PATCH 7/8] m68k: only generate FPU instructions of CONFIG_FPU

In reply to Greg Ungerer

Hi Greg,

Quoted 19 lines · Greg Ungerer

Most of the m68k code that supports a hardware FPU is surrounded by CONFIG_FPU. Except this setup code in setup_mm.c. Be consistent and surround these hardware FPU instructions with CONFIG_FPU instead of a check based on CONFIG_M68KFPU_EMU_ONLY.

The side effect of this is that we can now compile a kernel with no m68k/ColdFire hardware support FPU instructions at all (if we do not define CONFIG_FPU).

---
 arch/m68k/kernel/setup_mm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/m68k/kernel/setup_mm.c +0 -0
index 13f4640..00290c4 100644

arch/m68k/kernel/setup_mm.c void __init setup_arch(char **cmdline_p) · line 251

Quoted 8 lines
arch/m68k/kernel/setup_mm.c +1 -1
@@ -245,7 +245,7 @@ void __init setup_arch(char **cmdline_p)
         * We should really do our own FPU check at startup.
         * [what do we do with buggy 68LC040s? if we have problems
         *  with them, we should add a test to check_bugs() below] */
-#ifndef CONFIG_M68KFPU_EMU_ONLY
+#ifdef CONFIG_FPU
        /* clear the fpu if we have one */
        if (m68k_fputype & (FPU_68881|FPU_68882|FPU_68040|FPU_68060|FPU_COLDFIRE)) {
                volatile int zero = 0;

This piece of code is now compiled in if CONFIG_M68KFPU_EMU_ONLY=y?

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

author maintainer
#9 lore raw

Re: [PATCH 7/8] m68k: only generate FPU instructions of CONFIG_FPU

Hi Geert,

Quoted 17 lines · Geert Uytterhoeven

Hi Greg,

Quoted 14 lines · Greg Ungerer

Most of the m68k code that supports a hardware FPU is surrounded by CONFIG_FPU. Except this setup code in setup_mm.c. Be consistent and surround these hardware FPU instructions with CONFIG_FPU instead of a check based on CONFIG_M68KFPU_EMU_ONLY.

The side effect of this is that we can now compile a kernel with no m68k/ColdFire hardware support FPU instructions at all (if we do not define CONFIG_FPU).

---
 arch/m68k/kernel/setup_mm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 15 lines

arch/m68k/kernel/setup_mm.c void __init setup_arch(char **cmdline_p) · line 251

Quoted 13 lines
arch/m68k/kernel/setup_mm.c +1 -1
index 13f4640..00290c4 100644
@@ -245,7 +245,7 @@ void __init setup_arch(char **cmdline_p)
         * We should really do our own FPU check at startup.
         * [what do we do with buggy 68LC040s? if we have problems
         *  with them, we should add a test to check_bugs() below] */
-#ifndef CONFIG_M68KFPU_EMU_ONLY
+#ifdef CONFIG_FPU
        /* clear the fpu if we have one */
        if (m68k_fputype & (FPU_68881|FPU_68882|FPU_68040|FPU_68060|FPU_COLDFIRE)) {
                volatile int zero = 0;

This piece of code is now compiled in if CONFIG_M68KFPU_EMU_ONLY=y?

Yes, that is true. In that scenario I would expect m68k_fputype to be 0. So it wouldn't be executed.

The problem for me on ColdFire is that we currently do not support the FPU emulation (the assembler for it is not ColdFire clean). So in this case here we can't have CONFIG_M68KFPU_EMU_ONLY=y.

Would you prefer if it became:

  #if defined(CONFIG_FPU) && !defined(CONFIG_M68KFPU_EMU_ONL)

For the existing classic m68k machines they always currently have CONFIG_FPU set. So that would be no change for them. And for the ColdFire machines that do not have FPU hardware we are good because CONFIG_FPU won't be set.

Regards
Greg

#10 lore raw

Re: [PATCH 7/8] m68k: only generate FPU instructions of CONFIG_FPU

Hi Greg,

Quoted 35 lines · Greg Ungerer
Quoted 15 lines · Geert Uytterhoeven
Quoted 14 lines · Greg Ungerer

Most of the m68k code that supports a hardware FPU is surrounded by CONFIG_FPU. Except this setup code in setup_mm.c. Be consistent and surround these hardware FPU instructions with CONFIG_FPU instead of a check based on CONFIG_M68KFPU_EMU_ONLY.

The side effect of this is that we can now compile a kernel with no m68k/ColdFire hardware support FPU instructions at all (if we do not define CONFIG_FPU).

---
 arch/m68k/kernel/setup_mm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 15 lines

arch/m68k/kernel/setup_mm.c void __init setup_arch(char **cmdline_p) · line 251

Quoted 13 lines
arch/m68k/kernel/setup_mm.c +1 -1
index 13f4640..00290c4 100644
@@ -245,7 +245,7 @@ void __init setup_arch(char **cmdline_p)
         * We should really do our own FPU check at startup.
         * [what do we do with buggy 68LC040s? if we have problems
         *  with them, we should add a test to check_bugs() below] */
-#ifndef CONFIG_M68KFPU_EMU_ONLY
+#ifdef CONFIG_FPU
        /* clear the fpu if we have one */
        if (m68k_fputype & (FPU_68881|FPU_68882|FPU_68040|FPU_68060|FPU_COLDFIRE)) {
                volatile int zero = 0;

This piece of code is now compiled in if CONFIG_M68KFPU_EMU_ONLY=y?

Yes, that is true. In that scenario I would expect m68k_fputype to be 0. So it wouldn't be executed.

Quoted 7 lines

The problem for me on ColdFire is that we currently do not support the FPU emulation (the assembler for it is not ColdFire clean). So in this case here we can't have CONFIG_M68KFPU_EMU_ONLY=y.

Would you prefer if it became:

  #if defined(CONFIG_FPU) && !defined(CONFIG_M68KFPU_EMU_ONL)

(with the missing "Y" added)

Yes, I prefer not to change the semantics of M68KFPU_EMU_ONLY, whose help text states:

"This option prevents any floating-point instructions from being
compiled into the kernel"

Thanks!

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

author maintainer
#11 lore raw

Re: [PATCH 7/8] m68k: only generate FPU instructions of CONFIG_FPU

Hi Geert,

Quoted 42 lines · Geert Uytterhoeven

Hi Greg,

Quoted 39 lines · Greg Ungerer
Quoted 15 lines · Geert Uytterhoeven
Quoted 14 lines · Greg Ungerer

Most of the m68k code that supports a hardware FPU is surrounded by CONFIG_FPU. Except this setup code in setup_mm.c. Be consistent and surround these hardware FPU instructions with CONFIG_FPU instead of a check based on CONFIG_M68KFPU_EMU_ONLY.

The side effect of this is that we can now compile a kernel with no m68k/ColdFire hardware support FPU instructions at all (if we do not define CONFIG_FPU).

---
 arch/m68k/kernel/setup_mm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 15 lines

arch/m68k/kernel/setup_mm.c void __init setup_arch(char **cmdline_p) · line 251

Quoted 13 lines
arch/m68k/kernel/setup_mm.c +1 -1
index 13f4640..00290c4 100644
@@ -245,7 +245,7 @@ void __init setup_arch(char **cmdline_p)
         * We should really do our own FPU check at startup.
         * [what do we do with buggy 68LC040s? if we have problems
         *  with them, we should add a test to check_bugs() below] */
-#ifndef CONFIG_M68KFPU_EMU_ONLY
+#ifdef CONFIG_FPU
        /* clear the fpu if we have one */
        if (m68k_fputype & (FPU_68881|FPU_68882|FPU_68040|FPU_68060|FPU_COLDFIRE)) {
                volatile int zero = 0;

This piece of code is now compiled in if CONFIG_M68KFPU_EMU_ONLY=y?

Yes, that is true. In that scenario I would expect m68k_fputype to be 0. So it wouldn't be executed.

The problem for me on ColdFire is that we currently do not support the FPU emulation (the assembler for it is not ColdFire clean). So in this case here we can't have CONFIG_M68KFPU_EMU_ONLY=y.

Quoted 5 lines
Quoted 3 lines

Would you prefer if it became:

  #if defined(CONFIG_FPU) && !defined(CONFIG_M68KFPU_EMU_ONL)

(with the missing "Y" added)

Yep :-)

Quoted 5 lines

Yes, I prefer not to change the semantics of M68KFPU_EMU_ONLY, whose help text states:

"This option prevents any floating-point instructions from being
compiled into the kernel"

Ok, makes sense. I'll change an repost that patch.

Thanks!
Greg