Skip to content

Commit

Permalink
Merge tag 'csky-for-linus-4.21' of git://github.com/c-sky/csky-linux
Browse files Browse the repository at this point in the history
Pull arch/csky updates from Guo Ren:
 "Here are three main features (cpu_hotplug, basic ftrace, basic perf)
  and some bugfixes:

  Features:
   - Add CPU-hotplug support for SMP
   - Add ftrace with function trace and function graph trace
   - Add Perf support
   - Add EM_CSKY_OLD 39
   - optimize kernel panic print.
   - remove syscall_exit_work

  Bugfixes:
   - fix abiv2 mmap(... O_SYNC) failure
   - fix gdb coredump error
   - remove vdsp implement for kernel
   - fix qemu failure to bootup sometimes
   - fix ftrace call-graph panic
   - fix device tree node reference leak
   - remove meaningless header-y
   - fix save hi,lo,dspcr regs in switch_stack
   - remove unused members in processor.h"

* tag 'csky-for-linus-4.21' of git://github.com/c-sky/csky-linux:
  csky: Add perf support for C-SKY
  csky: Add EM_CSKY_OLD 39
  clocksource/drivers/c-sky: fixup ftrace call-graph panic
  csky: ftrace call graph supported.
  csky: basic ftrace supported
  csky: remove unused members in processor.h
  csky: optimize kernel panic print.
  csky: stacktrace supported.
  csky: CPU-hotplug supported for SMP
  clocksource/drivers/c-sky: fixup qemu fail to bootup sometimes.
  csky: fixup save hi,lo,dspcr regs in switch_stack.
  csky: remove syscall_exit_work
  csky: fixup remove vdsp implement for kernel.
  csky: bugfix gdb coredump error.
  csky: fixup abiv2 mmap(... O_SYNC) failed.
  csky: define syscall_get_arch()
  elf-em.h: add EM_CSKY
  csky: remove meaningless header-y
  csky: Don't leak device tree node reference
  • Loading branch information
torvalds committed Jan 5, 2019
2 parents a659811 + f50fd2d commit 9ee3b3f
Show file tree
Hide file tree
Showing 36 changed files with 1,555 additions and 222 deletions.
30 changes: 29 additions & 1 deletion arch/csky/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@ config CSKY
select GENERIC_SCHED_CLOCK
select GENERIC_SMP_IDLE_THREAD
select HAVE_ARCH_TRACEHOOK
select HAVE_FUNCTION_TRACER
select HAVE_FUNCTION_GRAPH_TRACER
select HAVE_GENERIC_DMA_COHERENT
select HAVE_KERNEL_GZIP
select HAVE_KERNEL_LZO
select HAVE_KERNEL_LZMA
select HAVE_PERF_EVENTS
select HAVE_C_RECORDMCOUNT
select HAVE_DMA_API_DEBUG
select HAVE_DMA_CONTIGUOUS
Expand All @@ -40,7 +43,7 @@ config CSKY
select OF
select OF_EARLY_FLATTREE
select OF_RESERVED_MEM
select PERF_USE_VMALLOC
select PERF_USE_VMALLOC if CPU_CK610
select RTC_LIB
select TIMER_OF
select USB_ARCH_HAS_EHCI
Expand Down Expand Up @@ -93,6 +96,9 @@ config MMU
config RWSEM_GENERIC_SPINLOCK
def_bool y

config STACKTRACE_SUPPORT
def_bool y

config TIME_LOW_RES
def_bool y

Expand Down Expand Up @@ -144,6 +150,19 @@ config CPU_CK860
select CPU_HAS_FPUV2
endchoice

choice
prompt "C-SKY PMU type"
depends on PERF_EVENTS
depends on CPU_CK807 || CPU_CK810 || CPU_CK860

config CPU_PMU_NONE
bool "None"

config CSKY_PMU_V1
bool "Performance Monitoring Unit Ver.1"

endchoice

choice
prompt "Power Manager Instruction (wait/doze/stop)"
default CPU_PM_NONE
Expand Down Expand Up @@ -197,6 +216,15 @@ config RAM_BASE
hex "DRAM start addr (the same with memory-section in dts)"
default 0x0

config HOTPLUG_CPU
bool "Support for hot-pluggable CPUs"
select GENERIC_IRQ_MIGRATION
depends on SMP
help
Say Y here to allow turning CPUs off and on. CPUs can be
controlled through /sys/devices/system/cpu/cpu1/hotplug/target.

Say N if you want to disable CPU hotplug.
endmenu

source "kernel/Kconfig.hz"
4 changes: 4 additions & 0 deletions arch/csky/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ ifeq ($(CSKYABI),abiv2)
KBUILD_CFLAGS += -mno-stack-size
endif

ifdef CONFIG_STACKTRACE
KBUILD_CFLAGS += -mbacktrace
endif

abidirs := $(patsubst %,arch/csky/%/,$(CSKYABI))
KBUILD_CFLAGS += $(patsubst %,-I$(srctree)/%inc,$(abidirs))

