blob: 84582bf1ed5fba787c216fecd22256551f1a63c5 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Pekka Paalanenf984b512008-05-12 21:20:57 +02002/*
3 * Memory mapped I/O tracing
4 *
5 * Copyright (C) 2008 Pekka Paalanen <pq@iki.fi>
6 */
7
8#define DEBUG 1
9
10#include <linux/kernel.h>
11#include <linux/mmiotrace.h>
Pekka Paalanen13829532008-05-12 21:20:58 +020012#include <linux/pci.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090013#include <linux/slab.h>
Li Zefana5dec552009-03-27 14:55:44 +080014#include <linux/time.h>
15
Arun Sharma600634972011-07-26 16:09:06 -070016#include <linux/atomic.h>
Pekka Paalanenf984b512008-05-12 21:20:57 +020017
18#include "trace.h"
Steven Rostedtf0868d12008-12-23 23:24:12 -050019#include "trace_output.h"
Pekka Paalanenf984b512008-05-12 21:20:57 +020020
Pekka Paalanend0a7e8ca2008-05-12 21:21:02 +020021struct header_iter {
22 struct pci_dev *dev;
23};
24
Pekka Paalanenf984b512008-05-12 21:20:57 +020025static struct trace_array *mmio_trace_array;
Pekka Paalanen20392382008-05-12 21:21:02 +020026static bool overrun_detected;
Pekka Paalanen7ee17682008-11-23 21:24:30 +020027static unsigned long prev_overruns;
Pekka Paalanen173ed242009-01-06 13:57:11 +020028static atomic_t dropped_count;
Pekka Paalanenf984b512008-05-12 21:20:57 +020029
Pekka Paalanenbd8ac682008-05-12 21:20:57 +020030static void mmio_reset_data(struct trace_array *tr)
31{
Pekka Paalanen20392382008-05-12 21:21:02 +020032 overrun_detected = false;
Pekka Paalanen7ee17682008-11-23 21:24:30 +020033 prev_overruns = 0;
Pekka Paalanenbd8ac682008-05-12 21:20:57 +020034
Steven Rostedt (VMware)1c5eb442020-01-09 18:53:48 -050035 tracing_reset_online_cpus(&tr->array_buffer);
Pekka Paalanenbd8ac682008-05-12 21:20:57 +020036}
Pekka Paalanenf984b512008-05-12 21:20:57 +020037
Frederic Weisbecker1c800252008-11-16 05:57:26 +010038static int mmio_trace_init(struct trace_array *tr)
Pekka Paalanenf984b512008-05-12 21:20:57 +020039{
40 pr_debug("in %s\n", __func__);
41 mmio_trace_array = tr;
Steven Rostedtc76f0692008-11-07 22:36:02 -050042
43 mmio_reset_data(tr);
44 enable_mmiotrace();
Frederic Weisbecker1c800252008-11-16 05:57:26 +010045 return 0;
Pekka Paalanenf984b512008-05-12 21:20:57 +020046}
47
48static void mmio_trace_reset(struct trace_array *tr)
49{
50 pr_debug("in %s\n", __func__);
Steven Rostedtc76f0692008-11-07 22:36:02 -050051
52 disable_mmiotrace();
Pekka Paalanenbd8ac682008-05-12 21:20:57 +020053 mmio_reset_data(tr);
54 mmio_trace_array = NULL;
Pekka Paalanenf984b512008-05-12 21:20:57 +020055}
56
Steven Rostedtbbf5b1a2008-11-07 22:36:02 -050057static void mmio_trace_start(struct trace_array *tr)
Pekka Paalanenf984b512008-05-12 21:20:57 +020058{
59 pr_debug("in %s\n", __func__);
Steven Rostedtbbf5b1a2008-11-07 22:36:02 -050060 mmio_reset_data(tr);
Pekka Paalanenbd8ac682008-05-12 21:20:57 +020061}
62
Steven Rostedt (Red Hat)a72e10a2014-11-12 16:26:06 -050063static void mmio_print_pcidev(struct trace_seq *s, const struct pci_dev *dev)
Pekka Paalanen13829532008-05-12 21:20:58 +020064{
Pekka Paalanen13829532008-05-12 21:20:58 +020065 int i;
66 resource_size_t start, end;
67 const struct pci_driver *drv = pci_dev_driver(dev);
68
Steven Rostedt (Red Hat)a72e10a2014-11-12 16:26:06 -050069 trace_seq_printf(s, "PCIDEV %02x%02x %04x%04x %x",
70 dev->bus->number, dev->devfn,
71 dev->vendor, dev->device, dev->irq);
Pekka Paalanen13829532008-05-12 21:20:58 +020072 for (i = 0; i < 7; i++) {
Bjorn Helgaas9a519332016-05-11 14:06:57 -050073 start = dev->resource[i].start;
Steven Rostedt (Red Hat)a72e10a2014-11-12 16:26:06 -050074 trace_seq_printf(s, " %llx",
Pekka Paalanen13829532008-05-12 21:20:58 +020075 (unsigned long long)(start |
76 (dev->resource[i].flags & PCI_REGION_FLAG_MASK)));
77 }
78 for (i = 0; i < 7; i++) {
Bjorn Helgaas9a519332016-05-11 14:06:57 -050079 start = dev->resource[i].start;
80 end = dev->resource[i].end;
Steven Rostedt (Red Hat)a72e10a2014-11-12 16:26:06 -050081 trace_seq_printf(s, " %llx",
Pekka Paalanen13829532008-05-12 21:20:58 +020082 dev->resource[i].start < dev->resource[i].end ?
83 (unsigned long long)(end - start) + 1 : 0);
84 }
85 if (drv)
Steven Rostedt (Red Hat)a72e10a2014-11-12 16:26:06 -050086 trace_seq_printf(s, " %s\n", drv->name);
Pekka Paalanen13829532008-05-12 21:20:58 +020087 else
Steven Rostedt (Red Hat)a72e10a2014-11-12 16:26:06 -050088 trace_seq_puts(s, " \n");
Pekka Paalanen13829532008-05-12 21:20:58 +020089}
90
Pekka Paalanend0a7e8ca2008-05-12 21:21:02 +020091static void destroy_header_iter(struct header_iter *hiter)
Pekka Paalanenbd8ac682008-05-12 21:20:57 +020092{
Pekka Paalanend0a7e8ca2008-05-12 21:21:02 +020093 if (!hiter)
94 return;
95 pci_dev_put(hiter->dev);
96 kfree(hiter);
97}
98
99static void mmio_pipe_open(struct trace_iterator *iter)
100{
101 struct header_iter *hiter;
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200102 struct trace_seq *s = &iter->seq;
Pekka Paalanen13829532008-05-12 21:20:58 +0200103
zhangwei(Jovi)146c3442013-07-15 16:32:44 +0800104 trace_seq_puts(s, "VERSION 20070824\n");
Pekka Paalanen13829532008-05-12 21:20:58 +0200105
Pekka Paalanend0a7e8ca2008-05-12 21:21:02 +0200106 hiter = kzalloc(sizeof(*hiter), GFP_KERNEL);
107 if (!hiter)
108 return;
109
110 hiter->dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL);
111 iter->private = hiter;
112}
113
114/* XXX: This is not called when the pipe is closed! */
115static void mmio_close(struct trace_iterator *iter)
116{
117 struct header_iter *hiter = iter->private;
118 destroy_header_iter(hiter);
119 iter->private = NULL;
120}
121
Pekka Paalanen20392382008-05-12 21:21:02 +0200122static unsigned long count_overruns(struct trace_iterator *iter)
123{
Pekka Paalanen173ed242009-01-06 13:57:11 +0200124 unsigned long cnt = atomic_xchg(&dropped_count, 0);
Steven Rostedt (VMware)1c5eb442020-01-09 18:53:48 -0500125 unsigned long over = ring_buffer_overruns(iter->array_buffer->buffer);
Pekka Paalanen7ee17682008-11-23 21:24:30 +0200126
127 if (over > prev_overruns)
Pekka Paalanen173ed242009-01-06 13:57:11 +0200128 cnt += over - prev_overruns;
Pekka Paalanen7ee17682008-11-23 21:24:30 +0200129 prev_overruns = over;
Pekka Paalanen20392382008-05-12 21:21:02 +0200130 return cnt;
131}
132
Pekka Paalanend0a7e8ca2008-05-12 21:21:02 +0200133static ssize_t mmio_read(struct trace_iterator *iter, struct file *filp,
134 char __user *ubuf, size_t cnt, loff_t *ppos)
135{
136 ssize_t ret;
137 struct header_iter *hiter = iter->private;
138 struct trace_seq *s = &iter->seq;
Pekka Paalanen20392382008-05-12 21:21:02 +0200139 unsigned long n;
140
141 n = count_overruns(iter);
142 if (n) {
143 /* XXX: This is later than where events were lost. */
144 trace_seq_printf(s, "MARK 0.000000 Lost %lu events.\n", n);
145 if (!overrun_detected)
Joe Perchesa395d6a2016-03-22 14:28:09 -0700146 pr_warn("mmiotrace has lost events\n");
Pekka Paalanen20392382008-05-12 21:21:02 +0200147 overrun_detected = true;
148 goto print_out;
149 }
Pekka Paalanend0a7e8ca2008-05-12 21:21:02 +0200150
151 if (!hiter)
152 return 0;
153
154 mmio_print_pcidev(s, hiter->dev);
155 hiter->dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, hiter->dev);
156
157 if (!hiter->dev) {
158 destroy_header_iter(hiter);
159 iter->private = NULL;
160 }
161
Pekka Paalanen20392382008-05-12 21:21:02 +0200162print_out:
Pekka Paalanend0a7e8ca2008-05-12 21:21:02 +0200163 ret = trace_seq_to_user(s, ubuf, cnt);
164 return (ret == -EBUSY) ? 0 : ret;
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200165}
166
Frederic Weisbecker07f4e4f2008-09-29 20:27:42 +0200167static enum print_line_t mmio_print_rw(struct trace_iterator *iter)
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200168{
169 struct trace_entry *entry = iter->ent;
Steven Rostedt7104f302008-10-01 10:52:51 -0400170 struct trace_mmiotrace_rw *field;
171 struct mmiotrace_rw *rw;
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200172 struct trace_seq *s = &iter->seq;
Steven Rostedt3928a8a2008-09-29 23:02:41 -0400173 unsigned long long t = ns2usecs(iter->ts);
Li Zefana5dec552009-03-27 14:55:44 +0800174 unsigned long usec_rem = do_div(t, USEC_PER_SEC);
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200175 unsigned secs = (unsigned long)t;
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200176
Steven Rostedt7104f302008-10-01 10:52:51 -0400177 trace_assign_type(field, entry);
178 rw = &field->rw;
179
Steven Rostedt777e2082008-09-29 23:02:42 -0400180 switch (rw->opcode) {
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200181 case MMIO_READ:
Steven Rostedt (Red Hat)a72e10a2014-11-12 16:26:06 -0500182 trace_seq_printf(s,
Steven Rostedt5e4abc92009-01-15 21:00:50 -0500183 "R %d %u.%06lu %d 0x%llx 0x%lx 0x%lx %d\n",
Pekka Paalanendee310d2008-05-12 21:21:03 +0200184 rw->width, secs, usec_rem, rw->map_id,
185 (unsigned long long)rw->phys,
Pekka Paalanen736ca612008-05-12 21:20:59 +0200186 rw->value, rw->pc, 0);
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200187 break;
188 case MMIO_WRITE:
Steven Rostedt (Red Hat)a72e10a2014-11-12 16:26:06 -0500189 trace_seq_printf(s,
Steven Rostedt5e4abc92009-01-15 21:00:50 -0500190 "W %d %u.%06lu %d 0x%llx 0x%lx 0x%lx %d\n",
Pekka Paalanendee310d2008-05-12 21:21:03 +0200191 rw->width, secs, usec_rem, rw->map_id,
192 (unsigned long long)rw->phys,
Pekka Paalanen736ca612008-05-12 21:20:59 +0200193 rw->value, rw->pc, 0);
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200194 break;
195 case MMIO_UNKNOWN_OP:
Steven Rostedt (Red Hat)a72e10a2014-11-12 16:26:06 -0500196 trace_seq_printf(s,
Steven Rostedt5e4abc92009-01-15 21:00:50 -0500197 "UNKNOWN %u.%06lu %d 0x%llx %02lx,%02lx,"
198 "%02lx 0x%lx %d\n",
Pekka Paalanendee310d2008-05-12 21:21:03 +0200199 secs, usec_rem, rw->map_id,
200 (unsigned long long)rw->phys,
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200201 (rw->value >> 16) & 0xff, (rw->value >> 8) & 0xff,
Pekka Paalanen736ca612008-05-12 21:20:59 +0200202 (rw->value >> 0) & 0xff, rw->pc, 0);
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200203 break;
204 default:
Steven Rostedt (Red Hat)a72e10a2014-11-12 16:26:06 -0500205 trace_seq_puts(s, "rw what?\n");
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200206 break;
207 }
Steven Rostedt (Red Hat)a72e10a2014-11-12 16:26:06 -0500208
209 return trace_handle_return(s);
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200210}
211
Frederic Weisbecker07f4e4f2008-09-29 20:27:42 +0200212static enum print_line_t mmio_print_map(struct trace_iterator *iter)
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200213{
214 struct trace_entry *entry = iter->ent;
Steven Rostedt7104f302008-10-01 10:52:51 -0400215 struct trace_mmiotrace_map *field;
216 struct mmiotrace_map *m;
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200217 struct trace_seq *s = &iter->seq;
Steven Rostedt3928a8a2008-09-29 23:02:41 -0400218 unsigned long long t = ns2usecs(iter->ts);
Li Zefana5dec552009-03-27 14:55:44 +0800219 unsigned long usec_rem = do_div(t, USEC_PER_SEC);
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200220 unsigned secs = (unsigned long)t;
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200221
Steven Rostedt7104f302008-10-01 10:52:51 -0400222 trace_assign_type(field, entry);
223 m = &field->map;
224
Steven Rostedt777e2082008-09-29 23:02:42 -0400225 switch (m->opcode) {
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200226 case MMIO_PROBE:
Steven Rostedt (Red Hat)a72e10a2014-11-12 16:26:06 -0500227 trace_seq_printf(s,
Steven Rostedt5e4abc92009-01-15 21:00:50 -0500228 "MAP %u.%06lu %d 0x%llx 0x%lx 0x%lx 0x%lx %d\n",
Pekka Paalanendee310d2008-05-12 21:21:03 +0200229 secs, usec_rem, m->map_id,
230 (unsigned long long)m->phys, m->virt, m->len,
Pekka Paalanene0fd5c22008-05-12 21:21:02 +0200231 0UL, 0);
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200232 break;
233 case MMIO_UNPROBE:
Steven Rostedt (Red Hat)a72e10a2014-11-12 16:26:06 -0500234 trace_seq_printf(s,
Steven Rostedt5e4abc92009-01-15 21:00:50 -0500235 "UNMAP %u.%06lu %d 0x%lx %d\n",
Pekka Paalanene0fd5c22008-05-12 21:21:02 +0200236 secs, usec_rem, m->map_id, 0UL, 0);
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200237 break;
238 default:
Steven Rostedt (Red Hat)a72e10a2014-11-12 16:26:06 -0500239 trace_seq_puts(s, "map what?\n");
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200240 break;
241 }
Steven Rostedt (Red Hat)a72e10a2014-11-12 16:26:06 -0500242
243 return trace_handle_return(s);
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200244}
245
Frederic Weisbecker07f4e4f2008-09-29 20:27:42 +0200246static enum print_line_t mmio_print_mark(struct trace_iterator *iter)
Pekka Paalanenfc5e27a2008-09-16 22:02:27 +0300247{
248 struct trace_entry *entry = iter->ent;
Steven Rostedt777e2082008-09-29 23:02:42 -0400249 struct print_entry *print = (struct print_entry *)entry;
Frederic Weisbecker48ead022009-03-12 18:24:49 +0100250 const char *msg = print->buf;
Pekka Paalanenfc5e27a2008-09-16 22:02:27 +0300251 struct trace_seq *s = &iter->seq;
Steven Rostedt3928a8a2008-09-29 23:02:41 -0400252 unsigned long long t = ns2usecs(iter->ts);
Frederic Weisbecker769b0442009-03-06 17:21:49 +0100253 unsigned long usec_rem = do_div(t, USEC_PER_SEC);
Pekka Paalanenfc5e27a2008-09-16 22:02:27 +0300254 unsigned secs = (unsigned long)t;
Pekka Paalanenfc5e27a2008-09-16 22:02:27 +0300255
256 /* The trailing newline must be in the message. */
Steven Rostedt (Red Hat)a72e10a2014-11-12 16:26:06 -0500257 trace_seq_printf(s, "MARK %u.%06lu %s", secs, usec_rem, msg);
Pekka Paalanenfc5e27a2008-09-16 22:02:27 +0300258
Steven Rostedt (Red Hat)a72e10a2014-11-12 16:26:06 -0500259 return trace_handle_return(s);
Pekka Paalanenfc5e27a2008-09-16 22:02:27 +0300260}
261
Frederic Weisbecker07f4e4f2008-09-29 20:27:42 +0200262static enum print_line_t mmio_print_line(struct trace_iterator *iter)
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200263{
264 switch (iter->ent->type) {
265 case TRACE_MMIO_RW:
266 return mmio_print_rw(iter);
267 case TRACE_MMIO_MAP:
268 return mmio_print_map(iter);
Pekka Paalanenfc5e27a2008-09-16 22:02:27 +0300269 case TRACE_PRINT:
270 return mmio_print_mark(iter);
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200271 default:
Frederic Weisbecker07f4e4f2008-09-29 20:27:42 +0200272 return TRACE_TYPE_HANDLED; /* ignore unknown entries */
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200273 }
Pekka Paalanenf984b512008-05-12 21:20:57 +0200274}
275
276static struct tracer mmio_tracer __read_mostly =
277{
278 .name = "mmiotrace",
279 .init = mmio_trace_init,
280 .reset = mmio_trace_reset,
Steven Rostedtbbf5b1a2008-11-07 22:36:02 -0500281 .start = mmio_trace_start,
Pekka Paalanend0a7e8ca2008-05-12 21:21:02 +0200282 .pipe_open = mmio_pipe_open,
283 .close = mmio_close,
284 .read = mmio_read,
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200285 .print_line = mmio_print_line,
Ziqian SUN (Zamir)c7b3ae02017-09-11 14:26:35 +0800286 .noboot = true,
Pekka Paalanenf984b512008-05-12 21:20:57 +0200287};
288
289__init static int init_mmio_trace(void)
290{
Pekka Paalanenf984b512008-05-12 21:20:57 +0200291 return register_tracer(&mmio_tracer);
292}
293device_initcall(init_mmio_trace);
294
Pekka Paalanen45dcd8b2008-09-16 21:56:41 +0300295static void __trace_mmiotrace_rw(struct trace_array *tr,
296 struct trace_array_cpu *data,
297 struct mmiotrace_rw *rw)
298{
Steven Rostedt (Red Hat)2425bcb2015-05-05 11:45:27 -0400299 struct trace_event_call *call = &event_mmiotrace_rw;
Steven Rostedt (VMware)13292492019-12-13 13:58:57 -0500300 struct trace_buffer *buffer = tr->array_buffer.buffer;
Steven Rostedt3928a8a2008-09-29 23:02:41 -0400301 struct ring_buffer_event *event;
Steven Rostedt777e2082008-09-29 23:02:42 -0400302 struct trace_mmiotrace_rw *entry;
Arnaldo Carvalho de Melo51a763d2009-02-05 16:14:13 -0200303 int pc = preempt_count();
Pekka Paalanen45dcd8b2008-09-16 21:56:41 +0300304
Steven Rostedte77405a2009-09-02 14:17:06 -0400305 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
Arnaldo Carvalho de Melo51a763d2009-02-05 16:14:13 -0200306 sizeof(*entry), 0, pc);
Pekka Paalanen173ed242009-01-06 13:57:11 +0200307 if (!event) {
308 atomic_inc(&dropped_count);
Steven Rostedt3928a8a2008-09-29 23:02:41 -0400309 return;
Pekka Paalanen173ed242009-01-06 13:57:11 +0200310 }
Steven Rostedt3928a8a2008-09-29 23:02:41 -0400311 entry = ring_buffer_event_data(event);
Steven Rostedt777e2082008-09-29 23:02:42 -0400312 entry->rw = *rw;
Steven Rostedt60ba7702009-09-12 23:34:04 -0400313
Tom Zanussif306cc82013-10-24 08:34:17 -0500314 if (!call_filter_check_discard(call, entry, buffer, event))
Steven Rostedt (Red Hat)b7f0c952015-09-25 17:38:44 -0400315 trace_buffer_unlock_commit(tr, buffer, event, 0, pc);
Pekka Paalanen45dcd8b2008-09-16 21:56:41 +0300316}
317
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200318void mmio_trace_rw(struct mmiotrace_rw *rw)
Pekka Paalanenf984b512008-05-12 21:20:57 +0200319{
320 struct trace_array *tr = mmio_trace_array;
Steven Rostedt (VMware)1c5eb442020-01-09 18:53:48 -0500321 struct trace_array_cpu *data = per_cpu_ptr(tr->array_buffer.data, smp_processor_id());
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200322 __trace_mmiotrace_rw(tr, data, rw);
323}
Pekka Paalanenf984b512008-05-12 21:20:57 +0200324
Pekka Paalanen45dcd8b2008-09-16 21:56:41 +0300325static void __trace_mmiotrace_map(struct trace_array *tr,
326 struct trace_array_cpu *data,
327 struct mmiotrace_map *map)
328{
Steven Rostedt (Red Hat)2425bcb2015-05-05 11:45:27 -0400329 struct trace_event_call *call = &event_mmiotrace_map;
Steven Rostedt (VMware)13292492019-12-13 13:58:57 -0500330 struct trace_buffer *buffer = tr->array_buffer.buffer;
Steven Rostedt3928a8a2008-09-29 23:02:41 -0400331 struct ring_buffer_event *event;
Steven Rostedt777e2082008-09-29 23:02:42 -0400332 struct trace_mmiotrace_map *entry;
Arnaldo Carvalho de Melo51a763d2009-02-05 16:14:13 -0200333 int pc = preempt_count();
Pekka Paalanen45dcd8b2008-09-16 21:56:41 +0300334
Steven Rostedte77405a2009-09-02 14:17:06 -0400335 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
Arnaldo Carvalho de Melo51a763d2009-02-05 16:14:13 -0200336 sizeof(*entry), 0, pc);
Pekka Paalanen173ed242009-01-06 13:57:11 +0200337 if (!event) {
338 atomic_inc(&dropped_count);
Steven Rostedt3928a8a2008-09-29 23:02:41 -0400339 return;
Pekka Paalanen173ed242009-01-06 13:57:11 +0200340 }
Steven Rostedt3928a8a2008-09-29 23:02:41 -0400341 entry = ring_buffer_event_data(event);
Steven Rostedt777e2082008-09-29 23:02:42 -0400342 entry->map = *map;
Steven Rostedt60ba7702009-09-12 23:34:04 -0400343
Tom Zanussif306cc82013-10-24 08:34:17 -0500344 if (!call_filter_check_discard(call, entry, buffer, event))
Steven Rostedt (Red Hat)b7f0c952015-09-25 17:38:44 -0400345 trace_buffer_unlock_commit(tr, buffer, event, 0, pc);
Pekka Paalanen45dcd8b2008-09-16 21:56:41 +0300346}
347
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200348void mmio_trace_mapping(struct mmiotrace_map *map)
349{
350 struct trace_array *tr = mmio_trace_array;
351 struct trace_array_cpu *data;
352
353 preempt_disable();
Steven Rostedt (VMware)1c5eb442020-01-09 18:53:48 -0500354 data = per_cpu_ptr(tr->array_buffer.data, smp_processor_id());
Pekka Paalanenbd8ac682008-05-12 21:20:57 +0200355 __trace_mmiotrace_map(tr, data, map);
356 preempt_enable();
Pekka Paalanenf984b512008-05-12 21:20:57 +0200357}
Pekka Paalanen9e57fb32008-09-16 22:00:34 +0300358
359int mmio_trace_printk(const char *fmt, va_list args)
360{
Steven Rostedt40ce74f2009-03-19 14:03:53 -0400361 return trace_vprintk(0, fmt, args);
Pekka Paalanen9e57fb32008-09-16 22:00:34 +0300362}