WIP FPC-III support
[linux/fpc-iii.git] / drivers / gpu / drm / i915 / gvt / trace.h
blob6d787750d279f63ed3f08e06d01a18401a52367e
1 /*
2 * Copyright © 2011-2016 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
23 * Authors:
24 * Jike Song <jike.song@intel.com>
26 * Contributors:
27 * Zhi Wang <zhi.a.wang@intel.com>
31 #if !defined(_GVT_TRACE_H_) || defined(TRACE_HEADER_MULTI_READ)
32 #define _GVT_TRACE_H_
34 #include <linux/types.h>
35 #include <linux/stringify.h>
36 #include <linux/tracepoint.h>
37 #include <asm/tsc.h>
39 #undef TRACE_SYSTEM
40 #define TRACE_SYSTEM gvt
42 TRACE_EVENT(spt_alloc,
43 TP_PROTO(int id, void *spt, int type, unsigned long mfn,
44 unsigned long gpt_gfn),
46 TP_ARGS(id, spt, type, mfn, gpt_gfn),
48 TP_STRUCT__entry(
49 __field(int, id)
50 __field(void *, spt)
51 __field(int, type)
52 __field(unsigned long, mfn)
53 __field(unsigned long, gpt_gfn)
56 TP_fast_assign(
57 __entry->id = id;
58 __entry->spt = spt;
59 __entry->type = type;
60 __entry->mfn = mfn;
61 __entry->gpt_gfn = gpt_gfn;
64 TP_printk("VM%d [alloc] spt %p type %d mfn 0x%lx gfn 0x%lx\n",
65 __entry->id,
66 __entry->spt,
67 __entry->type,
68 __entry->mfn,
69 __entry->gpt_gfn)
72 TRACE_EVENT(spt_free,
73 TP_PROTO(int id, void *spt, int type),
75 TP_ARGS(id, spt, type),
77 TP_STRUCT__entry(
78 __field(int, id)
79 __field(void *, spt)
80 __field(int, type)
83 TP_fast_assign(
84 __entry->id = id;
85 __entry->spt = spt;
86 __entry->type = type;
89 TP_printk("VM%u [free] spt %p type %d\n",
90 __entry->id,
91 __entry->spt,
92 __entry->type)
95 #define MAX_BUF_LEN 256
97 TRACE_EVENT(gma_index,
98 TP_PROTO(const char *prefix, unsigned long gma,
99 unsigned long index),
101 TP_ARGS(prefix, gma, index),
103 TP_STRUCT__entry(
104 __array(char, buf, MAX_BUF_LEN)
107 TP_fast_assign(
108 snprintf(__entry->buf, MAX_BUF_LEN,
109 "%s gma 0x%lx index 0x%lx\n", prefix, gma, index);
112 TP_printk("%s", __entry->buf)
115 TRACE_EVENT(gma_translate,
116 TP_PROTO(int id, char *type, int ring_id, int root_entry_type,
117 unsigned long gma, unsigned long gpa),
119 TP_ARGS(id, type, ring_id, root_entry_type, gma, gpa),
121 TP_STRUCT__entry(
122 __array(char, buf, MAX_BUF_LEN)
125 TP_fast_assign(
126 snprintf(__entry->buf, MAX_BUF_LEN,
127 "VM%d %s ring %d root_entry_type %d gma 0x%lx -> gpa 0x%lx\n",
128 id, type, ring_id, root_entry_type, gma, gpa);
131 TP_printk("%s", __entry->buf)
134 TRACE_EVENT(spt_refcount,
135 TP_PROTO(int id, char *action, void *spt, int before, int after),
137 TP_ARGS(id, action, spt, before, after),
139 TP_STRUCT__entry(
140 __array(char, buf, MAX_BUF_LEN)
143 TP_fast_assign(
144 snprintf(__entry->buf, MAX_BUF_LEN,
145 "VM%d [%s] spt %p before %d -> after %d\n",
146 id, action, spt, before, after);
149 TP_printk("%s", __entry->buf)
152 TRACE_EVENT(spt_change,
153 TP_PROTO(int id, char *action, void *spt, unsigned long gfn,
154 int type),
156 TP_ARGS(id, action, spt, gfn, type),
158 TP_STRUCT__entry(
159 __array(char, buf, MAX_BUF_LEN)
162 TP_fast_assign(
163 snprintf(__entry->buf, MAX_BUF_LEN,
164 "VM%d [%s] spt %p gfn 0x%lx type %d\n",
165 id, action, spt, gfn, type);
168 TP_printk("%s", __entry->buf)
171 TRACE_EVENT(spt_guest_change,
172 TP_PROTO(int id, const char *tag, void *spt, int type, u64 v,
173 unsigned long index),
175 TP_ARGS(id, tag, spt, type, v, index),
177 TP_STRUCT__entry(
178 __array(char, buf, MAX_BUF_LEN)
181 TP_fast_assign(
182 snprintf(__entry->buf, MAX_BUF_LEN,
183 "VM%d [%s] spt %p type %d entry 0x%llx index 0x%lx\n",
184 id, tag, spt, type, v, index);
187 TP_printk("%s", __entry->buf)
190 TRACE_EVENT(oos_change,
191 TP_PROTO(int id, const char *tag, int page_id, void *gpt, int type),
193 TP_ARGS(id, tag, page_id, gpt, type),
195 TP_STRUCT__entry(
196 __array(char, buf, MAX_BUF_LEN)
199 TP_fast_assign(
200 snprintf(__entry->buf, MAX_BUF_LEN,
201 "VM%d [oos %s] page id %d gpt %p type %d\n",
202 id, tag, page_id, gpt, type);
205 TP_printk("%s", __entry->buf)
208 TRACE_EVENT(oos_sync,
209 TP_PROTO(int id, int page_id, void *gpt, int type, u64 v,
210 unsigned long index),
212 TP_ARGS(id, page_id, gpt, type, v, index),
214 TP_STRUCT__entry(
215 __array(char, buf, MAX_BUF_LEN)
218 TP_fast_assign(
219 snprintf(__entry->buf, MAX_BUF_LEN,
220 "VM%d [oos sync] page id %d gpt %p type %d entry 0x%llx index 0x%lx\n",
221 id, page_id, gpt, type, v, index);
224 TP_printk("%s", __entry->buf)
227 #define GVT_CMD_STR_LEN 40
228 TRACE_EVENT(gvt_command,
229 TP_PROTO(u8 vgpu_id, u8 ring_id, u32 ip_gma, u32 *cmd_va,
230 u32 cmd_len, u32 buf_type, u32 buf_addr_type,
231 void *workload, const char *cmd_name),
233 TP_ARGS(vgpu_id, ring_id, ip_gma, cmd_va, cmd_len, buf_type,
234 buf_addr_type, workload, cmd_name),
236 TP_STRUCT__entry(
237 __field(u8, vgpu_id)
238 __field(u8, ring_id)
239 __field(u32, ip_gma)
240 __field(u32, buf_type)
241 __field(u32, buf_addr_type)
242 __field(u32, cmd_len)
243 __field(void*, workload)
244 __dynamic_array(u32, raw_cmd, cmd_len)
245 __array(char, cmd_name, GVT_CMD_STR_LEN)
248 TP_fast_assign(
249 __entry->vgpu_id = vgpu_id;
250 __entry->ring_id = ring_id;
251 __entry->ip_gma = ip_gma;
252 __entry->buf_type = buf_type;
253 __entry->buf_addr_type = buf_addr_type;
254 __entry->cmd_len = cmd_len;
255 __entry->workload = workload;
256 snprintf(__entry->cmd_name, GVT_CMD_STR_LEN, "%s", cmd_name);
257 memcpy(__get_dynamic_array(raw_cmd), cmd_va, cmd_len * sizeof(*cmd_va));
261 TP_printk("vgpu%d ring %d: address_type %u, buf_type %u, ip_gma %08x,cmd (name=%s,len=%u,raw cmd=%s), workload=%p\n",
262 __entry->vgpu_id,
263 __entry->ring_id,
264 __entry->buf_addr_type,
265 __entry->buf_type,
266 __entry->ip_gma,
267 __entry->cmd_name,
268 __entry->cmd_len,
269 __print_array(__get_dynamic_array(raw_cmd),
270 __entry->cmd_len, 4),
271 __entry->workload)
274 #define GVT_TEMP_STR_LEN 10
275 TRACE_EVENT(write_ir,
276 TP_PROTO(int id, char *reg_name, unsigned int reg, unsigned int new_val,
277 unsigned int old_val, bool changed),
279 TP_ARGS(id, reg_name, reg, new_val, old_val, changed),
281 TP_STRUCT__entry(
282 __field(int, id)
283 __array(char, buf, GVT_TEMP_STR_LEN)
284 __field(unsigned int, reg)
285 __field(unsigned int, new_val)
286 __field(unsigned int, old_val)
287 __field(bool, changed)
290 TP_fast_assign(
291 __entry->id = id;
292 snprintf(__entry->buf, GVT_TEMP_STR_LEN, "%s", reg_name);
293 __entry->reg = reg;
294 __entry->new_val = new_val;
295 __entry->old_val = old_val;
296 __entry->changed = changed;
299 TP_printk("VM%u write [%s] %x, new %08x, old %08x, changed %08x\n",
300 __entry->id, __entry->buf, __entry->reg, __entry->new_val,
301 __entry->old_val, __entry->changed)
304 TRACE_EVENT(propagate_event,
305 TP_PROTO(int id, const char *irq_name, int bit),
307 TP_ARGS(id, irq_name, bit),
309 TP_STRUCT__entry(
310 __field(int, id)
311 __array(char, buf, GVT_TEMP_STR_LEN)
312 __field(int, bit)
315 TP_fast_assign(
316 __entry->id = id;
317 snprintf(__entry->buf, GVT_TEMP_STR_LEN, "%s", irq_name);
318 __entry->bit = bit;
321 TP_printk("Set bit (%d) for (%s) for vgpu (%d)\n",
322 __entry->bit, __entry->buf, __entry->id)
325 TRACE_EVENT(inject_msi,
326 TP_PROTO(int id, unsigned int address, unsigned int data),
328 TP_ARGS(id, address, data),
330 TP_STRUCT__entry(
331 __field(int, id)
332 __field(unsigned int, address)
333 __field(unsigned int, data)
336 TP_fast_assign(
337 __entry->id = id;
338 __entry->address = address;
339 __entry->data = data;
342 TP_printk("vgpu%d:inject msi address %x data %x\n",
343 __entry->id, __entry->address, __entry->data)
346 TRACE_EVENT(render_mmio,
347 TP_PROTO(int old_id, int new_id, char *action, unsigned int reg,
348 unsigned int old_val, unsigned int new_val),
350 TP_ARGS(old_id, new_id, action, reg, old_val, new_val),
352 TP_STRUCT__entry(
353 __field(int, old_id)
354 __field(int, new_id)
355 __array(char, buf, GVT_TEMP_STR_LEN)
356 __field(unsigned int, reg)
357 __field(unsigned int, old_val)
358 __field(unsigned int, new_val)
361 TP_fast_assign(
362 __entry->old_id = old_id;
363 __entry->new_id = new_id;
364 snprintf(__entry->buf, GVT_TEMP_STR_LEN, "%s", action);
365 __entry->reg = reg;
366 __entry->old_val = old_val;
367 __entry->new_val = new_val;
370 TP_printk("VM%u -> VM%u %s reg %x, old %08x new %08x\n",
371 __entry->old_id, __entry->new_id,
372 __entry->buf, __entry->reg,
373 __entry->old_val, __entry->new_val)
376 #endif /* _GVT_TRACE_H_ */
378 /* This part must be out of protection */
379 #undef TRACE_INCLUDE_PATH
380 #define TRACE_INCLUDE_PATH .
381 #undef TRACE_INCLUDE_FILE
382 #define TRACE_INCLUDE_FILE trace
383 #include <trace/define_trace.h>