intel_ringbuffer.h 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _INTEL_RINGBUFFER_H_
  3. #define _INTEL_RINGBUFFER_H_
  4. #include <drm/drm_util.h>
  5. #include <linux/hashtable.h>
  6. #include <linux/seqlock.h>
  7. #include "i915_gem_batch_pool.h"
  8. #include "i915_reg.h"
  9. #include "i915_pmu.h"
  10. #include "i915_request.h"
  11. #include "i915_selftest.h"
  12. #include "i915_timeline.h"
  13. #include "intel_gpu_commands.h"
  14. #include "intel_workarounds.h"
  15. struct drm_printer;
  16. struct i915_sched_attr;
  17. #define I915_CMD_HASH_ORDER 9
  18. /* Early gen2 devices have a cacheline of just 32 bytes, using 64 is overkill,
  19. * but keeps the logic simple. Indeed, the whole purpose of this macro is just
  20. * to give some inclination as to some of the magic values used in the various
  21. * workarounds!
  22. */
  23. #define CACHELINE_BYTES 64
  24. #define CACHELINE_DWORDS (CACHELINE_BYTES / sizeof(uint32_t))
  25. struct intel_hw_status_page {
  26. struct i915_vma *vma;
  27. u32 *page_addr;
  28. u32 ggtt_offset;
  29. };
  30. #define I915_READ_TAIL(engine) I915_READ(RING_TAIL((engine)->mmio_base))
  31. #define I915_WRITE_TAIL(engine, val) I915_WRITE(RING_TAIL((engine)->mmio_base), val)
  32. #define I915_READ_START(engine) I915_READ(RING_START((engine)->mmio_base))
  33. #define I915_WRITE_START(engine, val) I915_WRITE(RING_START((engine)->mmio_base), val)
  34. #define I915_READ_HEAD(engine) I915_READ(RING_HEAD((engine)->mmio_base))
  35. #define I915_WRITE_HEAD(engine, val) I915_WRITE(RING_HEAD((engine)->mmio_base), val)
  36. #define I915_READ_CTL(engine) I915_READ(RING_CTL((engine)->mmio_base))
  37. #define I915_WRITE_CTL(engine, val) I915_WRITE(RING_CTL((engine)->mmio_base), val)
  38. #define I915_READ_IMR(engine) I915_READ(RING_IMR((engine)->mmio_base))
  39. #define I915_WRITE_IMR(engine, val) I915_WRITE(RING_IMR((engine)->mmio_base), val)
  40. #define I915_READ_MODE(engine) I915_READ(RING_MI_MODE((engine)->mmio_base))
  41. #define I915_WRITE_MODE(engine, val) I915_WRITE(RING_MI_MODE((engine)->mmio_base), val)
  42. /* seqno size is actually only a uint32, but since we plan to use MI_FLUSH_DW to
  43. * do the writes, and that must have qw aligned offsets, simply pretend it's 8b.
  44. */
  45. enum intel_engine_hangcheck_action {
  46. ENGINE_IDLE = 0,
  47. ENGINE_WAIT,
  48. ENGINE_ACTIVE_SEQNO,
  49. ENGINE_ACTIVE_HEAD,
  50. ENGINE_ACTIVE_SUBUNITS,
  51. ENGINE_WAIT_KICK,
  52. ENGINE_DEAD,
  53. };
  54. static inline const char *
  55. hangcheck_action_to_str(const enum intel_engine_hangcheck_action a)
  56. {
  57. switch (a) {
  58. case ENGINE_IDLE:
  59. return "idle";
  60. case ENGINE_WAIT:
  61. return "wait";
  62. case ENGINE_ACTIVE_SEQNO:
  63. return "active seqno";
  64. case ENGINE_ACTIVE_HEAD:
  65. return "active head";
  66. case ENGINE_ACTIVE_SUBUNITS:
  67. return "active subunits";
  68. case ENGINE_WAIT_KICK:
  69. return "wait kick";
  70. case ENGINE_DEAD:
  71. return "dead";
  72. }
  73. return "unknown";
  74. }
  75. #define I915_MAX_SLICES 3
  76. #define I915_MAX_SUBSLICES 8
  77. #define instdone_slice_mask(dev_priv__) \
  78. (INTEL_GEN(dev_priv__) == 7 ? \
  79. 1 : INTEL_INFO(dev_priv__)->sseu.slice_mask)
  80. #define instdone_subslice_mask(dev_priv__) \
  81. (INTEL_GEN(dev_priv__) == 7 ? \
  82. 1 : INTEL_INFO(dev_priv__)->sseu.subslice_mask[0])
  83. #define for_each_instdone_slice_subslice(dev_priv__, slice__, subslice__) \
  84. for ((slice__) = 0, (subslice__) = 0; \
  85. (slice__) < I915_MAX_SLICES; \
  86. (subslice__) = ((subslice__) + 1) < I915_MAX_SUBSLICES ? (subslice__) + 1 : 0, \
  87. (slice__) += ((subslice__) == 0)) \
  88. for_each_if((BIT(slice__) & instdone_slice_mask(dev_priv__)) && \
  89. (BIT(subslice__) & instdone_subslice_mask(dev_priv__)))
  90. struct intel_instdone {
  91. u32 instdone;
  92. /* The following exist only in the RCS engine */
  93. u32 slice_common;
  94. u32 sampler[I915_MAX_SLICES][I915_MAX_SUBSLICES];
  95. u32 row[I915_MAX_SLICES][I915_MAX_SUBSLICES];
  96. };
  97. struct intel_engine_hangcheck {
  98. u64 acthd;
  99. u32 seqno;
  100. enum intel_engine_hangcheck_action action;
  101. unsigned long action_timestamp;
  102. int deadlock;
  103. struct intel_instdone instdone;
  104. struct i915_request *active_request;
  105. bool stalled:1;
  106. bool wedged:1;
  107. };
  108. struct intel_ring {
  109. struct i915_vma *vma;
  110. void *vaddr;
  111. struct i915_timeline *timeline;
  112. struct list_head request_list;
  113. struct list_head active_link;
  114. u32 head;
  115. u32 tail;
  116. u32 emit;
  117. u32 space;
  118. u32 size;
  119. u32 effective_size;
  120. };
  121. struct i915_gem_context;
  122. struct drm_i915_reg_table;
  123. /*
  124. * we use a single page to load ctx workarounds so all of these
  125. * values are referred in terms of dwords
  126. *
  127. * struct i915_wa_ctx_bb:
  128. * offset: specifies batch starting position, also helpful in case
  129. * if we want to have multiple batches at different offsets based on
  130. * some criteria. It is not a requirement at the moment but provides
  131. * an option for future use.
  132. * size: size of the batch in DWORDS
  133. */
  134. struct i915_ctx_workarounds {
  135. struct i915_wa_ctx_bb {
  136. u32 offset;
  137. u32 size;
  138. } indirect_ctx, per_ctx;
  139. struct i915_vma *vma;
  140. };
  141. struct i915_request;
  142. #define I915_MAX_VCS 4
  143. #define I915_MAX_VECS 2
  144. /*
  145. * Engine IDs definitions.
  146. * Keep instances of the same type engine together.
  147. */
  148. enum intel_engine_id {
  149. RCS = 0,
  150. BCS,
  151. VCS,
  152. VCS2,
  153. VCS3,
  154. VCS4,
  155. #define _VCS(n) (VCS + (n))
  156. VECS,
  157. VECS2
  158. #define _VECS(n) (VECS + (n))
  159. };
  160. struct i915_priolist {
  161. struct rb_node node;
  162. struct list_head requests;
  163. int priority;
  164. };
  165. struct st_preempt_hang {
  166. struct completion completion;
  167. bool inject_hang;
  168. };
  169. /**
  170. * struct intel_engine_execlists - execlist submission queue and port state
  171. *
  172. * The struct intel_engine_execlists represents the combined logical state of
  173. * driver and the hardware state for execlist mode of submission.
  174. */
  175. struct intel_engine_execlists {
  176. /**
  177. * @tasklet: softirq tasklet for bottom handler
  178. */
  179. struct tasklet_struct tasklet;
  180. /**
  181. * @default_priolist: priority list for I915_PRIORITY_NORMAL
  182. */
  183. struct i915_priolist default_priolist;
  184. /**
  185. * @no_priolist: priority lists disabled
  186. */
  187. bool no_priolist;
  188. /**
  189. * @submit_reg: gen-specific execlist submission register
  190. * set to the ExecList Submission Port (elsp) register pre-Gen11 and to
  191. * the ExecList Submission Queue Contents register array for Gen11+
  192. */
  193. u32 __iomem *submit_reg;
  194. /**
  195. * @ctrl_reg: the enhanced execlists control register, used to load the
  196. * submit queue on the HW and to request preemptions to idle
  197. */
  198. u32 __iomem *ctrl_reg;
  199. /**
  200. * @port: execlist port states
  201. *
  202. * For each hardware ELSP (ExecList Submission Port) we keep
  203. * track of the last request and the number of times we submitted
  204. * that port to hw. We then count the number of times the hw reports
  205. * a context completion or preemption. As only one context can
  206. * be active on hw, we limit resubmission of context to port[0]. This
  207. * is called Lite Restore, of the context.
  208. */
  209. struct execlist_port {
  210. /**
  211. * @request_count: combined request and submission count
  212. */
  213. struct i915_request *request_count;
  214. #define EXECLIST_COUNT_BITS 2
  215. #define port_request(p) ptr_mask_bits((p)->request_count, EXECLIST_COUNT_BITS)
  216. #define port_count(p) ptr_unmask_bits((p)->request_count, EXECLIST_COUNT_BITS)
  217. #define port_pack(rq, count) ptr_pack_bits(rq, count, EXECLIST_COUNT_BITS)
  218. #define port_unpack(p, count) ptr_unpack_bits((p)->request_count, count, EXECLIST_COUNT_BITS)
  219. #define port_set(p, packed) ((p)->request_count = (packed))
  220. #define port_isset(p) ((p)->request_count)
  221. #define port_index(p, execlists) ((p) - (execlists)->port)
  222. /**
  223. * @context_id: context ID for port
  224. */
  225. GEM_DEBUG_DECL(u32 context_id);
  226. #define EXECLIST_MAX_PORTS 2
  227. } port[EXECLIST_MAX_PORTS];
  228. /**
  229. * @active: is the HW active? We consider the HW as active after
  230. * submitting any context for execution and until we have seen the
  231. * last context completion event. After that, we do not expect any
  232. * more events until we submit, and so can park the HW.
  233. *
  234. * As we have a small number of different sources from which we feed
  235. * the HW, we track the state of each inside a single bitfield.
  236. */
  237. unsigned int active;
  238. #define EXECLISTS_ACTIVE_USER 0
  239. #define EXECLISTS_ACTIVE_PREEMPT 1
  240. #define EXECLISTS_ACTIVE_HWACK 2
  241. /**
  242. * @port_mask: number of execlist ports - 1
  243. */
  244. unsigned int port_mask;
  245. /**
  246. * @queue_priority: Highest pending priority.
  247. *
  248. * When we add requests into the queue, or adjust the priority of
  249. * executing requests, we compute the maximum priority of those
  250. * pending requests. We can then use this value to determine if
  251. * we need to preempt the executing requests to service the queue.
  252. */
  253. int queue_priority;
  254. /**
  255. * @queue: queue of requests, in priority lists
  256. */
  257. struct rb_root_cached queue;
  258. /**
  259. * @csb_read: control register for Context Switch buffer
  260. *
  261. * Note this register is always in mmio.
  262. */
  263. u32 __iomem *csb_read;
  264. /**
  265. * @csb_write: control register for Context Switch buffer
  266. *
  267. * Note this register may be either mmio or HWSP shadow.
  268. */
  269. u32 *csb_write;
  270. /**
  271. * @csb_status: status array for Context Switch buffer
  272. *
  273. * Note these register may be either mmio or HWSP shadow.
  274. */
  275. u32 *csb_status;
  276. /**
  277. * @preempt_complete_status: expected CSB upon completing preemption
  278. */
  279. u32 preempt_complete_status;
  280. /**
  281. * @csb_write_reset: reset value for CSB write pointer
  282. *
  283. * As the CSB write pointer maybe either in HWSP or as a field
  284. * inside an mmio register, we want to reprogram it slightly
  285. * differently to avoid later confusion.
  286. */
  287. u32 csb_write_reset;
  288. /**
  289. * @csb_head: context status buffer head
  290. */
  291. u8 csb_head;
  292. I915_SELFTEST_DECLARE(struct st_preempt_hang preempt_hang;)
  293. };
  294. #define INTEL_ENGINE_CS_MAX_NAME 8
  295. struct intel_engine_cs {
  296. struct drm_i915_private *i915;
  297. char name[INTEL_ENGINE_CS_MAX_NAME];
  298. enum intel_engine_id id;
  299. unsigned int hw_id;
  300. unsigned int guc_id;
  301. u8 uabi_id;
  302. u8 uabi_class;
  303. u8 class;
  304. u8 instance;
  305. u32 context_size;
  306. u32 mmio_base;
  307. struct intel_ring *buffer;
  308. struct i915_timeline timeline;
  309. struct drm_i915_gem_object *default_state;
  310. void *pinned_default_state;
  311. unsigned long irq_posted;
  312. #define ENGINE_IRQ_BREADCRUMB 0
  313. /* Rather than have every client wait upon all user interrupts,
  314. * with the herd waking after every interrupt and each doing the
  315. * heavyweight seqno dance, we delegate the task (of being the
  316. * bottom-half of the user interrupt) to the first client. After
  317. * every interrupt, we wake up one client, who does the heavyweight
  318. * coherent seqno read and either goes back to sleep (if incomplete),
  319. * or wakes up all the completed clients in parallel, before then
  320. * transferring the bottom-half status to the next client in the queue.
  321. *
  322. * Compared to walking the entire list of waiters in a single dedicated
  323. * bottom-half, we reduce the latency of the first waiter by avoiding
  324. * a context switch, but incur additional coherent seqno reads when
  325. * following the chain of request breadcrumbs. Since it is most likely
  326. * that we have a single client waiting on each seqno, then reducing
  327. * the overhead of waking that client is much preferred.
  328. */
  329. struct intel_breadcrumbs {
  330. spinlock_t irq_lock; /* protects irq_*; irqsafe */
  331. struct intel_wait *irq_wait; /* oldest waiter by retirement */
  332. spinlock_t rb_lock; /* protects the rb and wraps irq_lock */
  333. struct rb_root waiters; /* sorted by retirement, priority */
  334. struct list_head signals; /* sorted by retirement */
  335. struct task_struct *signaler; /* used for fence signalling */
  336. struct timer_list fake_irq; /* used after a missed interrupt */
  337. struct timer_list hangcheck; /* detect missed interrupts */
  338. unsigned int hangcheck_interrupts;
  339. unsigned int irq_enabled;
  340. unsigned int irq_count;
  341. bool irq_armed : 1;
  342. I915_SELFTEST_DECLARE(bool mock : 1);
  343. } breadcrumbs;
  344. struct {
  345. /**
  346. * @enable: Bitmask of enable sample events on this engine.
  347. *
  348. * Bits correspond to sample event types, for instance
  349. * I915_SAMPLE_QUEUED is bit 0 etc.
  350. */
  351. u32 enable;
  352. /**
  353. * @enable_count: Reference count for the enabled samplers.
  354. *
  355. * Index number corresponds to the bit number from @enable.
  356. */
  357. unsigned int enable_count[I915_PMU_SAMPLE_BITS];
  358. /**
  359. * @sample: Counter values for sampling events.
  360. *
  361. * Our internal timer stores the current counters in this field.
  362. */
  363. #define I915_ENGINE_SAMPLE_MAX (I915_SAMPLE_SEMA + 1)
  364. struct i915_pmu_sample sample[I915_ENGINE_SAMPLE_MAX];
  365. } pmu;
  366. /*
  367. * A pool of objects to use as shadow copies of client batch buffers
  368. * when the command parser is enabled. Prevents the client from
  369. * modifying the batch contents after software parsing.
  370. */
  371. struct i915_gem_batch_pool batch_pool;
  372. struct intel_hw_status_page status_page;
  373. struct i915_ctx_workarounds wa_ctx;
  374. struct i915_wa_list wa_list;
  375. u32 irq_keep_mask; /* always keep these interrupts */
  376. u32 irq_enable_mask; /* bitmask to enable ring interrupt */
  377. void (*irq_enable)(struct intel_engine_cs *engine);
  378. void (*irq_disable)(struct intel_engine_cs *engine);
  379. int (*init_hw)(struct intel_engine_cs *engine);
  380. struct {
  381. struct i915_request *(*prepare)(struct intel_engine_cs *engine);
  382. void (*reset)(struct intel_engine_cs *engine,
  383. struct i915_request *rq);
  384. void (*finish)(struct intel_engine_cs *engine);
  385. } reset;
  386. void (*park)(struct intel_engine_cs *engine);
  387. void (*unpark)(struct intel_engine_cs *engine);
  388. void (*set_default_submission)(struct intel_engine_cs *engine);
  389. struct intel_context *(*context_pin)(struct intel_engine_cs *engine,
  390. struct i915_gem_context *ctx);
  391. int (*request_alloc)(struct i915_request *rq);
  392. int (*init_context)(struct i915_request *rq);
  393. int (*emit_flush)(struct i915_request *request, u32 mode);
  394. #define EMIT_INVALIDATE BIT(0)
  395. #define EMIT_FLUSH BIT(1)
  396. #define EMIT_BARRIER (EMIT_INVALIDATE | EMIT_FLUSH)
  397. int (*emit_bb_start)(struct i915_request *rq,
  398. u64 offset, u32 length,
  399. unsigned int dispatch_flags);
  400. #define I915_DISPATCH_SECURE BIT(0)
  401. #define I915_DISPATCH_PINNED BIT(1)
  402. void (*emit_breadcrumb)(struct i915_request *rq, u32 *cs);
  403. int emit_breadcrumb_sz;
  404. /* Pass the request to the hardware queue (e.g. directly into
  405. * the legacy ringbuffer or to the end of an execlist).
  406. *
  407. * This is called from an atomic context with irqs disabled; must
  408. * be irq safe.
  409. */
  410. void (*submit_request)(struct i915_request *rq);
  411. /* Call when the priority on a request has changed and it and its
  412. * dependencies may need rescheduling. Note the request itself may
  413. * not be ready to run!
  414. *
  415. * Called under the struct_mutex.
  416. */
  417. void (*schedule)(struct i915_request *request,
  418. const struct i915_sched_attr *attr);
  419. /*
  420. * Cancel all requests on the hardware, or queued for execution.
  421. * This should only cancel the ready requests that have been
  422. * submitted to the engine (via the engine->submit_request callback).
  423. * This is called when marking the device as wedged.
  424. */
  425. void (*cancel_requests)(struct intel_engine_cs *engine);
  426. /* Some chipsets are not quite as coherent as advertised and need
  427. * an expensive kick to force a true read of the up-to-date seqno.
  428. * However, the up-to-date seqno is not always required and the last
  429. * seen value is good enough. Note that the seqno will always be
  430. * monotonic, even if not coherent.
  431. */
  432. void (*irq_seqno_barrier)(struct intel_engine_cs *engine);
  433. void (*cleanup)(struct intel_engine_cs *engine);
  434. /* GEN8 signal/wait table - never trust comments!
  435. * signal to signal to signal to signal to signal to
  436. * RCS VCS BCS VECS VCS2
  437. * --------------------------------------------------------------------
  438. * RCS | NOP (0x00) | VCS (0x08) | BCS (0x10) | VECS (0x18) | VCS2 (0x20) |
  439. * |-------------------------------------------------------------------
  440. * VCS | RCS (0x28) | NOP (0x30) | BCS (0x38) | VECS (0x40) | VCS2 (0x48) |
  441. * |-------------------------------------------------------------------
  442. * BCS | RCS (0x50) | VCS (0x58) | NOP (0x60) | VECS (0x68) | VCS2 (0x70) |
  443. * |-------------------------------------------------------------------
  444. * VECS | RCS (0x78) | VCS (0x80) | BCS (0x88) | NOP (0x90) | VCS2 (0x98) |
  445. * |-------------------------------------------------------------------
  446. * VCS2 | RCS (0xa0) | VCS (0xa8) | BCS (0xb0) | VECS (0xb8) | NOP (0xc0) |
  447. * |-------------------------------------------------------------------
  448. *
  449. * Generalization:
  450. * f(x, y) := (x->id * NUM_RINGS * seqno_size) + (seqno_size * y->id)
  451. * ie. transpose of g(x, y)
  452. *
  453. * sync from sync from sync from sync from sync from
  454. * RCS VCS BCS VECS VCS2
  455. * --------------------------------------------------------------------
  456. * RCS | NOP (0x00) | VCS (0x28) | BCS (0x50) | VECS (0x78) | VCS2 (0xa0) |
  457. * |-------------------------------------------------------------------
  458. * VCS | RCS (0x08) | NOP (0x30) | BCS (0x58) | VECS (0x80) | VCS2 (0xa8) |
  459. * |-------------------------------------------------------------------
  460. * BCS | RCS (0x10) | VCS (0x38) | NOP (0x60) | VECS (0x88) | VCS2 (0xb0) |
  461. * |-------------------------------------------------------------------
  462. * VECS | RCS (0x18) | VCS (0x40) | BCS (0x68) | NOP (0x90) | VCS2 (0xb8) |
  463. * |-------------------------------------------------------------------
  464. * VCS2 | RCS (0x20) | VCS (0x48) | BCS (0x70) | VECS (0x98) | NOP (0xc0) |
  465. * |-------------------------------------------------------------------
  466. *
  467. * Generalization:
  468. * g(x, y) := (y->id * NUM_RINGS * seqno_size) + (seqno_size * x->id)
  469. * ie. transpose of f(x, y)
  470. */
  471. struct {
  472. #define GEN6_SEMAPHORE_LAST VECS_HW
  473. #define GEN6_NUM_SEMAPHORES (GEN6_SEMAPHORE_LAST + 1)
  474. #define GEN6_SEMAPHORES_MASK GENMASK(GEN6_SEMAPHORE_LAST, 0)
  475. struct {
  476. /* our mbox written by others */
  477. u32 wait[GEN6_NUM_SEMAPHORES];
  478. /* mboxes this ring signals to */
  479. i915_reg_t signal[GEN6_NUM_SEMAPHORES];
  480. } mbox;
  481. /* AKA wait() */
  482. int (*sync_to)(struct i915_request *rq,
  483. struct i915_request *signal);
  484. u32 *(*signal)(struct i915_request *rq, u32 *cs);
  485. } semaphore;
  486. struct intel_engine_execlists execlists;
  487. /* Contexts are pinned whilst they are active on the GPU. The last
  488. * context executed remains active whilst the GPU is idle - the
  489. * switch away and write to the context object only occurs on the
  490. * next execution. Contexts are only unpinned on retirement of the
  491. * following request ensuring that we can always write to the object
  492. * on the context switch even after idling. Across suspend, we switch
  493. * to the kernel context and trash it as the save may not happen
  494. * before the hardware is powered down.
  495. */
  496. struct intel_context *last_retired_context;
  497. /* status_notifier: list of callbacks for context-switch changes */
  498. struct atomic_notifier_head context_status_notifier;
  499. struct intel_engine_hangcheck hangcheck;
  500. #define I915_ENGINE_NEEDS_CMD_PARSER BIT(0)
  501. #define I915_ENGINE_SUPPORTS_STATS BIT(1)
  502. #define I915_ENGINE_HAS_PREEMPTION BIT(2)
  503. unsigned int flags;
  504. /*
  505. * Table of commands the command parser needs to know about
  506. * for this engine.
  507. */
  508. DECLARE_HASHTABLE(cmd_hash, I915_CMD_HASH_ORDER);
  509. /*
  510. * Table of registers allowed in commands that read/write registers.
  511. */
  512. const struct drm_i915_reg_table *reg_tables;
  513. int reg_table_count;
  514. /*
  515. * Returns the bitmask for the length field of the specified command.
  516. * Return 0 for an unrecognized/invalid command.
  517. *
  518. * If the command parser finds an entry for a command in the engine's
  519. * cmd_tables, it gets the command's length based on the table entry.
  520. * If not, it calls this function to determine the per-engine length
  521. * field encoding for the command (i.e. different opcode ranges use
  522. * certain bits to encode the command length in the header).
  523. */
  524. u32 (*get_cmd_length_mask)(u32 cmd_header);
  525. struct {
  526. /**
  527. * @lock: Lock protecting the below fields.
  528. */
  529. seqlock_t lock;
  530. /**
  531. * @enabled: Reference count indicating number of listeners.
  532. */
  533. unsigned int enabled;
  534. /**
  535. * @active: Number of contexts currently scheduled in.
  536. */
  537. unsigned int active;
  538. /**
  539. * @enabled_at: Timestamp when busy stats were enabled.
  540. */
  541. ktime_t enabled_at;
  542. /**
  543. * @start: Timestamp of the last idle to active transition.
  544. *
  545. * Idle is defined as active == 0, active is active > 0.
  546. */
  547. ktime_t start;
  548. /**
  549. * @total: Total time this engine was busy.
  550. *
  551. * Accumulated time not counting the most recent block in cases
  552. * where engine is currently busy (active > 0).
  553. */
  554. ktime_t total;
  555. } stats;
  556. };
  557. static inline bool
  558. intel_engine_needs_cmd_parser(const struct intel_engine_cs *engine)
  559. {
  560. return engine->flags & I915_ENGINE_NEEDS_CMD_PARSER;
  561. }
  562. static inline bool
  563. intel_engine_supports_stats(const struct intel_engine_cs *engine)
  564. {
  565. return engine->flags & I915_ENGINE_SUPPORTS_STATS;
  566. }
  567. static inline bool
  568. intel_engine_has_preemption(const struct intel_engine_cs *engine)
  569. {
  570. return engine->flags & I915_ENGINE_HAS_PREEMPTION;
  571. }
  572. static inline bool __execlists_need_preempt(int prio, int last)
  573. {
  574. return prio > max(0, last);
  575. }
  576. static inline void
  577. execlists_set_active(struct intel_engine_execlists *execlists,
  578. unsigned int bit)
  579. {
  580. __set_bit(bit, (unsigned long *)&execlists->active);
  581. }
  582. static inline bool
  583. execlists_set_active_once(struct intel_engine_execlists *execlists,
  584. unsigned int bit)
  585. {
  586. return !__test_and_set_bit(bit, (unsigned long *)&execlists->active);
  587. }
  588. static inline void
  589. execlists_clear_active(struct intel_engine_execlists *execlists,
  590. unsigned int bit)
  591. {
  592. __clear_bit(bit, (unsigned long *)&execlists->active);
  593. }
  594. static inline void
  595. execlists_clear_all_active(struct intel_engine_execlists *execlists)
  596. {
  597. execlists->active = 0;
  598. }
  599. static inline bool
  600. execlists_is_active(const struct intel_engine_execlists *execlists,
  601. unsigned int bit)
  602. {
  603. return test_bit(bit, (unsigned long *)&execlists->active);
  604. }
  605. void execlists_user_begin(struct intel_engine_execlists *execlists,
  606. const struct execlist_port *port);
  607. void execlists_user_end(struct intel_engine_execlists *execlists);
  608. void
  609. execlists_cancel_port_requests(struct intel_engine_execlists * const execlists);
  610. void
  611. execlists_unwind_incomplete_requests(struct intel_engine_execlists *execlists);
  612. static inline unsigned int
  613. execlists_num_ports(const struct intel_engine_execlists * const execlists)
  614. {
  615. return execlists->port_mask + 1;
  616. }
  617. static inline struct execlist_port *
  618. execlists_port_complete(struct intel_engine_execlists * const execlists,
  619. struct execlist_port * const port)
  620. {
  621. const unsigned int m = execlists->port_mask;
  622. GEM_BUG_ON(port_index(port, execlists) != 0);
  623. GEM_BUG_ON(!execlists_is_active(execlists, EXECLISTS_ACTIVE_USER));
  624. memmove(port, port + 1, m * sizeof(struct execlist_port));
  625. memset(port + m, 0, sizeof(struct execlist_port));
  626. return port;
  627. }
  628. static inline unsigned int
  629. intel_engine_flag(const struct intel_engine_cs *engine)
  630. {
  631. return BIT(engine->id);
  632. }
  633. static inline u32
  634. intel_read_status_page(const struct intel_engine_cs *engine, int reg)
  635. {
  636. /* Ensure that the compiler doesn't optimize away the load. */
  637. return READ_ONCE(engine->status_page.page_addr[reg]);
  638. }
  639. static inline void
  640. intel_write_status_page(struct intel_engine_cs *engine, int reg, u32 value)
  641. {
  642. /* Writing into the status page should be done sparingly. Since
  643. * we do when we are uncertain of the device state, we take a bit
  644. * of extra paranoia to try and ensure that the HWS takes the value
  645. * we give and that it doesn't end up trapped inside the CPU!
  646. */
  647. if (static_cpu_has(X86_FEATURE_CLFLUSH)) {
  648. mb();
  649. clflush(&engine->status_page.page_addr[reg]);
  650. engine->status_page.page_addr[reg] = value;
  651. clflush(&engine->status_page.page_addr[reg]);
  652. mb();
  653. } else {
  654. WRITE_ONCE(engine->status_page.page_addr[reg], value);
  655. }
  656. }
  657. /*
  658. * Reads a dword out of the status page, which is written to from the command
  659. * queue by automatic updates, MI_REPORT_HEAD, MI_STORE_DATA_INDEX, or
  660. * MI_STORE_DATA_IMM.
  661. *
  662. * The following dwords have a reserved meaning:
  663. * 0x00: ISR copy, updated when an ISR bit not set in the HWSTAM changes.
  664. * 0x04: ring 0 head pointer
  665. * 0x05: ring 1 head pointer (915-class)
  666. * 0x06: ring 2 head pointer (915-class)
  667. * 0x10-0x1b: Context status DWords (GM45)
  668. * 0x1f: Last written status offset. (GM45)
  669. * 0x20-0x2f: Reserved (Gen6+)
  670. *
  671. * The area from dword 0x30 to 0x3ff is available for driver usage.
  672. */
  673. #define I915_GEM_HWS_INDEX 0x30
  674. #define I915_GEM_HWS_INDEX_ADDR (I915_GEM_HWS_INDEX << MI_STORE_DWORD_INDEX_SHIFT)
  675. #define I915_GEM_HWS_PREEMPT_INDEX 0x32
  676. #define I915_GEM_HWS_PREEMPT_ADDR (I915_GEM_HWS_PREEMPT_INDEX << MI_STORE_DWORD_INDEX_SHIFT)
  677. #define I915_GEM_HWS_SCRATCH_INDEX 0x40
  678. #define I915_GEM_HWS_SCRATCH_ADDR (I915_GEM_HWS_SCRATCH_INDEX << MI_STORE_DWORD_INDEX_SHIFT)
  679. #define I915_HWS_CSB_BUF0_INDEX 0x10
  680. #define I915_HWS_CSB_WRITE_INDEX 0x1f
  681. #define CNL_HWS_CSB_WRITE_INDEX 0x2f
  682. struct intel_ring *
  683. intel_engine_create_ring(struct intel_engine_cs *engine,
  684. struct i915_timeline *timeline,
  685. int size);
  686. int intel_ring_pin(struct intel_ring *ring);
  687. void intel_ring_reset(struct intel_ring *ring, u32 tail);
  688. unsigned int intel_ring_update_space(struct intel_ring *ring);
  689. void intel_ring_unpin(struct intel_ring *ring);
  690. void intel_ring_free(struct intel_ring *ring);
  691. void intel_engine_stop(struct intel_engine_cs *engine);
  692. void intel_engine_cleanup(struct intel_engine_cs *engine);
  693. void intel_legacy_submission_resume(struct drm_i915_private *dev_priv);
  694. int __must_check intel_ring_cacheline_align(struct i915_request *rq);
  695. int intel_ring_wait_for_space(struct intel_ring *ring, unsigned int bytes);
  696. u32 __must_check *intel_ring_begin(struct i915_request *rq, unsigned int n);
  697. static inline void intel_ring_advance(struct i915_request *rq, u32 *cs)
  698. {
  699. /* Dummy function.
  700. *
  701. * This serves as a placeholder in the code so that the reader
  702. * can compare against the preceding intel_ring_begin() and
  703. * check that the number of dwords emitted matches the space
  704. * reserved for the command packet (i.e. the value passed to
  705. * intel_ring_begin()).
  706. */
  707. GEM_BUG_ON((rq->ring->vaddr + rq->ring->emit) != cs);
  708. }
  709. static inline u32 intel_ring_wrap(const struct intel_ring *ring, u32 pos)
  710. {
  711. return pos & (ring->size - 1);
  712. }
  713. static inline bool
  714. intel_ring_offset_valid(const struct intel_ring *ring,
  715. unsigned int pos)
  716. {
  717. if (pos & -ring->size) /* must be strictly within the ring */
  718. return false;
  719. if (!IS_ALIGNED(pos, 8)) /* must be qword aligned */
  720. return false;
  721. return true;
  722. }
  723. static inline u32 intel_ring_offset(const struct i915_request *rq, void *addr)
  724. {
  725. /* Don't write ring->size (equivalent to 0) as that hangs some GPUs. */
  726. u32 offset = addr - rq->ring->vaddr;
  727. GEM_BUG_ON(offset > rq->ring->size);
  728. return intel_ring_wrap(rq->ring, offset);
  729. }
  730. static inline void
  731. assert_ring_tail_valid(const struct intel_ring *ring, unsigned int tail)
  732. {
  733. GEM_BUG_ON(!intel_ring_offset_valid(ring, tail));
  734. /*
  735. * "Ring Buffer Use"
  736. * Gen2 BSpec "1. Programming Environment" / 1.4.4.6
  737. * Gen3 BSpec "1c Memory Interface Functions" / 2.3.4.5
  738. * Gen4+ BSpec "1c Memory Interface and Command Stream" / 5.3.4.5
  739. * "If the Ring Buffer Head Pointer and the Tail Pointer are on the
  740. * same cacheline, the Head Pointer must not be greater than the Tail
  741. * Pointer."
  742. *
  743. * We use ring->head as the last known location of the actual RING_HEAD,
  744. * it may have advanced but in the worst case it is equally the same
  745. * as ring->head and so we should never program RING_TAIL to advance
  746. * into the same cacheline as ring->head.
  747. */
  748. #define cacheline(a) round_down(a, CACHELINE_BYTES)
  749. GEM_BUG_ON(cacheline(tail) == cacheline(ring->head) &&
  750. tail < ring->head);
  751. #undef cacheline
  752. }
  753. static inline unsigned int
  754. intel_ring_set_tail(struct intel_ring *ring, unsigned int tail)
  755. {
  756. /* Whilst writes to the tail are strictly order, there is no
  757. * serialisation between readers and the writers. The tail may be
  758. * read by i915_request_retire() just as it is being updated
  759. * by execlists, as although the breadcrumb is complete, the context
  760. * switch hasn't been seen.
  761. */
  762. assert_ring_tail_valid(ring, tail);
  763. ring->tail = tail;
  764. return tail;
  765. }
  766. void intel_engine_init_global_seqno(struct intel_engine_cs *engine, u32 seqno);
  767. void intel_engine_setup_common(struct intel_engine_cs *engine);
  768. int intel_engine_init_common(struct intel_engine_cs *engine);
  769. void intel_engine_cleanup_common(struct intel_engine_cs *engine);
  770. int intel_init_render_ring_buffer(struct intel_engine_cs *engine);
  771. int intel_init_bsd_ring_buffer(struct intel_engine_cs *engine);
  772. int intel_init_blt_ring_buffer(struct intel_engine_cs *engine);
  773. int intel_init_vebox_ring_buffer(struct intel_engine_cs *engine);
  774. int intel_engine_stop_cs(struct intel_engine_cs *engine);
  775. void intel_engine_cancel_stop_cs(struct intel_engine_cs *engine);
  776. u64 intel_engine_get_active_head(const struct intel_engine_cs *engine);
  777. u64 intel_engine_get_last_batch_head(const struct intel_engine_cs *engine);
  778. static inline u32 intel_engine_last_submit(struct intel_engine_cs *engine)
  779. {
  780. /*
  781. * We are only peeking at the tail of the submit queue (and not the
  782. * queue itself) in order to gain a hint as to the current active
  783. * state of the engine. Callers are not expected to be taking
  784. * engine->timeline->lock, nor are they expected to be concerned
  785. * wtih serialising this hint with anything, so document it as
  786. * a hint and nothing more.
  787. */
  788. return READ_ONCE(engine->timeline.seqno);
  789. }
  790. static inline u32 intel_engine_get_seqno(struct intel_engine_cs *engine)
  791. {
  792. return intel_read_status_page(engine, I915_GEM_HWS_INDEX);
  793. }
  794. static inline bool intel_engine_signaled(struct intel_engine_cs *engine,
  795. u32 seqno)
  796. {
  797. return i915_seqno_passed(intel_engine_get_seqno(engine), seqno);
  798. }
  799. static inline bool intel_engine_has_completed(struct intel_engine_cs *engine,
  800. u32 seqno)
  801. {
  802. GEM_BUG_ON(!seqno);
  803. return intel_engine_signaled(engine, seqno);
  804. }
  805. static inline bool intel_engine_has_started(struct intel_engine_cs *engine,
  806. u32 seqno)
  807. {
  808. GEM_BUG_ON(!seqno);
  809. return intel_engine_signaled(engine, seqno - 1);
  810. }
  811. void intel_engine_get_instdone(struct intel_engine_cs *engine,
  812. struct intel_instdone *instdone);
  813. /*
  814. * Arbitrary size for largest possible 'add request' sequence. The code paths
  815. * are complex and variable. Empirical measurement shows that the worst case
  816. * is BDW at 192 bytes (6 + 6 + 36 dwords), then ILK at 136 bytes. However,
  817. * we need to allocate double the largest single packet within that emission
  818. * to account for tail wraparound (so 6 + 6 + 72 dwords for BDW).
  819. */
  820. #define MIN_SPACE_FOR_ADD_REQUEST 336
  821. static inline u32 intel_hws_seqno_address(struct intel_engine_cs *engine)
  822. {
  823. return engine->status_page.ggtt_offset + I915_GEM_HWS_INDEX_ADDR;
  824. }
  825. static inline u32 intel_hws_preempt_done_address(struct intel_engine_cs *engine)
  826. {
  827. return engine->status_page.ggtt_offset + I915_GEM_HWS_PREEMPT_ADDR;
  828. }
  829. /* intel_breadcrumbs.c -- user interrupt bottom-half for waiters */
  830. int intel_engine_init_breadcrumbs(struct intel_engine_cs *engine);
  831. static inline void intel_wait_init(struct intel_wait *wait)
  832. {
  833. wait->tsk = current;
  834. wait->request = NULL;
  835. }
  836. static inline void intel_wait_init_for_seqno(struct intel_wait *wait, u32 seqno)
  837. {
  838. wait->tsk = current;
  839. wait->seqno = seqno;
  840. }
  841. static inline bool intel_wait_has_seqno(const struct intel_wait *wait)
  842. {
  843. return wait->seqno;
  844. }
  845. static inline bool
  846. intel_wait_update_seqno(struct intel_wait *wait, u32 seqno)
  847. {
  848. wait->seqno = seqno;
  849. return intel_wait_has_seqno(wait);
  850. }
  851. static inline bool
  852. intel_wait_update_request(struct intel_wait *wait,
  853. const struct i915_request *rq)
  854. {
  855. return intel_wait_update_seqno(wait, i915_request_global_seqno(rq));
  856. }
  857. static inline bool
  858. intel_wait_check_seqno(const struct intel_wait *wait, u32 seqno)
  859. {
  860. return wait->seqno == seqno;
  861. }
  862. static inline bool
  863. intel_wait_check_request(const struct intel_wait *wait,
  864. const struct i915_request *rq)
  865. {
  866. return intel_wait_check_seqno(wait, i915_request_global_seqno(rq));
  867. }
  868. static inline bool intel_wait_complete(const struct intel_wait *wait)
  869. {
  870. return RB_EMPTY_NODE(&wait->node);
  871. }
  872. bool intel_engine_add_wait(struct intel_engine_cs *engine,
  873. struct intel_wait *wait);
  874. void intel_engine_remove_wait(struct intel_engine_cs *engine,
  875. struct intel_wait *wait);
  876. bool intel_engine_enable_signaling(struct i915_request *request, bool wakeup);
  877. void intel_engine_cancel_signaling(struct i915_request *request);
  878. static inline bool intel_engine_has_waiter(const struct intel_engine_cs *engine)
  879. {
  880. return READ_ONCE(engine->breadcrumbs.irq_wait);
  881. }
  882. unsigned int intel_engine_wakeup(struct intel_engine_cs *engine);
  883. #define ENGINE_WAKEUP_WAITER BIT(0)
  884. #define ENGINE_WAKEUP_ASLEEP BIT(1)
  885. void intel_engine_pin_breadcrumbs_irq(struct intel_engine_cs *engine);
  886. void intel_engine_unpin_breadcrumbs_irq(struct intel_engine_cs *engine);
  887. void __intel_engine_disarm_breadcrumbs(struct intel_engine_cs *engine);
  888. void intel_engine_disarm_breadcrumbs(struct intel_engine_cs *engine);
  889. void intel_engine_reset_breadcrumbs(struct intel_engine_cs *engine);
  890. void intel_engine_fini_breadcrumbs(struct intel_engine_cs *engine);
  891. static inline u32 *gen8_emit_pipe_control(u32 *batch, u32 flags, u32 offset)
  892. {
  893. memset(batch, 0, 6 * sizeof(u32));
  894. batch[0] = GFX_OP_PIPE_CONTROL(6);
  895. batch[1] = flags;
  896. batch[2] = offset;
  897. return batch + 6;
  898. }
  899. static inline u32 *
  900. gen8_emit_ggtt_write_rcs(u32 *cs, u32 value, u32 gtt_offset)
  901. {
  902. /* We're using qword write, offset should be aligned to 8 bytes. */
  903. GEM_BUG_ON(!IS_ALIGNED(gtt_offset, 8));
  904. /* w/a for post sync ops following a GPGPU operation we
  905. * need a prior CS_STALL, which is emitted by the flush
  906. * following the batch.
  907. */
  908. *cs++ = GFX_OP_PIPE_CONTROL(6);
  909. *cs++ = PIPE_CONTROL_GLOBAL_GTT_IVB | PIPE_CONTROL_CS_STALL |
  910. PIPE_CONTROL_QW_WRITE;
  911. *cs++ = gtt_offset;
  912. *cs++ = 0;
  913. *cs++ = value;
  914. /* We're thrashing one dword of HWS. */
  915. *cs++ = 0;
  916. return cs;
  917. }
  918. static inline u32 *
  919. gen8_emit_ggtt_write(u32 *cs, u32 value, u32 gtt_offset)
  920. {
  921. /* w/a: bit 5 needs to be zero for MI_FLUSH_DW address. */
  922. GEM_BUG_ON(gtt_offset & (1 << 5));
  923. /* Offset should be aligned to 8 bytes for both (QW/DW) write types */
  924. GEM_BUG_ON(!IS_ALIGNED(gtt_offset, 8));
  925. *cs++ = (MI_FLUSH_DW + 1) | MI_FLUSH_DW_OP_STOREDW;
  926. *cs++ = gtt_offset | MI_FLUSH_DW_USE_GTT;
  927. *cs++ = 0;
  928. *cs++ = value;
  929. return cs;
  930. }
  931. void intel_engines_sanitize(struct drm_i915_private *i915);
  932. bool intel_engine_is_idle(struct intel_engine_cs *engine);
  933. bool intel_engines_are_idle(struct drm_i915_private *dev_priv);
  934. bool intel_engine_has_kernel_context(const struct intel_engine_cs *engine);
  935. void intel_engine_lost_context(struct intel_engine_cs *engine);
  936. void intel_engines_park(struct drm_i915_private *i915);
  937. void intel_engines_unpark(struct drm_i915_private *i915);
  938. void intel_engines_reset_default_submission(struct drm_i915_private *i915);
  939. unsigned int intel_engines_has_context_isolation(struct drm_i915_private *i915);
  940. bool intel_engine_can_store_dword(struct intel_engine_cs *engine);
  941. __printf(3, 4)
  942. void intel_engine_dump(struct intel_engine_cs *engine,
  943. struct drm_printer *m,
  944. const char *header, ...);
  945. struct intel_engine_cs *
  946. intel_engine_lookup_user(struct drm_i915_private *i915, u8 class, u8 instance);
  947. static inline void intel_engine_context_in(struct intel_engine_cs *engine)
  948. {
  949. unsigned long flags;
  950. if (READ_ONCE(engine->stats.enabled) == 0)
  951. return;
  952. write_seqlock_irqsave(&engine->stats.lock, flags);
  953. if (engine->stats.enabled > 0) {
  954. if (engine->stats.active++ == 0)
  955. engine->stats.start = ktime_get();
  956. GEM_BUG_ON(engine->stats.active == 0);
  957. }
  958. write_sequnlock_irqrestore(&engine->stats.lock, flags);
  959. }
  960. static inline void intel_engine_context_out(struct intel_engine_cs *engine)
  961. {
  962. unsigned long flags;
  963. if (READ_ONCE(engine->stats.enabled) == 0)
  964. return;
  965. write_seqlock_irqsave(&engine->stats.lock, flags);
  966. if (engine->stats.enabled > 0) {
  967. ktime_t last;
  968. if (engine->stats.active && --engine->stats.active == 0) {
  969. /*
  970. * Decrement the active context count and in case GPU
  971. * is now idle add up to the running total.
  972. */
  973. last = ktime_sub(ktime_get(), engine->stats.start);
  974. engine->stats.total = ktime_add(engine->stats.total,
  975. last);
  976. } else if (engine->stats.active == 0) {
  977. /*
  978. * After turning on engine stats, context out might be
  979. * the first event in which case we account from the
  980. * time stats gathering was turned on.
  981. */
  982. last = ktime_sub(ktime_get(), engine->stats.enabled_at);
  983. engine->stats.total = ktime_add(engine->stats.total,
  984. last);
  985. }
  986. }
  987. write_sequnlock_irqrestore(&engine->stats.lock, flags);
  988. }
  989. int intel_enable_engine_stats(struct intel_engine_cs *engine);
  990. void intel_disable_engine_stats(struct intel_engine_cs *engine);
  991. ktime_t intel_engine_get_busy_time(struct intel_engine_cs *engine);
  992. #if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
  993. static inline bool inject_preempt_hang(struct intel_engine_execlists *execlists)
  994. {
  995. if (!execlists->preempt_hang.inject_hang)
  996. return false;
  997. complete(&execlists->preempt_hang.completion);
  998. return true;
  999. }
  1000. #else
  1001. static inline bool inject_preempt_hang(struct intel_engine_execlists *execlists)
  1002. {
  1003. return false;
  1004. }
  1005. #endif
  1006. #endif /* _INTEL_RINGBUFFER_H_ */