All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Maciej W. Rozycki" <macro@linux-mips.org>
To: Ralf Baechle <ralf@linux-mips.org>
Cc: linux-mips@linux-mips.org
Subject: [PATCH 48/48] MIPS: Factor out FPU feature probing
Date: Fri, 3 Apr 2015 23:27:54 +0100 (BST)	[thread overview]
Message-ID: <alpine.LFD.2.11.1504032259490.21028@eddie.linux-mips.org> (raw)
In-Reply-To: <alpine.LFD.2.11.1504030054200.21028@eddie.linux-mips.org>

Factor out FPU feature probing, mainly to remove code duplication from 
`fpu_disable'.  No functional change although shuffle some code to avoid 
forward references.

Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
---
linux-mips-fpu-probe.diff
Index: linux/arch/mips/kernel/cpu-probe.c
===================================================================
--- linux.orig/arch/mips/kernel/cpu-probe.c	2015-04-02 20:27:59.750245000 +0100
+++ linux/arch/mips/kernel/cpu-probe.c	2015-04-02 20:28:00.091243000 +0100
@@ -33,6 +33,41 @@
 #include <asm/uaccess.h>
 
 /*
+ * Get the FPU Implementation/Revision.
+ */
+static inline unsigned long cpu_get_fpu_id(void)
+{
+	unsigned long tmp, fpu_id;
+
+	tmp = read_c0_status();
+	__enable_fpu(FPU_AS_IS);
+	fpu_id = read_32bit_cp1_register(CP1_REVISION);
+	write_c0_status(tmp);
+	return fpu_id;
+}
+
+/*
+ * Check if the CPU has an external FPU.
+ */
+static inline int __cpu_has_fpu(void)
+{
+	return (cpu_get_fpu_id() & FPIR_IMP_MASK) != FPIR_IMP_NONE;
+}
+
+static inline unsigned long cpu_get_msa_id(void)
+{
+	unsigned long status, msa_id;
+
+	status = read_c0_status();
+	__enable_fpu(FPU_64BIT);
+	enable_msa();
+	msa_id = read_msa_ir();
+	disable_msa();
+	write_c0_status(status);
+	return msa_id;
+}
+
+/*
  * Determine the FCSR mask for FPU hardware.
  */
 static inline void cpu_set_fpu_fcsr_mask(struct cpuinfo_mips *c)
@@ -82,13 +117,42 @@ static void cpu_set_nofpu_id(struct cpui
 /* Determined FPU emulator mask to use for the boot CPU with "nofpu".  */
 static unsigned int mips_nofpu_msk31;
 
+/*
+ * Set options for FPU hardware.
+ */
+static void cpu_set_fpu_opts(struct cpuinfo_mips *c)
+{
+	c->fpu_id = cpu_get_fpu_id();
+	mips_nofpu_msk31 = c->fpu_msk31;
+
+	if (c->isa_level & (MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M64R1 |
+			    MIPS_CPU_ISA_M32R2 | MIPS_CPU_ISA_M64R2 |
+			    MIPS_CPU_ISA_M32R6 | MIPS_CPU_ISA_M64R6)) {
+		if (c->fpu_id & MIPS_FPIR_3D)
+			c->ases |= MIPS_ASE_MIPS3D;
+		if (c->fpu_id & MIPS_FPIR_FREP)
+			c->options |= MIPS_CPU_FRE;
+	}
+
+	cpu_set_fpu_fcsr_mask(c);
+}
+
+/*
+ * Set options for the FPU emulator.
+ */
+static void cpu_set_nofpu_opts(struct cpuinfo_mips *c)
+{
+	c->options &= ~MIPS_CPU_FPU;
+	c->fpu_msk31 = mips_nofpu_msk31;
+
+	cpu_set_nofpu_id(c);
+}
+
 static int mips_fpu_disabled;
 
 static int __init fpu_disable(char *s)
 {
-	boot_cpu_data.options &= ~MIPS_CPU_FPU;
-	boot_cpu_data.fpu_msk31 = mips_nofpu_msk31;
-	cpu_set_nofpu_id(&boot_cpu_data);
+	cpu_set_nofpu_opts(&boot_cpu_data);
 	mips_fpu_disabled = 1;
 
 	return 1;
@@ -231,41 +295,6 @@ static inline void set_elf_platform(int 
 		__elf_platform = plat;
 }
 
-/*
- * Get the FPU Implementation/Revision.
- */
-static inline unsigned long cpu_get_fpu_id(void)
-{
-	unsigned long tmp, fpu_id;
-
-	tmp = read_c0_status();
-	__enable_fpu(FPU_AS_IS);
-	fpu_id = read_32bit_cp1_register(CP1_REVISION);
-	write_c0_status(tmp);
-	return fpu_id;
-}
-
-/*
- * Check if the CPU has an external FPU.
- */
-static inline int __cpu_has_fpu(void)
-{
-	return (cpu_get_fpu_id() & FPIR_IMP_MASK) != FPIR_IMP_NONE;
-}
-
-static inline unsigned long cpu_get_msa_id(void)
-{
-	unsigned long status, msa_id;
-
-	status = read_c0_status();
-	__enable_fpu(FPU_64BIT);
-	enable_msa();
-	msa_id = read_msa_ir();
-	disable_msa();
-	write_c0_status(status);
-	return msa_id;
-}
-
 static inline void cpu_probe_vmbits(struct cpuinfo_mips *c)
 {
 #ifdef __NEED_VMBITS_PROBE
@@ -1434,22 +1463,10 @@ void cpu_probe(void)
 			       ~(1 << MIPS_PWCTL_PWEN_SHIFT));
 	}
 
-	if (c->options & MIPS_CPU_FPU) {
-		c->fpu_id = cpu_get_fpu_id();
-		mips_nofpu_msk31 = c->fpu_msk31;
-
-		if (c->isa_level & (MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M64R1 |
-				    MIPS_CPU_ISA_M32R2 | MIPS_CPU_ISA_M64R2 |
-				    MIPS_CPU_ISA_M32R6 | MIPS_CPU_ISA_M64R6)) {
-			if (c->fpu_id & MIPS_FPIR_3D)
-				c->ases |= MIPS_ASE_MIPS3D;
-			if (c->fpu_id & MIPS_FPIR_FREP)
-				c->options |= MIPS_CPU_FRE;
-		}
-
-		cpu_set_fpu_fcsr_mask(c);
-	} else
-		cpu_set_nofpu_id(c);
+	if (c->options & MIPS_CPU_FPU)
+		cpu_set_fpu_opts(c);
+	else
+		cpu_set_nofpu_opts(c);
 
 	if (cpu_has_mips_r2_r6) {
 		c->srsets = ((read_c0_srsctl() >> 26) & 0x0f) + 1;

  parent reply	other threads:[~2015-04-03 22:37 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-03 22:23 [PATCH 00/48] FPU and FP emulation clean-ups, fixes and feature updates Maciej W. Rozycki
2015-04-03 22:23 ` [PATCH 01/48] doc: kernel-parameters.txt: Mark `nofpu' for MIPS too Maciej W. Rozycki
2015-04-03 22:23 ` [PATCH 02/48] MIPS: mipsregs.h: Remove broken comments Maciej W. Rozycki
2015-04-03 22:23 ` [PATCH 03/48] MIPS: mipsregs.h: Reorder CP1 macro definitions Maciej W. Rozycki
2015-04-03 22:23 ` [PATCH 04/48] MIPS: mipsregs.h: Move TX39 macros out of the way Maciej W. Rozycki
2015-04-03 22:23 ` [PATCH 05/48] MIPS: mipsregs.h: Reindent CP0 Cause macros Maciej W. Rozycki
2015-04-03 22:24 ` [PATCH 06/48] MIPS: ieee754.h: Correct comments for special values Maciej W. Rozycki
2015-04-03 22:24 ` [PATCH 07/48] MIPS: ieee754.h: Supplement " Maciej W. Rozycki
2015-04-03 22:24 ` [PATCH 08/48] MIPS: Correct the comment for FPU emulator traps Maciej W. Rozycki
2015-04-03 22:24 ` [PATCH 09/48] MIPS: Clarify the comment for `__cpu_has_fpu' Maciej W. Rozycki
2015-04-03 22:24 ` [PATCH 10/48] MIPS: math-emu: Reindent `bc_op' emulation Maciej W. Rozycki
2015-04-03 22:24 ` [PATCH 11/48] MIPS: Correct the comment for and reformat `movf_func' Maciej W. Rozycki
2015-04-03 22:24 ` [PATCH 12/48] MIPS: math-emu: Fix oversize lines in comparisons Maciej W. Rozycki
2015-04-03 22:24 ` [PATCH 13/48] MIPS: ELF: Drop `get_fp_abi' Maciej W. Rozycki
2015-04-03 22:24 ` [PATCH 14/48] MIPS: mips-r2-to-r6-emul.h: Inline empty `mipsr2_decoder' Maciej W. Rozycki
2015-04-03 22:24 ` [PATCH 15/48] MIPS: Reindent R6 RI exception emulation Maciej W. Rozycki
2015-04-03 22:24 ` [PATCH 16/48] MIPS: math-emu: Remove `modeindex' macro Maciej W. Rozycki
2015-04-03 22:25 ` [PATCH 17/48] MIPS: bitops.h: Avoid inline asm for constant FLS Maciej W. Rozycki
2015-04-03 22:25 ` [PATCH 18/48] MIPS: math-emu: Factor out CFC1/CTC1 emulation Maciej W. Rozycki
2015-04-03 23:33   ` Sergei Shtylyov
2015-04-04  0:07     ` Maciej W. Rozycki
2015-04-03 22:25 ` [PATCH 19/48] MIPS: Normalise code flow in the CpU exception handler Maciej W. Rozycki
2015-04-03 22:25 ` [PATCH 20/48] MIPS: Use `FPU_CSR_ALL_X' in `__build_clear_fpe' Maciej W. Rozycki
2015-04-03 22:25 ` [PATCH 21/48] MIPS: math-emu: Update sNaN quieting handlers Maciej W. Rozycki
2015-04-03 22:25 ` [PATCH 23/48] MIPS: math-emu: Don't pass qNaNs through " Maciej W. Rozycki
2015-04-03 22:25 ` [PATCH 24/48] MIPS: math-emu: Reinstate sNaN " Maciej W. Rozycki
2015-04-03 22:25 ` [PATCH 25/48] MIPS: math-emu: Optimise NaN handling in comparisons Maciej W. Rozycki
2015-04-03 22:25 ` [PATCH 26/48] MIPS: math-emu: Remove redundant code from NaN comparison Maciej W. Rozycki
2015-04-03 22:25 ` [PATCH 27/48] MIPS: math-emu: Remove dead comparison helpers Maciej W. Rozycki
2015-04-03 22:25 ` [PATCH 29/48] MIPS: math-emu: Make NaN classifiers static Maciej W. Rozycki
2015-04-03 23:22   ` Sergei Shtylyov
2015-04-03 22:26 ` [PATCH 30/48] MIPS: Correct `nofpu' non-functionality Maciej W. Rozycki
2015-04-03 22:26 ` [PATCH 31/48] MIPS: Correct MIPS16 BREAK code interpretation Maciej W. Rozycki
2015-04-03 22:26 ` [PATCH 32/48] MIPS: BREAK instruction interpretation corrections Maciej W. Rozycki
2015-04-03 22:26 ` [PATCH 33/48] MIPS: Fix BREAK code interpretation heuristics Maciej W. Rozycki
2015-04-03 22:26 ` [PATCH 34/48] MIPS: math-emu: Fix delay-slot emulation cache incoherency Maciej W. Rozycki
2015-04-03 22:26 ` [PATCH 35/48] MIPS: Correct MIPS I FP context layout Maciej W. Rozycki
2015-04-03 22:26 ` [PATCH 36/48] MIPS: Correct FP ISA requirements Maciej W. Rozycki
2015-04-03 22:26 ` [PATCH 37/48] MIPS: math-emu: Correct delay-slot exception propagation Maciej W. Rozycki
2016-01-20 10:50   ` Aurelien Jarno
2016-01-20 15:15     ` Maciej W. Rozycki
2015-04-03 22:27 ` [PATCH 38/48] MIPS: math-emu: Move long fixed-point support into an `ar' library Maciej W. Rozycki
2015-04-03 22:27 ` [PATCH 39/48] MIPS: Respect the FCSR exception mask for `si_code' Maciej W. Rozycki
2015-04-03 22:27 ` [PATCH 40/48] MIPS: Always clear FCSR cause bits after emulation Maciej W. Rozycki
2015-04-03 22:27 ` [PATCH 41/48] MIPS: Set `si_code' for SIGFPE signals sent from emulation too Maciej W. Rozycki
2015-04-03 22:27 ` [PATCH 42/48] MIPS: Correct ISA masking in FPU feature determination Maciej W. Rozycki
2015-04-03 22:27 ` [PATCH 43/48] MIPS: math-emu: Set FIR feature flags for full emulation Maciej W. Rozycki
2015-04-03 23:18   ` Sergei Shtylyov
2015-04-03 22:27 ` [PATCH 44/48] MIPS: math-emu: Implement the FCCR, FEXR and FENR registers Maciej W. Rozycki
2015-04-03 22:27 ` [PATCH 45/48] MIPS: math-emu: Define IEEE 754-2008 feature control bits Maciej W. Rozycki
2015-04-03 22:27 ` [PATCH 46/48] MIPS: math-emu: Make ABS.fmt and NEG.fmt arithmetic again Maciej W. Rozycki
2015-04-07 15:24   ` Maciej W. Rozycki
2015-04-07 17:31     ` Ralf Baechle
2015-04-07 23:11       ` Maciej W. Rozycki
2015-04-03 22:27 ` [PATCH 47/48] MIPS: Respect the ISA level in FCSR handling Maciej W. Rozycki
2015-04-07 12:54   ` Ralf Baechle
2015-04-07 21:13     ` Maciej W. Rozycki
2015-04-07 22:45       ` Ralf Baechle
2015-04-03 22:27 ` Maciej W. Rozycki [this message]
2015-04-04 20:04 ` [PATCH 00/48] FPU and FP emulation clean-ups, fixes and feature updates Ralf Baechle
2015-04-04 20:55   ` Maciej W. Rozycki
2015-04-04 21:57     ` Ralf Baechle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LFD.2.11.1504032259490.21028@eddie.linux-mips.org \
    --to=macro@linux-mips.org \
    --cc=linux-mips@linux-mips.org \
    --cc=ralf@linux-mips.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.