1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 #ifndef KFD_DBGMGR_H_
25 #define KFD_DBGMGR_H_
26
27 #include "kfd_priv.h"
28
29
30 #pragma pack(push, 4)
31
32 enum HSA_DBG_WAVEOP {
33 HSA_DBG_WAVEOP_HALT = 1,
34 HSA_DBG_WAVEOP_RESUME = 2,
35 HSA_DBG_WAVEOP_KILL = 3,
36 HSA_DBG_WAVEOP_DEBUG = 4,
37 HSA_DBG_WAVEOP_TRAP = 5,
38 HSA_DBG_NUM_WAVEOP = 5,
39 HSA_DBG_MAX_WAVEOP = 0xFFFFFFFF
40 };
41
42 enum HSA_DBG_WAVEMODE {
43
44 HSA_DBG_WAVEMODE_SINGLE = 0,
45
46
47
48
49
50
51 HSA_DBG_WAVEMODE_BROADCAST_PROCESS = 2,
52
53 HSA_DBG_WAVEMODE_BROADCAST_PROCESS_CU = 3,
54 HSA_DBG_NUM_WAVEMODE = 3,
55 HSA_DBG_MAX_WAVEMODE = 0xFFFFFFFF
56 };
57
58 enum HSA_DBG_WAVEMSG_TYPE {
59 HSA_DBG_WAVEMSG_AUTO = 0,
60 HSA_DBG_WAVEMSG_USER = 1,
61 HSA_DBG_WAVEMSG_ERROR = 2,
62 HSA_DBG_NUM_WAVEMSG,
63 HSA_DBG_MAX_WAVEMSG = 0xFFFFFFFF
64 };
65
66 enum HSA_DBG_WATCH_MODE {
67 HSA_DBG_WATCH_READ = 0,
68 HSA_DBG_WATCH_NONREAD = 1,
69 HSA_DBG_WATCH_ATOMIC = 2,
70 HSA_DBG_WATCH_ALL = 3,
71 HSA_DBG_WATCH_NUM,
72 HSA_DBG_WATCH_SIZE = 0xFFFFFFFF
73 };
74
75
76 struct HsaDbgWaveMsgAMDGen2 {
77 union {
78 struct ui32 {
79 uint32_t UserData:8;
80 uint32_t ShaderArray:1;
81 uint32_t Priv:1;
82 uint32_t Reserved0:4;
83 uint32_t WaveId:4;
84 uint32_t SIMD:2;
85 uint32_t HSACU:4;
86 uint32_t ShaderEngine:2;
87 uint32_t MessageType:2;
88 uint32_t Reserved1:4;
89 } ui32;
90 uint32_t Value;
91 };
92 uint32_t Reserved2;
93 };
94
95 union HsaDbgWaveMessageAMD {
96 struct HsaDbgWaveMsgAMDGen2 WaveMsgInfoGen2;
97
98 };
99
100 struct HsaDbgWaveMessage {
101 void *MemoryVA;
102 union HsaDbgWaveMessageAMD DbgWaveMsg;
103 };
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124 enum HSA_EVENTTYPE {
125 HSA_EVENTTYPE_SIGNAL = 0,
126 HSA_EVENTTYPE_NODECHANGE = 1,
127 HSA_EVENTTYPE_DEVICESTATECHANGE = 2,
128
129
130 HSA_EVENTTYPE_HW_EXCEPTION = 3,
131 HSA_EVENTTYPE_SYSTEM_EVENT = 4,
132 HSA_EVENTTYPE_DEBUG_EVENT = 5,
133 HSA_EVENTTYPE_PROFILE_EVENT = 6,
134 HSA_EVENTTYPE_QUEUE_EVENT = 7,
135
136
137
138 HSA_EVENTTYPE_MAXID,
139 HSA_EVENTTYPE_TYPE_SIZE = 0xFFFFFFFF
140 };
141
142
143 struct HsaSyncVar {
144 union SyncVar {
145 void *UserData;
146 uint64_t UserDataPtrValue;
147 } SyncVar;
148 uint64_t SyncVarSize;
149 };
150
151
152
153 enum HSA_EVENTTYPE_NODECHANGE_FLAGS {
154 HSA_EVENTTYPE_NODECHANGE_ADD = 0,
155 HSA_EVENTTYPE_NODECHANGE_REMOVE = 1,
156 HSA_EVENTTYPE_NODECHANGE_SIZE = 0xFFFFFFFF
157 };
158
159 struct HsaNodeChange {
160
161 enum HSA_EVENTTYPE_NODECHANGE_FLAGS Flags;
162 };
163
164
165 enum HSA_EVENTTYPE_DEVICESTATECHANGE_FLAGS {
166
167 HSA_EVENTTYPE_DEVICESTATUSCHANGE_START = 0,
168
169 HSA_EVENTTYPE_DEVICESTATUSCHANGE_STOP = 1,
170 HSA_EVENTTYPE_DEVICESTATUSCHANGE_SIZE = 0xFFFFFFFF
171 };
172
173 enum HSA_DEVICE {
174 HSA_DEVICE_CPU = 0,
175 HSA_DEVICE_GPU = 1,
176 MAX_HSA_DEVICE = 2
177 };
178
179 struct HsaDeviceStateChange {
180 uint32_t NodeId;
181 enum HSA_DEVICE Device;
182 enum HSA_EVENTTYPE_DEVICESTATECHANGE_FLAGS Flags;
183 };
184
185 struct HsaEventData {
186 enum HSA_EVENTTYPE EventType;
187 union EventData {
188
189
190
191
192 struct HsaSyncVar SyncVar;
193
194
195 struct HsaNodeChange NodeChangeState;
196
197
198 struct HsaDeviceStateChange DeviceState;
199 } EventData;
200
201
202
203
204 uint64_t HWData1;
205
206 uint64_t HWData2;
207
208 uint32_t HWData3;
209 };
210
211 struct HsaEventDescriptor {
212
213 enum HSA_EVENTTYPE EventType;
214
215 uint32_t NodeId;
216
217
218
219 struct HsaSyncVar SyncVar;
220 };
221
222 struct HsaEvent {
223 uint32_t EventId;
224 struct HsaEventData EventData;
225 };
226
227 #pragma pack(pop)
228
229 enum DBGDEV_TYPE {
230 DBGDEV_TYPE_ILLEGAL = 0,
231 DBGDEV_TYPE_NODIQ = 1,
232 DBGDEV_TYPE_DIQ = 2,
233 DBGDEV_TYPE_TEST = 3
234 };
235
236 struct dbg_address_watch_info {
237 struct kfd_process *process;
238 enum HSA_DBG_WATCH_MODE *watch_mode;
239 uint64_t *watch_address;
240 uint64_t *watch_mask;
241 struct HsaEvent *watch_event;
242 uint32_t num_watch_points;
243 };
244
245 struct dbg_wave_control_info {
246 struct kfd_process *process;
247 uint32_t trapId;
248 enum HSA_DBG_WAVEOP operand;
249 enum HSA_DBG_WAVEMODE mode;
250 struct HsaDbgWaveMessage dbgWave_msg;
251 };
252
253 struct kfd_dbgdev {
254
255
256 struct kfd_dev *dev;
257
258
259 struct kernel_queue *kq;
260
261
262 struct process_queue_manager *pqm;
263
264
265 enum DBGDEV_TYPE type;
266
267
268 int (*dbgdev_register)(struct kfd_dbgdev *dbgdev);
269 int (*dbgdev_unregister)(struct kfd_dbgdev *dbgdev);
270 int (*dbgdev_address_watch)(struct kfd_dbgdev *dbgdev,
271 struct dbg_address_watch_info *adw_info);
272 int (*dbgdev_wave_control)(struct kfd_dbgdev *dbgdev,
273 struct dbg_wave_control_info *wac_info);
274
275 };
276
277 struct kfd_dbgmgr {
278 unsigned int pasid;
279 struct kfd_dev *dev;
280 struct kfd_dbgdev *dbgdev;
281 };
282
283
284 struct mutex *kfd_get_dbgmgr_mutex(void);
285 void kfd_dbgmgr_destroy(struct kfd_dbgmgr *pmgr);
286 bool kfd_dbgmgr_create(struct kfd_dbgmgr **ppmgr, struct kfd_dev *pdev);
287 long kfd_dbgmgr_register(struct kfd_dbgmgr *pmgr, struct kfd_process *p);
288 long kfd_dbgmgr_unregister(struct kfd_dbgmgr *pmgr, struct kfd_process *p);
289 long kfd_dbgmgr_wave_control(struct kfd_dbgmgr *pmgr,
290 struct dbg_wave_control_info *wac_info);
291 long kfd_dbgmgr_address_watch(struct kfd_dbgmgr *pmgr,
292 struct dbg_address_watch_info *adw_info);
293 #endif