dump_stack: unify debug information printed by show_regs()
[linux-3.10.git] / arch / blackfin / kernel / trace.c
index 317d427..c36efa0 100644 (file)
 #include <linux/hardirq.h>
 #include <linux/thread_info.h>
 #include <linux/mm.h>
+#include <linux/oom.h>
+#include <linux/sched.h>
 #include <linux/uaccess.h>
 #include <linux/module.h>
 #include <linux/kallsyms.h>
 #include <linux/err.h>
 #include <linux/fs.h>
+#include <linux/irq.h>
 #include <asm/dma.h>
 #include <asm/trace.h>
 #include <asm/fixed_code.h>
 #include <asm/traps.h>
 #include <asm/irq_handler.h>
+#include <asm/pda.h>
 
 void decode_address(char *buf, unsigned long address)
 {
        struct task_struct *p;
        struct mm_struct *mm;
-       unsigned long flags, offset;
-       unsigned char in_atomic = (bfin_read_IPEND() & 0x10) || in_atomic();
+       unsigned long offset;
        struct rb_node *n;
 
 #ifdef CONFIG_KALLSYMS
@@ -110,17 +113,17 @@ void decode_address(char *buf, unsigned long address)
         * mappings of all our processes and see if we can't be a whee
         * bit more specific
         */
-       write_lock_irqsave(&tasklist_lock, flags);
+       read_lock(&tasklist_lock);
        for_each_process(p) {
-               mm = (in_atomic ? p->mm : get_task_mm(p));
-               if (!mm)
-                       continue;
+               struct task_struct *t;
 
-               if (!down_read_trylock(&mm->mmap_sem)) {
-                       if (!in_atomic)
-                               mmput(mm);
+               t = find_lock_task_mm(p);
+               if (!t)
                        continue;
-               }
+
+               mm = t->mm;
+               if (!down_read_trylock(&mm->mmap_sem))
+                       goto __continue;
 
                for (n = rb_first(&mm->mm_rb); n; n = rb_next(n)) {
                        struct vm_area_struct *vma;
@@ -129,7 +132,7 @@ void decode_address(char *buf, unsigned long address)
 
                        if (address >= vma->vm_start && address < vma->vm_end) {
                                char _tmpbuf[256];
-                               char *name = p->comm;
+                               char *name = t->comm;
                                struct file *file = vma->vm_file;
 
                                if (file) {
@@ -162,8 +165,7 @@ void decode_address(char *buf, unsigned long address)
                                                name, vma->vm_start, vma->vm_end);
 
                                up_read(&mm->mmap_sem);
-                               if (!in_atomic)
-                                       mmput(mm);
+                               task_unlock(t);
 
                                if (buf[0] == '\0')
                                        sprintf(buf, "[ %s ] dynamic memory", name);
@@ -173,8 +175,8 @@ void decode_address(char *buf, unsigned long address)
                }
 
                up_read(&mm->mmap_sem);
-               if (!in_atomic)
-                       mmput(mm);
+__continue:
+               task_unlock(t);
        }
 
        /*
@@ -184,7 +186,7 @@ void decode_address(char *buf, unsigned long address)
        sprintf(buf, "/* kernel dynamic memory */");
 
 done:
-       write_unlock_irqrestore(&tasklist_lock, flags);
+       read_unlock(&tasklist_lock);
 }
 
 #define EXPAND_LEN ((1 << CONFIG_DEBUG_BFIN_HWTRACE_EXPAND_LEN) * 256 - 1)
@@ -672,6 +674,15 @@ void dump_bfin_trace_buffer(void)
                         * the trace buffer, (since it doesn't commit), so
                         * we print out the fault address here
                         */
+                       if (!fault && addr == ((unsigned short *)evt_ivhw)) {
+                               addr = (unsigned short *)bfin_read_TBUF();
+                               decode_address(buf, (unsigned long)addr);
+                               pr_notice("      FAULT : %s ", buf);
+                               decode_instruction(addr);
+                               pr_cont("\n");
+                               fault = 1;
+                               continue;
+                       }
                        if (!fault && addr == (unsigned short *)trap &&
                                (cpu_pda[cpu].seqstat & SEQSTAT_EXCAUSE) > VEC_EXCPT15) {
                                decode_address(buf, cpu_pda[cpu].icplb_fault_addr);
@@ -842,6 +853,8 @@ void show_regs(struct pt_regs *fp)
        unsigned char in_atomic = (bfin_read_IPEND() & 0x10) || in_atomic();
 
        pr_notice("\n");
+       show_regs_print_info(KERN_NOTICE);
+
        if (CPUID != bfin_cpuid())
                pr_notice("Compiled for cpu family 0x%04x (Rev %d), "
                        "but running on:0x%04x (Rev %d)\n",
@@ -902,10 +915,11 @@ void show_regs(struct pt_regs *fp)
        /* if no interrupts are going off, don't print this out */
        if (fp->ipend & ~0x3F) {
                for (i = 0; i < (NR_IRQS - 1); i++) {
+                       struct irq_desc *desc = irq_to_desc(i);
                        if (!in_atomic)
-                               raw_spin_lock_irqsave(&irq_desc[i].lock, flags);
+                               raw_spin_lock_irqsave(&desc->lock, flags);
 
-                       action = irq_desc[i].action;
+                       action = desc->action;
                        if (!action)
                                goto unlock;
 
@@ -918,7 +932,7 @@ void show_regs(struct pt_regs *fp)
                        pr_cont("\n");
 unlock:
                        if (!in_atomic)
-                               raw_spin_unlock_irqrestore(&irq_desc[i].lock, flags);
+                               raw_spin_unlock_irqrestore(&desc->lock, flags);
                }
        }