1 /*
2  * Copyright 2018 Advanced Micro Devices, Inc.
3  *
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:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20  * OTHER DEALINGS IN THE SOFTWARE.
21  *
22  * Authors: AMD
23  *
24  */
25 
26 #undef TRACE_SYSTEM
27 #define TRACE_SYSTEM amdgpu_dm
28 
29 #if !defined(_AMDGPU_DM_TRACE_H_) || defined(TRACE_HEADER_MULTI_READ)
30 #define _AMDGPU_DM_TRACE_H_
31 
32 #include <linux/tracepoint.h>
33 
34 DECLARE_EVENT_CLASS(amdgpu_dc_reg_template,
35 		    TP_PROTO(unsigned long *count, uint32_t reg, uint32_t value),
36 		    TP_ARGS(count, reg, value),
37 
38 		    TP_STRUCT__entry(
39 				     __field(uint32_t, reg)
40 				     __field(uint32_t, value)
41 		    ),
42 
43 		    TP_fast_assign(
44 				   __entry->reg = reg;
45 				   __entry->value = value;
46 				   *count = *count + 1;
47 		    ),
48 
49 		    TP_printk("reg=0x%08lx, value=0x%08lx",
50 			      (unsigned long)__entry->reg,
51 			      (unsigned long)__entry->value)
52 );
53 
54 DEFINE_EVENT(amdgpu_dc_reg_template, amdgpu_dc_rreg,
55 	     TP_PROTO(unsigned long *count, uint32_t reg, uint32_t value),
56 	     TP_ARGS(count, reg, value));
57 
58 DEFINE_EVENT(amdgpu_dc_reg_template, amdgpu_dc_wreg,
59 	     TP_PROTO(unsigned long *count, uint32_t reg, uint32_t value),
60 	     TP_ARGS(count, reg, value));
61 
62 TRACE_EVENT(amdgpu_dc_performance,
63 	TP_PROTO(unsigned long read_count, unsigned long write_count,
64 		unsigned long *last_read, unsigned long *last_write,
65 		const char *func, unsigned int line),
66 	TP_ARGS(read_count, write_count, last_read, last_write, func, line),
67 	TP_STRUCT__entry(
68 			__field(uint32_t, reads)
69 			__field(uint32_t, writes)
70 			__field(uint32_t, read_delta)
71 			__field(uint32_t, write_delta)
72 			__string(func, func)
73 			__field(uint32_t, line)
74 			),
75 	TP_fast_assign(
76 			__entry->reads = read_count;
77 			__entry->writes = write_count;
78 			__entry->read_delta = read_count - *last_read;
79 			__entry->write_delta = write_count - *last_write;
80 			__assign_str(func, func);
81 			__entry->line = line;
82 			*last_read = read_count;
83 			*last_write = write_count;
84 			),
85 	TP_printk("%s:%d reads=%08ld (%08ld total), writes=%08ld (%08ld total)",
86 			__get_str(func), __entry->line,
87 			(unsigned long)__entry->read_delta,
88 			(unsigned long)__entry->reads,
89 			(unsigned long)__entry->write_delta,
90 			(unsigned long)__entry->writes)
91 );
92 #endif /* _AMDGPU_DM_TRACE_H_ */
93 
94 #undef TRACE_INCLUDE_PATH
95 #define TRACE_INCLUDE_PATH .
96 #define TRACE_INCLUDE_FILE amdgpu_dm_trace
97 #include <trace/define_trace.h>
98