xtensa: clean up printk usage for boot/crash logging
authorMax Filippov <jcmvbkbc@gmail.com>
Fri, 4 Nov 2016 21:45:08 +0000 (14:45 -0700)
committerMax Filippov <jcmvbkbc@gmail.com>
Mon, 7 Nov 2016 07:31:46 +0000 (23:31 -0800)
Convert printk(KERN_* to pr_* and printk's without level to pr_cont.
This fixes torn register dumps, stack dumps, stack traces and timestamps
in the middle of 'Calibrating CPU frequency' message.
Also drop unused show_code and drop false comment about show_stack.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
arch/xtensa/kernel/time.c
arch/xtensa/kernel/traps.c

index 9a5bcd0381a71e987b29499d194061af8a1b2d22..be81e69b25bc98e46514c46e4a5a030afb87ecca 100644 (file)
@@ -172,10 +172,11 @@ void __init time_init(void)
 {
        of_clk_init(NULL);
 #ifdef CONFIG_XTENSA_CALIBRATE_CCOUNT
-       printk("Calibrating CPU frequency ");
+       pr_info("Calibrating CPU frequency ");
        calibrate_ccount();
-       printk("%d.%02d MHz\n", (int)ccount_freq/1000000,
-                       (int)(ccount_freq/10000)%100);
+       pr_cont("%d.%02d MHz\n",
+               (int)ccount_freq / 1000000,
+               (int)(ccount_freq / 10000) % 100);
 #else
        ccount_freq = CONFIG_XTENSA_CPU_CLOCK*1000000UL;
 #endif
@@ -210,9 +211,8 @@ irqreturn_t timer_interrupt(int irq, void *dev_id)
 void calibrate_delay(void)
 {
        loops_per_jiffy = ccount_freq / HZ;
-       printk("Calibrating delay loop (skipped)... "
-              "%lu.%02lu BogoMIPS preset\n",
-              loops_per_jiffy/(1000000/HZ),
-              (loops_per_jiffy/(10000/HZ)) % 100);
+       pr_info("Calibrating delay loop (skipped)... %lu.%02lu BogoMIPS preset\n",
+               loops_per_jiffy / (1000000 / HZ),
+               (loops_per_jiffy / (10000 / HZ)) % 100);
 }
 #endif
index d02fc304b31c10ea9019172b8fd15d8aaea41bdc..ce37d5b899fead50d312f06ed3c3f3982309d294 100644 (file)
@@ -465,26 +465,25 @@ void show_regs(struct pt_regs * regs)
 
        for (i = 0; i < 16; i++) {
                if ((i % 8) == 0)
-                       printk(KERN_INFO "a%02d:", i);
-               printk(KERN_CONT " %08lx", regs->areg[i]);
+                       pr_info("a%02d:", i);
+               pr_cont(" %08lx", regs->areg[i]);
        }
-       printk(KERN_CONT "\n");
-
-       printk("pc: %08lx, ps: %08lx, depc: %08lx, excvaddr: %08lx\n",
-              regs->pc, regs->ps, regs->depc, regs->excvaddr);
-       printk("lbeg: %08lx, lend: %08lx lcount: %08lx, sar: %08lx\n",
-              regs->lbeg, regs->lend, regs->lcount, regs->sar);
+       pr_cont("\n");
+       pr_info("pc: %08lx, ps: %08lx, depc: %08lx, excvaddr: %08lx\n",
+               regs->pc, regs->ps, regs->depc, regs->excvaddr);
+       pr_info("lbeg: %08lx, lend: %08lx lcount: %08lx, sar: %08lx\n",
+               regs->lbeg, regs->lend, regs->lcount, regs->sar);
        if (user_mode(regs))
-               printk("wb: %08lx, ws: %08lx, wmask: %08lx, syscall: %ld\n",
-                      regs->windowbase, regs->windowstart, regs->wmask,
-                      regs->syscall);
+               pr_cont("wb: %08lx, ws: %08lx, wmask: %08lx, syscall: %ld\n",
+                       regs->windowbase, regs->windowstart, regs->wmask,
+                       regs->syscall);
 }
 
 static int show_trace_cb(struct stackframe *frame, void *data)
 {
        if (kernel_text_address(frame->pc)) {
-               printk(" [<%08lx>] ", frame->pc);
-               print_symbol("%s\n", frame->pc);
+               pr_cont(" [<%08lx>]", frame->pc);
+               print_symbol(" %s\n", frame->pc);
        }
        return 0;
 }
@@ -494,19 +493,13 @@ void show_trace(struct task_struct *task, unsigned long *sp)
        if (!sp)
                sp = stack_pointer(task);
 
-       printk("Call Trace:");
-#ifdef CONFIG_KALLSYMS
-       printk("\n");
-#endif
+       pr_info("Call Trace:\n");
        walk_stackframe(sp, show_trace_cb, NULL);
-       printk("\n");
+#ifndef CONFIG_KALLSYMS
+       pr_cont("\n");
+#endif
 }
 
-/*
- * This routine abuses get_user()/put_user() to reference pointers
- * with at least a bit of error checking ...
- */
-
 static int kstack_depth_to_print = 24;
 
 void show_stack(struct task_struct *task, unsigned long *sp)
@@ -518,52 +511,29 @@ void show_stack(struct task_struct *task, unsigned long *sp)
                sp = stack_pointer(task);
        stack = sp;
 
-       printk("\nStack: ");
+       pr_info("Stack:\n");
 
        for (i = 0; i < kstack_depth_to_print; i++) {
                if (kstack_end(sp))
                        break;
-               if (i && ((i % 8) == 0))
-                       printk("\n       ");
-               printk("%08lx ", *sp++);
+               pr_cont(" %08lx", *sp++);
+               if (i % 8 == 7)
+                       pr_cont("\n");
        }
-       printk("\n");
        show_trace(task, stack);
 }
 
-void show_code(unsigned int *pc)
-{
-       long i;
-
-       printk("\nCode:");
-
-       for(i = -3 ; i < 6 ; i++) {
-               unsigned long insn;
-               if (__get_user(insn, pc + i)) {
-                       printk(" (Bad address in pc)\n");
-                       break;
-               }
-               printk("%c%08lx%c",(i?' ':'<'),insn,(i?' ':'>'));
-       }
-}
-
 DEFINE_SPINLOCK(die_lock);
 
 void die(const char * str, struct pt_regs * regs, long err)
 {
        static int die_counter;
-       int nl = 0;
 
        console_verbose();
        spin_lock_irq(&die_lock);
 
-       printk("%s: sig: %ld [#%d]\n", str, err, ++die_counter);
-#ifdef CONFIG_PREEMPT
-       printk("PREEMPT ");
-       nl = 1;
-#endif
-       if (nl)
-               printk("\n");
+       pr_info("%s: sig: %ld [#%d]%s\n", str, err, ++die_counter,
+               IS_ENABLED(CONFIG_PREEMPT) ? " PREEMPT" : "");
        show_regs(regs);
        if (!user_mode(regs))
                show_stack(NULL, (unsigned long*)regs->areg[1]);