summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/xe/xe_guc_fwif.h
blob: c281fdbfd2d679a262fd9440595828be85cd3ced (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
/* SPDX-License-Identifier: MIT */
/*
 * Copyright © 2022 Intel Corporation
 */

#ifndef _XE_GUC_FWIF_H
#define _XE_GUC_FWIF_H

#include <linux/bits.h>

#include "abi/guc_klvs_abi.h"

#define G2H_LEN_DW_SCHED_CONTEXT_MODE_SET	4
#define G2H_LEN_DW_DEREGISTER_CONTEXT		3
#define G2H_LEN_DW_TLB_INVALIDATE		3

#define GUC_CONTEXT_DISABLE		0
#define GUC_CONTEXT_ENABLE		1

#define GUC_CLIENT_PRIORITY_KMD_HIGH	0
#define GUC_CLIENT_PRIORITY_HIGH	1
#define GUC_CLIENT_PRIORITY_KMD_NORMAL	2
#define GUC_CLIENT_PRIORITY_NORMAL	3
#define GUC_CLIENT_PRIORITY_NUM		4

#define GUC_RENDER_ENGINE		0
#define GUC_VIDEO_ENGINE		1
#define GUC_BLITTER_ENGINE		2
#define GUC_VIDEOENHANCE_ENGINE		3
#define GUC_VIDEO_ENGINE2		4
#define GUC_MAX_ENGINES_NUM		(GUC_VIDEO_ENGINE2 + 1)

#define GUC_RENDER_CLASS		0
#define GUC_VIDEO_CLASS			1
#define GUC_VIDEOENHANCE_CLASS		2
#define GUC_BLITTER_CLASS		3
#define GUC_COMPUTE_CLASS		4
#define GUC_GSC_OTHER_CLASS		5
#define GUC_LAST_ENGINE_CLASS		GUC_GSC_OTHER_CLASS
#define GUC_MAX_ENGINE_CLASSES		16
#define GUC_MAX_INSTANCES_PER_CLASS	32

/* Helper for context registration H2G */
struct guc_ctxt_registration_info {
	u32 flags;
	u32 context_idx;
	u32 engine_class;
	u32 engine_submit_mask;
	u32 wq_desc_lo;
	u32 wq_desc_hi;
	u32 wq_base_lo;
	u32 wq_base_hi;
	u32 wq_size;
	u32 hwlrca_lo;
	u32 hwlrca_hi;
};
#define CONTEXT_REGISTRATION_FLAG_KMD	BIT(0)

/* 32-bit KLV structure as used by policy updates and others */
struct guc_klv_generic_dw_t {
	u32 kl;
	u32 value;
} __packed;

/* Format of the UPDATE_CONTEXT_POLICIES H2G data packet */
struct guc_update_exec_queue_policy_header {
	u32 action;
	u32 guc_id;
} __packed;

struct guc_update_exec_queue_policy {
	struct guc_update_exec_queue_policy_header header;
	struct guc_klv_generic_dw_t klv[GUC_CONTEXT_POLICIES_KLV_NUM_IDS];
} __packed;

/* GUC_CTL_* - Parameters for loading the GuC */
#define GUC_CTL_LOG_PARAMS		0
#define   GUC_LOG_VALID			BIT(0)
#define   GUC_LOG_NOTIFY_ON_HALF_FULL	BIT(1)
#define   GUC_LOG_CAPTURE_ALLOC_UNITS	BIT(2)
#define   GUC_LOG_LOG_ALLOC_UNITS	BIT(3)
#define   GUC_LOG_CRASH_SHIFT		4
#define   GUC_LOG_CRASH_MASK		(0x3 << GUC_LOG_CRASH_SHIFT)
#define   GUC_LOG_DEBUG_SHIFT		6
#define   GUC_LOG_DEBUG_MASK	        (0xF << GUC_LOG_DEBUG_SHIFT)
#define   GUC_LOG_CAPTURE_SHIFT		10
#define   GUC_LOG_CAPTURE_MASK	        (0x3 << GUC_LOG_CAPTURE_SHIFT)
#define   GUC_LOG_BUF_ADDR_SHIFT	12

#define GUC_CTL_WA			1
#define   GUC_WA_GAM_CREDITS		BIT(10)
#define   GUC_WA_DUAL_QUEUE		BIT(11)
#define   GUC_WA_RCS_RESET_BEFORE_RC6	BIT(13)
#define   GUC_WA_CONTEXT_ISOLATION	BIT(15)
#define   GUC_WA_PRE_PARSER		BIT(14)
#define   GUC_WA_HOLD_CCS_SWITCHOUT	BIT(17)
#define   GUC_WA_POLLCS			BIT(18)
#define   GUC_WA_RENDER_RST_RC6_EXIT	BIT(19)
#define   GUC_WA_RCS_REGS_IN_CCS_REGS_LIST	BIT(21)
#define   GUC_WA_ENABLE_TSC_CHECK_ON_RC6	BIT(22)

#define GUC_CTL_FEATURE			2
#define   GUC_CTL_ENABLE_SLPC		BIT(2)
#define   GUC_CTL_DISABLE_SCHEDULER	BIT(14)

#define GUC_CTL_DEBUG			3
#define   GUC_LOG_VERBOSITY_SHIFT	0
#define   GUC_LOG_VERBOSITY_LOW		(0 << GUC_LOG_VERBOSITY_SHIFT)
#define   GUC_LOG_VERBOSITY_MED		(1 << GUC_LOG_VERBOSITY_SHIFT)
#define   GUC_LOG_VERBOSITY_HIGH	(2 << GUC_LOG_VERBOSITY_SHIFT)
#define   GUC_LOG_VERBOSITY_ULTRA	(3 << GUC_LOG_VERBOSITY_SHIFT)
#define	  GUC_LOG_VERBOSITY_MIN		0
#define	  GUC_LOG_VERBOSITY_MAX		3
#define	  GUC_LOG_VERBOSITY_MASK	0x0000000f
#define	  GUC_LOG_DESTINATION_MASK	(3 << 4)
#define   GUC_LOG_DISABLED		(1 << 6)
#define   GUC_PROFILE_ENABLED		(1 << 7)

#define GUC_CTL_ADS			4
#define   GUC_ADS_ADDR_SHIFT		1
#define   GUC_ADS_ADDR_MASK		(0xFFFFF << GUC_ADS_ADDR_SHIFT)

#define GUC_CTL_DEVID			5

#define GUC_CTL_MAX_DWORDS		14

/* Scheduling policy settings */

#define GLOBAL_POLICY_MAX_NUM_WI 15

/* Don't reset an engine upon preemption failure */
#define GLOBAL_POLICY_DISABLE_ENGINE_RESET				BIT(0)

#define GLOBAL_POLICY_DEFAULT_DPC_PROMOTE_TIME_US 500000

struct guc_policies {
	u32 submission_queue_depth[GUC_MAX_ENGINE_CLASSES];
	/*
	 * In micro seconds. How much time to allow before DPC processing is
	 * called back via interrupt (to prevent DPC queue drain starving).
	 * Typically 1000s of micro seconds (example only, not granularity).
	 */
	u32 dpc_promote_time;

	/* Must be set to take these new values. */
	u32 is_valid;

	/*
	 * Max number of WIs to process per call. A large value may keep CS
	 * idle.
	 */
	u32 max_num_work_items;

	u32 global_flags;
	u32 reserved[4];
} __packed;

/* GuC MMIO reg state struct */
struct guc_mmio_reg {
	u32 offset;
	u32 value;
	u32 flags;
	u32 mask;
#define GUC_REGSET_MASKED		BIT(0)
#define GUC_REGSET_MASKED_WITH_VALUE	BIT(2)
#define GUC_REGSET_RESTORE_ONLY		BIT(3)
} __packed;

/* GuC register sets */
struct guc_mmio_reg_set {
	u32 address;
	u16 count;
	u16 reserved;
} __packed;

/* Generic GT SysInfo data types */
#define GUC_GENERIC_GT_SYSINFO_SLICE_ENABLED		0
#define GUC_GENERIC_GT_SYSINFO_VDBOX_SFC_SUPPORT_MASK	1
#define GUC_GENERIC_GT_SYSINFO_DOORBELL_COUNT_PER_SQIDI	2
#define GUC_GENERIC_GT_SYSINFO_MAX			16

/* HW info */
struct guc_gt_system_info {
	u8 mapping_table[GUC_MAX_ENGINE_CLASSES][GUC_MAX_INSTANCES_PER_CLASS];
	u32 engine_enabled_masks[GUC_MAX_ENGINE_CLASSES];
	u32 generic_gt_sysinfo[GUC_GENERIC_GT_SYSINFO_MAX];
} __packed;

enum {
	GUC_CAPTURE_LIST_INDEX_PF = 0,
	GUC_CAPTURE_LIST_INDEX_VF = 1,
	GUC_CAPTURE_LIST_INDEX_MAX = 2,
};

/* GuC Additional Data Struct */
struct guc_ads {
	struct guc_mmio_reg_set reg_state_list[GUC_MAX_ENGINE_CLASSES][GUC_MAX_INSTANCES_PER_CLASS];
	u32 reserved0;
	u32 scheduler_policies;
	u32 gt_system_info;
	u32 reserved1;
	u32 control_data;
	u32 golden_context_lrca[GUC_MAX_ENGINE_CLASSES];
	u32 eng_state_size[GUC_MAX_ENGINE_CLASSES];
	u32 private_data;
	u32 um_init_data;
	u32 capture_instance[GUC_CAPTURE_LIST_INDEX_MAX][GUC_MAX_ENGINE_CLASSES];
	u32 capture_class[GUC_CAPTURE_LIST_INDEX_MAX][GUC_MAX_ENGINE_CLASSES];
	u32 capture_global[GUC_CAPTURE_LIST_INDEX_MAX];
	u32 reserved[14];
} __packed;

/* Engine usage stats */
struct guc_engine_usage_record {
	u32 current_context_index;
	u32 last_switch_in_stamp;
	u32 reserved0;
	u32 total_runtime;
	u32 reserved1[4];
} __packed;

struct guc_engine_usage {
	struct guc_engine_usage_record engines[GUC_MAX_ENGINE_CLASSES][GUC_MAX_INSTANCES_PER_CLASS];
} __packed;

/* This action will be programmed in C1BC - SOFT_SCRATCH_15_REG */
enum xe_guc_recv_message {
	XE_GUC_RECV_MSG_CRASH_DUMP_POSTED = BIT(1),
	XE_GUC_RECV_MSG_EXCEPTION = BIT(30),
};

/* Page fault structures */
struct access_counter_desc {
	u32 dw0;
#define ACCESS_COUNTER_TYPE	BIT(0)
#define ACCESS_COUNTER_SUBG_LO	GENMASK(31, 1)

	u32 dw1;
#define ACCESS_COUNTER_SUBG_HI	BIT(0)
#define ACCESS_COUNTER_RSVD0	GENMASK(2, 1)
#define ACCESS_COUNTER_ENG_INSTANCE	GENMASK(8, 3)
#define ACCESS_COUNTER_ENG_CLASS	GENMASK(11, 9)
#define ACCESS_COUNTER_ASID	GENMASK(31, 12)

	u32 dw2;
#define ACCESS_COUNTER_VFID	GENMASK(5, 0)
#define ACCESS_COUNTER_RSVD1	GENMASK(7, 6)
#define ACCESS_COUNTER_GRANULARITY	GENMASK(10, 8)
#define ACCESS_COUNTER_RSVD2	GENMASK(16, 11)
#define ACCESS_COUNTER_VIRTUAL_ADDR_RANGE_LO	GENMASK(31, 17)

	u32 dw3;
#define ACCESS_COUNTER_VIRTUAL_ADDR_RANGE_HI	GENMASK(31, 0)
} __packed;

enum guc_um_queue_type {
	GUC_UM_HW_QUEUE_PAGE_FAULT = 0,
	GUC_UM_HW_QUEUE_PAGE_FAULT_RESPONSE,
	GUC_UM_HW_QUEUE_ACCESS_COUNTER,
	GUC_UM_HW_QUEUE_MAX
};

struct guc_um_queue_params {
	u64 base_dpa;
	u32 base_ggtt_address;
	u32 size_in_bytes;
	u32 rsvd[4];
} __packed;

struct guc_um_init_params {
	u64 page_response_timeout_in_us;
	u32 rsvd[6];
	struct guc_um_queue_params queue_params[GUC_UM_HW_QUEUE_MAX];
} __packed;

enum xe_guc_fault_reply_type {
	PFR_ACCESS = 0,
	PFR_ENGINE,
	PFR_VFID,
	PFR_ALL,
	PFR_INVALID
};

enum xe_guc_response_desc_type {
	TLB_INVALIDATION_DESC = 0,
	FAULT_RESPONSE_DESC
};

struct xe_guc_pagefault_desc {
	u32 dw0;
#define PFD_FAULT_LEVEL		GENMASK(2, 0)
#define PFD_SRC_ID		GENMASK(10, 3)
#define PFD_RSVD_0		GENMASK(17, 11)
#define XE2_PFD_TRVA_FAULT	BIT(18)
#define PFD_ENG_INSTANCE	GENMASK(24, 19)
#define PFD_ENG_CLASS		GENMASK(27, 25)
#define PFD_PDATA_LO		GENMASK(31, 28)

	u32 dw1;
#define PFD_PDATA_HI		GENMASK(11, 0)
#define PFD_PDATA_HI_SHIFT	4
#define PFD_ASID		GENMASK(31, 12)

	u32 dw2;
#define PFD_ACCESS_TYPE		GENMASK(1, 0)
#define PFD_FAULT_TYPE		GENMASK(3, 2)
#define PFD_VFID		GENMASK(9, 4)
#define PFD_RSVD_1		GENMASK(11, 10)
#define PFD_VIRTUAL_ADDR_LO	GENMASK(31, 12)
#define PFD_VIRTUAL_ADDR_LO_SHIFT 12

	u32 dw3;
#define PFD_VIRTUAL_ADDR_HI	GENMASK(31, 0)
#define PFD_VIRTUAL_ADDR_HI_SHIFT 32
} __packed;

struct xe_guc_pagefault_reply {
	u32 dw0;
#define PFR_VALID		BIT(0)
#define PFR_SUCCESS		BIT(1)
#define PFR_REPLY		GENMASK(4, 2)
#define PFR_RSVD_0		GENMASK(9, 5)
#define PFR_DESC_TYPE		GENMASK(11, 10)
#define PFR_ASID		GENMASK(31, 12)

	u32 dw1;
#define PFR_VFID		GENMASK(5, 0)
#define PFR_RSVD_1		BIT(6)
#define PFR_ENG_INSTANCE	GENMASK(12, 7)
#define PFR_ENG_CLASS		GENMASK(15, 13)
#define PFR_PDATA		GENMASK(31, 16)

	u32 dw2;
#define PFR_RSVD_2		GENMASK(31, 0)
} __packed;

struct xe_guc_acc_desc {
	u32 dw0;
#define ACC_TYPE	BIT(0)
#define ACC_TRIGGER	0
#define ACC_NOTIFY	1
#define ACC_SUBG_LO	GENMASK(31, 1)

	u32 dw1;
#define ACC_SUBG_HI	BIT(0)
#define ACC_RSVD0	GENMASK(2, 1)
#define ACC_ENG_INSTANCE	GENMASK(8, 3)
#define ACC_ENG_CLASS	GENMASK(11, 9)
#define ACC_ASID	GENMASK(31, 12)

	u32 dw2;
#define ACC_VFID	GENMASK(5, 0)
#define ACC_RSVD1	GENMASK(7, 6)
#define ACC_GRANULARITY	GENMASK(10, 8)
#define ACC_RSVD2	GENMASK(16, 11)
#define ACC_VIRTUAL_ADDR_RANGE_LO	GENMASK(31, 17)

	u32 dw3;
#define ACC_VIRTUAL_ADDR_RANGE_HI	GENMASK(31, 0)
} __packed;

#endif