1 /* SPDX-License-Identifier: GPL-2.0
2  *
3  * Copyright 2016-2021 HabanaLabs, Ltd.
4  * All Rights Reserved.
5  *
6  */
7 
8 #undef TRACE_SYSTEM
9 #define TRACE_SYSTEM habanalabs
10 
11 #if !defined(_TRACE_HABANALABS_H) || defined(TRACE_HEADER_MULTI_READ)
12 #define _TRACE_HABANALABS_H
13 
14 #include <linux/tracepoint.h>
15 
16 DECLARE_EVENT_CLASS(habanalabs_mmu_template,
17 	TP_PROTO(struct device *dev, u64 virt_addr, u64 phys_addr, u32 page_size, bool flush_pte),
18 
19 	TP_ARGS(dev, virt_addr, phys_addr, page_size, flush_pte),
20 
21 	TP_STRUCT__entry(
22 		__string(dname, dev_name(dev))
23 		__field(u64, virt_addr)
24 		__field(u64, phys_addr)
25 		__field(u32, page_size)
26 		__field(u8, flush_pte)
27 	),
28 
29 	TP_fast_assign(
30 		__assign_str(dname, dev_name(dev));
31 		__entry->virt_addr = virt_addr;
32 		__entry->phys_addr = phys_addr;
33 		__entry->page_size = page_size;
34 		__entry->flush_pte = flush_pte;
35 	),
36 
37 	TP_printk("%s: vaddr: %#llx, paddr: %#llx, psize: %#x, flush: %s",
38 		__get_str(dname),
39 		__entry->virt_addr,
40 		__entry->phys_addr,
41 		__entry->page_size,
42 		__entry->flush_pte ? "true" : "false")
43 );
44 
45 DEFINE_EVENT(habanalabs_mmu_template, habanalabs_mmu_map,
46 	TP_PROTO(struct device *dev, u64 virt_addr, u64 phys_addr, u32 page_size, bool flush_pte),
47 	TP_ARGS(dev, virt_addr, phys_addr, page_size, flush_pte));
48 
49 DEFINE_EVENT(habanalabs_mmu_template, habanalabs_mmu_unmap,
50 	TP_PROTO(struct device *dev, u64 virt_addr, u64 phys_addr, u32 page_size, bool flush_pte),
51 	TP_ARGS(dev, virt_addr, phys_addr, page_size, flush_pte));
52 
53 DECLARE_EVENT_CLASS(habanalabs_dma_alloc_template,
54 	TP_PROTO(struct device *dev, u64 cpu_addr, u64 dma_addr, size_t size, const char *caller),
55 
56 	TP_ARGS(dev, cpu_addr, dma_addr, size, caller),
57 
58 	TP_STRUCT__entry(
59 		__string(dname, dev_name(dev))
60 		__field(u64, cpu_addr)
61 		__field(u64, dma_addr)
62 		__field(u32, size)
63 		__field(const char *, caller)
64 	),
65 
66 	TP_fast_assign(
67 		__assign_str(dname, dev_name(dev));
68 		__entry->cpu_addr = cpu_addr;
69 		__entry->dma_addr = dma_addr;
70 		__entry->size = size;
71 		__entry->caller = caller;
72 	),
73 
74 	TP_printk("%s: cpu_addr: %#llx, dma_addr: %#llx, size: %#x, caller: %s",
75 		__get_str(dname),
76 		__entry->cpu_addr,
77 		__entry->dma_addr,
78 		__entry->size,
79 		__entry->caller)
80 );
81 
82 DEFINE_EVENT(habanalabs_dma_alloc_template, habanalabs_dma_alloc,
83 	TP_PROTO(struct device *dev, u64 cpu_addr, u64 dma_addr, size_t size, const char *caller),
84 	TP_ARGS(dev, cpu_addr, dma_addr, size, caller));
85 
86 DEFINE_EVENT(habanalabs_dma_alloc_template, habanalabs_dma_free,
87 	TP_PROTO(struct device *dev, u64 cpu_addr, u64 dma_addr, size_t size, const char *caller),
88 	TP_ARGS(dev, cpu_addr, dma_addr, size, caller));
89 
90 DECLARE_EVENT_CLASS(habanalabs_comms_template,
91 	TP_PROTO(struct device *dev, char *op_str),
92 
93 	TP_ARGS(dev, op_str),
94 
95 	TP_STRUCT__entry(
96 		__string(dname, dev_name(dev))
97 		__field(char *, op_str)
98 	),
99 
100 	TP_fast_assign(
101 		__assign_str(dname, dev_name(dev));
102 		__entry->op_str = op_str;
103 	),
104 
105 	TP_printk("%s: cms: %s",
106 		__get_str(dname),
107 		__entry->op_str)
108 );
109 
110 DEFINE_EVENT(habanalabs_comms_template, habanalabs_comms_protocol_cmd,
111 	TP_PROTO(struct device *dev, char *op_str),
112 	TP_ARGS(dev, op_str));
113 
114 DEFINE_EVENT(habanalabs_comms_template, habanalabs_comms_send_cmd,
115 	TP_PROTO(struct device *dev, char *op_str),
116 	TP_ARGS(dev, op_str));
117 
118 DEFINE_EVENT(habanalabs_comms_template, habanalabs_comms_wait_status,
119 	TP_PROTO(struct device *dev, char *op_str),
120 	TP_ARGS(dev, op_str));
121 
122 DEFINE_EVENT(habanalabs_comms_template, habanalabs_comms_wait_status_done,
123 	TP_PROTO(struct device *dev, char *op_str),
124 	TP_ARGS(dev, op_str));
125 
126 DECLARE_EVENT_CLASS(habanalabs_reg_access_template,
127 	TP_PROTO(struct device *dev, u32 addr, u32 val),
128 
129 	TP_ARGS(dev, addr, val),
130 
131 	TP_STRUCT__entry(
132 		__string(dname, dev_name(dev))
133 		__field(u32, addr)
134 		__field(u32, val)
135 	),
136 
137 	TP_fast_assign(
138 		__assign_str(dname, dev_name(dev));
139 		__entry->addr = addr;
140 		__entry->val = val;
141 	),
142 
143 	TP_printk("%s: addr: %#x, val: %#x",
144 		__get_str(dname),
145 		__entry->addr,
146 		__entry->val)
147 );
148 
149 DEFINE_EVENT(habanalabs_reg_access_template, habanalabs_rreg32,
150 	TP_PROTO(struct device *dev, u32 addr, u32 val),
151 	TP_ARGS(dev, addr, val));
152 
153 DEFINE_EVENT(habanalabs_reg_access_template, habanalabs_wreg32,
154 	TP_PROTO(struct device *dev, u32 addr, u32 val),
155 	TP_ARGS(dev, addr, val));
156 
157 DEFINE_EVENT(habanalabs_reg_access_template, habanalabs_elbi_read,
158 	TP_PROTO(struct device *dev, u32 addr, u32 val),
159 	TP_ARGS(dev, addr, val));
160 
161 DEFINE_EVENT(habanalabs_reg_access_template, habanalabs_elbi_write,
162 	TP_PROTO(struct device *dev, u32 addr, u32 val),
163 	TP_ARGS(dev, addr, val));
164 
165 #endif /* if !defined(_TRACE_HABANALABS_H) || defined(TRACE_HEADER_MULTI_READ) */
166 
167 /* This part must be outside protection */
168 #include <trace/define_trace.h>
169