From chris@linux-mips.org Mon Oct 24 12:41:17 2005
Received: with ECARTIS (v1.0.0; list maltalinux-cvs-patches); Mon, 24 Oct 2005 13:41:17 +0100 (BST)
From: chris@linux-mips.org
To:  maltalinux-cvs-patches@linux-mips.org
Subject: CVS Update@linux-mips.org: malta
Date: Mon, 24 Oct 2005 13:41:17 +0100
X-archive-position: 57
X-ecartis-version: Ecartis v1.0.0
Sender: maltalinux-cvs-patches-bounce@linux-mips.org
Errors-to: maltalinux-cvs-patches-bounce@linux-mips.org
X-original-sender: chris@linux-mips.org
Precedence: bulk
Reply-to: linux-mips@linux-mips.org
X-list: maltalinux-cvs-patches


CVSROOT:	/home/cvs
Module name:	malta
Changes by:	chris@ftp.linux-mips.org	05/10/24 13:41:16

Modified files:
	linux/arch/mips/kernel: Tag: MaltaRef_2_6 traps.c 
	linux/include/asm-mips: Tag: MaltaRef_2_6 cpu-features.h 

Log message:
	* include/asm-mips/cpu-features.h (cpu_has_fpu): Now tested per
	processor.
	
	* arch/mips/kernel/traps.c (do_mt): Allow kernel to be built
	MIPS32R1 again. Changed SMP FPU context switch to work on a
	per-processor basis.

diff -urN malta/linux/arch/mips/kernel/traps.c malta/linux/arch/mips/kernel/traps.c
--- malta/linux/arch/mips/kernel/traps.c	2005/07/28 17:26:19	1.193.1000.7
+++ malta/linux/arch/mips/kernel/traps.c	2005/10/24 12:41:16	1.193.1000.8
@@ -808,7 +808,8 @@
 
 	die_if_kernel("MIPS MT Thread exception in kernel", regs);
 
-	if (cpu_has_mipsmt) {
+#ifdef CONFIG_MIPS_CPU_MT
+ 	if (cpu_has_mipsmt) {
 		subcode = (read_vpe_c0_vpecontrol() & VPECONTROL_EXCPT) 
 			>> VPECONTROL_EXCPT_SHIFT;
 		switch(subcode) {
@@ -836,6 +837,7 @@
 			break;
 		}
 	}
+#endif /* CONFIG_MIPS_CPU_MT */
 	force_sig(SIGILL, current);
 }
 
@@ -1154,8 +1156,25 @@
 extern asmlinkage int fpu_emulator_save_context(struct sigcontext *sc);
 extern asmlinkage int fpu_emulator_restore_context(struct sigcontext *sc);
 
+#ifdef CONFIG_SMP
+int smp_save_fp_context (struct sigcontext *sc)
+{
+	return cpu_has_fpu ? _save_fp_context (sc) : fpu_emulator_save_context (sc);
+}
+
+int smp_restore_fp_context (struct sigcontext *sc)
+{
+	return cpu_has_fpu ? _restore_fp_context (sc) : fpu_emulator_restore_context (sc);
+}
+#endif
+
 static inline void signal_init(void)
 {
+#ifdef CONFIG_SMP
+	/* For now just do the cpu_has_fpu check when the functions are invoked */
+	save_fp_context = smp_save_fp_context;
+	restore_fp_context = smp_restore_fp_context;
+#else
 	if (cpu_has_fpu) {
 		save_fp_context = _save_fp_context;
 		restore_fp_context = _restore_fp_context;
@@ -1163,6 +1182,7 @@
 		save_fp_context = fpu_emulator_save_context;
 		restore_fp_context = fpu_emulator_restore_context;
 	}
+#endif
 }
 
 #ifdef CONFIG_MIPS32_COMPAT
diff -urN malta/linux/include/asm-mips/cpu-features.h malta/linux/include/asm-mips/cpu-features.h
--- malta/linux/include/asm-mips/cpu-features.h	2005/07/28 17:23:49	1.4.1000.5
+++ malta/linux/include/asm-mips/cpu-features.h	2005/10/24 12:41:16	1.4.1000.6
@@ -29,7 +29,11 @@
 #define cpu_has_4ktlb		(cpu_data[0].options & MIPS_CPU_4KTLB)
 #endif
 #ifndef cpu_has_fpu
-#define cpu_has_fpu		(cpu_data[0].options & MIPS_CPU_FPU)
+/*
+ * The kernel can(?) cope with SMP systems where some CPU's have a
+ * floating point unit and others don't
+ */
+#define cpu_has_fpu		(current_cpu_data.options & MIPS_CPU_FPU)
 #endif
 #ifndef cpu_has_32fpr
 #define cpu_has_32fpr		(cpu_data[0].options & MIPS_CPU_32FPR)

