Merge branch 'drm-patches' of git://git.kernel.org/pub/scm/linux/kernel/git/airlied...
[sfrench/cifs-2.6.git] / arch / s390 / kernel / debug.c
index 960ba6029c3a00c0f77727519450b3591278a272..06a3fbc12536d8a3dc49386e579db46b1ae1c592 100644 (file)
@@ -62,7 +62,7 @@ typedef struct
 } debug_sprintf_entry_t;
 
 
-extern void tod_to_timeval(uint64_t todval, struct timeval *xtime);
+extern void tod_to_timeval(uint64_t todval, struct timespec *xtime);
 
 /* internal function prototyes */
 
@@ -204,16 +204,13 @@ debug_areas_alloc(int pages_per_area, int nr_areas)
                        goto fail_malloc_areas2;
                }
                for(j = 0; j < pages_per_area; j++) {
-                       areas[i][j] = (debug_entry_t*)kmalloc(PAGE_SIZE,
-                                               GFP_KERNEL);
+                       areas[i][j] = kzalloc(PAGE_SIZE, GFP_KERNEL);
                        if(!areas[i][j]) {
                                for(j--; j >=0 ; j--) {
                                        kfree(areas[i][j]);
                                }
                                kfree(areas[i]);
                                goto fail_malloc_areas2;
-                       } else {
-                               memset(areas[i][j],0,PAGE_SIZE);
                        }
                }
        }
@@ -249,14 +246,12 @@ debug_info_alloc(char *name, int pages_per_area, int nr_areas, int buf_size,
        rc = (debug_info_t*) kmalloc(sizeof(debug_info_t), GFP_KERNEL);
        if(!rc)
                goto fail_malloc_rc;
-       rc->active_entries = (int*)kmalloc(nr_areas * sizeof(int), GFP_KERNEL);
+       rc->active_entries = kcalloc(nr_areas, sizeof(int), GFP_KERNEL);
        if(!rc->active_entries)
                goto fail_malloc_active_entries;
-       memset(rc->active_entries, 0, nr_areas * sizeof(int));
-       rc->active_pages = (int*)kmalloc(nr_areas * sizeof(int), GFP_KERNEL);
+       rc->active_pages = kcalloc(nr_areas, sizeof(int), GFP_KERNEL);
        if(!rc->active_pages)
                goto fail_malloc_active_pages;
-       memset(rc->active_pages, 0, nr_areas * sizeof(int));
        if((mode == ALL_AREAS) && (pages_per_area != 0)){
                rc->areas = debug_areas_alloc(pages_per_area, nr_areas);
                if(!rc->areas)
@@ -374,9 +369,24 @@ debug_info_copy(debug_info_t* in, int mode)
 {
         int i,j;
         debug_info_t* rc;
+        unsigned long flags;
+
+       /* get a consistent copy of the debug areas */
+       do {
+               rc = debug_info_alloc(in->name, in->pages_per_area,
+                       in->nr_areas, in->buf_size, in->level, mode);
+               spin_lock_irqsave(&in->lock, flags);
+               if(!rc)
+                       goto out;
+               /* has something changed in the meantime ? */
+               if((rc->pages_per_area == in->pages_per_area) &&
+                  (rc->nr_areas == in->nr_areas)) {
+                       break;
+               }
+               spin_unlock_irqrestore(&in->lock, flags);
+               debug_info_free(rc);
+       } while (1);
 
-        rc = debug_info_alloc(in->name, in->pages_per_area, in->nr_areas,
-                               in->buf_size, in->level, mode);
         if(!rc || (mode == NO_AREAS))
                 goto out;
 
@@ -386,6 +396,7 @@ debug_info_copy(debug_info_t* in, int mode)
                }
         }
 out:
+        spin_unlock_irqrestore(&in->lock, flags);
         return rc;
 }
 
@@ -470,7 +481,7 @@ out:
  * - goto next entry in p_info
  */
 
