blob: 17ef9cdf1b8ddc7a81ad18269b8582a71def8bea [file] [log] [blame]
Zou Nan hai8187a2b2010-05-21 09:08:55 +08001#ifndef _INTEL_RINGBUFFER_H_
2#define _INTEL_RINGBUFFER_H_
3
Brad Volkin44e895a2014-05-10 14:10:43 -07004#include <linux/hashtable.h>
5
6#define I915_CMD_HASH_ORDER 9
7
Ville Syrjälä633cf8f2012-12-03 18:43:32 +02008/*
9 * Gen2 BSpec "1. Programming Environment" / 1.4.4.6 "Ring Buffer Use"
10 * Gen3 BSpec "vol1c Memory Interface Functions" / 2.3.4.5 "Ring Buffer Use"
11 * Gen4+ BSpec "vol1c Memory Interface and Command Stream" / 5.3.4.5 "Ring Buffer Use"
12 *
13 * "If the Ring Buffer Head Pointer and the Tail Pointer are on the same
14 * cacheline, the Head Pointer must not be greater than the Tail
15 * Pointer."
16 */
17#define I915_RING_FREE_SPACE 64
18
Zou Nan hai8187a2b2010-05-21 09:08:55 +080019struct intel_hw_status_page {
Daniel Vetter4225d0f2012-04-26 23:28:16 +020020 u32 *page_addr;
Zou Nan hai8187a2b2010-05-21 09:08:55 +080021 unsigned int gfx_addr;
Chris Wilson05394f32010-11-08 19:18:58 +000022 struct drm_i915_gem_object *obj;
Zou Nan hai8187a2b2010-05-21 09:08:55 +080023};
24
Ben Widawskyb7287d82011-04-25 11:22:22 -070025#define I915_READ_TAIL(ring) I915_READ(RING_TAIL((ring)->mmio_base))
26#define I915_WRITE_TAIL(ring, val) I915_WRITE(RING_TAIL((ring)->mmio_base), val)
Zou Nan haicae58522010-11-09 17:17:32 +080027
Ben Widawskyb7287d82011-04-25 11:22:22 -070028#define I915_READ_START(ring) I915_READ(RING_START((ring)->mmio_base))
29#define I915_WRITE_START(ring, val) I915_WRITE(RING_START((ring)->mmio_base), val)
Zou Nan haicae58522010-11-09 17:17:32 +080030
Ben Widawskyb7287d82011-04-25 11:22:22 -070031#define I915_READ_HEAD(ring) I915_READ(RING_HEAD((ring)->mmio_base))
32#define I915_WRITE_HEAD(ring, val) I915_WRITE(RING_HEAD((ring)->mmio_base), val)
Zou Nan haicae58522010-11-09 17:17:32 +080033
Ben Widawskyb7287d82011-04-25 11:22:22 -070034#define I915_READ_CTL(ring) I915_READ(RING_CTL((ring)->mmio_base))
35#define I915_WRITE_CTL(ring, val) I915_WRITE(RING_CTL((ring)->mmio_base), val)
Zou Nan haicae58522010-11-09 17:17:32 +080036
Ben Widawskyb7287d82011-04-25 11:22:22 -070037#define I915_READ_IMR(ring) I915_READ(RING_IMR((ring)->mmio_base))
38#define I915_WRITE_IMR(ring, val) I915_WRITE(RING_IMR((ring)->mmio_base), val)
Daniel Vetter870e86d2010-08-02 16:29:44 +020039
Naresh Kumar Kachhie9fea572014-03-12 16:39:41 +053040#define I915_READ_MODE(ring) I915_READ(RING_MI_MODE((ring)->mmio_base))
Chris Wilson9991ae72014-04-02 16:36:07 +010041#define I915_WRITE_MODE(ring, val) I915_WRITE(RING_MI_MODE((ring)->mmio_base), val)
Naresh Kumar Kachhie9fea572014-03-12 16:39:41 +053042
Ben Widawsky3e789982014-06-30 09:53:37 -070043/* seqno size is actually only a uint32, but since we plan to use MI_FLUSH_DW to
44 * do the writes, and that must have qw aligned offsets, simply pretend it's 8b.
45 */
46#define i915_semaphore_seqno_size sizeof(uint64_t)
47#define GEN8_SIGNAL_OFFSET(__ring, to) \
48 (i915_gem_obj_ggtt_offset(dev_priv->semaphore_obj) + \
49 ((__ring)->id * I915_NUM_RINGS * i915_semaphore_seqno_size) + \
50 (i915_semaphore_seqno_size * (to)))
51
52#define GEN8_WAIT_OFFSET(__ring, from) \
53 (i915_gem_obj_ggtt_offset(dev_priv->semaphore_obj) + \
54 ((from) * I915_NUM_RINGS * i915_semaphore_seqno_size) + \
55 (i915_semaphore_seqno_size * (__ring)->id))
56
57#define GEN8_RING_SEMAPHORE_INIT do { \
58 if (!dev_priv->semaphore_obj) { \
59 break; \
60 } \
61 ring->semaphore.signal_ggtt[RCS] = GEN8_SIGNAL_OFFSET(ring, RCS); \
62 ring->semaphore.signal_ggtt[VCS] = GEN8_SIGNAL_OFFSET(ring, VCS); \
63 ring->semaphore.signal_ggtt[BCS] = GEN8_SIGNAL_OFFSET(ring, BCS); \
64 ring->semaphore.signal_ggtt[VECS] = GEN8_SIGNAL_OFFSET(ring, VECS); \
65 ring->semaphore.signal_ggtt[VCS2] = GEN8_SIGNAL_OFFSET(ring, VCS2); \
66 ring->semaphore.signal_ggtt[ring->id] = MI_SEMAPHORE_SYNC_INVALID; \
67 } while(0)
68
Jani Nikulaf2f4d822013-08-11 12:44:01 +030069enum intel_ring_hangcheck_action {
Mika Kuoppalada661462013-09-06 16:03:28 +030070 HANGCHECK_IDLE = 0,
Jani Nikulaf2f4d822013-08-11 12:44:01 +030071 HANGCHECK_WAIT,
72 HANGCHECK_ACTIVE,
73 HANGCHECK_KICK,
74 HANGCHECK_HUNG,
75};
Mika Kuoppalaad8beae2013-06-12 12:35:32 +030076
Mika Kuoppalab6b0fac2014-01-30 19:04:43 +020077#define HANGCHECK_SCORE_RING_HUNG 31
78
Mika Kuoppala92cab732013-05-24 17:16:07 +030079struct intel_ring_hangcheck {
Chris Wilson50877442014-03-21 12:41:53 +000080 u64 acthd;
Mika Kuoppala92cab732013-05-24 17:16:07 +030081 u32 seqno;
Mika Kuoppala05407ff2013-05-30 09:04:29 +030082 int score;
Mika Kuoppalaad8beae2013-06-12 12:35:32 +030083 enum intel_ring_hangcheck_action action;
Chris Wilson4be17382014-06-06 10:22:29 +010084 int deadlock;
Mika Kuoppala92cab732013-05-24 17:16:07 +030085};
86
Oscar Mateo8ee14972014-05-22 14:13:34 +010087struct intel_ringbuffer {
88 struct drm_i915_gem_object *obj;
89 void __iomem *virtual_start;
90
91 u32 head;
92 u32 tail;
93 int space;
94 int size;
95 int effective_size;
96
97 /** We track the position of the requests in the ring buffer, and
98 * when each is retired we increment last_retired_head as the GPU
99 * must have finished processing the request and so we know we
100 * can advance the ringbuffer up to that position.
101 *
102 * last_retired_head is set to -1 after the value is consumed so
103 * we can detect new retirements.
104 */
105 u32 last_retired_head;
106};
107
Oscar Mateoa4872ba2014-05-22 14:13:33 +0100108struct intel_engine_cs {
Zou Nan hai8187a2b2010-05-21 09:08:55 +0800109 const char *name;
Chris Wilson92204342010-09-18 11:02:01 +0100110 enum intel_ring_id {
Daniel Vetter96154f22011-12-14 13:57:00 +0100111 RCS = 0x0,
112 VCS,
113 BCS,
Ben Widawsky4a3dd192013-05-28 19:22:19 -0700114 VECS,
Zhao Yakui845f74a2014-04-17 10:37:37 +0800115 VCS2
Chris Wilson92204342010-09-18 11:02:01 +0100116 } id;
Zhao Yakui845f74a2014-04-17 10:37:37 +0800117#define I915_NUM_RINGS 5
Zhao Yakuib1a93302014-04-17 10:37:36 +0800118#define LAST_USER_RING (VECS + 1)
Daniel Vetter333e9fe2010-08-02 16:24:01 +0200119 u32 mmio_base;
Zou Nan hai8187a2b2010-05-21 09:08:55 +0800120 struct drm_device *dev;
Oscar Mateo8ee14972014-05-22 14:13:34 +0100121 struct intel_ringbuffer *buffer;
Zou Nan hai8187a2b2010-05-21 09:08:55 +0800122
Zou Nan hai8187a2b2010-05-21 09:08:55 +0800123 struct intel_hw_status_page status_page;
124
Daniel Vetterc7113cc2013-07-04 23:35:29 +0200125 unsigned irq_refcount; /* protected by dev_priv->irq_lock */
Daniel Vetter6a848cc2012-04-11 22:12:46 +0200126 u32 irq_enable_mask; /* bitmask to enable ring interrupt */
Chris Wilsondb53a302011-02-03 11:57:46 +0000127 u32 trace_irq_seqno;
Oscar Mateoa4872ba2014-05-22 14:13:33 +0100128 bool __must_check (*irq_get)(struct intel_engine_cs *ring);
129 void (*irq_put)(struct intel_engine_cs *ring);
Zou Nan hai8187a2b2010-05-21 09:08:55 +0800130
Oscar Mateoa4872ba2014-05-22 14:13:33 +0100131 int (*init)(struct intel_engine_cs *ring);
Zou Nan hai8187a2b2010-05-21 09:08:55 +0800132
Oscar Mateoa4872ba2014-05-22 14:13:33 +0100133 void (*write_tail)(struct intel_engine_cs *ring,
Chris Wilson297b0c52010-10-22 17:02:41 +0100134 u32 value);
Oscar Mateoa4872ba2014-05-22 14:13:33 +0100135 int __must_check (*flush)(struct intel_engine_cs *ring,
Chris Wilsonb72f3ac2011-01-04 17:34:02 +0000136 u32 invalidate_domains,
137 u32 flush_domains);
Oscar Mateoa4872ba2014-05-22 14:13:33 +0100138 int (*add_request)(struct intel_engine_cs *ring);
Chris Wilsonb2eadbc2012-08-09 10:58:30 +0100139 /* Some chipsets are not quite as coherent as advertised and need
140 * an expensive kick to force a true read of the up-to-date seqno.
141 * However, the up-to-date seqno is not always required and the last
142 * seen value is good enough. Note that the seqno will always be
143 * monotonic, even if not coherent.
144 */
Oscar Mateoa4872ba2014-05-22 14:13:33 +0100145 u32 (*get_seqno)(struct intel_engine_cs *ring,
Chris Wilsonb2eadbc2012-08-09 10:58:30 +0100146 bool lazy_coherency);
Oscar Mateoa4872ba2014-05-22 14:13:33 +0100147 void (*set_seqno)(struct intel_engine_cs *ring,
Mika Kuoppalab70ec5b2012-12-19 11:13:05 +0200148 u32 seqno);
Oscar Mateoa4872ba2014-05-22 14:13:33 +0100149 int (*dispatch_execbuffer)(struct intel_engine_cs *ring,
Ben Widawsky9bcb1442014-04-28 19:29:25 -0700150 u64 offset, u32 length,
Chris Wilsond7d4eed2012-10-17 12:09:54 +0100151 unsigned flags);
152#define I915_DISPATCH_SECURE 0x1
Daniel Vetterb45305f2012-12-17 16:21:27 +0100153#define I915_DISPATCH_PINNED 0x2
Oscar Mateoa4872ba2014-05-22 14:13:33 +0100154 void (*cleanup)(struct intel_engine_cs *ring);
Ben Widawskyebc348b2014-04-29 14:52:28 -0700155
Ben Widawsky3e789982014-06-30 09:53:37 -0700156 /* GEN8 signal/wait table - never trust comments!
157 * signal to signal to signal to signal to signal to
158 * RCS VCS BCS VECS VCS2
159 * --------------------------------------------------------------------
160 * RCS | NOP (0x00) | VCS (0x08) | BCS (0x10) | VECS (0x18) | VCS2 (0x20) |
161 * |-------------------------------------------------------------------
162 * VCS | RCS (0x28) | NOP (0x30) | BCS (0x38) | VECS (0x40) | VCS2 (0x48) |
163 * |-------------------------------------------------------------------
164 * BCS | RCS (0x50) | VCS (0x58) | NOP (0x60) | VECS (0x68) | VCS2 (0x70) |
165 * |-------------------------------------------------------------------
166 * VECS | RCS (0x78) | VCS (0x80) | BCS (0x88) | NOP (0x90) | VCS2 (0x98) |
167 * |-------------------------------------------------------------------
168 * VCS2 | RCS (0xa0) | VCS (0xa8) | BCS (0xb0) | VECS (0xb8) | NOP (0xc0) |
169 * |-------------------------------------------------------------------
170 *
171 * Generalization:
172 * f(x, y) := (x->id * NUM_RINGS * seqno_size) + (seqno_size * y->id)
173 * ie. transpose of g(x, y)
174 *
175 * sync from sync from sync from sync from sync from
176 * RCS VCS BCS VECS VCS2
177 * --------------------------------------------------------------------
178 * RCS | NOP (0x00) | VCS (0x28) | BCS (0x50) | VECS (0x78) | VCS2 (0xa0) |
179 * |-------------------------------------------------------------------
180 * VCS | RCS (0x08) | NOP (0x30) | BCS (0x58) | VECS (0x80) | VCS2 (0xa8) |
181 * |-------------------------------------------------------------------
182 * BCS | RCS (0x10) | VCS (0x38) | NOP (0x60) | VECS (0x88) | VCS2 (0xb0) |
183 * |-------------------------------------------------------------------
184 * VECS | RCS (0x18) | VCS (0x40) | BCS (0x68) | NOP (0x90) | VCS2 (0xb8) |
185 * |-------------------------------------------------------------------
186 * VCS2 | RCS (0x20) | VCS (0x48) | BCS (0x70) | VECS (0x98) | NOP (0xc0) |
187 * |-------------------------------------------------------------------
188 *
189 * Generalization:
190 * g(x, y) := (y->id * NUM_RINGS * seqno_size) + (seqno_size * x->id)
191 * ie. transpose of f(x, y)
192 */
Ben Widawskyebc348b2014-04-29 14:52:28 -0700193 struct {
194 u32 sync_seqno[I915_NUM_RINGS-1];
Ben Widawsky78325f22014-04-29 14:52:29 -0700195
Ben Widawsky3e789982014-06-30 09:53:37 -0700196 union {
197 struct {
198 /* our mbox written by others */
199 u32 wait[I915_NUM_RINGS];
200 /* mboxes this ring signals to */
201 u32 signal[I915_NUM_RINGS];
202 } mbox;
203 u64 signal_ggtt[I915_NUM_RINGS];
204 };
Ben Widawsky78325f22014-04-29 14:52:29 -0700205
206 /* AKA wait() */
Oscar Mateoa4872ba2014-05-22 14:13:33 +0100207 int (*sync_to)(struct intel_engine_cs *ring,
208 struct intel_engine_cs *to,
Ben Widawsky78325f22014-04-29 14:52:29 -0700209 u32 seqno);
Oscar Mateoa4872ba2014-05-22 14:13:33 +0100210 int (*signal)(struct intel_engine_cs *signaller,
Ben Widawsky024a43e2014-04-29 14:52:30 -0700211 /* num_dwords needed by caller */
212 unsigned int num_dwords);
Ben Widawskyebc348b2014-04-29 14:52:28 -0700213 } semaphore;
Ben Widawskyad776f82013-05-28 19:22:18 -0700214
Zou Nan hai8187a2b2010-05-21 09:08:55 +0800215 /**
216 * List of objects currently involved in rendering from the
217 * ringbuffer.
218 *
219 * Includes buffers having the contents of their GPU caches
220 * flushed, not necessarily primitives. last_rendering_seqno
221 * represents when the rendering involved will be completed.
222 *
223 * A reference is held on the buffer while on this list.
224 */
225 struct list_head active_list;
226
227 /**
228 * List of breadcrumbs associated with GPU requests currently
229 * outstanding.
230 */
231 struct list_head request_list;
232
Chris Wilsona56ba562010-09-28 10:07:56 +0100233 /**
234 * Do we have some not yet emitted requests outstanding?
235 */
Chris Wilson3c0e2342013-09-04 10:45:52 +0100236 struct drm_i915_gem_request *preallocated_lazy_request;
Chris Wilson18235212013-09-04 10:45:51 +0100237 u32 outstanding_lazy_seqno;
Daniel Vettercc889e02012-06-13 20:45:19 +0200238 bool gpu_caches_dirty;
Chris Wilsonc65355b2013-06-06 16:53:41 -0300239 bool fbc_dirty;
Chris Wilsona56ba562010-09-28 10:07:56 +0100240
Zou Nan hai8187a2b2010-05-21 09:08:55 +0800241 wait_queue_head_t irq_queue;
Zou Nan hai8d192152010-11-02 16:31:01 +0800242
Oscar Mateo273497e2014-05-22 14:13:37 +0100243 struct intel_context *default_context;
244 struct intel_context *last_context;
Ben Widawsky40521052012-06-04 14:42:43 -0700245
Mika Kuoppala92cab732013-05-24 17:16:07 +0300246 struct intel_ring_hangcheck hangcheck;
247
Chris Wilson0d1aaca2013-08-26 20:58:11 +0100248 struct {
249 struct drm_i915_gem_object *obj;
250 u32 gtt_offset;
251 volatile u32 *cpu_page;
252 } scratch;
Brad Volkin351e3db2014-02-18 10:15:46 -0800253
Brad Volkin44e895a2014-05-10 14:10:43 -0700254 bool needs_cmd_parser;
255
Brad Volkin351e3db2014-02-18 10:15:46 -0800256 /*
Brad Volkin44e895a2014-05-10 14:10:43 -0700257 * Table of commands the command parser needs to know about
Brad Volkin351e3db2014-02-18 10:15:46 -0800258 * for this ring.
259 */
Brad Volkin44e895a2014-05-10 14:10:43 -0700260 DECLARE_HASHTABLE(cmd_hash, I915_CMD_HASH_ORDER);
Brad Volkin351e3db2014-02-18 10:15:46 -0800261
262 /*
263 * Table of registers allowed in commands that read/write registers.
264 */
265 const u32 *reg_table;
266 int reg_count;
267
268 /*
269 * Table of registers allowed in commands that read/write registers, but
270 * only from the DRM master.
271 */
272 const u32 *master_reg_table;
273 int master_reg_count;
274
275 /*
276 * Returns the bitmask for the length field of the specified command.
277 * Return 0 for an unrecognized/invalid command.
278 *
279 * If the command parser finds an entry for a command in the ring's
280 * cmd_tables, it gets the command's length based on the table entry.
281 * If not, it calls this function to determine the per-ring length field
282 * encoding for the command (i.e. certain opcode ranges use certain bits
283 * to encode the command length in the header).
284 */
285 u32 (*get_cmd_length_mask)(u32 cmd_header);
Zou Nan hai8187a2b2010-05-21 09:08:55 +0800286};
287
Chris Wilsonb4519512012-05-11 14:29:30 +0100288static inline bool
Oscar Mateoa4872ba2014-05-22 14:13:33 +0100289intel_ring_initialized(struct intel_engine_cs *ring)
Chris Wilsonb4519512012-05-11 14:29:30 +0100290{
Oscar Mateoee1b1e52014-05-22 14:13:35 +0100291 return ring->buffer && ring->buffer->obj;
Chris Wilsonb4519512012-05-11 14:29:30 +0100292}
293
Daniel Vetter96154f22011-12-14 13:57:00 +0100294static inline unsigned
Oscar Mateoa4872ba2014-05-22 14:13:33 +0100295intel_ring_flag(struct intel_engine_cs *ring)
Daniel Vetter96154f22011-12-14 13:57:00 +0100296{
297 return 1 << ring->id;
298}
299
Zou Nan hai8187a2b2010-05-21 09:08:55 +0800300static inline u32
Oscar Mateoa4872ba2014-05-22 14:13:33 +0100301intel_ring_sync_index(struct intel_engine_cs *ring,
302 struct intel_engine_cs *other)
Chris Wilson1ec14ad2010-12-04 11:30:53 +0000303{
304 int idx;
305
306 /*
Rodrigo Vividdd4dbc2014-06-30 09:51:11 -0700307 * rcs -> 0 = vcs, 1 = bcs, 2 = vecs, 3 = vcs2;
308 * vcs -> 0 = bcs, 1 = vecs, 2 = vcs2, 3 = rcs;
309 * bcs -> 0 = vecs, 1 = vcs2. 2 = rcs, 3 = vcs;
310 * vecs -> 0 = vcs2, 1 = rcs, 2 = vcs, 3 = bcs;
311 * vcs2 -> 0 = rcs, 1 = vcs, 2 = bcs, 3 = vecs;
Chris Wilson1ec14ad2010-12-04 11:30:53 +0000312 */
313
314 idx = (other - ring) - 1;
315 if (idx < 0)
316 idx += I915_NUM_RINGS;
317
318 return idx;
319}
320
321static inline u32
Oscar Mateoa4872ba2014-05-22 14:13:33 +0100322intel_read_status_page(struct intel_engine_cs *ring,
Chris Wilson78501ea2010-10-27 12:18:21 +0100323 int reg)
Zou Nan hai8187a2b2010-05-21 09:08:55 +0800324{
Daniel Vetter4225d0f2012-04-26 23:28:16 +0200325 /* Ensure that the compiler doesn't optimize away the load. */
326 barrier();
327 return ring->status_page.page_addr[reg];
Zou Nan hai8187a2b2010-05-21 09:08:55 +0800328}
329
Mika Kuoppalab70ec5b2012-12-19 11:13:05 +0200330static inline void
Oscar Mateoa4872ba2014-05-22 14:13:33 +0100331intel_write_status_page(struct intel_engine_cs *ring,
Mika Kuoppalab70ec5b2012-12-19 11:13:05 +0200332 int reg, u32 value)
333{
334 ring->status_page.page_addr[reg] = value;
335}
336
Chris Wilson311bd682011-01-13 19:06:50 +0000337/**
338 * Reads a dword out of the status page, which is written to from the command
339 * queue by automatic updates, MI_REPORT_HEAD, MI_STORE_DATA_INDEX, or
340 * MI_STORE_DATA_IMM.
341 *
342 * The following dwords have a reserved meaning:
343 * 0x00: ISR copy, updated when an ISR bit not set in the HWSTAM changes.
344 * 0x04: ring 0 head pointer
345 * 0x05: ring 1 head pointer (915-class)
346 * 0x06: ring 2 head pointer (915-class)
347 * 0x10-0x1b: Context status DWords (GM45)
348 * 0x1f: Last written status offset. (GM45)
349 *
350 * The area from dword 0x20 to 0x3ff is available for driver usage.
351 */
Chris Wilson311bd682011-01-13 19:06:50 +0000352#define I915_GEM_HWS_INDEX 0x20
Jesse Barnes9a289772012-10-26 09:42:42 -0700353#define I915_GEM_HWS_SCRATCH_INDEX 0x30
354#define I915_GEM_HWS_SCRATCH_ADDR (I915_GEM_HWS_SCRATCH_INDEX << MI_STORE_DWORD_INDEX_SHIFT)
Chris Wilson311bd682011-01-13 19:06:50 +0000355
Oscar Mateoa4872ba2014-05-22 14:13:33 +0100356void intel_stop_ring_buffer(struct intel_engine_cs *ring);
357void intel_cleanup_ring_buffer(struct intel_engine_cs *ring);
Ben Widawsky96f298a2011-03-19 18:14:27 -0700358
Oscar Mateoa4872ba2014-05-22 14:13:33 +0100359int __must_check intel_ring_begin(struct intel_engine_cs *ring, int n);
360int __must_check intel_ring_cacheline_align(struct intel_engine_cs *ring);
361static inline void intel_ring_emit(struct intel_engine_cs *ring,
Chris Wilson78501ea2010-10-27 12:18:21 +0100362 u32 data)
Chris Wilsone898cd22010-08-04 15:18:14 +0100363{
Oscar Mateo93b0a4e2014-05-22 14:13:36 +0100364 struct intel_ringbuffer *ringbuf = ring->buffer;
365 iowrite32(data, ringbuf->virtual_start + ringbuf->tail);
366 ringbuf->tail += 4;
Chris Wilsone898cd22010-08-04 15:18:14 +0100367}
Oscar Mateoa4872ba2014-05-22 14:13:33 +0100368static inline void intel_ring_advance(struct intel_engine_cs *ring)
Chris Wilson09246732013-08-10 22:16:32 +0100369{
Oscar Mateo93b0a4e2014-05-22 14:13:36 +0100370 struct intel_ringbuffer *ringbuf = ring->buffer;
371 ringbuf->tail &= ringbuf->size - 1;
Chris Wilson09246732013-08-10 22:16:32 +0100372}
Oscar Mateoa4872ba2014-05-22 14:13:33 +0100373void __intel_ring_advance(struct intel_engine_cs *ring);
Chris Wilson09246732013-08-10 22:16:32 +0100374
Oscar Mateoa4872ba2014-05-22 14:13:33 +0100375int __must_check intel_ring_idle(struct intel_engine_cs *ring);
376void intel_ring_init_seqno(struct intel_engine_cs *ring, u32 seqno);
377int intel_ring_flush_all_caches(struct intel_engine_cs *ring);
378int intel_ring_invalidate_all_caches(struct intel_engine_cs *ring);
Zou Nan hai8187a2b2010-05-21 09:08:55 +0800379
Xiang, Haihao5c1143b2010-09-16 10:43:11 +0800380int intel_init_render_ring_buffer(struct drm_device *dev);
381int intel_init_bsd_ring_buffer(struct drm_device *dev);
Zhao Yakui845f74a2014-04-17 10:37:37 +0800382int intel_init_bsd2_ring_buffer(struct drm_device *dev);
Chris Wilson549f7362010-10-19 11:19:32 +0100383int intel_init_blt_ring_buffer(struct drm_device *dev);
Ben Widawsky9a8a2212013-05-28 19:22:23 -0700384int intel_init_vebox_ring_buffer(struct drm_device *dev);
Zou Nan hai8187a2b2010-05-21 09:08:55 +0800385
Oscar Mateoa4872ba2014-05-22 14:13:33 +0100386u64 intel_ring_get_active_head(struct intel_engine_cs *ring);
387void intel_ring_setup_status_page(struct intel_engine_cs *ring);
Daniel Vetter79f321b2010-09-24 21:20:10 +0200388
Oscar Mateoa4872ba2014-05-22 14:13:33 +0100389static inline u32 intel_ring_get_tail(struct intel_engine_cs *ring)
Chris Wilsona71d8d92012-02-15 11:25:36 +0000390{
Oscar Mateoee1b1e52014-05-22 14:13:35 +0100391 return ring->buffer->tail;
Chris Wilsona71d8d92012-02-15 11:25:36 +0000392}
393
Oscar Mateoa4872ba2014-05-22 14:13:33 +0100394static inline u32 intel_ring_get_seqno(struct intel_engine_cs *ring)
Chris Wilson9d7730912012-11-27 16:22:52 +0000395{
Chris Wilson18235212013-09-04 10:45:51 +0100396 BUG_ON(ring->outstanding_lazy_seqno == 0);
397 return ring->outstanding_lazy_seqno;
Chris Wilson9d7730912012-11-27 16:22:52 +0000398}
399
Oscar Mateoa4872ba2014-05-22 14:13:33 +0100400static inline void i915_trace_irq_get(struct intel_engine_cs *ring, u32 seqno)
Chris Wilsondb53a302011-02-03 11:57:46 +0000401{
402 if (ring->trace_irq_seqno == 0 && ring->irq_get(ring))
403 ring->trace_irq_seqno = seqno;
404}
405
Chris Wilsone8616b62011-01-20 09:57:11 +0000406/* DRI warts */
407int intel_render_ring_init_dri(struct drm_device *dev, u64 start, u32 size);
408
Zou Nan hai8187a2b2010-05-21 09:08:55 +0800409#endif /* _INTEL_RINGBUFFER_H_ */