aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVineet Gupta <vgupta@synopsys.com>2017-04-20 18:36:51 -0400
committerVineet Gupta <vgupta@synopsys.com>2017-04-20 18:37:49 -0400
commit3d5e80125a6e5649c6bdad8d5780e39ea422c67d (patch)
tree5db65bfac17a6dbbff36d055b0292e9addeb8d90
parent6492f09e864417d382e22b922ae30693a7ce2982 (diff)
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: Vineet Gupta <vgupta@synopsys.com>
-rw-r--r--arch/arc/Kconfig8
-rw-r--r--arch/arc/include/asm/entry-arcv2.h10
-rw-r--r--arch/arc/include/asm/ptrace.h4
-rw-r--r--arch/arc/kernel/setup.c30
4 files changed, 43 insertions, 9 deletions
diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index c9f30f4763ab..5d7fb3e7cb97 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -406,6 +406,14 @@ config ARC_HAS_DIV_REM
406 bool "Insn: div, divu, rem, remu" 406 bool "Insn: div, divu, rem, remu"
407 default y 407 default y
408 408
409config ARC_HAS_ACCL_REGS
410 bool "Reg Pair ACCL:ACCH (FPU and/or MPY > 6)"
411 default n
412 help
413 Depending on the configuration, CPU can contain accumulator reg-pair
414 (also referred to as r58:r59). These can also be used by gcc as GPR so
415 kernel needs to save/restore per process
416
409endif # ISA_ARCV2 417endif # ISA_ARCV2
410 418
411endmenu # "ARC CPU Configuration" 419endmenu # "ARC CPU Configuration"
diff --git a/arch/arc/include/asm/entry-arcv2.h b/arch/arc/include/asm/entry-arcv2.h
index aee1a77934cf..ac85380d14a4 100644
--- a/arch/arc/include/asm/entry-arcv2.h
+++ b/arch/arc/include/asm/entry-arcv2.h
@@ -16,6 +16,11 @@
16 ; 16 ;
17 ; Now manually save: r12, sp, fp, gp, r25 17 ; Now manually save: r12, sp, fp, gp, r25
18 18
19#ifdef CONFIG_ARC_HAS_ACCL_REGS
20 PUSH r59
21 PUSH r58
22#endif
23
19 PUSH r30 24 PUSH r30
20 PUSH r12 25 PUSH r12
21 26
@@ -75,6 +80,11 @@
75 POP r12 80 POP r12
76 POP r30 81 POP r30
77 82
83#ifdef CONFIG_ARC_HAS_ACCL_REGS
84 POP r58
85 POP r59
86#endif
87
78.endm 88.endm
79 89
80/*------------------------------------------------------------------------*/ 90/*------------------------------------------------------------------------*/
diff --git a/arch/arc/include/asm/ptrace.h b/arch/arc/include/asm/ptrace.h
index 47111d565a95..5297faa8a378 100644
--- a/arch/arc/include/asm/ptrace.h
+++ b/arch/arc/include/asm/ptrace.h
@@ -86,6 +86,10 @@ struct pt_regs {
86 86
87 unsigned long r12, r30; 87 unsigned long r12, r30;
88 88
89#ifdef CONFIG_ARC_HAS_ACCL_REGS
90 unsigned long r58, r59; /* ACCL/ACCH used by FPU / DSP MPY */
91#endif
92
89 /*------- Below list auto saved by h/w -----------*/ 93 /*------- Below list auto saved by h/w -----------*/
90 unsigned long r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11; 94 unsigned long r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11;
91 95
diff --git a/arch/arc/kernel/setup.c b/arch/arc/kernel/setup.c
index fa62404ba58f..fc8211f338ad 100644
--- a/arch/arc/kernel/setup.c
+++ b/arch/arc/kernel/setup.c
@@ -319,7 +319,8 @@ static char *arc_extn_mumbojumbo(int cpu_id, char *buf, int len)
319static void arc_chk_core_config(void) 319static void arc_chk_core_config(void)
320{ 320{
321 struct cpuinfo_arc *cpu = &cpuinfo_arc700[smp_processor_id()]; 321 struct cpuinfo_arc *cpu = &cpuinfo_arc700[smp_processor_id()];
322 int fpu_enabled; 322 int saved = 0, present = 0;
323 char *opt_nm = NULL;;
323 324
324 if (!cpu->extn.timer0) 325 if (!cpu->extn.timer0)
325 panic("Timer0 is not present!\n"); 326 panic("Timer0 is not present!\n");
@@ -346,17 +347,28 @@ static void arc_chk_core_config(void)
346 347
347 /* 348 /*
348 * FP hardware/software config sanity 349 * FP hardware/software config sanity
349 * -If hardware contains DPFP, kernel needs to save/restore FPU state 350 * -If hardware present, kernel needs to save/restore FPU state
350 * -If not, it will crash trying to save/restore the non-existant regs 351 * -If not, it will crash trying to save/restore the non-existant regs
351 *
352 * (only DPDP checked since SP has no arch visible regs)
353 */ 352 */
354 fpu_enabled = IS_ENABLED(CONFIG_ARC_FPU_SAVE_RESTORE);
355 353
356 if (cpu->extn.fpu_dp && !fpu_enabled) 354 if (is_isa_arcompact()) {
357 pr_warn("CONFIG_ARC_FPU_SAVE_RESTORE needed for working apps\n"); 355 opt_nm = "CONFIG_ARC_FPU_SAVE_RESTORE";
358 else if (!cpu->extn.fpu_dp && fpu_enabled) 356 saved = IS_ENABLED(CONFIG_ARC_FPU_SAVE_RESTORE);
359 panic("FPU non-existent, disable CONFIG_ARC_FPU_SAVE_RESTORE\n"); 357
358 /* only DPDP checked since SP has no arch visible regs */
359 present = cpu->extn.fpu_dp;
360 } else {
361 opt_nm = "CONFIG_ARC_HAS_ACCL_REGS";
362 saved = IS_ENABLED(CONFIG_ARC_HAS_ACCL_REGS);
363
364 /* Accumulator Low:High pair (r58:59) present if DSP MPY or FPU */
365 present = cpu->extn_mpy.dsp | cpu->extn.fpu_sp | cpu->extn.fpu_dp;
366 }
367
368 if (present && !saved)
369 pr_warn("Enable %s for working apps\n", opt_nm);
370 else if (!present && saved)
371 panic("Disable %s, hardware NOT present\n", opt_nm);
360} 372}
361 373
362/* 374/*