1 /* SPDX-License-Identifier: GPL-2.0 */
2 #if !defined(_MSM_GPU_TRACE_H_) || defined(TRACE_HEADER_MULTI_READ)
3 #define _MSM_GPU_TRACE_H_
4 
5 #include <linux/tracepoint.h>
6 
7 #undef TRACE_SYSTEM
8 #define TRACE_SYSTEM drm_msm_gpu
9 #define TRACE_INCLUDE_FILE msm_gpu_trace
10 
11 TRACE_EVENT(msm_gpu_submit,
12 	    TP_PROTO(pid_t pid, u32 ringid, u32 id, u32 nr_bos, u32 nr_cmds),
13 	    TP_ARGS(pid, ringid, id, nr_bos, nr_cmds),
14 	    TP_STRUCT__entry(
15 		    __field(pid_t, pid)
16 		    __field(u32, id)
17 		    __field(u32, ringid)
18 		    __field(u32, nr_cmds)
19 		    __field(u32, nr_bos)
20 		    ),
21 	    TP_fast_assign(
22 		    __entry->pid = pid;
23 		    __entry->id = id;
24 		    __entry->ringid = ringid;
25 		    __entry->nr_bos = nr_bos;
26 		    __entry->nr_cmds = nr_cmds
27 		    ),
28 	    TP_printk("id=%d pid=%d ring=%d bos=%d cmds=%d",
29 		    __entry->id, __entry->pid, __entry->ringid,
30 		    __entry->nr_bos, __entry->nr_cmds)
31 );
32 
33 TRACE_EVENT(msm_gpu_submit_flush,
34 	    TP_PROTO(struct msm_gem_submit *submit, u64 ticks),
35 	    TP_ARGS(submit, ticks),
36 	    TP_STRUCT__entry(
37 		    __field(pid_t, pid)
38 		    __field(u32, id)
39 		    __field(u32, ringid)
40 		    __field(u32, seqno)
41 		    __field(u64, ticks)
42 		    ),
43 	    TP_fast_assign(
44 		    __entry->pid = pid_nr(submit->pid);
45 		    __entry->id = submit->ident;
46 		    __entry->ringid = submit->ring->id;
47 		    __entry->seqno = submit->seqno;
48 		    __entry->ticks = ticks;
49 		    ),
50 	    TP_printk("id=%d pid=%d ring=%d:%d ticks=%lld",
51 		    __entry->id, __entry->pid, __entry->ringid, __entry->seqno,
52 		    __entry->ticks)
53 );
54 
55 
56 TRACE_EVENT(msm_gpu_submit_retired,
57 	    TP_PROTO(struct msm_gem_submit *submit, u64 elapsed, u64 clock,
58 		    u64 start, u64 end),
59 	    TP_ARGS(submit, elapsed, clock, start, end),
60 	    TP_STRUCT__entry(
61 		    __field(pid_t, pid)
62 		    __field(u32, id)
63 		    __field(u32, ringid)
64 		    __field(u32, seqno)
65 		    __field(u64, elapsed)
66 		    __field(u64, clock)
67 		    __field(u64, start_ticks)
68 		    __field(u64, end_ticks)
69 		    ),
70 	    TP_fast_assign(
71 		    __entry->pid = pid_nr(submit->pid);
72 		    __entry->id = submit->ident;
73 		    __entry->ringid = submit->ring->id;
74 		    __entry->seqno = submit->seqno;
75 		    __entry->elapsed = elapsed;
76 		    __entry->clock = clock;
77 		    __entry->start_ticks = start;
78 		    __entry->end_ticks = end;
79 		    ),
80 	    TP_printk("id=%d pid=%d ring=%d:%d elapsed=%lld ns mhz=%lld start=%lld end=%lld",
81 		    __entry->id, __entry->pid, __entry->ringid, __entry->seqno,
82 		    __entry->elapsed, __entry->clock,
83 		    __entry->start_ticks, __entry->end_ticks)
84 );
85 
86 
87 TRACE_EVENT(msm_gpu_freq_change,
88 		TP_PROTO(u32 freq),
89 		TP_ARGS(freq),
90 		TP_STRUCT__entry(
91 			__field(u32, freq)
92 			),
93 		TP_fast_assign(
94 			/* trace freq in MHz to match intel_gpu_freq_change, to make life easier
95 			 * for userspace
96 			 */
97 			__entry->freq = DIV_ROUND_UP(freq, 1000000);
98 			),
99 		TP_printk("new_freq=%u", __entry->freq)
100 );
101 
102 
103 TRACE_EVENT(msm_gmu_freq_change,
104 		TP_PROTO(u32 freq, u32 perf_index),
105 		TP_ARGS(freq, perf_index),
106 		TP_STRUCT__entry(
107 			__field(u32, freq)
108 			__field(u32, perf_index)
109 			),
110 		TP_fast_assign(
111 			__entry->freq = freq;
112 			__entry->perf_index = perf_index;
113 			),
114 		TP_printk("freq=%u, perf_index=%u", __entry->freq, __entry->perf_index)
115 );
116 
117 
118 TRACE_EVENT(msm_gem_shrink,
119 		TP_PROTO(u32 nr_to_scan, u32 purged, u32 evicted,
120 			 u32 active_purged, u32 active_evicted),
121 		TP_ARGS(nr_to_scan, purged, evicted, active_purged, active_evicted),
122 		TP_STRUCT__entry(
123 			__field(u32, nr_to_scan)
124 			__field(u32, purged)
125 			__field(u32, evicted)
126 			__field(u32, active_purged)
127 			__field(u32, active_evicted)
128 			),
129 		TP_fast_assign(
130 			__entry->nr_to_scan = nr_to_scan;
131 			__entry->purged = purged;
132 			__entry->evicted = evicted;
133 			__entry->active_purged = active_purged;
134 			__entry->active_evicted = active_evicted;
135 			),
136 		TP_printk("nr_to_scan=%u pg, purged=%u pg, evicted=%u pg, active_purged=%u pg, active_evicted=%u pg",
137 			  __entry->nr_to_scan, __entry->purged, __entry->evicted,
138 			  __entry->active_purged, __entry->active_evicted)
139 );
140 
141 
142 TRACE_EVENT(msm_gem_purge_vmaps,
143 		TP_PROTO(u32 unmapped),
144 		TP_ARGS(unmapped),
145 		TP_STRUCT__entry(
146 			__field(u32, unmapped)
147 			),
148 		TP_fast_assign(
149 			__entry->unmapped = unmapped;
150 			),
151 		TP_printk("Purging %u vmaps", __entry->unmapped)
152 );
153 
154 
155 TRACE_EVENT(msm_gpu_suspend,
156 		TP_PROTO(int dummy),
157 		TP_ARGS(dummy),
158 		TP_STRUCT__entry(
159 			__field(u32, dummy)
160 			),
161 		TP_fast_assign(
162 			__entry->dummy = dummy;
163 			),
164 		TP_printk("%u", __entry->dummy)
165 );
166 
167 
168 TRACE_EVENT(msm_gpu_resume,
169 		TP_PROTO(int dummy),
170 		TP_ARGS(dummy),
171 		TP_STRUCT__entry(
172 			__field(u32, dummy)
173 			),
174 		TP_fast_assign(
175 			__entry->dummy = dummy;
176 			),
177 		TP_printk("%u", __entry->dummy)
178 );
179 
180 #endif
181 
182 #undef TRACE_INCLUDE_PATH
183 #define TRACE_INCLUDE_PATH ../../drivers/gpu/drm/msm
184 #include <trace/define_trace.h>
185