forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 748e4f3d702def1a4bff191e0cf93b6a05340f01
kernel/arch/microblaze/kernel/unwind.c
....@@ -154,7 +154,8 @@
154154 static void microblaze_unwind_inner(struct task_struct *task,
155155 unsigned long pc, unsigned long fp,
156156 unsigned long leaf_return,
157
- struct stack_trace *trace);
157
+ struct stack_trace *trace,
158
+ const char *loglvl);
158159
159160 /**
160161 * unwind_trap - Unwind through a system trap, that stored previous state
....@@ -162,16 +163,18 @@
162163 */
163164 #ifdef CONFIG_MMU
164165 static inline void unwind_trap(struct task_struct *task, unsigned long pc,
165
- unsigned long fp, struct stack_trace *trace)
166
+ unsigned long fp, struct stack_trace *trace,
167
+ const char *loglvl)
166168 {
167169 /* To be implemented */
168170 }
169171 #else
170172 static inline void unwind_trap(struct task_struct *task, unsigned long pc,
171
- unsigned long fp, struct stack_trace *trace)
173
+ unsigned long fp, struct stack_trace *trace,
174
+ const char *loglvl)
172175 {
173176 const struct pt_regs *regs = (const struct pt_regs *) fp;
174
- microblaze_unwind_inner(task, regs->pc, regs->r1, regs->r15, trace);
177
+ microblaze_unwind_inner(task, regs->pc, regs->r1, regs->r15, trace, loglvl);
175178 }
176179 #endif
177180
....@@ -184,11 +187,13 @@
184187 * the caller's return address.
185188 * @trace : Where to store stack backtrace (PC values).
186189 * NULL == print backtrace to kernel log
190
+ * @loglvl : Used for printk log level if (trace == NULL).
187191 */
188192 static void microblaze_unwind_inner(struct task_struct *task,
189193 unsigned long pc, unsigned long fp,
190194 unsigned long leaf_return,
191
- struct stack_trace *trace)
195
+ struct stack_trace *trace,
196
+ const char *loglvl)
192197 {
193198 int ofs = 0;
194199
....@@ -214,11 +219,11 @@
214219 const struct pt_regs *regs =
215220 (const struct pt_regs *) fp;
216221 #endif
217
- pr_info("HW EXCEPTION\n");
222
+ printk("%sHW EXCEPTION\n", loglvl);
218223 #ifndef CONFIG_MMU
219224 microblaze_unwind_inner(task, regs->r17 - 4,
220225 fp + EX_HANDLER_STACK_SIZ,
221
- regs->r15, trace);
226
+ regs->r15, trace, loglvl);
222227 #endif
223228 return;
224229 }
....@@ -228,8 +233,8 @@
228233 if ((return_to >= handler->start_addr)
229234 && (return_to <= handler->end_addr)) {
230235 if (!trace)
231
- pr_info("%s\n", handler->trap_name);
232
- unwind_trap(task, pc, fp, trace);
236
+ printk("%s%s\n", loglvl, handler->trap_name);
237
+ unwind_trap(task, pc, fp, trace, loglvl);
233238 return;
234239 }
235240 }
....@@ -248,13 +253,13 @@
248253 } else {
249254 /* Have we reached userland? */
250255 if (unlikely(pc == task_pt_regs(task)->pc)) {
251
- pr_info("[<%p>] PID %lu [%s]\n",
252
- (void *) pc,
256
+ printk("%s[<%p>] PID %lu [%s]\n",
257
+ loglvl, (void *) pc,
253258 (unsigned long) task->pid,
254259 task->comm);
255260 break;
256261 } else
257
- print_ip_sym(pc);
262
+ print_ip_sym(loglvl, pc);
258263 }
259264
260265 /* Stop when we reach anything not part of the kernel */
....@@ -282,14 +287,16 @@
282287 * @task : Task whose stack we are to unwind (NULL == current)
283288 * @trace : Where to store stack backtrace (PC values).
284289 * NULL == print backtrace to kernel log
290
+ * @loglvl : Used for printk log level if (trace == NULL).
285291 */
286
-void microblaze_unwind(struct task_struct *task, struct stack_trace *trace)
292
+void microblaze_unwind(struct task_struct *task, struct stack_trace *trace,
293
+ const char *loglvl)
287294 {
288295 if (task) {
289296 if (task == current) {
290297 const struct pt_regs *regs = task_pt_regs(task);
291298 microblaze_unwind_inner(task, regs->pc, regs->r1,
292
- regs->r15, trace);
299
+ regs->r15, trace, loglvl);
293300 } else {
294301 struct thread_info *thread_info =
295302 (struct thread_info *)(task->stack);
....@@ -299,7 +306,8 @@
299306 microblaze_unwind_inner(task,
300307 (unsigned long) &_switch_to,
301308 cpu_context->r1,
302
- cpu_context->r15, trace);
309
+ cpu_context->r15,
310
+ trace, loglvl);
303311 }
304312 } else {
305313 unsigned long pc, fp;
....@@ -314,7 +322,7 @@
314322 );
315323
316324 /* Since we are not a leaf function, use leaf_return = 0 */
317
- microblaze_unwind_inner(current, pc, fp, 0, trace);
325
+ microblaze_unwind_inner(current, pc, fp, 0, trace, loglvl);
318326 }
319327 }
320328