spi: efm32: Convert to use GPIO descriptors
[linux/fpc-iii.git] / arch / csky / kernel / stacktrace.c
blobfec777a643f13d38b419899d9abe6a6daab52300
1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd. */
4 #include <linux/sched/debug.h>
5 #include <linux/sched/task_stack.h>
6 #include <linux/stacktrace.h>
7 #include <linux/ftrace.h>
9 void save_stack_trace(struct stack_trace *trace)
11 save_stack_trace_tsk(current, trace);
13 EXPORT_SYMBOL_GPL(save_stack_trace);
15 void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
17 unsigned long *fp, *stack_start, *stack_end;
18 unsigned long addr;
19 int skip = trace->skip;
20 int savesched;
21 int graph_idx = 0;
23 if (tsk == current) {
24 asm volatile("mov %0, r8\n":"=r"(fp));
25 savesched = 1;
26 } else {
27 fp = (unsigned long *)thread_saved_fp(tsk);
28 savesched = 0;
31 addr = (unsigned long) fp & THREAD_MASK;
32 stack_start = (unsigned long *) addr;
33 stack_end = (unsigned long *) (addr + THREAD_SIZE);
35 while (fp > stack_start && fp < stack_end) {
36 unsigned long lpp, fpp;
38 fpp = fp[0];
39 lpp = fp[1];
40 if (!__kernel_text_address(lpp))
41 break;
42 else
43 lpp = ftrace_graph_ret_addr(tsk, &graph_idx, lpp, NULL);
45 if (savesched || !in_sched_functions(lpp)) {
46 if (skip) {
47 skip--;
48 } else {
49 trace->entries[trace->nr_entries++] = lpp;
50 if (trace->nr_entries >= trace->max_entries)
51 break;
54 fp = (unsigned long *)fpp;
57 EXPORT_SYMBOL_GPL(save_stack_trace_tsk);