RK3368 GPU: Rogue N Init.
[firefly-linux-kernel-4.4.55.git] / drivers / staging / imgtec / rogue / rogue_trace_events.h
1 /*************************************************************************/ /*!
2 @File
3 @Copyright      Copyright (c) Imagination Technologies Ltd. All Rights Reserved
4 @License        Dual MIT/GPLv2
5
6 The contents of this file are subject to the MIT license as set out below.
7
8 Permission is hereby granted, free of charge, to any person obtaining a copy
9 of this software and associated documentation files (the "Software"), to deal
10 in the Software without restriction, including without limitation the rights
11 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 copies of the Software, and to permit persons to whom the Software is
13 furnished to do so, subject to the following conditions:
14
15 The above copyright notice and this permission notice shall be included in
16 all copies or substantial portions of the Software.
17
18 Alternatively, the contents of this file may be used under the terms of
19 the GNU General Public License Version 2 ("GPL") in which case the provisions
20 of GPL are applicable instead of those above.
21
22 If you wish to allow use of your version of this file only under the terms of
23 GPL, and not to allow others to use your version of this file under the terms
24 of the MIT license, indicate your decision by deleting the provisions above
25 and replace them with the notice and other provisions required by GPL as set
26 out in the file called "GPL-COPYING" included in this distribution. If you do
27 not delete the provisions above, a recipient may use your version of this file
28 under the terms of either the MIT license or GPL.
29
30 This License is also included in this distribution in the file called
31 "MIT-COPYING".
32
33 EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
34 PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
35 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
36 PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
37 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
38 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
39 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
40 */ /**************************************************************************/
41 #undef TRACE_SYSTEM
42 #define TRACE_SYSTEM rogue
43
44 #if !defined(_ROGUE_TRACE_EVENTS_H) || defined(TRACE_HEADER_MULTI_READ)
45 #define _ROGUE_TRACE_EVENTS_H
46
47 #include <linux/tracepoint.h>
48 #include <linux/time.h>
49
50 #define show_secs_from_ns(ns) \
51         ({ \
52                 u64 t = ns + (NSEC_PER_USEC / 2); \
53                 do_div(t, NSEC_PER_SEC); \
54                 t; \
55         })
56
57 #define show_usecs_from_ns(ns) \
58         ({ \
59                 u64 t = ns + (NSEC_PER_USEC / 2) ; \
60                 u32 rem; \
61                 do_div(t, NSEC_PER_USEC); \
62                 rem = do_div(t, USEC_PER_SEC); \
63         })
64
65 void trace_fence_update_enabled_callback(void);
66 void trace_fence_update_disabled_callback(void);
67
68 TRACE_EVENT_FN(rogue_fence_update,
69
70         TP_PROTO(const char *comm, const char *cmd, const char *dm, u32 ctx_id, u32 offset,
71                 u32 sync_fwaddr, u32 sync_value),
72
73         TP_ARGS(comm, cmd, dm, ctx_id, offset, sync_fwaddr, sync_value),
74
75         TP_STRUCT__entry(
76                 __string(       comm,           comm            )
77                 __string(       cmd,            cmd             )
78                 __string(       dm,             dm              )
79                 __field(        u32,            ctx_id          )
80                 __field(        u32,            offset          )
81                 __field(        u32,            sync_fwaddr     )
82                 __field(        u32,            sync_value      )
83         ),
84
85         TP_fast_assign(
86                 __assign_str(comm, comm);
87                 __assign_str(cmd, cmd);
88                 __assign_str(dm, dm);
89                 __entry->ctx_id = ctx_id;
90                 __entry->offset = offset;
91                 __entry->sync_fwaddr = sync_fwaddr;
92                 __entry->sync_value = sync_value;
93         ),
94
95         TP_printk("comm=%s cmd=%s dm=%s ctx_id=%lu offset=%lu sync_fwaddr=%#lx sync_value=%#lx",
96                 __get_str(comm),
97                 __get_str(cmd),
98                 __get_str(dm),
99                 (unsigned long)__entry->ctx_id,
100                 (unsigned long)__entry->offset,
101                 (unsigned long)__entry->sync_fwaddr,
102                 (unsigned long)__entry->sync_value),
103
104         trace_fence_update_enabled_callback,
105         trace_fence_update_disabled_callback
106 );
107
108 void trace_fence_check_enabled_callback(void);
109 void trace_fence_check_disabled_callback(void);
110
111 TRACE_EVENT_FN(rogue_fence_check,
112
113         TP_PROTO(const char *comm, const char *cmd, const char *dm, u32 ctx_id, u32 offset,
114                 u32 sync_fwaddr, u32 sync_value),
115
116         TP_ARGS(comm, cmd, dm, ctx_id, offset, sync_fwaddr, sync_value),
117
118         TP_STRUCT__entry(
119                 __string(       comm,           comm            )
120                 __string(       cmd,            cmd             )
121                 __string(       dm,             dm              )
122                 __field(        u32,            ctx_id          )
123                 __field(        u32,            offset          )
124                 __field(        u32,            sync_fwaddr     )
125                 __field(        u32,            sync_value      )
126         ),
127
128         TP_fast_assign(
129                 __assign_str(comm, comm);
130                 __assign_str(cmd, cmd);
131                 __assign_str(dm, dm);
132                 __entry->ctx_id = ctx_id;
133                 __entry->offset = offset;
134                 __entry->sync_fwaddr = sync_fwaddr;
135                 __entry->sync_value = sync_value;
136         ),
137
138         TP_printk("comm=%s cmd=%s dm=%s ctx_id=%lu offset=%lu sync_fwaddr=%#lx sync_value=%#lx",
139                 __get_str(comm),
140                 __get_str(cmd),
141                 __get_str(dm),
142                 (unsigned long)__entry->ctx_id,
143                 (unsigned long)__entry->offset,
144                 (unsigned long)__entry->sync_fwaddr,
145                 (unsigned long)__entry->sync_value),
146
147         trace_fence_check_enabled_callback,
148         trace_fence_check_disabled_callback
149 );
150
151 TRACE_EVENT(rogue_create_fw_context,
152
153         TP_PROTO(const char *comm, const char *dm, u32 ctx_id),
154
155         TP_ARGS(comm, dm, ctx_id),
156
157         TP_STRUCT__entry(
158                 __string(       comm,           comm            )
159                 __string(       dm,             dm              )
160                 __field(        u32,            ctx_id          )
161         ),
162
163         TP_fast_assign(
164                 __assign_str(comm, comm);
165                 __assign_str(dm, dm);
166                 __entry->ctx_id = ctx_id;
167         ),
168
169         TP_printk("comm=%s dm=%s ctx_id=%lu",
170                 __get_str(comm),
171                 __get_str(dm),
172                 (unsigned long)__entry->ctx_id)
173 );
174
175 #if defined(SUPPORT_GPUTRACE_EVENTS)
176
177 void PVRGpuTraceEnableUfoCallback(void);
178 void PVRGpuTraceDisableUfoCallback(void);
179
180 TRACE_EVENT_FN(rogue_ufo_update,
181
182         TP_PROTO(u64 timestamp, u32 ctx_id, u32 job_id, u32 fwaddr,
183                 u32 old_value, u32 new_value),
184
185         TP_ARGS(timestamp, ctx_id, job_id, fwaddr, old_value, new_value),
186
187         TP_STRUCT__entry(
188                 __field(        u64,            timestamp   )
189                 __field(        u32,            ctx_id      )
190                 __field(        u32,            job_id      )
191                 __field(        u32,            fwaddr      )
192                 __field(        u32,            old_value   )
193                 __field(        u32,            new_value   )
194         ),
195
196         TP_fast_assign(
197                 __entry->timestamp = timestamp;
198                 __entry->ctx_id = ctx_id;
199                 __entry->job_id = job_id;
200                 __entry->fwaddr = fwaddr;
201                 __entry->old_value = old_value;
202                 __entry->new_value = new_value;
203         ),
204
205         TP_printk("ts=%llu.%06lu ctx_id=%lu job_id=%lu fwaddr=%#lx "
206                 "old_value=%#lx new_value=%#lx",
207                 (unsigned long long)show_secs_from_ns(__entry->timestamp),
208                 (unsigned long)show_usecs_from_ns(__entry->timestamp),
209                 (unsigned long)__entry->ctx_id,
210                 (unsigned long)__entry->job_id,
211                 (unsigned long)__entry->fwaddr,
212                 (unsigned long)__entry->old_value,
213                 (unsigned long)__entry->new_value),
214         PVRGpuTraceEnableUfoCallback,
215         PVRGpuTraceDisableUfoCallback
216 );
217
218 TRACE_EVENT_FN(rogue_ufo_check_fail,
219
220         TP_PROTO(u64 timestamp, u32 ctx_id, u32 job_id, u32 fwaddr,
221                 u32 value, u32 required),
222
223         TP_ARGS(timestamp, ctx_id, job_id, fwaddr, value, required),
224
225         TP_STRUCT__entry(
226                 __field(        u64,            timestamp   )
227                 __field(        u32,            ctx_id      )
228                 __field(        u32,            job_id      )
229                 __field(        u32,            fwaddr      )
230                 __field(        u32,            value       )
231                 __field(        u32,            required    )
232         ),
233
234         TP_fast_assign(
235                 __entry->timestamp = timestamp;
236                 __entry->ctx_id = ctx_id;
237                 __entry->job_id = job_id;
238                 __entry->fwaddr = fwaddr;
239                 __entry->value = value;
240                 __entry->required = required;
241         ),
242
243         TP_printk("ts=%llu.%06lu ctx_id=%lu job_id=%lu fwaddr=%#lx "
244                 "value=%#lx required=%#lx",
245                 (unsigned long long)show_secs_from_ns(__entry->timestamp),
246                 (unsigned long)show_usecs_from_ns(__entry->timestamp),
247                 (unsigned long)__entry->ctx_id,
248                 (unsigned long)__entry->job_id,
249                 (unsigned long)__entry->fwaddr,
250                 (unsigned long)__entry->value,
251                 (unsigned long)__entry->required),
252         PVRGpuTraceEnableUfoCallback,
253         PVRGpuTraceDisableUfoCallback
254 );
255
256 TRACE_EVENT_FN(rogue_ufo_pr_check_fail,
257
258         TP_PROTO(u64 timestamp, u32 ctx_id, u32 job_id, u32 fwaddr,
259                 u32 value, u32 required),
260
261         TP_ARGS(timestamp, ctx_id, job_id, fwaddr, value, required),
262
263         TP_STRUCT__entry(
264                 __field(        u64,            timestamp   )
265                 __field(        u32,            ctx_id      )
266                 __field(        u32,            job_id      )
267                 __field(        u32,            fwaddr      )
268                 __field(        u32,            value       )
269                 __field(        u32,            required    )
270         ),
271
272         TP_fast_assign(
273                 __entry->timestamp = timestamp;
274                 __entry->ctx_id = ctx_id;
275                 __entry->job_id = job_id;
276                 __entry->fwaddr = fwaddr;
277                 __entry->value = value;
278                 __entry->required = required;
279         ),
280
281         TP_printk("ts=%llu.%06lu ctx_id=%lu job_id=%lu fwaddr=%#lx "
282                 "value=%#lx required=%#lx",
283                 (unsigned long long)show_secs_from_ns(__entry->timestamp),
284                 (unsigned long)show_usecs_from_ns(__entry->timestamp),
285                 (unsigned long)__entry->ctx_id,
286                 (unsigned long)__entry->job_id,
287                 (unsigned long)__entry->fwaddr,
288                 (unsigned long)__entry->value,
289                 (unsigned long)__entry->required),
290         PVRGpuTraceEnableUfoCallback,
291         PVRGpuTraceDisableUfoCallback
292 );
293
294 TRACE_EVENT_FN(rogue_ufo_check_success,
295
296         TP_PROTO(u64 timestamp, u32 ctx_id, u32 job_id, u32 fwaddr, u32 value),
297
298         TP_ARGS(timestamp, ctx_id, job_id, fwaddr, value),
299
300         TP_STRUCT__entry(
301                 __field(        u64,            timestamp   )
302                 __field(        u32,            ctx_id      )
303                 __field(        u32,            job_id      )
304                 __field(        u32,            fwaddr      )
305                 __field(        u32,            value       )
306         ),
307
308         TP_fast_assign(
309                 __entry->timestamp = timestamp;
310                 __entry->ctx_id = ctx_id;
311                 __entry->job_id = job_id;
312                 __entry->fwaddr = fwaddr;
313                 __entry->value = value;
314         ),
315
316         TP_printk("ts=%llu.%06lu ctx_id=%lu job_id=%lu fwaddr=%#lx value=%#lx",
317                 (unsigned long long)show_secs_from_ns(__entry->timestamp),
318                 (unsigned long)show_usecs_from_ns(__entry->timestamp),
319                 (unsigned long)__entry->ctx_id,
320                 (unsigned long)__entry->job_id,
321                 (unsigned long)__entry->fwaddr,
322                 (unsigned long)__entry->value),
323         PVRGpuTraceEnableUfoCallback,
324         PVRGpuTraceDisableUfoCallback
325 );
326
327 TRACE_EVENT_FN(rogue_ufo_pr_check_success,
328
329         TP_PROTO(u64 timestamp, u32 ctx_id, u32 job_id, u32 fwaddr, u32 value),
330
331         TP_ARGS(timestamp, ctx_id, job_id, fwaddr, value),
332
333         TP_STRUCT__entry(
334                 __field(        u64,            timestamp   )
335                 __field(        u32,            ctx_id      )
336                 __field(        u32,            job_id      )
337                 __field(        u32,            fwaddr      )
338                 __field(        u32,            value       )
339         ),
340
341         TP_fast_assign(
342                 __entry->timestamp = timestamp;
343                 __entry->ctx_id = ctx_id;
344                 __entry->job_id = job_id;
345                 __entry->fwaddr = fwaddr;
346                 __entry->value = value;
347         ),
348
349         TP_printk("ts=%llu.%06lu ctx_id=%lu job_id=%lu fwaddr=%#lx value=%#lx",
350                 (unsigned long long)show_secs_from_ns(__entry->timestamp),
351                 (unsigned long)show_usecs_from_ns(__entry->timestamp),
352                 (unsigned long)__entry->ctx_id,
353                 (unsigned long)__entry->job_id,
354                 (unsigned long)__entry->fwaddr,
355                 (unsigned long)__entry->value),
356         PVRGpuTraceEnableUfoCallback,
357         PVRGpuTraceDisableUfoCallback
358 );
359
360 TRACE_EVENT(rogue_events_lost,
361
362         TP_PROTO(u32 event_source, u32 last_ordinal, u32 curr_ordinal),
363
364         TP_ARGS(event_source, last_ordinal, curr_ordinal),
365
366         TP_STRUCT__entry(
367                 __field(        u32,            event_source     )
368                 __field(        u32,            last_ordinal     )
369                 __field(        u32,            curr_ordinal     )
370         ),
371
372         TP_fast_assign(
373                 __entry->event_source = event_source;
374                 __entry->last_ordinal = last_ordinal;
375                 __entry->curr_ordinal = curr_ordinal;
376         ),
377
378         TP_printk("event_source=%s last_ordinal=%u curr_ordinal=%u",
379                 __print_symbolic(__entry->event_source, {0, "GPU"}, {1, "Host"}),
380                 __entry->last_ordinal,
381                 __entry->curr_ordinal)
382 );
383
384 void PVRGpuTraceEnableFirmwareActivityCallback(void);
385 void PVRGpuTraceDisableFirmwareActivityCallback(void);
386
387 TRACE_EVENT_FN(rogue_firmware_activity,
388
389         TP_PROTO(u64 timestamp, const char *task, u32 fw_event),
390
391         TP_ARGS(timestamp, task, fw_event),
392
393         TP_STRUCT__entry(
394                 __field(        u64,            timestamp       )
395                 __string(       task,           task            )
396                 __field(        u32,            fw_event        )
397         ),
398
399         TP_fast_assign(
400                 __entry->timestamp = timestamp;
401                 __assign_str(task, task);
402                 __entry->fw_event = fw_event;
403         ),
404
405         TP_printk("ts=%llu.%06lu task=%s event=%s",
406                 (unsigned long long)show_secs_from_ns(__entry->timestamp),
407                 (unsigned long)show_usecs_from_ns(__entry->timestamp),
408                 __get_str(task),
409                 __print_symbolic(__entry->fw_event,
410                         /* These values are from pvr_gputrace.h. */
411                         { 1, "begin" },
412                         { 2, "end" })),
413
414         PVRGpuTraceEnableFirmwareActivityCallback,
415         PVRGpuTraceDisableFirmwareActivityCallback
416 );
417
418 #endif /* defined(SUPPORT_GPUTRACE_EVENTS) */
419
420 #undef show_secs_from_ns
421 #undef show_usecs_from_ns
422
423 #endif /* _ROGUE_TRACE_EVENTS_H */
424
425 #undef TRACE_INCLUDE_PATH
426 #undef TRACE_INCLUDE_FILE
427 #define TRACE_INCLUDE_PATH .
428
429 /* This is needed because the name of this file doesn't match TRACE_SYSTEM. */
430 #define TRACE_INCLUDE_FILE rogue_trace_events
431
432 /* This part must be outside protection */
433 #include <trace/define_trace.h>