Commit 3d5e8012 authored by Vineet Gupta's avatar Vineet Gupta

ARCv2: entry: save Accumulator register pair (r58:59) if present

Accumulator is present in configs with FPU and/or DSP MPY (mpy > 6)

Instead of doing this in pt_regs (and thus every kernel entry/exit),
this could have been done in context switch (and for user task only) as
currently kernel doesn't clobber these registers for its own accord.
However we will soon start using 64-bit multiply instructions for kernel
which can clobber these. Also gcc folks also plan to start using these
as GPRs, hence better to always save/restore them
Signed-off-by: default avatarVineet Gupta <vgupta@synopsys.com>
parent 6492f09e
...@@ -406,6 +406,14 @@ config ARC_HAS_DIV_REM ...@@ -406,6 +406,14 @@ config ARC_HAS_DIV_REM
bool "Insn: div, divu, rem, remu" bool "Insn: div, divu, rem, remu"
default y default y
config ARC_HAS_ACCL_REGS
bool "Reg Pair ACCL:ACCH (FPU and/or MPY > 6)"
default n
help
Depending on the configuration, CPU can contain accumulator reg-pair
(also referred to as r58:r59). These can also be used by gcc as GPR so
kernel needs to save/restore per process
endif # ISA_ARCV2 endif # ISA_ARCV2
endmenu # "ARC CPU Configuration" endmenu # "ARC CPU Configuration"
......
...@@ -16,6 +16,11 @@ ...@@ -16,6 +16,11 @@
; ;
; Now manually save: r12, sp, fp, gp, r25 ; Now manually save: r12, sp, fp, gp, r25
#ifdef CONFIG_ARC_HAS_ACCL_REGS
PUSH r59
PUSH r58
#endif
PUSH r30 PUSH r30
PUSH r12 PUSH r12
...@@ -75,6 +80,11 @@ ...@@ -75,6 +80,11 @@
POP r12 POP r12
POP r30 POP r30
#ifdef CONFIG_ARC_HAS_ACCL_REGS
POP r58
POP r59
#endif
.endm .endm
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
......
...@@ -86,6 +86,10 @@ struct pt_regs { ...@@ -86,6 +86,10 @@ struct pt_regs {
unsigned long r12, r30; unsigned long r12, r30;
#ifdef CONFIG_ARC_HAS_ACCL_REGS
unsigned long r58, r59; /* ACCL/ACCH used by FPU / DSP MPY */
#endif
/*------- Below list auto saved by h/w -----------*/ /*------- Below list auto saved by h/w -----------*/
unsigned long r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11; unsigned long r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11;
......
...@@ -319,7 +319,8 @@ static char *arc_extn_mumbojumbo(int cpu_id, char *buf, int len) ...@@ -319,7 +319,8 @@ static char *arc_extn_mumbojumbo(int cpu_id, char *buf, int len)
static void arc_chk_core_config(void) static void arc_chk_core_config(void)
{ {
struct cpuinfo_arc *cpu = &cpuinfo_arc700[smp_processor_id()]; struct cpuinfo_arc *cpu = &cpuinfo_arc700[smp_processor_id()];
int fpu_enabled; int saved = 0, present = 0;
char *opt_nm = NULL;;
if (!cpu->extn.timer0) if (!cpu->extn.timer0)
panic("Timer0 is not present!\n"); panic("Timer0 is not present!\n");
...@@ -346,17 +347,28 @@ static void arc_chk_core_config(void) ...@@ -346,17 +347,28 @@ static void arc_chk_core_config(void)
/* /*
* FP hardware/software config sanity * FP hardware/software config sanity
* -If hardware contains DPFP, kernel needs to save/restore FPU state * -If hardware present, kernel needs to save/restore FPU state
* -If not, it will crash trying to save/restore the non-existant regs * -If not, it will crash trying to save/restore the non-existant regs
*
* (only DPDP checked since SP has no arch visible regs)
*/ */
fpu_enabled = IS_ENABLED(CONFIG_ARC_FPU_SAVE_RESTORE);
if (cpu->extn.fpu_dp && !fpu_enabled) if (is_isa_arcompact()) {
pr_warn("CONFIG_ARC_FPU_SAVE_RESTORE needed for working apps\n"); opt_nm = "CONFIG_ARC_FPU_SAVE_RESTORE";
else if (!cpu->extn.fpu_dp && fpu_enabled) saved = IS_ENABLED(CONFIG_ARC_FPU_SAVE_RESTORE);
panic("FPU non-existent, disable CONFIG_ARC_FPU_SAVE_RESTORE\n");
/* only DPDP checked since SP has no arch visible regs */
present = cpu->extn.fpu_dp;
} else {
opt_nm = "CONFIG_ARC_HAS_ACCL_REGS";
saved = IS_ENABLED(CONFIG_ARC_HAS_ACCL_REGS);
/* Accumulator Low:High pair (r58:59) present if DSP MPY or FPU */
present = cpu->extn_mpy.dsp | cpu->extn.fpu_sp | cpu->extn.fpu_dp;
}
if (present && !saved)
pr_warn("Enable %s for working apps\n", opt_nm);
else if (!present && saved)
panic("Disable %s, hardware NOT present\n", opt_nm);
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment