ALSA: usb-audio: add UAC2 sepecific Feature Unit controls
[safe/jmp/linux-2.6] / kernel / trace / trace_mmiotrace.c
index 1a266aa..017fa37 100644 (file)
@@ -9,8 +9,13 @@
 #include <linux/kernel.h>
 #include <linux/mmiotrace.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
+#include <linux/time.h>
+
+#include <asm/atomic.h>
 
 #include "trace.h"
+#include "trace_output.h"
 
 struct header_iter {
        struct pci_dev *dev;
@@ -18,46 +23,40 @@ struct header_iter {
 
 static struct trace_array *mmio_trace_array;
 static bool overrun_detected;
+static unsigned long prev_overruns;
+static atomic_t dropped_count;
 
 static void mmio_reset_data(struct trace_array *tr)
 {
-       int cpu;
-
        overrun_detected = false;
-       tr->time_start = ftrace_now(tr->cpu);
+       prev_overruns = 0;
 
-       for_each_online_cpu(cpu)
-               tracing_reset(tr, cpu);
+       tracing_reset_online_cpus(tr);
 }
 
-static void mmio_trace_init(struct trace_array *tr)
+static int mmio_trace_init(struct trace_array *tr)
 {
        pr_debug("in %s\n", __func__);
        mmio_trace_array = tr;
-       if (tr->ctrl) {
-               mmio_reset_data(tr);
-               enable_mmiotrace();
-       }
+
+       mmio_reset_data(tr);
+       enable_mmiotrace();
+       return 0;
 }
 
 static void mmio_trace_reset(struct trace_array *tr)
 {
        pr_debug("in %s\n", __func__);
-       if (tr->ctrl)
-               disable_mmiotrace();
+
+       disable_mmiotrace();
        mmio_reset_data(tr);
        mmio_trace_array = NULL;
 }
 
-static void mmio_trace_ctrl_update(struct trace_array *tr)
+static void mmio_trace_start(struct trace_array *tr)
 {
        pr_debug("in %s\n", __func__);
-       if (tr->ctrl) {
-               mmio_reset_data(tr);
-               enable_mmiotrace();
-       } else {
-               disable_mmiotrace();
-       }
+       mmio_reset_data(tr);
 }
 
 static int mmio_print_pcidev(struct trace_seq *s, const struct pci_dev *dev)
@@ -128,16 +127,12 @@ static void mmio_close(struct trace_iterator *iter)
 
 static unsigned long count_overruns(struct trace_iterator *iter)
 {
-       int cpu;
-       unsigned long cnt = 0;
-/* FIXME: */
-#if 0
-       for_each_online_cpu(cpu) {
-               cnt += iter->overrun[cpu];
-               iter->overrun[cpu] = 0;
-       }
-#endif
-       (void)cpu;
+       unsigned long cnt = atomic_xchg(&dropped_count, 0);
+       unsigned long over = ring_buffer_overruns(iter->tr->buffer);
+
+       if (over > prev_overruns)
+               cnt += over - prev_overruns;
+       prev_overruns = over;
        return cnt;
 }
 
@@ -178,33 +173,36 @@ print_out:
 static enum print_line_t mmio_print_rw(struct trace_iterator *iter)
 {
        struct trace_entry *entry = iter->ent;
-       struct trace_mmiotrace_rw *field =
-               (struct trace_mmiotrace_rw *)entry;
-       struct mmiotrace_rw *rw = &field->rw;
+       struct trace_mmiotrace_rw *field;
+       struct mmiotrace_rw *rw;
        struct trace_seq *s     = &iter->seq;
        unsigned long long t    = ns2usecs(iter->ts);
-       unsigned long usec_rem  = do_div(t, 1000000ULL);
+       unsigned long usec_rem  = do_div(t, USEC_PER_SEC);
        unsigned secs           = (unsigned long)t;
        int ret = 1;
 
+       trace_assign_type(field, entry);
+       rw = &field->rw;
+
        switch (rw->opcode) {
        case MMIO_READ:
                ret = trace_seq_printf(s,
-                       "R %d %lu.%06lu %d 0x%llx 0x%lx 0x%lx %d\n",
+                       "R %d %u.%06lu %d 0x%llx 0x%lx 0x%lx %d\n",
                        rw->width, secs, usec_rem, rw->map_id,
                        (unsigned long long)rw->phys,
                        rw->value, rw->pc, 0);
                break;
        case MMIO_WRITE:
                ret = trace_seq_printf(s,
-                       "W %d %lu.%06lu %d 0x%llx 0x%lx 0x%lx %d\n",
+                       "W %d %u.%06lu %d 0x%llx 0x%lx 0x%lx %d\n",
                        rw->width, secs, usec_rem, rw->map_id,
                        (unsigned long long)rw->phys,
                        rw->value, rw->pc, 0);
                break;
        case MMIO_UNKNOWN_OP:
                ret = trace_seq_printf(s,
-                       "UNKNOWN %lu.%06lu %d 0x%llx %02x,%02x,%02x 0x%lx %d\n",
+                       "UNKNOWN %u.%06lu %d 0x%llx %02lx,%02lx,"
+                       "%02lx 0x%lx %d\n",
                        secs, usec_rem, rw->map_id,
                        (unsigned long long)rw->phys,
                        (rw->value >> 16) & 0xff, (rw->value >> 8) & 0xff,
@@ -222,24 +220,28 @@ static enum print_line_t mmio_print_rw(struct trace_iterator *iter)
 static enum print_line_t mmio_print_map(struct trace_iterator *iter)
 {
        struct trace_entry *entry = iter->ent;
-       struct mmiotrace_map *m = (struct mmiotrace_map *)entry;
+       struct trace_mmiotrace_map *field;
+       struct mmiotrace_map *m;
        struct trace_seq *s     = &iter->seq;
        unsigned long long t    = ns2usecs(iter->ts);
-       unsigned long usec_rem  = do_div(t, 1000000ULL);
+       unsigned long usec_rem  = do_div(t, USEC_PER_SEC);
        unsigned secs           = (unsigned long)t;
        int ret;
 
+       trace_assign_type(field, entry);
+       m = &field->map;
+
        switch (m->opcode) {
        case MMIO_PROBE:
                ret = trace_seq_printf(s,
-                       "MAP %lu.%06lu %d 0x%llx 0x%lx 0x%lx 0x%lx %d\n",
+                       "MAP %u.%06lu %d 0x%llx 0x%lx 0x%lx 0x%lx %d\n",
                        secs, usec_rem, m->map_id,
                        (unsigned long long)m->phys, m->virt, m->len,
                        0UL, 0);
                break;
        case MMIO_UNPROBE:
                ret = trace_seq_printf(s,
-                       "UNMAP %lu.%06lu %d 0x%lx %d\n",
+                       "UNMAP %u.%06lu %d 0x%lx %d\n",
                        secs, usec_rem, m->map_id, 0UL, 0);
                break;
        default:
@@ -258,18 +260,15 @@ static enum print_line_t mmio_print_mark(struct trace_iterator *iter)
        const char *msg         = print->buf;
        struct trace_seq *s     = &iter->seq;
        unsigned long long t    = ns2usecs(iter->ts);
-       unsigned long usec_rem  = do_div(t, 1000000ULL);
+       unsigned long usec_rem  = do_div(t, USEC_PER_SEC);
        unsigned secs           = (unsigned long)t;
        int ret;
 
        /* The trailing newline must be in the message. */
-       ret = trace_seq_printf(s, "MARK %lu.%06lu %s", secs, usec_rem, msg);
+       ret = trace_seq_printf(s, "MARK %u.%06lu %s", secs, usec_rem, msg);
        if (!ret)
                return TRACE_TYPE_PARTIAL_LINE;
 
-       if (entry->flags & TRACE_FLAG_CONT)
-               trace_seq_print_cont(s, iter);
-
        return TRACE_TYPE_HANDLED;
 }
 
@@ -292,10 +291,10 @@ static struct tracer mmio_tracer __read_mostly =
        .name           = "mmiotrace",
        .init           = mmio_trace_init,
        .reset          = mmio_trace_reset,
+       .start          = mmio_trace_start,
        .pipe_open      = mmio_pipe_open,
        .close          = mmio_close,
        .read           = mmio_read,
-       .ctrl_update    = mmio_trace_ctrl_update,
        .print_line     = mmio_print_line,
 };
 
@@ -309,21 +308,23 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
                                struct trace_array_cpu *data,
                                struct mmiotrace_rw *rw)
 {
+       struct ftrace_event_call *call = &event_mmiotrace_rw;
+       struct ring_buffer *buffer = tr->buffer;
        struct ring_buffer_event *event;
        struct trace_mmiotrace_rw *entry;
-       unsigned long irq_flags;
+       int pc = preempt_count();
 
-       event   = ring_buffer_lock_reserve(tr->buffer, sizeof(*entry),
-                                          &irq_flags);
-       if (!event)
+       event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
+                                         sizeof(*entry), 0, pc);
+       if (!event) {
+               atomic_inc(&dropped_count);
                return;
+       }
        entry   = ring_buffer_event_data(event);
-       tracing_generic_entry_update(&entry->ent, 0);
-       entry->ent.type                 = TRACE_MMIO_RW;
        entry->rw                       = *rw;
-       ring_buffer_unlock_commit(tr->buffer, event, irq_flags);
 
-       trace_wake_up();
+       if (!filter_check_discard(call, entry, buffer, event))
+               trace_buffer_unlock_commit(buffer, event, 0, pc);
 }
 
 void mmio_trace_rw(struct mmiotrace_rw *rw)
@@ -337,21 +338,23 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
                                struct trace_array_cpu *data,
                                struct mmiotrace_map *map)
 {
+       struct ftrace_event_call *call = &event_mmiotrace_map;
+       struct ring_buffer *buffer = tr->buffer;
        struct ring_buffer_event *event;
        struct trace_mmiotrace_map *entry;
-       unsigned long irq_flags;
+       int pc = preempt_count();
 
-       event   = ring_buffer_lock_reserve(tr->buffer, sizeof(*entry),
-                                          &irq_flags);
-       if (!event)
+       event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
+                                         sizeof(*entry), 0, pc);
+       if (!event) {
+               atomic_inc(&dropped_count);
                return;
+       }
        entry   = ring_buffer_event_data(event);
-       tracing_generic_entry_update(&entry->ent, 0);
-       entry->ent.type                 = TRACE_MMIO_MAP;
        entry->map                      = *map;
-       ring_buffer_unlock_commit(tr->buffer, event, irq_flags);
 
-       trace_wake_up();
+       if (!filter_check_discard(call, entry, buffer, event))
+               trace_buffer_unlock_commit(buffer, event, 0, pc);
 }
 
 void mmio_trace_mapping(struct mmiotrace_map *map)