MIPS: micromips: Fix improper definition of ISA exception bit.
PATCH v7 1/1 MIPS: micromips: Fix improper definition of ISA exception bit.
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.
---
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(-)
arch/mips/include/asm/mipsregs.h +19 -1
@@ -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) \
arch/mips/kernel/cpu-probe.c +0 -3
@@ -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 ;
arch/mips/kernel/traps.c +5 -0
@@ -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);
Signature · 1 line
1.7.2.5
Quoted 41 lines · Steven J. Hill
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 <[email protected]>Acked-by David Daney <[email protected]>---
Changes from v6:
* Add '#ifdefSYS_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(-)arch/mips/include/asm/mipsregs.h +6
-1@@ -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 ) +{
arch/mips/include/asm/mipsregs.h do { \ · line 1178
Quoted 10 lines
arch/mips/include/asm/mipsregs.h +10
-0+#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