blob: 2be8c4f2403d8c6f79df5cb7e5605eec01ea4a23 [file] [log] [blame]
Pekka Paalanenf984b512008-05-12 21:20:57 +02001/*
2 * Memory mapped I/O tracing
3 *
4 * Copyright (C) 2008 Pekka Paalanen <pq@iki.fi>
5 */
6
7#define DEBUG 1
8
9#include <linux/kernel.h>
10#include <linux/mmiotrace.h>
Pekka Paalanen13829532008-05-12 21:20:58 +020011#include <linux/pci.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090012#include <linux/slab.h>
Li Zefana5dec552009-03-27 14:55:44 +080013#include <linux/time.h>
14
Arun Sharma600634972011-07-26 16:09:06 -070015#include <linux/atomic.h>
Pekka Paalanenf984b512008-05-12 21:20:57 +020016
17#include "trace.h"
Steven Rostedtf0868d12008-12-23 23:24:12 -050018#include "trace_output.h"
Pekka Paalanenf984b512008-05-12 21:20:57 +020019
Pekka Paalanend0a7e8ca2008-05-12 21:21:02 +020020struct header_iter {
21 struct pci_dev *dev;
22};
23
Pekka Paalanenf984b512008-05-12 21:20:57 +020024static struct trace_array *mmio_trace_array;
Pekka Paalanen20392382008-05-12 21:21:02 +020025static bool overrun_detected;
Pekka Paalanen7ee17682008-11-23 21:24:30 +020026static unsigned long prev_overruns;
Pekka Paalanen173ed242009-01-06 13:57:11 +020027static atomic_t dropped_count;
Pekka Paalanenf984b512008-05-12 21:20:57 +020028
Pekka Paalanenbd8ac682008-05-12 21:20:57 +020029static void mmio_reset_data(struct trace_array *tr)
30{
Pekka Paalanen20392382008-05-12 21:21:02 +020031 overrun_detected = false;
Pekka Paalanen7ee17682008-11-23 21:24:30 +020032 prev_overruns = 0;
Pekka Paalanenbd8ac682008-05-12 21:20:57 +020033
Steven Rostedt (Red Hat)12883ef2013-03-05 09:24:35 -050034 tracing_reset_online_cpus(&tr->trace_buffer);
Pekka Paalanenbd8ac682008-05-12 21:20:57 +020035}
Pekka Paalanenf984b512008-05-12 21:20:57 +020036
Frederic Weisbecker1c800252008-11-16 05:57:26 +010037static int mmio_trace_init(struct trace_array *tr)
Pekka Paalanenf984b512008-05-12 21:20:57 +020038{
39 pr_debug("in %s\n", __func__);
40 mmio_trace_array = tr;
Steven Rostedtc76f0692008-11-07 22:36:02 -050041
42 mmio_reset_data(tr);
43 enable_mmiotrace();
Frederic Weisbecker1c800252008-11-16 05:57:26 +010044 return 0;
Pekka Paalanenf984b512008-05-12 21:20:57 +020045}
46
47static void mmio_trace_reset(struct trace_array *tr)
48{
49 pr_debug("in %s\n", __func__);
Steven Rostedtc76f0692008-11-07 22:36:02 -050050
51 disable_mmiotrace();
Pekka Paalanenbd8ac682008-05-12 21:20:57 +020052 mmio_reset_data(tr);
53 mmio_trace_array = NULL;
Pekka Paalanenf984b512008-05-12 21:20:57 +020054}
55
Steven Rostedtbbf5b1a2008-11-07 22:36:02 -050056static void mmio_trace_start(struct trace_array *tr)
Pekka Paalanenf984b512008-05-12 21:20:57 +020057{
58 pr_debug("in %s\n", __func__);
Steven Rostedtbbf5b1a2008-11-07 22:36:02 -050059 mmio_reset_data(tr);
Pekka Paalanenbd8ac682008-05-12 21:20:57 +020060}
61
Steven Rostedt (Red Hat)a72e10a2014-11-12 16:26:06 -050062static void mmio_print_pcidev(struct trace_seq *s, const struct pci_dev *dev)
Pekka Paalanen13829532008-05-12 21:20:58 +020063{
Pekka Paalanen13829532008-05-12 21:20:58 +020064 int i;
65 resource_size_t start, end;
66 const struct pci_driver *drv = pci_dev_driver(dev);
67
Steven Rostedt (Red Hat)a72e10a2014-11-12 16:26:06 -050068 trace_seq_printf(s, "PCIDEV %02x%02x %04x%04x %x",
69 dev->bus->number, dev->devfn,
70 dev->vendor, dev->device, dev->irq);
Pekka Paalanen13829532008-05-12 21:20:58 +020071 /*
72 * XXX: is pci_resource_to_user() appropriate, since we are
73 * supposed to interpret the __ioremap() phys_addr argument based on
74 * these printed values?
75 */
76 for (i = 0; i < 7; i++) {
77 pci_resource_to_user(dev, i, &dev->resource[i], &start, &end);
Steven Rostedt (Red Hat)a72e10a2014-11-12 16:26:06 -050078 trace_seq_printf(s, " %llx",
Pekka Paalanen13829532008-05-12 21:20:58 +020079 (unsigned long long)(start |
80 (dev->resource[i].flags & PCI_REGION_FLAG_MASK)));
81 }
82 for (i = 0; i < 7; i++) {
83 pci_resource_to_user(dev, i, &dev->resource[i], &start, &end);
Steven Rostedt (Red Hat)a72e10a2014-11-12 16:26:06 -050084 trace_seq_printf(s, " %llx",
Pekka Paalanen13829532008-05-12 21:20:58 +020085 dev->resource[i].start < dev->resource[i].end ?
86 (unsigned long long)(end - start) + 1 : 0);
87 }
88 if (drv)
Steven Rostedt (Red Hat)a72e10a2014-11-12 16:26:06 -050089 trace_seq_printf(s, " %s\n", drv->name);
Pekka Paalanen13829532008-05-12 21:20:58 +020090 else
Steven Rostedt (Red Hat)a72e10a2014-11-12 16:26:06 -050091 trace_seq_puts(s, " \n");
Pekka Paalanen13829532008-05-12 21:20:58 +020092}
93
Pekka Paalanend0a7e8ca2008-05-12 21:21:02 +020094static void destroy_header_iter(struct header_iter *hiter)
Pekka Paalanenbd8ac682008-05-12 21:20:57 +020095{
Pekka Paalanend0a7e8ca2008-05-12 21:21:02 +020096 if (!hiter)
97 return;
98 pci_dev_put(hiter->dev);
99 kfree(hiter);
100}
101
102static void mmio_pipe_open(struct trace_iterator *iter)
103{
104 struct header_iter *hiter;
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200105 struct trace_seq *s = &iter->seq;
Pekka Paalanen13829532008-05-12 21:20:58 +0200106
zhangwei(Jovi)146c3442013-07-15 16:32:44 +0800107 trace_seq_puts(s, "VERSION 20070824\n");
Pekka Paalanen13829532008-05-12 21:20:58 +0200108
Pekka Paalanend0a7e8ca2008-05-12 21:21:02 +0200109 hiter = kzalloc(sizeof(*hiter), GFP_KERNEL);
110 if (!hiter)
111 return;
112
113 hiter->dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL);
114 iter->private = hiter;
115}
116
117/* XXX: This is not called when the pipe is closed! */
118static void mmio_close(struct trace_iterator *iter)
119{
120 struct header_iter *hiter = iter->private;
121 destroy_header_iter(hiter);
122 iter->private = NULL;
123}
124
Pekka Paalanen20392382008-05-12 21:21:02 +0200125static unsigned long count_overruns(struct trace_iterator *iter)
126{
Pekka Paalanen173ed242009-01-06 13:57:11 +0200127 unsigned long cnt = atomic_xchg(&dropped_count, 0);
Steven Rostedt (Red Hat)12883ef2013-03-05 09:24:35 -0500128 unsigned long over = ring_buffer_overruns(iter->trace_buffer->buffer);
Pekka Paalanen7ee17682008-11-23 21:24:30 +0200129
130 if (over > prev_overruns)
Pekka Paalanen173ed242009-01-06 13:57:11 +0200131 cnt += over - prev_overruns;
Pekka Paalanen7ee17682008-11-23 21:24:30 +0200132 prev_overruns = over;
Pekka Paalanen20392382008-05-12 21:21:02 +0200133 return cnt;
134}
135
Pekka Paalanend0a7e8ca2008-05-12 21:21:02 +0200136static ssize_t mmio_read(struct trace_iterator *iter, struct file *filp,
137 char __user *ubuf, size_t cnt, loff_t *ppos)
138{
139 ssize_t ret;
140 struct header_iter *hiter = iter->private;
141 struct trace_seq *s = &iter->seq;
Pekka Paalanen20392382008-05-12 21:21:02 +0200142 unsigned long n;
143
144 n = count_overruns(iter);
145 if (n) {
146 /* XXX: This is later than where events were lost. */
147 trace_seq_printf(s, "MARK 0.000000 Lost %lu events.\n", n);
148 if (!overrun_detected)
149 pr_warning("mmiotrace has lost events.\n");
150 overrun_detected = true;
151 goto print_out;
152 }
Pekka Paalanend0a7e8ca2008-05-12 21:21:02 +0200153
154 if (!hiter)
155 return 0;
156
157 mmio_print_pcidev(s, hiter->dev);
158 hiter->dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, hiter->dev);
159
160 if (!hiter->dev) {
161 destroy_header_iter(hiter);
162 iter->private = NULL;
163 }
164
Pekka Paalanen20392382008-05-12 21:21:02 +0200165print_out:
Pekka Paalanend0a7e8ca2008-05-12 21:21:02 +0200166 ret = trace_seq_to_user(s, ubuf, cnt);
167 return (ret == -EBUSY) ? 0 : ret;
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200168}
169
Frederic Weisbecker07f4e4f2008-09-29 20:27:42 +0200170static enum print_line_t mmio_print_rw(struct trace_iterator *iter)
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200171{
172 struct trace_entry *entry = iter->ent;
Steven Rostedt7104f302008-10-01 10:52:51 -0400173 struct trace_mmiotrace_rw *field;
174 struct mmiotrace_rw *rw;
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200175 struct trace_seq *s = &iter->seq;
Steven Rostedt3928a8a2008-09-29 23:02:41 -0400176 unsigned long long t = ns2usecs(iter->ts);
Li Zefana5dec552009-03-27 14:55:44 +0800177 unsigned long usec_rem = do_div(t, USEC_PER_SEC);
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200178 unsigned secs = (unsigned long)t;
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200179
Steven Rostedt7104f302008-10-01 10:52:51 -0400180 trace_assign_type(field, entry);
181 rw = &field->rw;
182
Steven Rostedt777e2082008-09-29 23:02:42 -0400183 switch (rw->opcode) {
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200184 case MMIO_READ:
Steven Rostedt (Red Hat)a72e10a2014-11-12 16:26:06 -0500185 trace_seq_printf(s,
Steven Rostedt5e4abc92009-01-15 21:00:50 -0500186 "R %d %u.%06lu %d 0x%llx 0x%lx 0x%lx %d\n",
Pekka Paalanendee310d2008-05-12 21:21:03 +0200187 rw->width, secs, usec_rem, rw->map_id,
188 (unsigned long long)rw->phys,
Pekka Paalanen736ca612008-05-12 21:20:59 +0200189 rw->value, rw->pc, 0);
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200190 break;
191 case MMIO_WRITE:
Steven Rostedt (Red Hat)a72e10a2014-11-12 16:26:06 -0500192 trace_seq_printf(s,
Steven Rostedt5e4abc92009-01-15 21:00:50 -0500193 "W %d %u.%06lu %d 0x%llx 0x%lx 0x%lx %d\n",
Pekka Paalanendee310d2008-05-12 21:21:03 +0200194 rw->width, secs, usec_rem, rw->map_id,
195 (unsigned long long)rw->phys,
Pekka Paalanen736ca612008-05-12 21:20:59 +0200196 rw->value, rw->pc, 0);
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200197 break;
198 case MMIO_UNKNOWN_OP:
Steven Rostedt (Red Hat)a72e10a2014-11-12 16:26:06 -0500199 trace_seq_printf(s,
Steven Rostedt5e4abc92009-01-15 21:00:50 -0500200 "UNKNOWN %u.%06lu %d 0x%llx %02lx,%02lx,"
201 "%02lx 0x%lx %d\n",
Pekka Paalanendee310d2008-05-12 21:21:03 +0200202 secs, usec_rem, rw->map_id,
203 (unsigned long long)rw->phys,
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200204 (rw->value >> 16) & 0xff, (rw->value >> 8) & 0xff,
Pekka Paalanen736ca612008-05-12 21:20:59 +0200205 (rw->value >> 0) & 0xff, rw->pc, 0);
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200206 break;
207 default:
Steven Rostedt (Red Hat)a72e10a2014-11-12 16:26:06 -0500208 trace_seq_puts(s, "rw what?\n");
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200209 break;
210 }
Steven Rostedt (Red Hat)a72e10a2014-11-12 16:26:06 -0500211
212 return trace_handle_return(s);
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200213}
214
Frederic Weisbecker07f4e4f2008-09-29 20:27:42 +0200215static enum print_line_t mmio_print_map(struct trace_iterator *iter)
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200216{
217 struct trace_entry *entry = iter->ent;
Steven Rostedt7104f302008-10-01 10:52:51 -0400218 struct trace_mmiotrace_map *field;
219 struct mmiotrace_map *m;
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200220 struct trace_seq *s = &iter->seq;
Steven Rostedt3928a8a2008-09-29 23:02:41 -0400221 unsigned long long t = ns2usecs(iter->ts);
Li Zefana5dec552009-03-27 14:55:44 +0800222 unsigned long usec_rem = do_div(t, USEC_PER_SEC);
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200223 unsigned secs = (unsigned long)t;
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200224
Steven Rostedt7104f302008-10-01 10:52:51 -0400225 trace_assign_type(field, entry);
226 m = &field->map;
227
Steven Rostedt777e2082008-09-29 23:02:42 -0400228 switch (m->opcode) {
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200229 case MMIO_PROBE:
Steven Rostedt (Red Hat)a72e10a2014-11-12 16:26:06 -0500230 trace_seq_printf(s,
Steven Rostedt5e4abc92009-01-15 21:00:50 -0500231 "MAP %u.%06lu %d 0x%llx 0x%lx 0x%lx 0x%lx %d\n",
Pekka Paalanendee310d2008-05-12 21:21:03 +0200232 secs, usec_rem, m->map_id,
233 (unsigned long long)m->phys, m->virt, m->len,
Pekka Paalanene0fd5c22008-05-12 21:21:02 +0200234 0UL, 0);
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200235 break;
236 case MMIO_UNPROBE:
Steven Rostedt (Red Hat)a72e10a2014-11-12 16:26:06 -0500237 trace_seq_printf(s,
Steven Rostedt5e4abc92009-01-15 21:00:50 -0500238 "UNMAP %u.%06lu %d 0x%lx %d\n",
Pekka Paalanene0fd5c22008-05-12 21:21:02 +0200239 secs, usec_rem, m->map_id, 0UL, 0);
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200240 break;
241 default:
Steven Rostedt (Red Hat)a72e10a2014-11-12 16:26:06 -0500242 trace_seq_puts(s, "map what?\n");
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200243 break;
244 }
Steven Rostedt (Red Hat)a72e10a2014-11-12 16:26:06 -0500245
246 return trace_handle_return(s);
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200247}
248
Frederic Weisbecker07f4e4f2008-09-29 20:27:42 +0200249static enum print_line_t mmio_print_mark(struct trace_iterator *iter)
Pekka Paalanenfc5e27a2008-09-16 22:02:27 +0300250{
251 struct trace_entry *entry = iter->ent;
Steven Rostedt777e2082008-09-29 23:02:42 -0400252 struct print_entry *print = (struct print_entry *)entry;
Frederic Weisbecker48ead022009-03-12 18:24:49 +0100253 const char *msg = print->buf;
Pekka Paalanenfc5e27a2008-09-16 22:02:27 +0300254 struct trace_seq *s = &iter->seq;
Steven Rostedt3928a8a2008-09-29 23:02:41 -0400255 unsigned long long t = ns2usecs(iter->ts);
Frederic Weisbecker769b0442009-03-06 17:21:49 +0100256 unsigned long usec_rem = do_div(t, USEC_PER_SEC);
Pekka Paalanenfc5e27a2008-09-16 22:02:27 +0300257 unsigned secs = (unsigned long)t;
Pekka Paalanenfc5e27a2008-09-16 22:02:27 +0300258
259 /* The trailing newline must be in the message. */
Steven Rostedt (Red Hat)a72e10a2014-11-12 16:26:06 -0500260 trace_seq_printf(s, "MARK %u.%06lu %s", secs, usec_rem, msg);
Pekka Paalanenfc5e27a2008-09-16 22:02:27 +0300261
Steven Rostedt (Red Hat)a72e10a2014-11-12 16:26:06 -0500262 return trace_handle_return(s);
Pekka Paalanenfc5e27a2008-09-16 22:02:27 +0300263}
264
Frederic Weisbecker07f4e4f2008-09-29 20:27:42 +0200265static enum print_line_t mmio_print_line(struct trace_iterator *iter)
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200266{
267 switch (iter->ent->type) {
268 case TRACE_MMIO_RW:
269 return mmio_print_rw(iter);
270 case TRACE_MMIO_MAP:
271 return mmio_print_map(iter);
Pekka Paalanenfc5e27a2008-09-16 22:02:27 +0300272 case TRACE_PRINT:
273 return mmio_print_mark(iter);
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200274 default:
Frederic Weisbecker07f4e4f2008-09-29 20:27:42 +0200275 return TRACE_TYPE_HANDLED; /* ignore unknown entries */
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200276 }
Pekka Paalanenf984b512008-05-12 21:20:57 +0200277}
278
279static struct tracer mmio_tracer __read_mostly =
280{
281 .name = "mmiotrace",
282 .init = mmio_trace_init,
283 .reset = mmio_trace_reset,
Steven Rostedtbbf5b1a2008-11-07 22:36:02 -0500284 .start = mmio_trace_start,
Pekka Paalanend0a7e8ca2008-05-12 21:21:02 +0200285 .pipe_open = mmio_pipe_open,
286 .close = mmio_close,
287 .read = mmio_read,
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200288 .print_line = mmio_print_line,
Pekka Paalanenf984b512008-05-12 21:20:57 +0200289};
290
291__init static int init_mmio_trace(void)
292{
Pekka Paalanenf984b512008-05-12 21:20:57 +0200293 return register_tracer(&mmio_tracer);
294}
295device_initcall(init_mmio_trace);
296
Pekka Paalanen45dcd8b2008-09-16 21:56:41 +0300297static void __trace_mmiotrace_rw(struct trace_array *tr,
298 struct trace_array_cpu *data,
299 struct mmiotrace_rw *rw)
300{
Steven Rostedt (Red Hat)2425bcb2015-05-05 11:45:27 -0400301 struct trace_event_call *call = &event_mmiotrace_rw;
Steven Rostedt (Red Hat)12883ef2013-03-05 09:24:35 -0500302 struct ring_buffer *buffer = tr->trace_buffer.buffer;
Steven Rostedt3928a8a2008-09-29 23:02:41 -0400303 struct ring_buffer_event *event;
Steven Rostedt777e2082008-09-29 23:02:42 -0400304 struct trace_mmiotrace_rw *entry;
Arnaldo Carvalho de Melo51a763d2009-02-05 16:14:13 -0200305 int pc = preempt_count();
Pekka Paalanen45dcd8b2008-09-16 21:56:41 +0300306
Steven Rostedte77405a2009-09-02 14:17:06 -0400307 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
Arnaldo Carvalho de Melo51a763d2009-02-05 16:14:13 -0200308 sizeof(*entry), 0, pc);
Pekka Paalanen173ed242009-01-06 13:57:11 +0200309 if (!event) {
310 atomic_inc(&dropped_count);
Steven Rostedt3928a8a2008-09-29 23:02:41 -0400311 return;
Pekka Paalanen173ed242009-01-06 13:57:11 +0200312 }
Steven Rostedt3928a8a2008-09-29 23:02:41 -0400313 entry = ring_buffer_event_data(event);
Steven Rostedt777e2082008-09-29 23:02:42 -0400314 entry->rw = *rw;
Steven Rostedt60ba7702009-09-12 23:34:04 -0400315
Tom Zanussif306cc82013-10-24 08:34:17 -0500316 if (!call_filter_check_discard(call, entry, buffer, event))
Steven Rostedt (Red Hat)b7f0c952015-09-25 17:38:44 -0400317 trace_buffer_unlock_commit(tr, buffer, event, 0, pc);
Pekka Paalanen45dcd8b2008-09-16 21:56:41 +0300318}
319
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200320void mmio_trace_rw(struct mmiotrace_rw *rw)
Pekka Paalanenf984b512008-05-12 21:20:57 +0200321{
322 struct trace_array *tr = mmio_trace_array;
Steven Rostedt (Red Hat)12883ef2013-03-05 09:24:35 -0500323 struct trace_array_cpu *data = per_cpu_ptr(tr->trace_buffer.data, smp_processor_id());
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200324 __trace_mmiotrace_rw(tr, data, rw);
325}
Pekka Paalanenf984b512008-05-12 21:20:57 +0200326
Pekka Paalanen45dcd8b2008-09-16 21:56:41 +0300327static void __trace_mmiotrace_map(struct trace_array *tr,
328 struct trace_array_cpu *data,
329 struct mmiotrace_map *map)
330{
Steven Rostedt (Red Hat)2425bcb2015-05-05 11:45:27 -0400331 struct trace_event_call *call = &event_mmiotrace_map;
Steven Rostedt (Red Hat)12883ef2013-03-05 09:24:35 -0500332 struct ring_buffer *buffer = tr->trace_buffer.buffer;
Steven Rostedt3928a8a2008-09-29 23:02:41 -0400333 struct ring_buffer_event *event;
Steven Rostedt777e2082008-09-29 23:02:42 -0400334 struct trace_mmiotrace_map *entry;
Arnaldo Carvalho de Melo51a763d2009-02-05 16:14:13 -0200335 int pc = preempt_count();
Pekka Paalanen45dcd8b2008-09-16 21:56:41 +0300336
Steven Rostedte77405a2009-09-02 14:17:06 -0400337 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
Arnaldo Carvalho de Melo51a763d2009-02-05 16:14:13 -0200338 sizeof(*entry), 0, pc);
Pekka Paalanen173ed242009-01-06 13:57:11 +0200339 if (!event) {
340 atomic_inc(&dropped_count);
Steven Rostedt3928a8a2008-09-29 23:02:41 -0400341 return;
Pekka Paalanen173ed242009-01-06 13:57:11 +0200342 }
Steven Rostedt3928a8a2008-09-29 23:02:41 -0400343 entry = ring_buffer_event_data(event);
Steven Rostedt777e2082008-09-29 23:02:42 -0400344 entry->map = *map;
Steven Rostedt60ba7702009-09-12 23:34:04 -0400345
Tom Zanussif306cc82013-10-24 08:34:17 -0500346 if (!call_filter_check_discard(call, entry, buffer, event))
Steven Rostedt (Red Hat)b7f0c952015-09-25 17:38:44 -0400347 trace_buffer_unlock_commit(tr, buffer, event, 0, pc);
Pekka Paalanen45dcd8b2008-09-16 21:56:41 +0300348}
349
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200350void mmio_trace_mapping(struct mmiotrace_map *map)
351{
352 struct trace_array *tr = mmio_trace_array;
353 struct trace_array_cpu *data;
354
355 preempt_disable();
Steven Rostedt (Red Hat)12883ef2013-03-05 09:24:35 -0500356 data = per_cpu_ptr(tr->trace_buffer.data, smp_processor_id());
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200357 __trace_mmiotrace_map(tr, data, map);
358 preempt_enable();
Pekka Paalanenf984b512008-05-12 21:20:57 +0200359}
Pekka Paalanen9e57fb32008-09-16 22:00:34 +0300360
361int mmio_trace_printk(const char *fmt, va_list args)
362{
Steven Rostedt40ce74f2009-03-19 14:03:53 -0400363 return trace_vprintk(0, fmt, args);
Pekka Paalanen9e57fb32008-09-16 22:00:34 +0300364}