xref: /linux/arch/powerpc/include/asm/trace.h (revision e7d759f31ca295d589f7420719c311870bb3166f)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #undef TRACE_SYSTEM
3 #define TRACE_SYSTEM powerpc
4 
5 #if !defined(_TRACE_POWERPC_H) || defined(TRACE_HEADER_MULTI_READ)
6 #define _TRACE_POWERPC_H
7 
8 #include <linux/tracepoint.h>
9 
10 struct pt_regs;
11 
12 DECLARE_EVENT_CLASS(ppc64_interrupt_class,
13 
14 	TP_PROTO(struct pt_regs *regs),
15 
16 	TP_ARGS(regs),
17 
18 	TP_STRUCT__entry(
19 		__field(struct pt_regs *, regs)
20 	),
21 
22 	TP_fast_assign(
23 		__entry->regs = regs;
24 	),
25 
26 	TP_printk("pt_regs=%p", __entry->regs)
27 );
28 
29 DEFINE_EVENT(ppc64_interrupt_class, irq_entry,
30 
31 	TP_PROTO(struct pt_regs *regs),
32 
33 	TP_ARGS(regs)
34 );
35 
36 DEFINE_EVENT(ppc64_interrupt_class, irq_exit,
37 
38 	TP_PROTO(struct pt_regs *regs),
39 
40 	TP_ARGS(regs)
41 );
42 
43 DEFINE_EVENT(ppc64_interrupt_class, timer_interrupt_entry,
44 
45 	TP_PROTO(struct pt_regs *regs),
46 
47 	TP_ARGS(regs)
48 );
49 
50 DEFINE_EVENT(ppc64_interrupt_class, timer_interrupt_exit,
51 
52 	TP_PROTO(struct pt_regs *regs),
53 
54 	TP_ARGS(regs)
55 );
56 
57 #ifdef CONFIG_PPC_DOORBELL
58 DEFINE_EVENT(ppc64_interrupt_class, doorbell_entry,
59 
60 	TP_PROTO(struct pt_regs *regs),
61 
62 	TP_ARGS(regs)
63 );
64 
65 DEFINE_EVENT(ppc64_interrupt_class, doorbell_exit,
66 
67 	TP_PROTO(struct pt_regs *regs),
68 
69 	TP_ARGS(regs)
70 );
71 #endif
72 
73 #ifdef CONFIG_PPC_PSERIES
74 extern int hcall_tracepoint_regfunc(void);
75 extern void hcall_tracepoint_unregfunc(void);
76 
77 TRACE_EVENT_FN_COND(hcall_entry,
78 
79 	TP_PROTO(unsigned long opcode, unsigned long *args),
80 
81 	TP_ARGS(opcode, args),
82 
83 	TP_CONDITION(cpu_online(raw_smp_processor_id())),
84 
85 	TP_STRUCT__entry(
86 		__field(unsigned long, opcode)
87 	),
88 
89 	TP_fast_assign(
90 		__entry->opcode = opcode;
91 	),
92 
93 	TP_printk("opcode=%lu", __entry->opcode),
94 
95 	hcall_tracepoint_regfunc, hcall_tracepoint_unregfunc
96 );
97 
98 TRACE_EVENT_FN_COND(hcall_exit,
99 
100 	TP_PROTO(unsigned long opcode, long retval, unsigned long *retbuf),
101 
102 	TP_ARGS(opcode, retval, retbuf),
103 
104 	TP_CONDITION(cpu_online(raw_smp_processor_id())),
105 
106 	TP_STRUCT__entry(
107 		__field(unsigned long, opcode)
108 		__field(long, retval)
109 	),
110 
111 	TP_fast_assign(
112 		__entry->opcode = opcode;
113 		__entry->retval = retval;
114 	),
115 
116 	TP_printk("opcode=%lu retval=%ld", __entry->opcode, __entry->retval),
117 
118 	hcall_tracepoint_regfunc, hcall_tracepoint_unregfunc
119 );
120 #endif
121 
122 #ifdef CONFIG_PPC_RTAS
123 
124 #include <asm/rtas-types.h>
125 
126 TRACE_EVENT(rtas_input,
127 
128 	TP_PROTO(struct rtas_args *rtas_args, const char *name),
129 
130 	TP_ARGS(rtas_args, name),
131 
132 	TP_STRUCT__entry(
133 		__field(__u32, nargs)
134 		__string(name, name)
135 		__dynamic_array(__u32, inputs, be32_to_cpu(rtas_args->nargs))
136 	),
137 
138 	TP_fast_assign(
139 		__entry->nargs = be32_to_cpu(rtas_args->nargs);
140 		__assign_str(name, name);
141 		be32_to_cpu_array(__get_dynamic_array(inputs), rtas_args->args, __entry->nargs);
142 	),
143 
144 	TP_printk("%s arguments: %s", __get_str(name),
145 		  __print_array(__get_dynamic_array(inputs), __entry->nargs, 4)
146 	)
147 );
148 
149 TRACE_EVENT(rtas_output,
150 
151 	TP_PROTO(struct rtas_args *rtas_args, const char *name),
152 
153 	TP_ARGS(rtas_args, name),
154 
155 	TP_STRUCT__entry(
156 		__field(__u32, nr_other)
157 		__field(__s32, status)
158 		__string(name, name)
159 		__dynamic_array(__u32, other_outputs, be32_to_cpu(rtas_args->nret) - 1)
160 	),
161 
162 	TP_fast_assign(
163 		__entry->nr_other = be32_to_cpu(rtas_args->nret) - 1;
164 		__entry->status = be32_to_cpu(rtas_args->rets[0]);
165 		__assign_str(name, name);
166 		be32_to_cpu_array(__get_dynamic_array(other_outputs),
167 				  &rtas_args->rets[1], __entry->nr_other);
168 	),
169 
170 	TP_printk("%s status: %d, other outputs: %s", __get_str(name), __entry->status,
171 		  __print_array(__get_dynamic_array(other_outputs),
172 				__entry->nr_other, 4)
173 	)
174 );
175 
176 DECLARE_EVENT_CLASS(rtas_parameter_block,
177 
178 	TP_PROTO(struct rtas_args *rtas_args),
179 
180 	TP_ARGS(rtas_args),
181 
182 	TP_STRUCT__entry(
183 		__field(u32, token)
184 		__field(u32, nargs)
185 		__field(u32, nret)
186 		__array(__u32, params, 16)
187 	),
188 
189 	TP_fast_assign(
190 		__entry->token = be32_to_cpu(rtas_args->token);
191 		__entry->nargs = be32_to_cpu(rtas_args->nargs);
192 		__entry->nret = be32_to_cpu(rtas_args->nret);
193 		be32_to_cpu_array(__entry->params, rtas_args->args, ARRAY_SIZE(rtas_args->args));
194 	),
195 
196 	TP_printk("token=%u nargs=%u nret=%u params:"
197 		  " [0]=0x%08x [1]=0x%08x [2]=0x%08x [3]=0x%08x"
198 		  " [4]=0x%08x [5]=0x%08x [6]=0x%08x [7]=0x%08x"
199 		  " [8]=0x%08x [9]=0x%08x [10]=0x%08x [11]=0x%08x"
200 		  " [12]=0x%08x [13]=0x%08x [14]=0x%08x [15]=0x%08x",
201 		  __entry->token, __entry->nargs, __entry->nret,
202 		  __entry->params[0], __entry->params[1], __entry->params[2], __entry->params[3],
203 		  __entry->params[4], __entry->params[5], __entry->params[6], __entry->params[7],
204 		  __entry->params[8], __entry->params[9], __entry->params[10], __entry->params[11],
205 		  __entry->params[12], __entry->params[13], __entry->params[14], __entry->params[15]
206 	)
207 );
208 
209 DEFINE_EVENT(rtas_parameter_block, rtas_ll_entry,
210 
211 	TP_PROTO(struct rtas_args *rtas_args),
212 
213 	TP_ARGS(rtas_args)
214 );
215 
216 DEFINE_EVENT(rtas_parameter_block, rtas_ll_exit,
217 
218 	TP_PROTO(struct rtas_args *rtas_args),
219 
220 	TP_ARGS(rtas_args)
221 );
222 
223 #endif /* CONFIG_PPC_RTAS */
224 
225 #ifdef CONFIG_PPC_POWERNV
226 extern int opal_tracepoint_regfunc(void);
227 extern void opal_tracepoint_unregfunc(void);
228 
229 TRACE_EVENT_FN(opal_entry,
230 
231 	TP_PROTO(unsigned long opcode, unsigned long *args),
232 
233 	TP_ARGS(opcode, args),
234 
235 	TP_STRUCT__entry(
236 		__field(unsigned long, opcode)
237 	),
238 
239 	TP_fast_assign(
240 		__entry->opcode = opcode;
241 	),
242 
243 	TP_printk("opcode=%lu", __entry->opcode),
244 
245 	opal_tracepoint_regfunc, opal_tracepoint_unregfunc
246 );
247 
248 TRACE_EVENT_FN(opal_exit,
249 
250 	TP_PROTO(unsigned long opcode, unsigned long retval),
251 
252 	TP_ARGS(opcode, retval),
253 
254 	TP_STRUCT__entry(
255 		__field(unsigned long, opcode)
256 		__field(unsigned long, retval)
257 	),
258 
259 	TP_fast_assign(
260 		__entry->opcode = opcode;
261 		__entry->retval = retval;
262 	),
263 
264 	TP_printk("opcode=%lu retval=%lu", __entry->opcode, __entry->retval),
265 
266 	opal_tracepoint_regfunc, opal_tracepoint_unregfunc
267 );
268 #endif
269 
270 TRACE_EVENT(hash_fault,
271 
272 	    TP_PROTO(unsigned long addr, unsigned long access, unsigned long trap),
273 	    TP_ARGS(addr, access, trap),
274 	    TP_STRUCT__entry(
275 		    __field(unsigned long, addr)
276 		    __field(unsigned long, access)
277 		    __field(unsigned long, trap)
278 		    ),
279 
280 	    TP_fast_assign(
281 		    __entry->addr = addr;
282 		    __entry->access = access;
283 		    __entry->trap = trap;
284 		    ),
285 
286 	    TP_printk("hash fault with addr 0x%lx and access = 0x%lx trap = 0x%lx",
287 		      __entry->addr, __entry->access, __entry->trap)
288 );
289 
290 
291 TRACE_EVENT(tlbie,
292 
293 	TP_PROTO(unsigned long lpid, unsigned long local, unsigned long rb,
294 		unsigned long rs, unsigned long ric, unsigned long prs,
295 		unsigned long r),
296 	TP_ARGS(lpid, local, rb, rs, ric, prs, r),
297 	TP_STRUCT__entry(
298 		__field(unsigned long, lpid)
299 		__field(unsigned long, local)
300 		__field(unsigned long, rb)
301 		__field(unsigned long, rs)
302 		__field(unsigned long, ric)
303 		__field(unsigned long, prs)
304 		__field(unsigned long, r)
305 		),
306 
307 	TP_fast_assign(
308 		__entry->lpid = lpid;
309 		__entry->local = local;
310 		__entry->rb = rb;
311 		__entry->rs = rs;
312 		__entry->ric = ric;
313 		__entry->prs = prs;
314 		__entry->r = r;
315 		),
316 
317 	TP_printk("lpid=%ld, local=%ld, rb=0x%lx, rs=0x%lx, ric=0x%lx, "
318 		"prs=0x%lx, r=0x%lx", __entry->lpid, __entry->local,
319 		__entry->rb, __entry->rs, __entry->ric, __entry->prs,
320 		__entry->r)
321 );
322 
323 TRACE_EVENT(tlbia,
324 
325 	TP_PROTO(unsigned long id),
326 	TP_ARGS(id),
327 	TP_STRUCT__entry(
328 		__field(unsigned long, id)
329 		),
330 
331 	TP_fast_assign(
332 		__entry->id = id;
333 		),
334 
335 	TP_printk("ctx.id=0x%lx", __entry->id)
336 );
337 
338 #endif /* _TRACE_POWERPC_H */
339 
340 #undef TRACE_INCLUDE_PATH
341 #undef TRACE_INCLUDE_FILE
342 
343 #define TRACE_INCLUDE_PATH asm
344 #define TRACE_INCLUDE_FILE trace
345 
346 #include <trace/define_trace.h>
347