* [PATCH v7] MIPS: micromips: Fix improper definition of ISA exception bit.
@ 2013-06-05 21:13 Steven J. Hill
2013-06-05 21:27 ` Sergei Shtylyov
0 siblings, 1 reply; 2+ messages in thread
From: Steven J. Hill @ 2013-06-05 21:13 UTC (permalink / raw)
To: linux-mips; +Cc: Steven J. Hill, ralf
The ISA exception bit selects whether exceptions are taken in classic
or microMIPS mode. This bit is Config3.ISAOnExc and was improperly
defined as bits 16 and 17 instead of just bit 16. A new function was
added so that platforms could set this bit when running a kernel
compiled with only microMIPS instructions.
Signed-off-by: Steven J. Hill <Steven.Hill@imgtec.com>
Acked-by: David Daney <david.daney@cavium.com>
---
Changes from v6:
* Add '#ifdef SYS_SUPPORTS_MICROMIPS' around body of
'set_micromips_exception_mode' function. Platforms that
do not support microMIPS will optimize it out.
arch/mips/include/asm/mipsregs.h | 20 +++++++++++++++++++-
arch/mips/kernel/cpu-probe.c | 3 ---
arch/mips/kernel/traps.c | 5 +++++
3 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/arch/mips/include/asm/mipsregs.h b/arch/mips/include/asm/mipsregs.h
index 87e6207..0a9544a 100644
--- a/arch/mips/include/asm/mipsregs.h
+++ b/arch/mips/include/asm/mipsregs.h
@@ -596,7 +596,7 @@
#define MIPS_CONF3_RXI (_ULCAST_(1) << 12)
#define MIPS_CONF3_ULRI (_ULCAST_(1) << 13)
#define MIPS_CONF3_ISA (_ULCAST_(3) << 14)
-#define MIPS_CONF3_ISA_OE (_ULCAST_(3) << 16)
+#define MIPS_CONF3_ISA_OE (_ULCAST_(1) << 16)
#define MIPS_CONF3_VZ (_ULCAST_(1) << 23)
#define MIPS_CONF4_MMUSIZEEXT (_ULCAST_(255) << 0)
@@ -1161,6 +1161,24 @@ do { \
#define write_c0_brcm_sleepcount(val) __write_32bit_c0_register($22, 7, val)
/*
+ * Set exceptions to be taken in microMIPS mode only, otherwise
+ * set for classic exceptions.
+ */
+static inline void set_micromips_exception_mode(void)
+{
+#ifdef SYS_SUPPORTS_MICROMIPS
+ unsigned int config3 = read_c0_config3();
+
+#ifdef CONFIG_CPU_MICROMIPS
+ if (config3 & MIPS_CONF3_ISA)
+ write_c0_config3(config3 | MIPS_CONF3_ISA_OE);
+ else
+#endif
+ write_c0_config3(config3 & ~MIPS_CONF3_ISA_OE);
+#endif
+}
+
+/*
* Macros to access the floating point coprocessor control registers
*/
#define read_32bit_cp1_register(source) \
diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c
index c6568bf..b0d04a2 100644
--- a/arch/mips/kernel/cpu-probe.c
+++ b/arch/mips/kernel/cpu-probe.c
@@ -272,9 +272,6 @@ static inline unsigned int decode_config3(struct cpuinfo_mips *c)
c->options |= MIPS_CPU_ULRI;
if (config3 & MIPS_CONF3_ISA)
c->options |= MIPS_CPU_MICROMIPS;
-#ifdef CONFIG_CPU_MICROMIPS
- write_c0_config3(read_c0_config3() | MIPS_CONF3_ISA_OE);
-#endif
if (config3 & MIPS_CONF3_VZ)
c->ases |= MIPS_ASE_VZ;
diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index a75ae40..151ed59 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -1837,6 +1837,11 @@ void __init trap_init(void)
ebase += (read_c0_ebase() & 0x3ffff000);
}
+ /*
+ * Set microMIPS exceptions for platforms that support it.
+ */
+ set_micromips_exception_mode();
+
if (board_ebase_setup)
board_ebase_setup();
per_cpu_trap_init(true);
--
1.7.2.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v7] MIPS: micromips: Fix improper definition of ISA exception bit.
2013-06-05 21:13 [PATCH v7] MIPS: micromips: Fix improper definition of ISA exception bit Steven J. Hill
@ 2013-06-05 21:27 ` Sergei Shtylyov
0 siblings, 0 replies; 2+ messages in thread
From: Sergei Shtylyov @ 2013-06-05 21:27 UTC (permalink / raw)
To: Steven J. Hill; +Cc: linux-mips, ralf
On 06/06/2013 01:13 AM, Steven J. Hill wrote:
> The ISA exception bit selects whether exceptions are taken in classic
> or microMIPS mode. This bit is Config3.ISAOnExc and was improperly
> defined as bits 16 and 17 instead of just bit 16. A new function was
> added so that platforms could set this bit when running a kernel
> compiled with only microMIPS instructions.
>
> Signed-off-by: Steven J. Hill <Steven.Hill@imgtec.com>
> Acked-by: David Daney <david.daney@cavium.com>
> ---
> Changes from v6:
> * Add '#ifdef SYS_SUPPORTS_MICROMIPS' around body of
> 'set_micromips_exception_mode' function. Platforms that
> do not support microMIPS will optimize it out.
>
> arch/mips/include/asm/mipsregs.h | 20 +++++++++++++++++++-
> arch/mips/kernel/cpu-probe.c | 3 ---
> arch/mips/kernel/traps.c | 5 +++++
> 3 files changed, 24 insertions(+), 4 deletions(-)
>
> diff --git a/arch/mips/include/asm/mipsregs.h b/arch/mips/include/asm/mipsregs.h
> index 87e6207..0a9544a 100644
> --- a/arch/mips/include/asm/mipsregs.h
> +++ b/arch/mips/include/asm/mipsregs.h
> @@ -596,7 +596,7 @@
> #define MIPS_CONF3_RXI (_ULCAST_(1) << 12)
> #define MIPS_CONF3_ULRI (_ULCAST_(1) << 13)
> #define MIPS_CONF3_ISA (_ULCAST_(3) << 14)
> -#define MIPS_CONF3_ISA_OE (_ULCAST_(3) << 16)
> +#define MIPS_CONF3_ISA_OE (_ULCAST_(1) << 16)
> #define MIPS_CONF3_VZ (_ULCAST_(1) << 23)
>
> #define MIPS_CONF4_MMUSIZEEXT (_ULCAST_(255) << 0)
> @@ -1161,6 +1161,24 @@ do { \
> #define write_c0_brcm_sleepcount(val) __write_32bit_c0_register($22, 7, val)
>
> /*
> + * Set exceptions to be taken in microMIPS mode only, otherwise
> + * set for classic exceptions.
> + */
> +static inline void set_micromips_exception_mode(void)
> +{
> +#ifdef SYS_SUPPORTS_MICROMIPS
> + unsigned int config3 = read_c0_config3();
> +
> +#ifdef CONFIG_CPU_MICROMIPS
> + if (config3 & MIPS_CONF3_ISA)
> + write_c0_config3(config3 | MIPS_CONF3_ISA_OE);
> + else
> +#endif
> + write_c0_config3(config3 & ~MIPS_CONF3_ISA_OE);
> +#endif
Let me remind that #ifdef's inside the function body are considered
ugly and
should be avoided if at all possible (by defining an empty
implementation in the
#else branch).
WBR, Sergei
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-06-05 21:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-05 21:13 [PATCH v7] MIPS: micromips: Fix improper definition of ISA exception bit Steven J. Hill
2013-06-05 21:27 ` Sergei Shtylyov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox