Skip to content

Commit ea839b4

Browse files
committed
Merge tag 'arc-4.11-final' of git://git.kernel.org/pub/scm/linux/kernel/git/vgupta/arc
Pull ARC fix from Vineet Gupta: "Last minute fixes for ARC: - build error in Mellanox nps platform - addressing lack of saving FPU regs in releavnt configs" * tag 'arc-4.11-final' of git://git.kernel.org/pub/scm/linux/kernel/git/vgupta/arc: ARCv2: entry: save Accumulator register pair (r58:59) if present ARC: [plat-eznps] Fix build error
2 parents 8f9cedc + 3d5e801 commit ea839b4

File tree

5 files changed

+45
-10
lines changed

5 files changed

+45
-10
lines changed

arch/arc/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,14 @@ config ARC_HAS_DIV_REM
406406
bool "Insn: div, divu, rem, remu"
407407
default y
408408

409+
config 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+
409417
endif # ISA_ARCV2
410418

411419
endmenu # "ARC CPU Configuration"

arch/arc/include/asm/atomic.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@
1717
#include <asm/barrier.h>
1818
#include <asm/smp.h>
1919

20+
#define ATOMIC_INIT(i) { (i) }
21+
2022
#ifndef CONFIG_ARC_PLAT_EZNPS
2123

2224
#define atomic_read(v) READ_ONCE((v)->counter)
23-
#define ATOMIC_INIT(i) { (i) }
2425

2526
#ifdef CONFIG_ARC_HAS_LLSC
2627

arch/arc/include/asm/entry-arcv2.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
;
1717
; Now manually save: r12, sp, fp, gp, r25
1818

19+
#ifdef CONFIG_ARC_HAS_ACCL_REGS
20+
PUSH r59
21+
PUSH r58
22+
#endif
23+
1924
PUSH r30
2025
PUSH r12
2126

@@ -75,6 +80,11 @@
7580
POP r12
7681
POP r30
7782

83+
#ifdef CONFIG_ARC_HAS_ACCL_REGS
84+
POP r58
85+
POP r59
86+
#endif
87+
7888
.endm
7989

8090
/*------------------------------------------------------------------------*/

arch/arc/include/asm/ptrace.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ struct pt_regs {
8686

8787
unsigned long r12, r30;
8888

89+
#ifdef CONFIG_ARC_HAS_ACCL_REGS
90+
unsigned long r58, r59; /* ACCL/ACCH used by FPU / DSP MPY */
91+
#endif
92+
8993
/*------- Below list auto saved by h/w -----------*/
9094
unsigned long r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11;
9195

arch/arc/kernel/setup.c

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,8 @@ static char *arc_extn_mumbojumbo(int cpu_id, char *buf, int len)
319319
static void arc_chk_core_config(void)
320320
{
321321
struct cpuinfo_arc *cpu = &cpuinfo_arc700[smp_processor_id()];
322-
int fpu_enabled;
322+
int saved = 0, present = 0;
323+
char *opt_nm = NULL;;
323324

324325
if (!cpu->extn.timer0)
325326
panic("Timer0 is not present!\n");
@@ -346,17 +347,28 @@ static void arc_chk_core_config(void)
346347

347348
/*
348349
* 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
350351
* -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)
353352
*/
354-
fpu_enabled = IS_ENABLED(CONFIG_ARC_FPU_SAVE_RESTORE);
355353

356-
if (cpu->extn.fpu_dp && !fpu_enabled)
357-
pr_warn("CONFIG_ARC_FPU_SAVE_RESTORE needed for working apps\n");
358-
else if (!cpu->extn.fpu_dp && fpu_enabled)
359-
panic("FPU non-existent, disable CONFIG_ARC_FPU_SAVE_RESTORE\n");
354+
if (is_isa_arcompact()) {
355+
opt_nm = "CONFIG_ARC_FPU_SAVE_RESTORE";
356+
saved = IS_ENABLED(CONFIG_ARC_FPU_SAVE_RESTORE);
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);
360372
}
361373

362374
/*

0 commit comments

Comments
 (0)