xref: /openbmc/linux/include/trace/events/iommu.h (revision 2cf1c348)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * iommu trace points
4  *
5  * Copyright (C) 2013 Shuah Khan <shuah.kh@samsung.com>
6  *
7  */
8 #undef TRACE_SYSTEM
9 #define TRACE_SYSTEM iommu
10 
11 #if !defined(_TRACE_IOMMU_H) || defined(TRACE_HEADER_MULTI_READ)
12 #define _TRACE_IOMMU_H
13 
14 #include <linux/tracepoint.h>
15 
16 struct device;
17 
18 DECLARE_EVENT_CLASS(iommu_group_event,
19 
20 	TP_PROTO(int group_id, struct device *dev),
21 
22 	TP_ARGS(group_id, dev),
23 
24 	TP_STRUCT__entry(
25 		__field(int, gid)
26 		__string(device, dev_name(dev))
27 	),
28 
29 	TP_fast_assign(
30 		__entry->gid = group_id;
31 		__assign_str(device, dev_name(dev));
32 	),
33 
34 	TP_printk("IOMMU: groupID=%d device=%s",
35 			__entry->gid, __get_str(device)
36 	)
37 );
38 
39 DEFINE_EVENT(iommu_group_event, add_device_to_group,
40 
41 	TP_PROTO(int group_id, struct device *dev),
42 
43 	TP_ARGS(group_id, dev)
44 
45 );
46 
47 DEFINE_EVENT(iommu_group_event, remove_device_from_group,
48 
49 	TP_PROTO(int group_id, struct device *dev),
50 
51 	TP_ARGS(group_id, dev)
52 );
53 
54 DECLARE_EVENT_CLASS(iommu_device_event,
55 
56 	TP_PROTO(struct device *dev),
57 
58 	TP_ARGS(dev),
59 
60 	TP_STRUCT__entry(
61 		__string(device, dev_name(dev))
62 	),
63 
64 	TP_fast_assign(
65 		__assign_str(device, dev_name(dev));
66 	),
67 
68 	TP_printk("IOMMU: device=%s", __get_str(device)
69 	)
70 );
71 
72 DEFINE_EVENT(iommu_device_event, attach_device_to_domain,
73 
74 	TP_PROTO(struct device *dev),
75 
76 	TP_ARGS(dev)
77 );
78 
79 DEFINE_EVENT(iommu_device_event, detach_device_from_domain,
80 
81 	TP_PROTO(struct device *dev),
82 
83 	TP_ARGS(dev)
84 );
85 
86 TRACE_EVENT(map,
87 
88 	TP_PROTO(unsigned long iova, phys_addr_t paddr, size_t size),
89 
90 	TP_ARGS(iova, paddr, size),
91 
92 	TP_STRUCT__entry(
93 		__field(u64, iova)
94 		__field(u64, paddr)
95 		__field(size_t, size)
96 	),
97 
98 	TP_fast_assign(
99 		__entry->iova = iova;
100 		__entry->paddr = paddr;
101 		__entry->size = size;
102 	),
103 
104 	TP_printk("IOMMU: iova=0x%016llx - 0x%016llx paddr=0x%016llx size=%zu",
105 		  __entry->iova, __entry->iova + __entry->size, __entry->paddr,
106 		  __entry->size
107 	)
108 );
109 
110 TRACE_EVENT(unmap,
111 
112 	TP_PROTO(unsigned long iova, size_t size, size_t unmapped_size),
113 
114 	TP_ARGS(iova, size, unmapped_size),
115 
116 	TP_STRUCT__entry(
117 		__field(u64, iova)
118 		__field(size_t, size)
119 		__field(size_t, unmapped_size)
120 	),
121 
122 	TP_fast_assign(
123 		__entry->iova = iova;
124 		__entry->size = size;
125 		__entry->unmapped_size = unmapped_size;
126 	),
127 
128 	TP_printk("IOMMU: iova=0x%016llx - 0x%016llx size=%zu unmapped_size=%zu",
129 		  __entry->iova, __entry->iova + __entry->size,
130 		  __entry->size, __entry->unmapped_size
131 	)
132 );
133 
134 DECLARE_EVENT_CLASS(iommu_error,
135 
136 	TP_PROTO(struct device *dev, unsigned long iova, int flags),
137 
138 	TP_ARGS(dev, iova, flags),
139 
140 	TP_STRUCT__entry(
141 		__string(device, dev_name(dev))
142 		__string(driver, dev_driver_string(dev))
143 		__field(u64, iova)
144 		__field(int, flags)
145 	),
146 
147 	TP_fast_assign(
148 		__assign_str(device, dev_name(dev));
149 		__assign_str(driver, dev_driver_string(dev));
150 		__entry->iova = iova;
151 		__entry->flags = flags;
152 	),
153 
154 	TP_printk("IOMMU:%s %s iova=0x%016llx flags=0x%04x",
155 			__get_str(driver), __get_str(device),
156 			__entry->iova, __entry->flags
157 	)
158 );
159 
160 DEFINE_EVENT(iommu_error, io_page_fault,
161 
162 	TP_PROTO(struct device *dev, unsigned long iova, int flags),
163 
164 	TP_ARGS(dev, iova, flags)
165 );
166 #endif /* _TRACE_IOMMU_H */
167 
168 /* This part must be outside protection */
169 #include <trace/define_trace.h>
170