Expand Down
1 change: 1 addition & 0 deletions arch/csky/abiv1/inc/abi/pgtable-bits.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#define _PAGE_CACHE (3<<9)
#define _PAGE_UNCACHE (2<<9)
#define _PAGE_SO _PAGE_UNCACHE

#define _CACHE_MASK (7<<9)

Expand Down
17 changes: 17 additions & 0 deletions arch/csky/abiv1/inc/abi/switch_context.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* SPDX-License-Identifier: GPL-2.0 */
// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.

#ifndef __ABI_CSKY_PTRACE_H
#define __ABI_CSKY_PTRACE_H

struct switch_stack {
unsigned long r8;
unsigned long r9;
unsigned long r10;
unsigned long r11;
unsigned long r12;
unsigned long r13;
unsigned long r14;
unsigned long r15;
};
#endif /* __ABI_CSKY_PTRACE_H */
1 change: 1 addition & 0 deletions arch/csky/abiv2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ obj-y += strcmp.o
obj-y += strcpy.o
obj-y += strlen.o
obj-y += strksyms.o
obj-$(CONFIG_FUNCTION_TRACER) += mcount.o
28 changes: 25 additions & 3 deletions arch/csky/abiv2/inc/abi/entry.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
stw lr, (sp, 60)
mflo lr
stw lr, (sp, 64)
mfcr lr, cr14
stw lr, (sp, 68)
#endif
subi sp, 80
.endm
Expand All @@ -77,6 +79,8 @@
mthi a0
ldw a0, (sp, 144)
mtlo a0
ldw a0, (sp, 148)
mtcr a0, cr14
#endif

ldw a0, (sp, 24)
Expand All @@ -93,21 +97,39 @@
.endm

.macro SAVE_SWITCH_STACK
subi sp, 64
subi sp, 64
stm r4-r11, (sp)
stw r15, (sp, 32)
stw lr, (sp, 32)
stw r16, (sp, 36)
stw r17, (sp, 40)
stw r26, (sp, 44)
stw r27, (sp, 48)
stw r28, (sp, 52)
stw r29, (sp, 56)
stw r30, (sp, 60)
#ifdef CONFIG_CPU_HAS_HILO
subi sp, 16
mfhi lr
stw lr, (sp, 0)
mflo lr
stw lr, (sp, 4)
mfcr lr, cr14
stw lr, (sp, 8)
#endif
.endm

.macro RESTORE_SWITCH_STACK
#ifdef CONFIG_CPU_HAS_HILO
ldw lr, (sp, 0)
mthi lr
ldw lr, (sp, 4)
mtlo lr
ldw lr, (sp, 8)
mtcr lr, cr14
addi sp, 16
#endif
ldm r4-r11, (sp)
ldw r15, (sp, 32)
ldw lr, (sp, 32)
ldw r16, (sp, 36)
ldw r17, (sp, 40)
ldw r26, (sp, 44)
Expand Down
2 changes: 1 addition & 1 deletion arch/csky/abiv2/inc/abi/pgtable-bits.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
#define _CACHE_MASK _PAGE_CACHE

#define _CACHE_CACHED (_PAGE_VALID | _PAGE_CACHE | _PAGE_BUF)
#define _CACHE_UNCACHED (_PAGE_VALID | _PAGE_SO)
#define _CACHE_UNCACHED (_PAGE_VALID)

#endif /* __ASM_CSKY_PGTABLE_BITS_H */
32 changes: 32 additions & 0 deletions arch/csky/abiv2/inc/abi/switch_context.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/* SPDX-License-Identifier: GPL-2.0 */
// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.

#ifndef __ABI_CSKY_PTRACE_H
#define __ABI_CSKY_PTRACE_H

struct switch_stack {
#ifdef CONFIG_CPU_HAS_HILO
unsigned long rhi;
unsigned long rlo;
unsigned long cr14;
unsigned long pad;
#endif
unsigned long r4;
unsigned long r5;
unsigned long r6;
unsigned long r7;
unsigned long r8;
unsigned long r9;
unsigned long r10;
unsigned long r11;

unsigned long r15;
unsigned long r16;
unsigned long r17;
unsigned long r26;
unsigned long r27;
unsigned long r28;
unsigned long r29;
unsigned long r30;
};
#endif /* __ABI_CSKY_PTRACE_H */
124 changes: 124 additions & 0 deletions arch/csky/abiv2/mcount.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
/* SPDX-License-Identifier: GPL-2.0 */
// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.

#include <linux/linkage.h>
#include <asm/ftrace.h>

/*
* csky-gcc with -pg will put the following asm after prologue:
* push r15
* jsri _mcount
*
* stack layout after mcount_enter in _mcount():
*
* current sp => 0:+-------+
* | a0-a3 | -> must save all argument regs
* +16:+-------+
* | lr | -> _mcount lr (instrumente function's pc)
* +20:+-------+
* | fp=r8 | -> instrumented function fp
* +24:+-------+
* | plr | -> instrumented function lr (parent's pc)
* +-------+
*/

