clk: samsung: Add bus clock for GPU/G3D on Exynos4412
[linux/fpc-iii.git] / arch / sh / kernel / dumpstack.c
blob9f1c9c11d62df46a8e7ace2f54663f0e076e799b
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Copyright (C) 1991, 1992 Linus Torvalds
4 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
5 * Copyright (C) 2009 Matt Fleming
6 * Copyright (C) 2002 - 2012 Paul Mundt
7 */
8 #include <linux/kallsyms.h>
9 #include <linux/ftrace.h>
10 #include <linux/debug_locks.h>
11 #include <linux/sched/debug.h>
12 #include <linux/sched/task_stack.h>
13 #include <linux/kdebug.h>
14 #include <linux/export.h>
15 #include <linux/uaccess.h>
16 #include <asm/unwinder.h>
17 #include <asm/stacktrace.h>
19 void dump_mem(const char *str, unsigned long bottom, unsigned long top)
21 unsigned long p;
22 int i;
24 printk("%s(0x%08lx to 0x%08lx)\n", str, bottom, top);
26 for (p = bottom & ~31; p < top; ) {
27 printk("%04lx: ", p & 0xffff);
29 for (i = 0; i < 8; i++, p += 4) {
30 unsigned int val;
32 if (p < bottom || p >= top)
33 printk(" ");
34 else {
35 if (__get_user(val, (unsigned int __user *)p)) {
36 printk("\n");
37 return;
39 printk("%08x ", val);
42 printk("\n");
46 void printk_address(unsigned long address, int reliable)
48 printk(" [<%p>] %s%pS\n", (void *) address,
49 reliable ? "" : "? ", (void *) address);
52 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
53 static void
54 print_ftrace_graph_addr(unsigned long addr, void *data,
55 const struct stacktrace_ops *ops,
56 struct thread_info *tinfo, int *graph)
58 struct task_struct *task = tinfo->task;
59 struct ftrace_ret_stack *ret_stack;
60 unsigned long ret_addr;
62 if (addr != (unsigned long)return_to_handler)
63 return;
65 if (!task->ret_stack)
66 return;
68 ret_stack = ftrace_graph_get_ret_stack(task, *graph);
69 if (!ret_stack)
70 return;
72 ret_addr = ret_stack->ret;
74 ops->address(data, ret_addr, 1);
76 (*graph)++;
78 #else
79 static inline void
80 print_ftrace_graph_addr(unsigned long addr, void *data,
81 const struct stacktrace_ops *ops,
82 struct thread_info *tinfo, int *graph)
83 { }
84 #endif
86 void
87 stack_reader_dump(struct task_struct *task, struct pt_regs *regs,
88 unsigned long *sp, const struct stacktrace_ops *ops,
89 void *data)
91 struct thread_info *context;
92 int graph = 0;
94 context = (struct thread_info *)
95 ((unsigned long)sp & (~(THREAD_SIZE - 1)));
97 while (!kstack_end(sp)) {
98 unsigned long addr = *sp++;
100 if (__kernel_text_address(addr)) {
101 ops->address(data, addr, 1);
103 print_ftrace_graph_addr(addr, data, ops,
104 context, &graph);
109 static int print_trace_stack(void *data, char *name)
111 printk("%s <%s> ", (char *)data, name);
112 return 0;
116 * Print one address/symbol entries per line.
118 static void print_trace_address(void *data, unsigned long addr, int reliable)
120 printk("%s", (char *)data);
121 printk_address(addr, reliable);
124 static const struct stacktrace_ops print_trace_ops = {
125 .stack = print_trace_stack,
126 .address = print_trace_address,
129 void show_trace(struct task_struct *tsk, unsigned long *sp,
130 struct pt_regs *regs)
132 if (regs && user_mode(regs))
133 return;
135 printk("\nCall trace:\n");
137 unwind_stack(tsk, regs, sp, &print_trace_ops, "");
139 printk("\n");
141 if (!tsk)
142 tsk = current;
144 debug_show_held_locks(tsk);
147 void show_stack(struct task_struct *tsk, unsigned long *sp)
149 unsigned long stack;
151 if (!tsk)
152 tsk = current;
153 if (tsk == current)
154 sp = (unsigned long *)current_stack_pointer;
155 else
156 sp = (unsigned long *)tsk->thread.sp;
158 stack = (unsigned long)sp;
159 dump_mem("Stack: ", stack, THREAD_SIZE +
160 (unsigned long)task_stack_page(tsk));
161 show_trace(tsk, sp, NULL);