-extern inline int
+static inline int
 debug_next_entry(file_private_info_t *p_info)
 {
        debug_info_t *id;
@@ -593,19 +604,15 @@ debug_open(struct inode *inode, struct file *file)
        debug_info_t *debug_info, *debug_info_snapshot;
 
        down(&debug_lock);
-
-       /* find debug log and view */
-       debug_info = debug_area_first;
-       while(debug_info != NULL){
-               for (i = 0; i < DEBUG_MAX_VIEWS; i++) {
-                       if (!debug_info->views[i])
-                               continue;
-                       else if (debug_info->debugfs_entries[i] ==
-                                file->f_dentry) {
-                               goto found;     /* found view ! */
-                       }
+       debug_info = (struct debug_info*)file->f_dentry->d_inode->u.generic_ip;
+       /* find debug view */
+       for (i = 0; i < DEBUG_MAX_VIEWS; i++) {
+               if (!debug_info->views[i])
+                       continue;
+               else if (debug_info->debugfs_entries[i] ==
+                        file->f_dentry) {
+                       goto found;     /* found view ! */
                }
-               debug_info = debug_info->next;
        }
        /* no entry found */
        rc = -EINVAL;
@@ -788,7 +795,7 @@ debug_set_level(debug_info_t* id, int new_level)
  * - set active entry to next in the ring buffer
  */
 
-extern inline void
+static inline void
 proceed_active_entry(debug_info_t * id)
 {
        if ((id->active_entries[id->active_area] += id->entry_size)
@@ -805,7 +812,7 @@ proceed_active_entry(debug_info_t * id)
  * - set active area to next in the ring buffer
  */
 
-extern inline void
+static inline void
 proceed_active_area(debug_info_t * id)
 {
        id->active_area++;
@@ -816,7 +823,7 @@ proceed_active_area(debug_info_t * id)
  * get_active_entry:
  */
 
-extern inline debug_entry_t*
+static inline debug_entry_t*
 get_active_entry(debug_info_t * id)
 {
        return (debug_entry_t *) (((char *) id->areas[id->active_area]
@@ -829,11 +836,11 @@ get_active_entry(debug_info_t * id)
  * - set timestamp, caller address, cpu number etc.
  */
 
-extern inline void
+static inline void
 debug_finish_entry(debug_info_t * id, debug_entry_t* active, int level,
                        int exception)
 {
-       STCK(active->id.stck);
+       active->id.stck = get_clock();
        active->id.fields.cpuid = smp_processor_id();
        active->caller = __builtin_return_address(0);
        active->id.fields.exception = exception;
@@ -959,7 +966,7 @@ debug_entry_t
  * counts arguments in format string for sprintf view
  */
 
-extern inline int
+static inline int
 debug_count_numargs(char *string)
 {
        int numargs=0;
@@ -1078,7 +1085,7 @@ debug_register_view(debug_info_t * id, struct debug_view *view)
        if (view->input_proc)
                mode |= S_IWUSR;
        pde = debugfs_create_file(view->name, mode, id->debugfs_root_entry,
-                               NULL, &debug_file_ops);
+                               id , &debug_file_ops);
        if (!pde){
                printk(KERN_WARNING "debug: debugfs_create_file() failed!"\
                        " Cannot register view %s/%s\n", id->name,view->name);
@@ -1432,7 +1439,7 @@ int
 debug_dflt_header_fn(debug_info_t * id, struct debug_view *view,
                         int area, debug_entry_t * entry, char *out_buf)
 {
-       struct timeval time_val;
+       struct timespec time_spec;
        unsigned long long time;
        char *except_str;
        unsigned long caller;
@@ -1443,7 +1450,7 @@ debug_dflt_header_fn(debug_info_t * id, struct debug_view *view,
        time = entry->id.stck;
        /* adjust todclock to 1970 */
        time -= 0x8126d60e46000000LL - (0x3c26700LL * 1000000 * 4096);
-       tod_to_timeval(time, &time_val);
+       tod_to_timeval(time, &time_spec);
 
        if (entry->id.fields.exception)
                except_str = "*";
@@ -1451,7 +1458,7 @@ debug_dflt_header_fn(debug_info_t * id, struct debug_view *view,
                except_str = "-";
        caller = ((unsigned long) entry->caller) & PSW_ADDR_INSN;
        rc += sprintf(out_buf, "%02i %011lu:%06lu %1u %1s %02i %p  ",
-                     area, time_val.tv_sec, time_val.tv_usec, level,
+                     area, time_spec.tv_sec, time_spec.tv_nsec / 1000, level,
                      except_str, entry->id.fields.cpuid, (void *) caller);
        return rc;
 }