.macro mcount_enter
subi sp, 24
stw a0, (sp, 0)
stw a1, (sp, 4)
stw a2, (sp, 8)
stw a3, (sp, 12)
stw lr, (sp, 16)
stw r8, (sp, 20)
.endm

.macro mcount_exit
ldw a0, (sp, 0)
ldw a1, (sp, 4)
ldw a2, (sp, 8)
ldw a3, (sp, 12)
ldw t1, (sp, 16)
ldw r8, (sp, 20)
ldw lr, (sp, 24)
addi sp, 28
jmp t1
.endm

.macro save_return_regs
subi sp, 16
stw a0, (sp, 0)
stw a1, (sp, 4)
stw a2, (sp, 8)
stw a3, (sp, 12)
.endm

.macro restore_return_regs
mov lr, a0
ldw a0, (sp, 0)
ldw a1, (sp, 4)
ldw a2, (sp, 8)
ldw a3, (sp, 12)
addi sp, 16
.endm

ENTRY(ftrace_stub)
jmp lr
END(ftrace_stub)

ENTRY(_mcount)
mcount_enter

/* r26 is link register, only used with jsri translation */
lrw r26, ftrace_trace_function
ldw r26, (r26, 0)
lrw a1, ftrace_stub
cmpne r26, a1
bf skip_ftrace

mov a0, lr
subi a0, MCOUNT_INSN_SIZE
ldw a1, (sp, 24)

jsr r26

#ifndef CONFIG_FUNCTION_GRAPH_TRACER
skip_ftrace:
mcount_exit
#else
skip_ftrace:
lrw a0, ftrace_graph_return
ldw a0, (a0, 0)
lrw a1, ftrace_stub
cmpne a0, a1
bt ftrace_graph_caller

lrw a0, ftrace_graph_entry
ldw a0, (a0, 0)
lrw a1, ftrace_graph_entry_stub
cmpne a0, a1
bt ftrace_graph_caller

mcount_exit
#endif
END(_mcount)

#ifdef CONFIG_FUNCTION_GRAPH_TRACER
ENTRY(ftrace_graph_caller)
mov a0, sp
addi a0, 24
ldw a1, (sp, 16)
subi a1, MCOUNT_INSN_SIZE
mov a2, r8
lrw r26, prepare_ftrace_return
jsr r26
mcount_exit
END(ftrace_graph_caller)

ENTRY(return_to_handler)
save_return_regs
mov a0, r8
jsri ftrace_return_to_handler
restore_return_regs
jmp lr
END(return_to_handler)
#endif
8 changes: 1 addition & 7 deletions arch/csky/abiv2/memcpy.S
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,7 @@ ENTRY(memcpy)

LABLE_ALIGN
.L_len_larger_16bytes:
#if defined(__CSKY_VDSPV2__)
vldx.8 vr0, (r1), r19
PRE_BNEZAD (r18)
addi r1, 16
vstx.8 vr0, (r0), r19
addi r0, 16
#elif defined(__CK860__)
#if defined(__CK860__)
ldw r3, (r1, 0)
stw r3, (r0, 0)
ldw r3, (r1, 4)
Expand Down
13 changes: 10 additions & 3 deletions arch/csky/include/asm/elf.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
#include <asm/ptrace.h>
#include <abi/regdef.h>

#define ELF_ARCH 252
#define ELF_ARCH EM_CSKY
#define EM_CSKY_OLD 39

/* CSKY Relocations */
#define R_CSKY_NONE 0
Expand All @@ -31,14 +32,20 @@ typedef unsigned long elf_greg_t;

typedef struct user_fp elf_fpregset_t;

#define ELF_NGREG (sizeof(struct pt_regs) / sizeof(elf_greg_t))
/*
* In gdb/bfd elf32-csky.c, csky_elf_grok_prstatus() use fixed size of
* elf_prstatus. It's 148 for abiv1 and 220 for abiv2, the size is enough
* for coredump and no need full sizeof(struct pt_regs).
*/
#define ELF_NGREG ((sizeof(struct pt_regs) / sizeof(elf_greg_t)) - 2)

typedef elf_greg_t elf_gregset_t[ELF_NGREG];

/*
* This is used to ensure we don't load something for the wrong architecture.
*/
#define elf_check_arch(x) ((x)->e_machine == ELF_ARCH)
#define elf_check_arch(x) (((x)->e_machine == ELF_ARCH) || \
((x)->e_machine == EM_CSKY_OLD))

/*
* These are used to set parameters in the core dumps.
Expand Down
13 changes: 13 additions & 0 deletions arch/csky/include/asm/ftrace.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* SPDX-License-Identifier: GPL-2.0 */
// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.

#ifndef __ASM_CSKY_FTRACE_H
#define __ASM_CSKY_FTRACE_H

#define MCOUNT_INSN_SIZE 4

#define HAVE_FUNCTION_GRAPH_FP_TEST

#define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR

#endif /* __ASM_CSKY_FTRACE_H */
Loading

0 comments on commit 9ee3b3f

Please sign in to comment.