1
2
3
4
5
6#ifndef __INTEL_ENGINE_TYPES__
7#define __INTEL_ENGINE_TYPES__
8
9#include <linux/average.h>
10#include <linux/hashtable.h>
11#include <linux/irq_work.h>
12#include <linux/kref.h>
13#include <linux/list.h>
14#include <linux/llist.h>
15#include <linux/rbtree.h>
16#include <linux/timer.h>
17#include <linux/types.h>
18#include <linux/workqueue.h>
19
20#include "i915_gem.h"
21#include "i915_pmu.h"
22#include "i915_priolist_types.h"
23#include "i915_selftest.h"
24#include "intel_sseu.h"
25#include "intel_timeline_types.h"
26#include "intel_uncore.h"
27#include "intel_wakeref.h"
28#include "intel_workarounds_types.h"
29
30
31#define RENDER_CLASS 0
32#define VIDEO_DECODE_CLASS 1
33#define VIDEO_ENHANCEMENT_CLASS 2
34#define COPY_ENGINE_CLASS 3
35#define OTHER_CLASS 4
36#define MAX_ENGINE_CLASS 4
37#define MAX_ENGINE_INSTANCE 7
38
39#define I915_MAX_SLICES 3
40#define I915_MAX_SUBSLICES 8
41
42#define I915_CMD_HASH_ORDER 9
43
44struct dma_fence;
45struct drm_i915_gem_object;
46struct drm_i915_reg_table;
47struct i915_gem_context;
48struct i915_request;
49struct i915_sched_attr;
50struct i915_sched_engine;
51struct intel_gt;
52struct intel_ring;
53struct intel_uncore;
54struct intel_breadcrumbs;
55
56typedef u32 intel_engine_mask_t;
57#define ALL_ENGINES ((intel_engine_mask_t)~0ul)
58
59struct intel_hw_status_page {
60 struct list_head timelines;
61 struct i915_vma *vma;
62 u32 *addr;
63};
64
65struct intel_instdone {
66 u32 instdone;
67
68 u32 slice_common;
69 u32 slice_common_extra[2];
70 u32 sampler[I915_MAX_SLICES][I915_MAX_SUBSLICES];
71 u32 row[I915_MAX_SLICES][I915_MAX_SUBSLICES];
72};
73
74
75
76
77
78
79
80
81
82
83
84
85struct i915_ctx_workarounds {
86 struct i915_wa_ctx_bb {
87 u32 offset;
88 u32 size;
89 } indirect_ctx, per_ctx;
90 struct i915_vma *vma;
91};
92
93#define I915_MAX_VCS 8
94#define I915_MAX_VECS 4
95
96
97
98
99
100enum intel_engine_id {
101 RCS0 = 0,
102 BCS0,
103 VCS0,
104 VCS1,
105 VCS2,
106 VCS3,
107 VCS4,
108 VCS5,
109 VCS6,
110 VCS7,
111#define _VCS(n) (VCS0 + (n))
112 VECS0,
113 VECS1,
114 VECS2,
115 VECS3,
116#define _VECS(n) (VECS0 + (n))
117 I915_NUM_ENGINES
118#define INVALID_ENGINE ((enum intel_engine_id)-1)
119};
120
121
122DECLARE_EWMA(_engine_latency, 6, 4)
123
124struct st_preempt_hang {
125 struct completion completion;
126 unsigned int count;
127};
128
129
130
131
132
133
134
135struct intel_engine_execlists {
136
137
138
139 struct timer_list timer;
140
141
142
143
144 struct timer_list preempt;
145
146
147
148
149 u32 ccid;
150
151
152
153
154
155
156
157
158 u32 yield;
159
160
161
162
163
164
165
166
167
168
169
170
171 u32 error_interrupt;
172#define ERROR_CSB BIT(31)
173#define ERROR_PREEMPT BIT(30)
174
175
176
177
178 u32 reset_ccid;
179
180
181
182
183
184
185 u32 __iomem *submit_reg;
186
187
188
189
190
191 u32 __iomem *ctrl_reg;
192
193#define EXECLIST_MAX_PORTS 2
194
195
196
197 struct i915_request * const *active;
198
199
200
201
202
203
204
205
206 struct i915_request *inflight[EXECLIST_MAX_PORTS + 1 ];
207
208
209
210
211
212
213
214 struct i915_request *pending[EXECLIST_MAX_PORTS + 1];
215
216
217
218
219 unsigned int port_mask;
220
221
222
223
224
225
226 struct rb_root_cached virtual;
227
228
229
230
231
232
233 u32 *csb_write;
234
235
236
237
238
239
240 u64 *csb_status;
241
242
243
244
245 u8 csb_size;
246
247
248
249
250 u8 csb_head;
251
252 I915_SELFTEST_DECLARE(struct st_preempt_hang preempt_hang;)
253};
254
255#define INTEL_ENGINE_CS_MAX_NAME 8
256
257struct intel_engine_cs {
258 struct drm_i915_private *i915;
259 struct intel_gt *gt;
260 struct intel_uncore *uncore;
261 char name[INTEL_ENGINE_CS_MAX_NAME];
262
263 enum intel_engine_id id;
264 enum intel_engine_id legacy_idx;
265
266 unsigned int guc_id;
267
268 intel_engine_mask_t mask;
269
270 u8 class;
271 u8 instance;
272
273 u16 uabi_class;
274 u16 uabi_instance;
275
276 u32 uabi_capabilities;
277 u32 context_size;
278 u32 mmio_base;
279
280
281
282
283
284
285
286
287 enum forcewake_domains fw_domain;
288 unsigned int fw_active;
289
290 unsigned long context_tag;
291
292 struct rb_node uabi_node;
293
294 struct intel_sseu sseu;
295
296 struct i915_sched_engine *sched_engine;
297
298
299 struct i915_request *request_pool;
300
301 struct intel_context *hung_ce;
302
303 struct llist_head barrier_tasks;
304
305 struct intel_context *kernel_context;
306
307 intel_engine_mask_t saturated;
308
309 struct {
310 struct delayed_work work;
311 struct i915_request *systole;
312 unsigned long blocked;
313 } heartbeat;
314
315 unsigned long serial;
316
317 unsigned long wakeref_serial;
318 struct intel_wakeref wakeref;
319 struct file *default_state;
320
321 struct {
322 struct intel_ring *ring;
323 struct intel_timeline *timeline;
324 } legacy;
325
326
327
328
329
330
331 struct ewma__engine_latency latency;
332
333
334 struct intel_breadcrumbs *breadcrumbs;
335
336 struct intel_engine_pmu {
337
338
339
340
341
342
343 u32 enable;
344
345
346
347
348
349 unsigned int enable_count[I915_ENGINE_SAMPLE_COUNT];
350
351
352
353
354
355
356
357 struct i915_pmu_sample sample[I915_ENGINE_SAMPLE_COUNT];
358 } pmu;
359
360 struct intel_hw_status_page status_page;
361 struct i915_ctx_workarounds wa_ctx;
362 struct i915_wa_list ctx_wa_list;
363 struct i915_wa_list wa_list;
364 struct i915_wa_list whitelist;
365
366 u32 irq_keep_mask;
367 u32 irq_enable_mask;
368 void (*irq_enable)(struct intel_engine_cs *engine);
369 void (*irq_disable)(struct intel_engine_cs *engine);
370 void (*irq_handler)(struct intel_engine_cs *engine, u16 iir);
371
372 void (*sanitize)(struct intel_engine_cs *engine);
373 int (*resume)(struct intel_engine_cs *engine);
374
375 struct {
376 void (*prepare)(struct intel_engine_cs *engine);
377
378 void (*rewind)(struct intel_engine_cs *engine, bool stalled);
379 void (*cancel)(struct intel_engine_cs *engine);
380
381 void (*finish)(struct intel_engine_cs *engine);
382 } reset;
383
384 void (*park)(struct intel_engine_cs *engine);
385 void (*unpark)(struct intel_engine_cs *engine);
386
387 void (*bump_serial)(struct intel_engine_cs *engine);
388
389 void (*set_default_submission)(struct intel_engine_cs *engine);
390
391 const struct intel_context_ops *cops;
392
393 int (*request_alloc)(struct i915_request *rq);
394
395 int (*emit_flush)(struct i915_request *request, u32 mode);
396#define EMIT_INVALIDATE BIT(0)
397#define EMIT_FLUSH BIT(1)
398#define EMIT_BARRIER (EMIT_INVALIDATE | EMIT_FLUSH)
399 int (*emit_bb_start)(struct i915_request *rq,
400 u64 offset, u32 length,
401 unsigned int dispatch_flags);
402#define I915_DISPATCH_SECURE BIT(0)
403#define I915_DISPATCH_PINNED BIT(1)
404 int (*emit_init_breadcrumb)(struct i915_request *rq);
405 u32 *(*emit_fini_breadcrumb)(struct i915_request *rq,
406 u32 *cs);
407 unsigned int emit_fini_breadcrumb_dw;
408
409
410
411
412
413
414
415 void (*submit_request)(struct i915_request *rq);
416
417 void (*release)(struct intel_engine_cs *engine);
418
419
420
421
422 void (*add_active_request)(struct i915_request *rq);
423 void (*remove_active_request)(struct i915_request *rq);
424
425 struct intel_engine_execlists execlists;
426
427
428
429
430
431
432 struct intel_timeline *retire;
433 struct work_struct retire_work;
434
435
436 struct atomic_notifier_head context_status_notifier;
437
438#define I915_ENGINE_USING_CMD_PARSER BIT(0)
439#define I915_ENGINE_SUPPORTS_STATS BIT(1)
440#define I915_ENGINE_HAS_PREEMPTION BIT(2)
441#define I915_ENGINE_HAS_SEMAPHORES BIT(3)
442#define I915_ENGINE_HAS_TIMESLICES BIT(4)
443#define I915_ENGINE_IS_VIRTUAL BIT(5)
444#define I915_ENGINE_HAS_RELATIVE_MMIO BIT(6)
445#define I915_ENGINE_REQUIRES_CMD_PARSER BIT(7)
446#define I915_ENGINE_WANT_FORCED_PREEMPTION BIT(8)
447 unsigned int flags;
448
449
450
451
452
453 DECLARE_HASHTABLE(cmd_hash, I915_CMD_HASH_ORDER);
454
455
456
457
458 const struct drm_i915_reg_table *reg_tables;
459 int reg_table_count;
460
461
462
463
464
465
466
467
468
469
470
471 u32 (*get_cmd_length_mask)(u32 cmd_header);
472
473 struct {
474
475
476
477 unsigned int active;
478
479
480
481
482 seqcount_t lock;
483
484
485
486
487
488
489
490 ktime_t total;
491
492
493
494
495
496
497 ktime_t start;
498
499
500
501
502 ktime_t rps;
503 } stats;
504
505 struct {
506 unsigned long heartbeat_interval_ms;
507 unsigned long max_busywait_duration_ns;
508 unsigned long preempt_timeout_ms;
509 unsigned long stop_timeout_ms;
510 unsigned long timeslice_duration_ms;
511 } props, defaults;
512
513 I915_SELFTEST_DECLARE(struct fault_attr reset_timeout);
514};
515
516static inline bool
517intel_engine_using_cmd_parser(const struct intel_engine_cs *engine)
518{
519 return engine->flags & I915_ENGINE_USING_CMD_PARSER;
520}
521
522static inline bool
523intel_engine_requires_cmd_parser(const struct intel_engine_cs *engine)
524{
525 return engine->flags & I915_ENGINE_REQUIRES_CMD_PARSER;
526}
527
528static inline bool
529intel_engine_supports_stats(const struct intel_engine_cs *engine)
530{
531 return engine->flags & I915_ENGINE_SUPPORTS_STATS;
532}
533
534static inline bool
535intel_engine_has_preemption(const struct intel_engine_cs *engine)
536{
537 return engine->flags & I915_ENGINE_HAS_PREEMPTION;
538}
539
540static inline bool
541intel_engine_has_semaphores(const struct intel_engine_cs *engine)
542{
543 return engine->flags & I915_ENGINE_HAS_SEMAPHORES;
544}
545
546static inline bool
547intel_engine_has_timeslices(const struct intel_engine_cs *engine)
548{
549 if (!IS_ACTIVE(CONFIG_DRM_I915_TIMESLICE_DURATION))
550 return false;
551
552 return engine->flags & I915_ENGINE_HAS_TIMESLICES;
553}
554
555static inline bool
556intel_engine_is_virtual(const struct intel_engine_cs *engine)
557{
558 return engine->flags & I915_ENGINE_IS_VIRTUAL;
559}
560
561static inline bool
562intel_engine_has_relative_mmio(const struct intel_engine_cs * const engine)
563{
564 return engine->flags & I915_ENGINE_HAS_RELATIVE_MMIO;
565}
566
567#define instdone_has_slice(dev_priv___, sseu___, slice___) \
568 ((GRAPHICS_VER(dev_priv___) == 7 ? 1 : ((sseu___)->slice_mask)) & BIT(slice___))
569
570#define instdone_has_subslice(dev_priv__, sseu__, slice__, subslice__) \
571 (GRAPHICS_VER(dev_priv__) == 7 ? (1 & BIT(subslice__)) : \
572 intel_sseu_has_subslice(sseu__, 0, subslice__))
573
574#define for_each_instdone_slice_subslice(dev_priv_, sseu_, slice_, subslice_) \
575 for ((slice_) = 0, (subslice_) = 0; (slice_) < I915_MAX_SLICES; \
576 (subslice_) = ((subslice_) + 1) % I915_MAX_SUBSLICES, \
577 (slice_) += ((subslice_) == 0)) \
578 for_each_if((instdone_has_slice(dev_priv_, sseu_, slice_)) && \
579 (instdone_has_subslice(dev_priv_, sseu_, slice_, \
580 subslice_)))
581#endif
582