Eric Anholt | 62fdfea | 2010-05-21 13:26:39 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2008-2010 Intel Corporation |
| 3 | * |
| 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 5 | * copy of this software and associated documentation files (the "Software"), |
| 6 | * to deal in the Software without restriction, including without limitation |
| 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 8 | * and/or sell copies of the Software, and to permit persons to whom the |
| 9 | * Software is furnished to do so, subject to the following conditions: |
| 10 | * |
| 11 | * The above copyright notice and this permission notice (including the next |
| 12 | * paragraph) shall be included in all copies or substantial portions of the |
| 13 | * Software. |
| 14 | * |
| 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS |
| 21 | * IN THE SOFTWARE. |
| 22 | * |
| 23 | * Authors: |
| 24 | * Eric Anholt <eric@anholt.net> |
| 25 | * Zou Nan hai <nanhai.zou@intel.com> |
| 26 | * Xiang Hai hao<haihao.xiang@intel.com> |
| 27 | * |
| 28 | */ |
| 29 | |
Zeng Zhaoxiu | a4d8a0f | 2015-12-06 18:26:30 +0800 | [diff] [blame] | 30 | #include <linux/log2.h> |
David Howells | 760285e | 2012-10-02 18:01:07 +0100 | [diff] [blame] | 31 | #include <drm/drmP.h> |
Eric Anholt | 62fdfea | 2010-05-21 13:26:39 -0700 | [diff] [blame] | 32 | #include "i915_drv.h" |
David Howells | 760285e | 2012-10-02 18:01:07 +0100 | [diff] [blame] | 33 | #include <drm/i915_drm.h> |
Eric Anholt | 62fdfea | 2010-05-21 13:26:39 -0700 | [diff] [blame] | 34 | #include "i915_trace.h" |
Xiang, Haihao | 881f47b | 2010-09-19 14:40:43 +0100 | [diff] [blame] | 35 | #include "intel_drv.h" |
Eric Anholt | 62fdfea | 2010-05-21 13:26:39 -0700 | [diff] [blame] | 36 | |
Chris Wilson | a044246 | 2016-04-29 09:07:05 +0100 | [diff] [blame] | 37 | /* Rough estimate of the typical request size, performing a flush, |
| 38 | * set-context and then emitting the batch. |
| 39 | */ |
| 40 | #define LEGACY_REQUEST_SIZE 200 |
| 41 | |
Oscar Mateo | 82e104c | 2014-07-24 17:04:26 +0100 | [diff] [blame] | 42 | int __intel_ring_space(int head, int tail, int size) |
Chris Wilson | 1cf0ba1 | 2014-05-05 09:07:33 +0100 | [diff] [blame] | 43 | { |
Dave Gordon | 4f54741 | 2014-11-27 11:22:48 +0000 | [diff] [blame] | 44 | int space = head - tail; |
| 45 | if (space <= 0) |
Chris Wilson | 1cf0ba1 | 2014-05-05 09:07:33 +0100 | [diff] [blame] | 46 | space += size; |
Dave Gordon | 4f54741 | 2014-11-27 11:22:48 +0000 | [diff] [blame] | 47 | return space - I915_RING_FREE_SPACE; |
Chris Wilson | 1cf0ba1 | 2014-05-05 09:07:33 +0100 | [diff] [blame] | 48 | } |
| 49 | |
Dave Gordon | ebd0fd4 | 2014-11-27 11:22:49 +0000 | [diff] [blame] | 50 | void intel_ring_update_space(struct intel_ringbuffer *ringbuf) |
| 51 | { |
| 52 | if (ringbuf->last_retired_head != -1) { |
| 53 | ringbuf->head = ringbuf->last_retired_head; |
| 54 | ringbuf->last_retired_head = -1; |
| 55 | } |
| 56 | |
| 57 | ringbuf->space = __intel_ring_space(ringbuf->head & HEAD_ADDR, |
| 58 | ringbuf->tail, ringbuf->size); |
| 59 | } |
| 60 | |
Tvrtko Ursulin | 117897f | 2016-03-16 11:00:40 +0000 | [diff] [blame] | 61 | bool intel_engine_stopped(struct intel_engine_cs *engine) |
Chris Wilson | 0924673 | 2013-08-10 22:16:32 +0100 | [diff] [blame] | 62 | { |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 63 | struct drm_i915_private *dev_priv = engine->i915; |
Tvrtko Ursulin | 666796d | 2016-03-16 11:00:39 +0000 | [diff] [blame] | 64 | return dev_priv->gpu_error.stop_rings & intel_engine_flag(engine); |
Mika Kuoppala | 88b4aa8 | 2014-03-28 18:18:18 +0200 | [diff] [blame] | 65 | } |
Chris Wilson | 0924673 | 2013-08-10 22:16:32 +0100 | [diff] [blame] | 66 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 67 | static void __intel_ring_advance(struct intel_engine_cs *engine) |
Mika Kuoppala | 88b4aa8 | 2014-03-28 18:18:18 +0200 | [diff] [blame] | 68 | { |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 69 | struct intel_ringbuffer *ringbuf = engine->buffer; |
Oscar Mateo | 93b0a4e | 2014-05-22 14:13:36 +0100 | [diff] [blame] | 70 | ringbuf->tail &= ringbuf->size - 1; |
Tvrtko Ursulin | 117897f | 2016-03-16 11:00:40 +0000 | [diff] [blame] | 71 | if (intel_engine_stopped(engine)) |
Chris Wilson | 0924673 | 2013-08-10 22:16:32 +0100 | [diff] [blame] | 72 | return; |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 73 | engine->write_tail(engine, ringbuf->tail); |
Chris Wilson | 0924673 | 2013-08-10 22:16:32 +0100 | [diff] [blame] | 74 | } |
| 75 | |
Chris Wilson | b72f3ac | 2011-01-04 17:34:02 +0000 | [diff] [blame] | 76 | static int |
John Harrison | a84c3ae | 2015-05-29 17:43:57 +0100 | [diff] [blame] | 77 | gen2_render_ring_flush(struct drm_i915_gem_request *req, |
Chris Wilson | 46f0f8d | 2012-04-18 11:12:11 +0100 | [diff] [blame] | 78 | u32 invalidate_domains, |
| 79 | u32 flush_domains) |
| 80 | { |
Tvrtko Ursulin | 4a570db | 2016-03-16 11:00:38 +0000 | [diff] [blame] | 81 | struct intel_engine_cs *engine = req->engine; |
Chris Wilson | 46f0f8d | 2012-04-18 11:12:11 +0100 | [diff] [blame] | 82 | u32 cmd; |
| 83 | int ret; |
| 84 | |
| 85 | cmd = MI_FLUSH; |
Daniel Vetter | 31b14c9 | 2012-04-19 16:45:22 +0200 | [diff] [blame] | 86 | if (((invalidate_domains|flush_domains) & I915_GEM_DOMAIN_RENDER) == 0) |
Chris Wilson | 46f0f8d | 2012-04-18 11:12:11 +0100 | [diff] [blame] | 87 | cmd |= MI_NO_WRITE_FLUSH; |
| 88 | |
| 89 | if (invalidate_domains & I915_GEM_DOMAIN_SAMPLER) |
| 90 | cmd |= MI_READ_FLUSH; |
| 91 | |
John Harrison | 5fb9de1 | 2015-05-29 17:44:07 +0100 | [diff] [blame] | 92 | ret = intel_ring_begin(req, 2); |
Chris Wilson | 46f0f8d | 2012-04-18 11:12:11 +0100 | [diff] [blame] | 93 | if (ret) |
| 94 | return ret; |
| 95 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 96 | intel_ring_emit(engine, cmd); |
| 97 | intel_ring_emit(engine, MI_NOOP); |
| 98 | intel_ring_advance(engine); |
Chris Wilson | 46f0f8d | 2012-04-18 11:12:11 +0100 | [diff] [blame] | 99 | |
| 100 | return 0; |
| 101 | } |
| 102 | |
| 103 | static int |
John Harrison | a84c3ae | 2015-05-29 17:43:57 +0100 | [diff] [blame] | 104 | gen4_render_ring_flush(struct drm_i915_gem_request *req, |
Chris Wilson | 46f0f8d | 2012-04-18 11:12:11 +0100 | [diff] [blame] | 105 | u32 invalidate_domains, |
| 106 | u32 flush_domains) |
Eric Anholt | 62fdfea | 2010-05-21 13:26:39 -0700 | [diff] [blame] | 107 | { |
Tvrtko Ursulin | 4a570db | 2016-03-16 11:00:38 +0000 | [diff] [blame] | 108 | struct intel_engine_cs *engine = req->engine; |
Chris Wilson | 6f392d5 | 2010-08-07 11:01:22 +0100 | [diff] [blame] | 109 | u32 cmd; |
Chris Wilson | b72f3ac | 2011-01-04 17:34:02 +0000 | [diff] [blame] | 110 | int ret; |
Chris Wilson | 6f392d5 | 2010-08-07 11:01:22 +0100 | [diff] [blame] | 111 | |
Chris Wilson | 36d527d | 2011-03-19 22:26:49 +0000 | [diff] [blame] | 112 | /* |
| 113 | * read/write caches: |
| 114 | * |
| 115 | * I915_GEM_DOMAIN_RENDER is always invalidated, but is |
| 116 | * only flushed if MI_NO_WRITE_FLUSH is unset. On 965, it is |
| 117 | * also flushed at 2d versus 3d pipeline switches. |
| 118 | * |
| 119 | * read-only caches: |
| 120 | * |
| 121 | * I915_GEM_DOMAIN_SAMPLER is flushed on pre-965 if |
| 122 | * MI_READ_FLUSH is set, and is always flushed on 965. |
| 123 | * |
| 124 | * I915_GEM_DOMAIN_COMMAND may not exist? |
| 125 | * |
| 126 | * I915_GEM_DOMAIN_INSTRUCTION, which exists on 965, is |
| 127 | * invalidated when MI_EXE_FLUSH is set. |
| 128 | * |
| 129 | * I915_GEM_DOMAIN_VERTEX, which exists on 965, is |
| 130 | * invalidated with every MI_FLUSH. |
| 131 | * |
| 132 | * TLBs: |
| 133 | * |
| 134 | * On 965, TLBs associated with I915_GEM_DOMAIN_COMMAND |
| 135 | * and I915_GEM_DOMAIN_CPU in are invalidated at PTE write and |
| 136 | * I915_GEM_DOMAIN_RENDER and I915_GEM_DOMAIN_SAMPLER |
| 137 | * are flushed at any MI_FLUSH. |
| 138 | */ |
| 139 | |
| 140 | cmd = MI_FLUSH | MI_NO_WRITE_FLUSH; |
Chris Wilson | 46f0f8d | 2012-04-18 11:12:11 +0100 | [diff] [blame] | 141 | if ((invalidate_domains|flush_domains) & I915_GEM_DOMAIN_RENDER) |
Chris Wilson | 36d527d | 2011-03-19 22:26:49 +0000 | [diff] [blame] | 142 | cmd &= ~MI_NO_WRITE_FLUSH; |
Chris Wilson | 36d527d | 2011-03-19 22:26:49 +0000 | [diff] [blame] | 143 | if (invalidate_domains & I915_GEM_DOMAIN_INSTRUCTION) |
| 144 | cmd |= MI_EXE_FLUSH; |
| 145 | |
| 146 | if (invalidate_domains & I915_GEM_DOMAIN_COMMAND && |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 147 | (IS_G4X(req->i915) || IS_GEN5(req->i915))) |
Chris Wilson | 36d527d | 2011-03-19 22:26:49 +0000 | [diff] [blame] | 148 | cmd |= MI_INVALIDATE_ISP; |
| 149 | |
John Harrison | 5fb9de1 | 2015-05-29 17:44:07 +0100 | [diff] [blame] | 150 | ret = intel_ring_begin(req, 2); |
Chris Wilson | 36d527d | 2011-03-19 22:26:49 +0000 | [diff] [blame] | 151 | if (ret) |
| 152 | return ret; |
| 153 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 154 | intel_ring_emit(engine, cmd); |
| 155 | intel_ring_emit(engine, MI_NOOP); |
| 156 | intel_ring_advance(engine); |
Chris Wilson | b72f3ac | 2011-01-04 17:34:02 +0000 | [diff] [blame] | 157 | |
| 158 | return 0; |
Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 159 | } |
| 160 | |
Jesse Barnes | 8d31528 | 2011-10-16 10:23:31 +0200 | [diff] [blame] | 161 | /** |
| 162 | * Emits a PIPE_CONTROL with a non-zero post-sync operation, for |
| 163 | * implementing two workarounds on gen6. From section 1.4.7.1 |
| 164 | * "PIPE_CONTROL" of the Sandy Bridge PRM volume 2 part 1: |
| 165 | * |
| 166 | * [DevSNB-C+{W/A}] Before any depth stall flush (including those |
| 167 | * produced by non-pipelined state commands), software needs to first |
| 168 | * send a PIPE_CONTROL with no bits set except Post-Sync Operation != |
| 169 | * 0. |
| 170 | * |
| 171 | * [Dev-SNB{W/A}]: Before a PIPE_CONTROL with Write Cache Flush Enable |
| 172 | * =1, a PIPE_CONTROL with any non-zero post-sync-op is required. |
| 173 | * |
| 174 | * And the workaround for these two requires this workaround first: |
| 175 | * |
| 176 | * [Dev-SNB{W/A}]: Pipe-control with CS-stall bit set must be sent |
| 177 | * BEFORE the pipe-control with a post-sync op and no write-cache |
| 178 | * flushes. |
| 179 | * |
| 180 | * And this last workaround is tricky because of the requirements on |
| 181 | * that bit. From section 1.4.7.2.3 "Stall" of the Sandy Bridge PRM |
| 182 | * volume 2 part 1: |
| 183 | * |
| 184 | * "1 of the following must also be set: |
| 185 | * - Render Target Cache Flush Enable ([12] of DW1) |
| 186 | * - Depth Cache Flush Enable ([0] of DW1) |
| 187 | * - Stall at Pixel Scoreboard ([1] of DW1) |
| 188 | * - Depth Stall ([13] of DW1) |
| 189 | * - Post-Sync Operation ([13] of DW1) |
| 190 | * - Notify Enable ([8] of DW1)" |
| 191 | * |
| 192 | * The cache flushes require the workaround flush that triggered this |
| 193 | * one, so we can't use it. Depth stall would trigger the same. |
| 194 | * Post-sync nonzero is what triggered this second workaround, so we |
| 195 | * can't use that one either. Notify enable is IRQs, which aren't |
| 196 | * really our business. That leaves only stall at scoreboard. |
| 197 | */ |
| 198 | static int |
John Harrison | f2cf1fc | 2015-05-29 17:43:58 +0100 | [diff] [blame] | 199 | intel_emit_post_sync_nonzero_flush(struct drm_i915_gem_request *req) |
Jesse Barnes | 8d31528 | 2011-10-16 10:23:31 +0200 | [diff] [blame] | 200 | { |
Tvrtko Ursulin | 4a570db | 2016-03-16 11:00:38 +0000 | [diff] [blame] | 201 | struct intel_engine_cs *engine = req->engine; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 202 | u32 scratch_addr = engine->scratch.gtt_offset + 2 * CACHELINE_BYTES; |
Jesse Barnes | 8d31528 | 2011-10-16 10:23:31 +0200 | [diff] [blame] | 203 | int ret; |
| 204 | |
John Harrison | 5fb9de1 | 2015-05-29 17:44:07 +0100 | [diff] [blame] | 205 | ret = intel_ring_begin(req, 6); |
Jesse Barnes | 8d31528 | 2011-10-16 10:23:31 +0200 | [diff] [blame] | 206 | if (ret) |
| 207 | return ret; |
| 208 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 209 | intel_ring_emit(engine, GFX_OP_PIPE_CONTROL(5)); |
| 210 | intel_ring_emit(engine, PIPE_CONTROL_CS_STALL | |
Jesse Barnes | 8d31528 | 2011-10-16 10:23:31 +0200 | [diff] [blame] | 211 | PIPE_CONTROL_STALL_AT_SCOREBOARD); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 212 | intel_ring_emit(engine, scratch_addr | PIPE_CONTROL_GLOBAL_GTT); /* address */ |
| 213 | intel_ring_emit(engine, 0); /* low dword */ |
| 214 | intel_ring_emit(engine, 0); /* high dword */ |
| 215 | intel_ring_emit(engine, MI_NOOP); |
| 216 | intel_ring_advance(engine); |
Jesse Barnes | 8d31528 | 2011-10-16 10:23:31 +0200 | [diff] [blame] | 217 | |
John Harrison | 5fb9de1 | 2015-05-29 17:44:07 +0100 | [diff] [blame] | 218 | ret = intel_ring_begin(req, 6); |
Jesse Barnes | 8d31528 | 2011-10-16 10:23:31 +0200 | [diff] [blame] | 219 | if (ret) |
| 220 | return ret; |
| 221 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 222 | intel_ring_emit(engine, GFX_OP_PIPE_CONTROL(5)); |
| 223 | intel_ring_emit(engine, PIPE_CONTROL_QW_WRITE); |
| 224 | intel_ring_emit(engine, scratch_addr | PIPE_CONTROL_GLOBAL_GTT); /* address */ |
| 225 | intel_ring_emit(engine, 0); |
| 226 | intel_ring_emit(engine, 0); |
| 227 | intel_ring_emit(engine, MI_NOOP); |
| 228 | intel_ring_advance(engine); |
Jesse Barnes | 8d31528 | 2011-10-16 10:23:31 +0200 | [diff] [blame] | 229 | |
| 230 | return 0; |
| 231 | } |
| 232 | |
| 233 | static int |
John Harrison | a84c3ae | 2015-05-29 17:43:57 +0100 | [diff] [blame] | 234 | gen6_render_ring_flush(struct drm_i915_gem_request *req, |
| 235 | u32 invalidate_domains, u32 flush_domains) |
Jesse Barnes | 8d31528 | 2011-10-16 10:23:31 +0200 | [diff] [blame] | 236 | { |
Tvrtko Ursulin | 4a570db | 2016-03-16 11:00:38 +0000 | [diff] [blame] | 237 | struct intel_engine_cs *engine = req->engine; |
Jesse Barnes | 8d31528 | 2011-10-16 10:23:31 +0200 | [diff] [blame] | 238 | u32 flags = 0; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 239 | u32 scratch_addr = engine->scratch.gtt_offset + 2 * CACHELINE_BYTES; |
Jesse Barnes | 8d31528 | 2011-10-16 10:23:31 +0200 | [diff] [blame] | 240 | int ret; |
| 241 | |
Paulo Zanoni | b311150 | 2012-08-17 18:35:42 -0300 | [diff] [blame] | 242 | /* Force SNB workarounds for PIPE_CONTROL flushes */ |
John Harrison | f2cf1fc | 2015-05-29 17:43:58 +0100 | [diff] [blame] | 243 | ret = intel_emit_post_sync_nonzero_flush(req); |
Paulo Zanoni | b311150 | 2012-08-17 18:35:42 -0300 | [diff] [blame] | 244 | if (ret) |
| 245 | return ret; |
| 246 | |
Jesse Barnes | 8d31528 | 2011-10-16 10:23:31 +0200 | [diff] [blame] | 247 | /* Just flush everything. Experiments have shown that reducing the |
| 248 | * number of bits based on the write domains has little performance |
| 249 | * impact. |
| 250 | */ |
Chris Wilson | 7d54a90 | 2012-08-10 10:18:10 +0100 | [diff] [blame] | 251 | if (flush_domains) { |
| 252 | flags |= PIPE_CONTROL_RENDER_TARGET_CACHE_FLUSH; |
| 253 | flags |= PIPE_CONTROL_DEPTH_CACHE_FLUSH; |
| 254 | /* |
| 255 | * Ensure that any following seqno writes only happen |
| 256 | * when the render cache is indeed flushed. |
| 257 | */ |
Daniel Vetter | 97f209b | 2012-06-28 09:48:42 +0200 | [diff] [blame] | 258 | flags |= PIPE_CONTROL_CS_STALL; |
Chris Wilson | 7d54a90 | 2012-08-10 10:18:10 +0100 | [diff] [blame] | 259 | } |
| 260 | if (invalidate_domains) { |
| 261 | flags |= PIPE_CONTROL_TLB_INVALIDATE; |
| 262 | flags |= PIPE_CONTROL_INSTRUCTION_CACHE_INVALIDATE; |
| 263 | flags |= PIPE_CONTROL_TEXTURE_CACHE_INVALIDATE; |
| 264 | flags |= PIPE_CONTROL_VF_CACHE_INVALIDATE; |
| 265 | flags |= PIPE_CONTROL_CONST_CACHE_INVALIDATE; |
| 266 | flags |= PIPE_CONTROL_STATE_CACHE_INVALIDATE; |
| 267 | /* |
| 268 | * TLB invalidate requires a post-sync write. |
| 269 | */ |
Jesse Barnes | 3ac7831 | 2012-10-25 12:15:47 -0700 | [diff] [blame] | 270 | flags |= PIPE_CONTROL_QW_WRITE | PIPE_CONTROL_CS_STALL; |
Chris Wilson | 7d54a90 | 2012-08-10 10:18:10 +0100 | [diff] [blame] | 271 | } |
Jesse Barnes | 8d31528 | 2011-10-16 10:23:31 +0200 | [diff] [blame] | 272 | |
John Harrison | 5fb9de1 | 2015-05-29 17:44:07 +0100 | [diff] [blame] | 273 | ret = intel_ring_begin(req, 4); |
Jesse Barnes | 8d31528 | 2011-10-16 10:23:31 +0200 | [diff] [blame] | 274 | if (ret) |
| 275 | return ret; |
| 276 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 277 | intel_ring_emit(engine, GFX_OP_PIPE_CONTROL(4)); |
| 278 | intel_ring_emit(engine, flags); |
| 279 | intel_ring_emit(engine, scratch_addr | PIPE_CONTROL_GLOBAL_GTT); |
| 280 | intel_ring_emit(engine, 0); |
| 281 | intel_ring_advance(engine); |
Jesse Barnes | 8d31528 | 2011-10-16 10:23:31 +0200 | [diff] [blame] | 282 | |
| 283 | return 0; |
| 284 | } |
| 285 | |
Chris Wilson | 6c6cf5a | 2012-07-20 18:02:28 +0100 | [diff] [blame] | 286 | static int |
John Harrison | f2cf1fc | 2015-05-29 17:43:58 +0100 | [diff] [blame] | 287 | gen7_render_ring_cs_stall_wa(struct drm_i915_gem_request *req) |
Paulo Zanoni | f398763 | 2012-08-17 18:35:43 -0300 | [diff] [blame] | 288 | { |
Tvrtko Ursulin | 4a570db | 2016-03-16 11:00:38 +0000 | [diff] [blame] | 289 | struct intel_engine_cs *engine = req->engine; |
Paulo Zanoni | f398763 | 2012-08-17 18:35:43 -0300 | [diff] [blame] | 290 | int ret; |
| 291 | |
John Harrison | 5fb9de1 | 2015-05-29 17:44:07 +0100 | [diff] [blame] | 292 | ret = intel_ring_begin(req, 4); |
Paulo Zanoni | f398763 | 2012-08-17 18:35:43 -0300 | [diff] [blame] | 293 | if (ret) |
| 294 | return ret; |
| 295 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 296 | intel_ring_emit(engine, GFX_OP_PIPE_CONTROL(4)); |
| 297 | intel_ring_emit(engine, PIPE_CONTROL_CS_STALL | |
Paulo Zanoni | f398763 | 2012-08-17 18:35:43 -0300 | [diff] [blame] | 298 | PIPE_CONTROL_STALL_AT_SCOREBOARD); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 299 | intel_ring_emit(engine, 0); |
| 300 | intel_ring_emit(engine, 0); |
| 301 | intel_ring_advance(engine); |
Paulo Zanoni | f398763 | 2012-08-17 18:35:43 -0300 | [diff] [blame] | 302 | |
| 303 | return 0; |
| 304 | } |
| 305 | |
| 306 | static int |
John Harrison | a84c3ae | 2015-05-29 17:43:57 +0100 | [diff] [blame] | 307 | gen7_render_ring_flush(struct drm_i915_gem_request *req, |
Paulo Zanoni | 4772eae | 2012-08-17 18:35:41 -0300 | [diff] [blame] | 308 | u32 invalidate_domains, u32 flush_domains) |
| 309 | { |
Tvrtko Ursulin | 4a570db | 2016-03-16 11:00:38 +0000 | [diff] [blame] | 310 | struct intel_engine_cs *engine = req->engine; |
Paulo Zanoni | 4772eae | 2012-08-17 18:35:41 -0300 | [diff] [blame] | 311 | u32 flags = 0; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 312 | u32 scratch_addr = engine->scratch.gtt_offset + 2 * CACHELINE_BYTES; |
Paulo Zanoni | 4772eae | 2012-08-17 18:35:41 -0300 | [diff] [blame] | 313 | int ret; |
| 314 | |
Paulo Zanoni | f398763 | 2012-08-17 18:35:43 -0300 | [diff] [blame] | 315 | /* |
| 316 | * Ensure that any following seqno writes only happen when the render |
| 317 | * cache is indeed flushed. |
| 318 | * |
| 319 | * Workaround: 4th PIPE_CONTROL command (except the ones with only |
| 320 | * read-cache invalidate bits set) must have the CS_STALL bit set. We |
| 321 | * don't try to be clever and just set it unconditionally. |
| 322 | */ |
| 323 | flags |= PIPE_CONTROL_CS_STALL; |
| 324 | |
Paulo Zanoni | 4772eae | 2012-08-17 18:35:41 -0300 | [diff] [blame] | 325 | /* Just flush everything. Experiments have shown that reducing the |
| 326 | * number of bits based on the write domains has little performance |
| 327 | * impact. |
| 328 | */ |
| 329 | if (flush_domains) { |
| 330 | flags |= PIPE_CONTROL_RENDER_TARGET_CACHE_FLUSH; |
| 331 | flags |= PIPE_CONTROL_DEPTH_CACHE_FLUSH; |
Francisco Jerez | 965fd60 | 2016-01-13 18:59:39 -0800 | [diff] [blame] | 332 | flags |= PIPE_CONTROL_DC_FLUSH_ENABLE; |
Chris Wilson | 40a2448 | 2015-08-21 16:08:41 +0100 | [diff] [blame] | 333 | flags |= PIPE_CONTROL_FLUSH_ENABLE; |
Paulo Zanoni | 4772eae | 2012-08-17 18:35:41 -0300 | [diff] [blame] | 334 | } |
| 335 | if (invalidate_domains) { |
| 336 | flags |= PIPE_CONTROL_TLB_INVALIDATE; |
| 337 | flags |= PIPE_CONTROL_INSTRUCTION_CACHE_INVALIDATE; |
| 338 | flags |= PIPE_CONTROL_TEXTURE_CACHE_INVALIDATE; |
| 339 | flags |= PIPE_CONTROL_VF_CACHE_INVALIDATE; |
| 340 | flags |= PIPE_CONTROL_CONST_CACHE_INVALIDATE; |
| 341 | flags |= PIPE_CONTROL_STATE_CACHE_INVALIDATE; |
Chris Wilson | 148b83d | 2014-12-16 08:44:31 +0000 | [diff] [blame] | 342 | flags |= PIPE_CONTROL_MEDIA_STATE_CLEAR; |
Paulo Zanoni | 4772eae | 2012-08-17 18:35:41 -0300 | [diff] [blame] | 343 | /* |
| 344 | * TLB invalidate requires a post-sync write. |
| 345 | */ |
| 346 | flags |= PIPE_CONTROL_QW_WRITE; |
Ville Syrjälä | b9e1faa | 2013-02-14 21:53:51 +0200 | [diff] [blame] | 347 | flags |= PIPE_CONTROL_GLOBAL_GTT_IVB; |
Paulo Zanoni | f398763 | 2012-08-17 18:35:43 -0300 | [diff] [blame] | 348 | |
Chris Wilson | add284a | 2014-12-16 08:44:32 +0000 | [diff] [blame] | 349 | flags |= PIPE_CONTROL_STALL_AT_SCOREBOARD; |
| 350 | |
Paulo Zanoni | f398763 | 2012-08-17 18:35:43 -0300 | [diff] [blame] | 351 | /* Workaround: we must issue a pipe_control with CS-stall bit |
| 352 | * set before a pipe_control command that has the state cache |
| 353 | * invalidate bit set. */ |
John Harrison | f2cf1fc | 2015-05-29 17:43:58 +0100 | [diff] [blame] | 354 | gen7_render_ring_cs_stall_wa(req); |
Paulo Zanoni | 4772eae | 2012-08-17 18:35:41 -0300 | [diff] [blame] | 355 | } |
| 356 | |
John Harrison | 5fb9de1 | 2015-05-29 17:44:07 +0100 | [diff] [blame] | 357 | ret = intel_ring_begin(req, 4); |
Paulo Zanoni | 4772eae | 2012-08-17 18:35:41 -0300 | [diff] [blame] | 358 | if (ret) |
| 359 | return ret; |
| 360 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 361 | intel_ring_emit(engine, GFX_OP_PIPE_CONTROL(4)); |
| 362 | intel_ring_emit(engine, flags); |
| 363 | intel_ring_emit(engine, scratch_addr); |
| 364 | intel_ring_emit(engine, 0); |
| 365 | intel_ring_advance(engine); |
Paulo Zanoni | 4772eae | 2012-08-17 18:35:41 -0300 | [diff] [blame] | 366 | |
| 367 | return 0; |
| 368 | } |
| 369 | |
Ben Widawsky | a5f3d68 | 2013-11-02 21:07:27 -0700 | [diff] [blame] | 370 | static int |
John Harrison | f2cf1fc | 2015-05-29 17:43:58 +0100 | [diff] [blame] | 371 | gen8_emit_pipe_control(struct drm_i915_gem_request *req, |
Kenneth Graunke | 884ceac | 2014-06-28 02:04:20 +0300 | [diff] [blame] | 372 | u32 flags, u32 scratch_addr) |
| 373 | { |
Tvrtko Ursulin | 4a570db | 2016-03-16 11:00:38 +0000 | [diff] [blame] | 374 | struct intel_engine_cs *engine = req->engine; |
Kenneth Graunke | 884ceac | 2014-06-28 02:04:20 +0300 | [diff] [blame] | 375 | int ret; |
| 376 | |
John Harrison | 5fb9de1 | 2015-05-29 17:44:07 +0100 | [diff] [blame] | 377 | ret = intel_ring_begin(req, 6); |
Kenneth Graunke | 884ceac | 2014-06-28 02:04:20 +0300 | [diff] [blame] | 378 | if (ret) |
| 379 | return ret; |
| 380 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 381 | intel_ring_emit(engine, GFX_OP_PIPE_CONTROL(6)); |
| 382 | intel_ring_emit(engine, flags); |
| 383 | intel_ring_emit(engine, scratch_addr); |
| 384 | intel_ring_emit(engine, 0); |
| 385 | intel_ring_emit(engine, 0); |
| 386 | intel_ring_emit(engine, 0); |
| 387 | intel_ring_advance(engine); |
Kenneth Graunke | 884ceac | 2014-06-28 02:04:20 +0300 | [diff] [blame] | 388 | |
| 389 | return 0; |
| 390 | } |
| 391 | |
| 392 | static int |
John Harrison | a84c3ae | 2015-05-29 17:43:57 +0100 | [diff] [blame] | 393 | gen8_render_ring_flush(struct drm_i915_gem_request *req, |
Ben Widawsky | a5f3d68 | 2013-11-02 21:07:27 -0700 | [diff] [blame] | 394 | u32 invalidate_domains, u32 flush_domains) |
| 395 | { |
| 396 | u32 flags = 0; |
Tvrtko Ursulin | 4a570db | 2016-03-16 11:00:38 +0000 | [diff] [blame] | 397 | u32 scratch_addr = req->engine->scratch.gtt_offset + 2 * CACHELINE_BYTES; |
Kenneth Graunke | 02c9f7e | 2014-01-27 14:20:16 -0800 | [diff] [blame] | 398 | int ret; |
Ben Widawsky | a5f3d68 | 2013-11-02 21:07:27 -0700 | [diff] [blame] | 399 | |
| 400 | flags |= PIPE_CONTROL_CS_STALL; |
| 401 | |
| 402 | if (flush_domains) { |
| 403 | flags |= PIPE_CONTROL_RENDER_TARGET_CACHE_FLUSH; |
| 404 | flags |= PIPE_CONTROL_DEPTH_CACHE_FLUSH; |
Francisco Jerez | 965fd60 | 2016-01-13 18:59:39 -0800 | [diff] [blame] | 405 | flags |= PIPE_CONTROL_DC_FLUSH_ENABLE; |
Chris Wilson | 40a2448 | 2015-08-21 16:08:41 +0100 | [diff] [blame] | 406 | flags |= PIPE_CONTROL_FLUSH_ENABLE; |
Ben Widawsky | a5f3d68 | 2013-11-02 21:07:27 -0700 | [diff] [blame] | 407 | } |
| 408 | if (invalidate_domains) { |
| 409 | flags |= PIPE_CONTROL_TLB_INVALIDATE; |
| 410 | flags |= PIPE_CONTROL_INSTRUCTION_CACHE_INVALIDATE; |
| 411 | flags |= PIPE_CONTROL_TEXTURE_CACHE_INVALIDATE; |
| 412 | flags |= PIPE_CONTROL_VF_CACHE_INVALIDATE; |
| 413 | flags |= PIPE_CONTROL_CONST_CACHE_INVALIDATE; |
| 414 | flags |= PIPE_CONTROL_STATE_CACHE_INVALIDATE; |
| 415 | flags |= PIPE_CONTROL_QW_WRITE; |
| 416 | flags |= PIPE_CONTROL_GLOBAL_GTT_IVB; |
Kenneth Graunke | 02c9f7e | 2014-01-27 14:20:16 -0800 | [diff] [blame] | 417 | |
| 418 | /* WaCsStallBeforeStateCacheInvalidate:bdw,chv */ |
John Harrison | f2cf1fc | 2015-05-29 17:43:58 +0100 | [diff] [blame] | 419 | ret = gen8_emit_pipe_control(req, |
Kenneth Graunke | 02c9f7e | 2014-01-27 14:20:16 -0800 | [diff] [blame] | 420 | PIPE_CONTROL_CS_STALL | |
| 421 | PIPE_CONTROL_STALL_AT_SCOREBOARD, |
| 422 | 0); |
| 423 | if (ret) |
| 424 | return ret; |
Ben Widawsky | a5f3d68 | 2013-11-02 21:07:27 -0700 | [diff] [blame] | 425 | } |
| 426 | |
John Harrison | f2cf1fc | 2015-05-29 17:43:58 +0100 | [diff] [blame] | 427 | return gen8_emit_pipe_control(req, flags, scratch_addr); |
Ben Widawsky | a5f3d68 | 2013-11-02 21:07:27 -0700 | [diff] [blame] | 428 | } |
| 429 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 430 | static void ring_write_tail(struct intel_engine_cs *engine, |
Chris Wilson | 297b0c5 | 2010-10-22 17:02:41 +0100 | [diff] [blame] | 431 | u32 value) |
Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 432 | { |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 433 | struct drm_i915_private *dev_priv = engine->i915; |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 434 | I915_WRITE_TAIL(engine, value); |
Xiang, Haihao | d46eefa | 2010-09-16 10:43:12 +0800 | [diff] [blame] | 435 | } |
| 436 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 437 | u64 intel_ring_get_active_head(struct intel_engine_cs *engine) |
Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 438 | { |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 439 | struct drm_i915_private *dev_priv = engine->i915; |
Chris Wilson | 5087744 | 2014-03-21 12:41:53 +0000 | [diff] [blame] | 440 | u64 acthd; |
Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 441 | |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 442 | if (INTEL_GEN(dev_priv) >= 8) |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 443 | acthd = I915_READ64_2x32(RING_ACTHD(engine->mmio_base), |
| 444 | RING_ACTHD_UDW(engine->mmio_base)); |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 445 | else if (INTEL_GEN(dev_priv) >= 4) |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 446 | acthd = I915_READ(RING_ACTHD(engine->mmio_base)); |
Chris Wilson | 5087744 | 2014-03-21 12:41:53 +0000 | [diff] [blame] | 447 | else |
| 448 | acthd = I915_READ(ACTHD); |
| 449 | |
| 450 | return acthd; |
Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 451 | } |
| 452 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 453 | static void ring_setup_phys_status_page(struct intel_engine_cs *engine) |
Daniel Vetter | 035dc1e | 2013-07-03 12:56:54 +0200 | [diff] [blame] | 454 | { |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 455 | struct drm_i915_private *dev_priv = engine->i915; |
Daniel Vetter | 035dc1e | 2013-07-03 12:56:54 +0200 | [diff] [blame] | 456 | u32 addr; |
| 457 | |
| 458 | addr = dev_priv->status_page_dmah->busaddr; |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 459 | if (INTEL_GEN(dev_priv) >= 4) |
Daniel Vetter | 035dc1e | 2013-07-03 12:56:54 +0200 | [diff] [blame] | 460 | addr |= (dev_priv->status_page_dmah->busaddr >> 28) & 0xf0; |
| 461 | I915_WRITE(HWS_PGA, addr); |
| 462 | } |
| 463 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 464 | static void intel_ring_setup_status_page(struct intel_engine_cs *engine) |
Damien Lespiau | af75f26 | 2015-02-10 19:32:17 +0000 | [diff] [blame] | 465 | { |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 466 | struct drm_i915_private *dev_priv = engine->i915; |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 467 | i915_reg_t mmio; |
Damien Lespiau | af75f26 | 2015-02-10 19:32:17 +0000 | [diff] [blame] | 468 | |
| 469 | /* The ring status page addresses are no longer next to the rest of |
| 470 | * the ring registers as of gen7. |
| 471 | */ |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 472 | if (IS_GEN7(dev_priv)) { |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 473 | switch (engine->id) { |
Damien Lespiau | af75f26 | 2015-02-10 19:32:17 +0000 | [diff] [blame] | 474 | case RCS: |
| 475 | mmio = RENDER_HWS_PGA_GEN7; |
| 476 | break; |
| 477 | case BCS: |
| 478 | mmio = BLT_HWS_PGA_GEN7; |
| 479 | break; |
| 480 | /* |
| 481 | * VCS2 actually doesn't exist on Gen7. Only shut up |
| 482 | * gcc switch check warning |
| 483 | */ |
| 484 | case VCS2: |
| 485 | case VCS: |
| 486 | mmio = BSD_HWS_PGA_GEN7; |
| 487 | break; |
| 488 | case VECS: |
| 489 | mmio = VEBOX_HWS_PGA_GEN7; |
| 490 | break; |
| 491 | } |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 492 | } else if (IS_GEN6(dev_priv)) { |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 493 | mmio = RING_HWS_PGA_GEN6(engine->mmio_base); |
Damien Lespiau | af75f26 | 2015-02-10 19:32:17 +0000 | [diff] [blame] | 494 | } else { |
| 495 | /* XXX: gen8 returns to sanity */ |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 496 | mmio = RING_HWS_PGA(engine->mmio_base); |
Damien Lespiau | af75f26 | 2015-02-10 19:32:17 +0000 | [diff] [blame] | 497 | } |
| 498 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 499 | I915_WRITE(mmio, (u32)engine->status_page.gfx_addr); |
Damien Lespiau | af75f26 | 2015-02-10 19:32:17 +0000 | [diff] [blame] | 500 | POSTING_READ(mmio); |
| 501 | |
| 502 | /* |
| 503 | * Flush the TLB for this page |
| 504 | * |
| 505 | * FIXME: These two bits have disappeared on gen8, so a question |
| 506 | * arises: do we still need this and if so how should we go about |
| 507 | * invalidating the TLB? |
| 508 | */ |
Tvrtko Ursulin | ac657f6 | 2016-05-10 10:57:08 +0100 | [diff] [blame] | 509 | if (IS_GEN(dev_priv, 6, 7)) { |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 510 | i915_reg_t reg = RING_INSTPM(engine->mmio_base); |
Damien Lespiau | af75f26 | 2015-02-10 19:32:17 +0000 | [diff] [blame] | 511 | |
| 512 | /* ring should be idle before issuing a sync flush*/ |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 513 | WARN_ON((I915_READ_MODE(engine) & MODE_IDLE) == 0); |
Damien Lespiau | af75f26 | 2015-02-10 19:32:17 +0000 | [diff] [blame] | 514 | |
| 515 | I915_WRITE(reg, |
| 516 | _MASKED_BIT_ENABLE(INSTPM_TLB_INVALIDATE | |
| 517 | INSTPM_SYNC_FLUSH)); |
| 518 | if (wait_for((I915_READ(reg) & INSTPM_SYNC_FLUSH) == 0, |
| 519 | 1000)) |
| 520 | DRM_ERROR("%s: wait for SyncFlush to complete for TLB invalidation timed out\n", |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 521 | engine->name); |
Damien Lespiau | af75f26 | 2015-02-10 19:32:17 +0000 | [diff] [blame] | 522 | } |
| 523 | } |
| 524 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 525 | static bool stop_ring(struct intel_engine_cs *engine) |
Chris Wilson | 9991ae7 | 2014-04-02 16:36:07 +0100 | [diff] [blame] | 526 | { |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 527 | struct drm_i915_private *dev_priv = engine->i915; |
Chris Wilson | 9991ae7 | 2014-04-02 16:36:07 +0100 | [diff] [blame] | 528 | |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 529 | if (!IS_GEN2(dev_priv)) { |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 530 | I915_WRITE_MODE(engine, _MASKED_BIT_ENABLE(STOP_RING)); |
| 531 | if (wait_for((I915_READ_MODE(engine) & MODE_IDLE) != 0, 1000)) { |
| 532 | DRM_ERROR("%s : timed out trying to stop ring\n", |
| 533 | engine->name); |
Chris Wilson | 9bec9b1 | 2014-08-11 09:21:35 +0100 | [diff] [blame] | 534 | /* Sometimes we observe that the idle flag is not |
| 535 | * set even though the ring is empty. So double |
| 536 | * check before giving up. |
| 537 | */ |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 538 | if (I915_READ_HEAD(engine) != I915_READ_TAIL(engine)) |
Chris Wilson | 9bec9b1 | 2014-08-11 09:21:35 +0100 | [diff] [blame] | 539 | return false; |
Chris Wilson | 9991ae7 | 2014-04-02 16:36:07 +0100 | [diff] [blame] | 540 | } |
| 541 | } |
| 542 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 543 | I915_WRITE_CTL(engine, 0); |
| 544 | I915_WRITE_HEAD(engine, 0); |
| 545 | engine->write_tail(engine, 0); |
Chris Wilson | 9991ae7 | 2014-04-02 16:36:07 +0100 | [diff] [blame] | 546 | |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 547 | if (!IS_GEN2(dev_priv)) { |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 548 | (void)I915_READ_CTL(engine); |
| 549 | I915_WRITE_MODE(engine, _MASKED_BIT_DISABLE(STOP_RING)); |
Chris Wilson | 9991ae7 | 2014-04-02 16:36:07 +0100 | [diff] [blame] | 550 | } |
| 551 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 552 | return (I915_READ_HEAD(engine) & HEAD_ADDR) == 0; |
Chris Wilson | 9991ae7 | 2014-04-02 16:36:07 +0100 | [diff] [blame] | 553 | } |
| 554 | |
Tomas Elf | fc0768c | 2016-03-21 16:26:59 +0000 | [diff] [blame] | 555 | void intel_engine_init_hangcheck(struct intel_engine_cs *engine) |
| 556 | { |
| 557 | memset(&engine->hangcheck, 0, sizeof(engine->hangcheck)); |
| 558 | } |
| 559 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 560 | static int init_ring_common(struct intel_engine_cs *engine) |
Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 561 | { |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 562 | struct drm_i915_private *dev_priv = engine->i915; |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 563 | struct intel_ringbuffer *ringbuf = engine->buffer; |
Oscar Mateo | 93b0a4e | 2014-05-22 14:13:36 +0100 | [diff] [blame] | 564 | struct drm_i915_gem_object *obj = ringbuf->obj; |
Daniel Vetter | b7884eb | 2012-06-04 11:18:15 +0200 | [diff] [blame] | 565 | int ret = 0; |
Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 566 | |
Mika Kuoppala | 59bad94 | 2015-01-16 11:34:40 +0200 | [diff] [blame] | 567 | intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL); |
Daniel Vetter | b7884eb | 2012-06-04 11:18:15 +0200 | [diff] [blame] | 568 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 569 | if (!stop_ring(engine)) { |
Chris Wilson | 9991ae7 | 2014-04-02 16:36:07 +0100 | [diff] [blame] | 570 | /* G45 ring initialization often fails to reset head to zero */ |
Chris Wilson | 6fd0d56 | 2010-12-05 20:42:33 +0000 | [diff] [blame] | 571 | DRM_DEBUG_KMS("%s head not reset to zero " |
| 572 | "ctl %08x head %08x tail %08x start %08x\n", |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 573 | engine->name, |
| 574 | I915_READ_CTL(engine), |
| 575 | I915_READ_HEAD(engine), |
| 576 | I915_READ_TAIL(engine), |
| 577 | I915_READ_START(engine)); |
Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 578 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 579 | if (!stop_ring(engine)) { |
Chris Wilson | 6fd0d56 | 2010-12-05 20:42:33 +0000 | [diff] [blame] | 580 | DRM_ERROR("failed to set %s head to zero " |
| 581 | "ctl %08x head %08x tail %08x start %08x\n", |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 582 | engine->name, |
| 583 | I915_READ_CTL(engine), |
| 584 | I915_READ_HEAD(engine), |
| 585 | I915_READ_TAIL(engine), |
| 586 | I915_READ_START(engine)); |
Chris Wilson | 9991ae7 | 2014-04-02 16:36:07 +0100 | [diff] [blame] | 587 | ret = -EIO; |
| 588 | goto out; |
Chris Wilson | 6fd0d56 | 2010-12-05 20:42:33 +0000 | [diff] [blame] | 589 | } |
Eric Anholt | 62fdfea | 2010-05-21 13:26:39 -0700 | [diff] [blame] | 590 | } |
| 591 | |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 592 | if (I915_NEED_GFX_HWS(dev_priv)) |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 593 | intel_ring_setup_status_page(engine); |
Chris Wilson | 9991ae7 | 2014-04-02 16:36:07 +0100 | [diff] [blame] | 594 | else |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 595 | ring_setup_phys_status_page(engine); |
Chris Wilson | 9991ae7 | 2014-04-02 16:36:07 +0100 | [diff] [blame] | 596 | |
Jiri Kosina | ece4a17 | 2014-08-07 16:29:53 +0200 | [diff] [blame] | 597 | /* Enforce ordering by reading HEAD register back */ |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 598 | I915_READ_HEAD(engine); |
Jiri Kosina | ece4a17 | 2014-08-07 16:29:53 +0200 | [diff] [blame] | 599 | |
Daniel Vetter | 0d8957c | 2012-08-07 09:54:14 +0200 | [diff] [blame] | 600 | /* Initialize the ring. This must happen _after_ we've cleared the ring |
| 601 | * registers with the above sequence (the readback of the HEAD registers |
| 602 | * also enforces ordering), otherwise the hw might lose the new ring |
| 603 | * register values. */ |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 604 | I915_WRITE_START(engine, i915_gem_obj_ggtt_offset(obj)); |
Chris Wilson | 9546889 | 2014-08-07 15:39:54 +0100 | [diff] [blame] | 605 | |
| 606 | /* WaClearRingBufHeadRegAtInit:ctg,elk */ |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 607 | if (I915_READ_HEAD(engine)) |
Chris Wilson | 9546889 | 2014-08-07 15:39:54 +0100 | [diff] [blame] | 608 | DRM_DEBUG("%s initialization failed [head=%08x], fudging\n", |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 609 | engine->name, I915_READ_HEAD(engine)); |
| 610 | I915_WRITE_HEAD(engine, 0); |
| 611 | (void)I915_READ_HEAD(engine); |
Chris Wilson | 9546889 | 2014-08-07 15:39:54 +0100 | [diff] [blame] | 612 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 613 | I915_WRITE_CTL(engine, |
Oscar Mateo | 93b0a4e | 2014-05-22 14:13:36 +0100 | [diff] [blame] | 614 | ((ringbuf->size - PAGE_SIZE) & RING_NR_PAGES) |
Chris Wilson | 5d031e5 | 2012-02-08 13:34:13 +0000 | [diff] [blame] | 615 | | RING_VALID); |
Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 616 | |
Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 617 | /* If the head is still not zero, the ring is dead */ |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 618 | if (wait_for((I915_READ_CTL(engine) & RING_VALID) != 0 && |
| 619 | I915_READ_START(engine) == i915_gem_obj_ggtt_offset(obj) && |
| 620 | (I915_READ_HEAD(engine) & HEAD_ADDR) == 0, 50)) { |
Chris Wilson | e74cfed | 2010-11-09 10:16:56 +0000 | [diff] [blame] | 621 | DRM_ERROR("%s initialization failed " |
Chris Wilson | 48e48a0 | 2014-04-09 09:19:44 +0100 | [diff] [blame] | 622 | "ctl %08x (valid? %d) head %08x tail %08x start %08x [expected %08lx]\n", |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 623 | engine->name, |
| 624 | I915_READ_CTL(engine), |
| 625 | I915_READ_CTL(engine) & RING_VALID, |
| 626 | I915_READ_HEAD(engine), I915_READ_TAIL(engine), |
| 627 | I915_READ_START(engine), |
| 628 | (unsigned long)i915_gem_obj_ggtt_offset(obj)); |
Daniel Vetter | b7884eb | 2012-06-04 11:18:15 +0200 | [diff] [blame] | 629 | ret = -EIO; |
| 630 | goto out; |
Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 631 | } |
| 632 | |
Dave Gordon | ebd0fd4 | 2014-11-27 11:22:49 +0000 | [diff] [blame] | 633 | ringbuf->last_retired_head = -1; |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 634 | ringbuf->head = I915_READ_HEAD(engine); |
| 635 | ringbuf->tail = I915_READ_TAIL(engine) & TAIL_ADDR; |
Dave Gordon | ebd0fd4 | 2014-11-27 11:22:49 +0000 | [diff] [blame] | 636 | intel_ring_update_space(ringbuf); |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 637 | |
Tomas Elf | fc0768c | 2016-03-21 16:26:59 +0000 | [diff] [blame] | 638 | intel_engine_init_hangcheck(engine); |
Chris Wilson | 50f018d | 2013-06-10 11:20:19 +0100 | [diff] [blame] | 639 | |
Daniel Vetter | b7884eb | 2012-06-04 11:18:15 +0200 | [diff] [blame] | 640 | out: |
Mika Kuoppala | 59bad94 | 2015-01-16 11:34:40 +0200 | [diff] [blame] | 641 | intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL); |
Daniel Vetter | b7884eb | 2012-06-04 11:18:15 +0200 | [diff] [blame] | 642 | |
| 643 | return ret; |
Eric Anholt | 62fdfea | 2010-05-21 13:26:39 -0700 | [diff] [blame] | 644 | } |
Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 645 | |
Oscar Mateo | 9b1136d | 2014-07-24 17:04:24 +0100 | [diff] [blame] | 646 | void |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 647 | intel_fini_pipe_control(struct intel_engine_cs *engine) |
Oscar Mateo | 9b1136d | 2014-07-24 17:04:24 +0100 | [diff] [blame] | 648 | { |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 649 | if (engine->scratch.obj == NULL) |
Oscar Mateo | 9b1136d | 2014-07-24 17:04:24 +0100 | [diff] [blame] | 650 | return; |
| 651 | |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 652 | if (INTEL_GEN(engine->i915) >= 5) { |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 653 | kunmap(sg_page(engine->scratch.obj->pages->sgl)); |
| 654 | i915_gem_object_ggtt_unpin(engine->scratch.obj); |
Oscar Mateo | 9b1136d | 2014-07-24 17:04:24 +0100 | [diff] [blame] | 655 | } |
| 656 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 657 | drm_gem_object_unreference(&engine->scratch.obj->base); |
| 658 | engine->scratch.obj = NULL; |
Oscar Mateo | 9b1136d | 2014-07-24 17:04:24 +0100 | [diff] [blame] | 659 | } |
| 660 | |
| 661 | int |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 662 | intel_init_pipe_control(struct intel_engine_cs *engine) |
Chris Wilson | c6df541 | 2010-12-15 09:56:50 +0000 | [diff] [blame] | 663 | { |
Chris Wilson | c6df541 | 2010-12-15 09:56:50 +0000 | [diff] [blame] | 664 | int ret; |
| 665 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 666 | WARN_ON(engine->scratch.obj); |
Chris Wilson | c6df541 | 2010-12-15 09:56:50 +0000 | [diff] [blame] | 667 | |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 668 | engine->scratch.obj = i915_gem_object_create(engine->i915->dev, 4096); |
Chris Wilson | fe3db79 | 2016-04-25 13:32:13 +0100 | [diff] [blame] | 669 | if (IS_ERR(engine->scratch.obj)) { |
Chris Wilson | c6df541 | 2010-12-15 09:56:50 +0000 | [diff] [blame] | 670 | DRM_ERROR("Failed to allocate seqno page\n"); |
Chris Wilson | fe3db79 | 2016-04-25 13:32:13 +0100 | [diff] [blame] | 671 | ret = PTR_ERR(engine->scratch.obj); |
| 672 | engine->scratch.obj = NULL; |
Chris Wilson | c6df541 | 2010-12-15 09:56:50 +0000 | [diff] [blame] | 673 | goto err; |
| 674 | } |
Chris Wilson | e4ffd17 | 2011-04-04 09:44:39 +0100 | [diff] [blame] | 675 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 676 | ret = i915_gem_object_set_cache_level(engine->scratch.obj, |
| 677 | I915_CACHE_LLC); |
Daniel Vetter | a9cc726 | 2014-02-14 14:01:13 +0100 | [diff] [blame] | 678 | if (ret) |
| 679 | goto err_unref; |
Chris Wilson | c6df541 | 2010-12-15 09:56:50 +0000 | [diff] [blame] | 680 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 681 | ret = i915_gem_obj_ggtt_pin(engine->scratch.obj, 4096, 0); |
Chris Wilson | c6df541 | 2010-12-15 09:56:50 +0000 | [diff] [blame] | 682 | if (ret) |
| 683 | goto err_unref; |
| 684 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 685 | engine->scratch.gtt_offset = i915_gem_obj_ggtt_offset(engine->scratch.obj); |
| 686 | engine->scratch.cpu_page = kmap(sg_page(engine->scratch.obj->pages->sgl)); |
| 687 | if (engine->scratch.cpu_page == NULL) { |
Wei Yongjun | 56b085a | 2013-05-28 17:51:44 +0800 | [diff] [blame] | 688 | ret = -ENOMEM; |
Chris Wilson | c6df541 | 2010-12-15 09:56:50 +0000 | [diff] [blame] | 689 | goto err_unpin; |
Wei Yongjun | 56b085a | 2013-05-28 17:51:44 +0800 | [diff] [blame] | 690 | } |
Chris Wilson | c6df541 | 2010-12-15 09:56:50 +0000 | [diff] [blame] | 691 | |
Ville Syrjälä | 2b1086c | 2013-02-12 22:01:38 +0200 | [diff] [blame] | 692 | DRM_DEBUG_DRIVER("%s pipe control offset: 0x%08x\n", |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 693 | engine->name, engine->scratch.gtt_offset); |
Chris Wilson | c6df541 | 2010-12-15 09:56:50 +0000 | [diff] [blame] | 694 | return 0; |
| 695 | |
| 696 | err_unpin: |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 697 | i915_gem_object_ggtt_unpin(engine->scratch.obj); |
Chris Wilson | c6df541 | 2010-12-15 09:56:50 +0000 | [diff] [blame] | 698 | err_unref: |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 699 | drm_gem_object_unreference(&engine->scratch.obj->base); |
Chris Wilson | c6df541 | 2010-12-15 09:56:50 +0000 | [diff] [blame] | 700 | err: |
Chris Wilson | c6df541 | 2010-12-15 09:56:50 +0000 | [diff] [blame] | 701 | return ret; |
| 702 | } |
| 703 | |
John Harrison | e2be4fa | 2015-05-29 17:43:54 +0100 | [diff] [blame] | 704 | static int intel_ring_workarounds_emit(struct drm_i915_gem_request *req) |
Arun Siluvery | 86d7f23 | 2014-08-26 14:44:50 +0100 | [diff] [blame] | 705 | { |
Tvrtko Ursulin | 4a570db | 2016-03-16 11:00:38 +0000 | [diff] [blame] | 706 | struct intel_engine_cs *engine = req->engine; |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 707 | struct i915_workarounds *w = &req->i915->workarounds; |
| 708 | int ret, i; |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 709 | |
Francisco Jerez | 0223580 | 2015-10-07 14:44:01 +0300 | [diff] [blame] | 710 | if (w->count == 0) |
Mika Kuoppala | 7225342 | 2014-10-07 17:21:26 +0300 | [diff] [blame] | 711 | return 0; |
Arun Siluvery | 888b599 | 2014-08-26 14:44:51 +0100 | [diff] [blame] | 712 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 713 | engine->gpu_caches_dirty = true; |
John Harrison | 4866d72 | 2015-05-29 17:43:55 +0100 | [diff] [blame] | 714 | ret = intel_ring_flush_all_caches(req); |
Arun Siluvery | 86d7f23 | 2014-08-26 14:44:50 +0100 | [diff] [blame] | 715 | if (ret) |
| 716 | return ret; |
| 717 | |
John Harrison | 5fb9de1 | 2015-05-29 17:44:07 +0100 | [diff] [blame] | 718 | ret = intel_ring_begin(req, (w->count * 2 + 2)); |
Mika Kuoppala | 7225342 | 2014-10-07 17:21:26 +0300 | [diff] [blame] | 719 | if (ret) |
| 720 | return ret; |
| 721 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 722 | intel_ring_emit(engine, MI_LOAD_REGISTER_IMM(w->count)); |
Mika Kuoppala | 7225342 | 2014-10-07 17:21:26 +0300 | [diff] [blame] | 723 | for (i = 0; i < w->count; i++) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 724 | intel_ring_emit_reg(engine, w->reg[i].addr); |
| 725 | intel_ring_emit(engine, w->reg[i].value); |
Mika Kuoppala | 7225342 | 2014-10-07 17:21:26 +0300 | [diff] [blame] | 726 | } |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 727 | intel_ring_emit(engine, MI_NOOP); |
Mika Kuoppala | 7225342 | 2014-10-07 17:21:26 +0300 | [diff] [blame] | 728 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 729 | intel_ring_advance(engine); |
Mika Kuoppala | 7225342 | 2014-10-07 17:21:26 +0300 | [diff] [blame] | 730 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 731 | engine->gpu_caches_dirty = true; |
John Harrison | 4866d72 | 2015-05-29 17:43:55 +0100 | [diff] [blame] | 732 | ret = intel_ring_flush_all_caches(req); |
Mika Kuoppala | 7225342 | 2014-10-07 17:21:26 +0300 | [diff] [blame] | 733 | if (ret) |
| 734 | return ret; |
| 735 | |
| 736 | DRM_DEBUG_DRIVER("Number of Workarounds emitted: %d\n", w->count); |
| 737 | |
| 738 | return 0; |
| 739 | } |
| 740 | |
John Harrison | 8753181 | 2015-05-29 17:43:44 +0100 | [diff] [blame] | 741 | static int intel_rcs_ctx_init(struct drm_i915_gem_request *req) |
Daniel Vetter | 8f0e2b9 | 2014-12-02 16:19:07 +0100 | [diff] [blame] | 742 | { |
| 743 | int ret; |
| 744 | |
John Harrison | e2be4fa | 2015-05-29 17:43:54 +0100 | [diff] [blame] | 745 | ret = intel_ring_workarounds_emit(req); |
Daniel Vetter | 8f0e2b9 | 2014-12-02 16:19:07 +0100 | [diff] [blame] | 746 | if (ret != 0) |
| 747 | return ret; |
| 748 | |
John Harrison | be01363 | 2015-05-29 17:43:45 +0100 | [diff] [blame] | 749 | ret = i915_gem_render_state_init(req); |
Daniel Vetter | 8f0e2b9 | 2014-12-02 16:19:07 +0100 | [diff] [blame] | 750 | if (ret) |
Chris Wilson | e26e1b9 | 2016-01-29 16:49:05 +0000 | [diff] [blame] | 751 | return ret; |
Daniel Vetter | 8f0e2b9 | 2014-12-02 16:19:07 +0100 | [diff] [blame] | 752 | |
Chris Wilson | e26e1b9 | 2016-01-29 16:49:05 +0000 | [diff] [blame] | 753 | return 0; |
Daniel Vetter | 8f0e2b9 | 2014-12-02 16:19:07 +0100 | [diff] [blame] | 754 | } |
| 755 | |
Mika Kuoppala | 7225342 | 2014-10-07 17:21:26 +0300 | [diff] [blame] | 756 | static int wa_add(struct drm_i915_private *dev_priv, |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 757 | i915_reg_t addr, |
| 758 | const u32 mask, const u32 val) |
Mika Kuoppala | 7225342 | 2014-10-07 17:21:26 +0300 | [diff] [blame] | 759 | { |
| 760 | const u32 idx = dev_priv->workarounds.count; |
| 761 | |
| 762 | if (WARN_ON(idx >= I915_MAX_WA_REGS)) |
| 763 | return -ENOSPC; |
| 764 | |
| 765 | dev_priv->workarounds.reg[idx].addr = addr; |
| 766 | dev_priv->workarounds.reg[idx].value = val; |
| 767 | dev_priv->workarounds.reg[idx].mask = mask; |
| 768 | |
| 769 | dev_priv->workarounds.count++; |
| 770 | |
| 771 | return 0; |
| 772 | } |
| 773 | |
Mika Kuoppala | ca5a0fb | 2015-08-11 15:44:31 +0100 | [diff] [blame] | 774 | #define WA_REG(addr, mask, val) do { \ |
Damien Lespiau | cf4b0de | 2014-12-08 17:35:37 +0000 | [diff] [blame] | 775 | const int r = wa_add(dev_priv, (addr), (mask), (val)); \ |
Mika Kuoppala | 7225342 | 2014-10-07 17:21:26 +0300 | [diff] [blame] | 776 | if (r) \ |
| 777 | return r; \ |
Mika Kuoppala | ca5a0fb | 2015-08-11 15:44:31 +0100 | [diff] [blame] | 778 | } while (0) |
Mika Kuoppala | 7225342 | 2014-10-07 17:21:26 +0300 | [diff] [blame] | 779 | |
| 780 | #define WA_SET_BIT_MASKED(addr, mask) \ |
Damien Lespiau | 2645934 | 2014-12-08 17:35:38 +0000 | [diff] [blame] | 781 | WA_REG(addr, (mask), _MASKED_BIT_ENABLE(mask)) |
Mika Kuoppala | 7225342 | 2014-10-07 17:21:26 +0300 | [diff] [blame] | 782 | |
| 783 | #define WA_CLR_BIT_MASKED(addr, mask) \ |
Damien Lespiau | 2645934 | 2014-12-08 17:35:38 +0000 | [diff] [blame] | 784 | WA_REG(addr, (mask), _MASKED_BIT_DISABLE(mask)) |
Mika Kuoppala | 7225342 | 2014-10-07 17:21:26 +0300 | [diff] [blame] | 785 | |
Damien Lespiau | 9853325 | 2014-12-08 17:33:51 +0000 | [diff] [blame] | 786 | #define WA_SET_FIELD_MASKED(addr, mask, value) \ |
Damien Lespiau | cf4b0de | 2014-12-08 17:35:37 +0000 | [diff] [blame] | 787 | WA_REG(addr, mask, _MASKED_FIELD(mask, value)) |
Mika Kuoppala | 7225342 | 2014-10-07 17:21:26 +0300 | [diff] [blame] | 788 | |
Damien Lespiau | cf4b0de | 2014-12-08 17:35:37 +0000 | [diff] [blame] | 789 | #define WA_SET_BIT(addr, mask) WA_REG(addr, mask, I915_READ(addr) | (mask)) |
| 790 | #define WA_CLR_BIT(addr, mask) WA_REG(addr, mask, I915_READ(addr) & ~(mask)) |
Mika Kuoppala | 7225342 | 2014-10-07 17:21:26 +0300 | [diff] [blame] | 791 | |
Damien Lespiau | cf4b0de | 2014-12-08 17:35:37 +0000 | [diff] [blame] | 792 | #define WA_WRITE(addr, val) WA_REG(addr, 0xffffffff, val) |
Mika Kuoppala | 7225342 | 2014-10-07 17:21:26 +0300 | [diff] [blame] | 793 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 794 | static int wa_ring_whitelist_reg(struct intel_engine_cs *engine, |
| 795 | i915_reg_t reg) |
Arun Siluvery | 33136b0 | 2016-01-21 21:43:47 +0000 | [diff] [blame] | 796 | { |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 797 | struct drm_i915_private *dev_priv = engine->i915; |
Arun Siluvery | 33136b0 | 2016-01-21 21:43:47 +0000 | [diff] [blame] | 798 | struct i915_workarounds *wa = &dev_priv->workarounds; |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 799 | const uint32_t index = wa->hw_whitelist_count[engine->id]; |
Arun Siluvery | 33136b0 | 2016-01-21 21:43:47 +0000 | [diff] [blame] | 800 | |
| 801 | if (WARN_ON(index >= RING_MAX_NONPRIV_SLOTS)) |
| 802 | return -EINVAL; |
| 803 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 804 | WA_WRITE(RING_FORCE_TO_NONPRIV(engine->mmio_base, index), |
Arun Siluvery | 33136b0 | 2016-01-21 21:43:47 +0000 | [diff] [blame] | 805 | i915_mmio_reg_offset(reg)); |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 806 | wa->hw_whitelist_count[engine->id]++; |
Arun Siluvery | 33136b0 | 2016-01-21 21:43:47 +0000 | [diff] [blame] | 807 | |
| 808 | return 0; |
| 809 | } |
| 810 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 811 | static int gen8_init_workarounds(struct intel_engine_cs *engine) |
Arun Siluvery | e9a64ad | 2015-09-25 17:40:37 +0100 | [diff] [blame] | 812 | { |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 813 | struct drm_i915_private *dev_priv = engine->i915; |
Arun Siluvery | 68c6198 | 2015-09-25 17:40:38 +0100 | [diff] [blame] | 814 | |
| 815 | WA_SET_BIT_MASKED(INSTPM, INSTPM_FORCE_ORDERING); |
Arun Siluvery | e9a64ad | 2015-09-25 17:40:37 +0100 | [diff] [blame] | 816 | |
Arun Siluvery | 717d84d | 2015-09-25 17:40:39 +0100 | [diff] [blame] | 817 | /* WaDisableAsyncFlipPerfMode:bdw,chv */ |
| 818 | WA_SET_BIT_MASKED(MI_MODE, ASYNC_FLIP_PERF_DISABLE); |
| 819 | |
Arun Siluvery | d058119 | 2015-09-25 17:40:40 +0100 | [diff] [blame] | 820 | /* WaDisablePartialInstShootdown:bdw,chv */ |
| 821 | WA_SET_BIT_MASKED(GEN8_ROW_CHICKEN, |
| 822 | PARTIAL_INSTRUCTION_SHOOTDOWN_DISABLE); |
| 823 | |
Arun Siluvery | a340af5 | 2015-09-25 17:40:45 +0100 | [diff] [blame] | 824 | /* Use Force Non-Coherent whenever executing a 3D context. This is a |
| 825 | * workaround for for a possible hang in the unlikely event a TLB |
| 826 | * invalidation occurs during a PSD flush. |
| 827 | */ |
| 828 | /* WaForceEnableNonCoherent:bdw,chv */ |
Arun Siluvery | 120f5d2 | 2015-09-25 17:40:46 +0100 | [diff] [blame] | 829 | /* WaHdcDisableFetchWhenMasked:bdw,chv */ |
Arun Siluvery | a340af5 | 2015-09-25 17:40:45 +0100 | [diff] [blame] | 830 | WA_SET_BIT_MASKED(HDC_CHICKEN0, |
Arun Siluvery | 120f5d2 | 2015-09-25 17:40:46 +0100 | [diff] [blame] | 831 | HDC_DONOT_FETCH_MEM_WHEN_MASKED | |
Arun Siluvery | a340af5 | 2015-09-25 17:40:45 +0100 | [diff] [blame] | 832 | HDC_FORCE_NON_COHERENT); |
| 833 | |
Arun Siluvery | 6def8fd | 2015-09-25 17:40:42 +0100 | [diff] [blame] | 834 | /* From the Haswell PRM, Command Reference: Registers, CACHE_MODE_0: |
| 835 | * "The Hierarchical Z RAW Stall Optimization allows non-overlapping |
| 836 | * polygons in the same 8x4 pixel/sample area to be processed without |
| 837 | * stalling waiting for the earlier ones to write to Hierarchical Z |
| 838 | * buffer." |
| 839 | * |
| 840 | * This optimization is off by default for BDW and CHV; turn it on. |
| 841 | */ |
| 842 | WA_CLR_BIT_MASKED(CACHE_MODE_0_GEN7, HIZ_RAW_STALL_OPT_DISABLE); |
| 843 | |
Arun Siluvery | 4840463 | 2015-09-25 17:40:43 +0100 | [diff] [blame] | 844 | /* Wa4x4STCOptimizationDisable:bdw,chv */ |
| 845 | WA_SET_BIT_MASKED(CACHE_MODE_1, GEN8_4x4_STC_OPTIMIZATION_DISABLE); |
| 846 | |
Arun Siluvery | 7eebcde | 2015-09-25 17:40:44 +0100 | [diff] [blame] | 847 | /* |
| 848 | * BSpec recommends 8x4 when MSAA is used, |
| 849 | * however in practice 16x4 seems fastest. |
| 850 | * |
| 851 | * Note that PS/WM thread counts depend on the WIZ hashing |
| 852 | * disable bit, which we don't touch here, but it's good |
| 853 | * to keep in mind (see 3DSTATE_PS and 3DSTATE_WM). |
| 854 | */ |
| 855 | WA_SET_FIELD_MASKED(GEN7_GT_MODE, |
| 856 | GEN6_WIZ_HASHING_MASK, |
| 857 | GEN6_WIZ_HASHING_16x4); |
| 858 | |
Arun Siluvery | e9a64ad | 2015-09-25 17:40:37 +0100 | [diff] [blame] | 859 | return 0; |
| 860 | } |
| 861 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 862 | static int bdw_init_workarounds(struct intel_engine_cs *engine) |
Mika Kuoppala | 7225342 | 2014-10-07 17:21:26 +0300 | [diff] [blame] | 863 | { |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 864 | struct drm_i915_private *dev_priv = engine->i915; |
Arun Siluvery | e9a64ad | 2015-09-25 17:40:37 +0100 | [diff] [blame] | 865 | int ret; |
Mika Kuoppala | 7225342 | 2014-10-07 17:21:26 +0300 | [diff] [blame] | 866 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 867 | ret = gen8_init_workarounds(engine); |
Arun Siluvery | e9a64ad | 2015-09-25 17:40:37 +0100 | [diff] [blame] | 868 | if (ret) |
| 869 | return ret; |
| 870 | |
Rodrigo Vivi | 101b376 | 2014-10-09 07:11:47 -0700 | [diff] [blame] | 871 | /* WaDisableThreadStallDopClockGating:bdw (pre-production) */ |
Arun Siluvery | d058119 | 2015-09-25 17:40:40 +0100 | [diff] [blame] | 872 | WA_SET_BIT_MASKED(GEN8_ROW_CHICKEN, STALL_DOP_GATING_DISABLE); |
Arun Siluvery | 86d7f23 | 2014-08-26 14:44:50 +0100 | [diff] [blame] | 873 | |
Rodrigo Vivi | 101b376 | 2014-10-09 07:11:47 -0700 | [diff] [blame] | 874 | /* WaDisableDopClockGating:bdw */ |
Mika Kuoppala | 7225342 | 2014-10-07 17:21:26 +0300 | [diff] [blame] | 875 | WA_SET_BIT_MASKED(GEN7_ROW_CHICKEN2, |
| 876 | DOP_CLOCK_GATING_DISABLE); |
Arun Siluvery | 86d7f23 | 2014-08-26 14:44:50 +0100 | [diff] [blame] | 877 | |
Mika Kuoppala | 7225342 | 2014-10-07 17:21:26 +0300 | [diff] [blame] | 878 | WA_SET_BIT_MASKED(HALF_SLICE_CHICKEN3, |
| 879 | GEN8_SAMPLER_POWER_BYPASS_DIS); |
Arun Siluvery | 86d7f23 | 2014-08-26 14:44:50 +0100 | [diff] [blame] | 880 | |
Mika Kuoppala | 7225342 | 2014-10-07 17:21:26 +0300 | [diff] [blame] | 881 | WA_SET_BIT_MASKED(HDC_CHICKEN0, |
Damien Lespiau | 35cb6f3 | 2015-02-10 10:31:00 +0000 | [diff] [blame] | 882 | /* WaForceContextSaveRestoreNonCoherent:bdw */ |
| 883 | HDC_FORCE_CONTEXT_SAVE_RESTORE_NON_COHERENT | |
Damien Lespiau | 35cb6f3 | 2015-02-10 10:31:00 +0000 | [diff] [blame] | 884 | /* WaDisableFenceDestinationToSLM:bdw (pre-prod) */ |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 885 | (IS_BDW_GT3(dev_priv) ? HDC_FENCE_DEST_SLM_DISABLE : 0)); |
Arun Siluvery | 86d7f23 | 2014-08-26 14:44:50 +0100 | [diff] [blame] | 886 | |
Arun Siluvery | 86d7f23 | 2014-08-26 14:44:50 +0100 | [diff] [blame] | 887 | return 0; |
| 888 | } |
| 889 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 890 | static int chv_init_workarounds(struct intel_engine_cs *engine) |
Ville Syrjälä | 00e1e62 | 2014-08-27 17:33:12 +0300 | [diff] [blame] | 891 | { |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 892 | struct drm_i915_private *dev_priv = engine->i915; |
Arun Siluvery | e9a64ad | 2015-09-25 17:40:37 +0100 | [diff] [blame] | 893 | int ret; |
Ville Syrjälä | 00e1e62 | 2014-08-27 17:33:12 +0300 | [diff] [blame] | 894 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 895 | ret = gen8_init_workarounds(engine); |
Arun Siluvery | e9a64ad | 2015-09-25 17:40:37 +0100 | [diff] [blame] | 896 | if (ret) |
| 897 | return ret; |
| 898 | |
Ville Syrjälä | 00e1e62 | 2014-08-27 17:33:12 +0300 | [diff] [blame] | 899 | /* WaDisableThreadStallDopClockGating:chv */ |
Arun Siluvery | d058119 | 2015-09-25 17:40:40 +0100 | [diff] [blame] | 900 | WA_SET_BIT_MASKED(GEN8_ROW_CHICKEN, STALL_DOP_GATING_DISABLE); |
Ville Syrjälä | 00e1e62 | 2014-08-27 17:33:12 +0300 | [diff] [blame] | 901 | |
Kenneth Graunke | d60de81 | 2015-01-10 18:02:22 -0800 | [diff] [blame] | 902 | /* Improve HiZ throughput on CHV. */ |
| 903 | WA_SET_BIT_MASKED(HIZ_CHICKEN, CHV_HZ_8X8_MODE_IN_1X); |
| 904 | |
Mika Kuoppala | 7225342 | 2014-10-07 17:21:26 +0300 | [diff] [blame] | 905 | return 0; |
| 906 | } |
| 907 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 908 | static int gen9_init_workarounds(struct intel_engine_cs *engine) |
Hoath, Nicholas | 3b10653 | 2015-02-05 10:47:16 +0000 | [diff] [blame] | 909 | { |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 910 | struct drm_i915_private *dev_priv = engine->i915; |
Arun Siluvery | e0f3fa0 | 2016-01-21 21:43:48 +0000 | [diff] [blame] | 911 | int ret; |
Hoath, Nicholas | ab0dfaf | 2015-02-05 10:47:18 +0000 | [diff] [blame] | 912 | |
Mika Kuoppala | e5f81d6 | 2016-06-07 17:18:54 +0300 | [diff] [blame] | 913 | /* WaEnableLbsSlaRetryTimerDecrement:skl,bxt,kbl */ |
Mika Kuoppala | 9c4cbf8 | 2015-10-12 13:20:59 +0300 | [diff] [blame] | 914 | I915_WRITE(BDW_SCRATCH1, I915_READ(BDW_SCRATCH1) | |
| 915 | GEN9_LBS_SLA_RETRY_TIMER_DECREMENT_ENABLE); |
| 916 | |
Mika Kuoppala | e5f81d6 | 2016-06-07 17:18:54 +0300 | [diff] [blame] | 917 | /* WaDisableKillLogic:bxt,skl,kbl */ |
Mika Kuoppala | 9c4cbf8 | 2015-10-12 13:20:59 +0300 | [diff] [blame] | 918 | I915_WRITE(GAM_ECOCHK, I915_READ(GAM_ECOCHK) | |
| 919 | ECOCHK_DIS_TLB); |
| 920 | |
Mika Kuoppala | e5f81d6 | 2016-06-07 17:18:54 +0300 | [diff] [blame] | 921 | /* WaClearFlowControlGpgpuContextSave:skl,bxt,kbl */ |
| 922 | /* WaDisablePartialInstShootdown:skl,bxt,kbl */ |
Hoath, Nicholas | ab0dfaf | 2015-02-05 10:47:18 +0000 | [diff] [blame] | 923 | WA_SET_BIT_MASKED(GEN8_ROW_CHICKEN, |
Tim Gore | 950b2aa | 2016-03-16 16:13:46 +0000 | [diff] [blame] | 924 | FLOW_CONTROL_ENABLE | |
Hoath, Nicholas | ab0dfaf | 2015-02-05 10:47:18 +0000 | [diff] [blame] | 925 | PARTIAL_INSTRUCTION_SHOOTDOWN_DISABLE); |
| 926 | |
Mika Kuoppala | e5f81d6 | 2016-06-07 17:18:54 +0300 | [diff] [blame] | 927 | /* Syncing dependencies between camera and graphics:skl,bxt,kbl */ |
Nick Hoath | 8424171 | 2015-02-05 10:47:20 +0000 | [diff] [blame] | 928 | WA_SET_BIT_MASKED(HALF_SLICE_CHICKEN3, |
| 929 | GEN9_DISABLE_OCL_OOB_SUPPRESS_LOGIC); |
| 930 | |
Jani Nikula | e87a005 | 2015-10-20 15:22:02 +0300 | [diff] [blame] | 931 | /* WaDisableDgMirrorFixInHalfSliceChicken5:skl,bxt */ |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 932 | if (IS_SKL_REVID(dev_priv, 0, SKL_REVID_B0) || |
| 933 | IS_BXT_REVID(dev_priv, 0, BXT_REVID_A1)) |
Damien Lespiau | a86eb58 | 2015-02-11 18:21:44 +0000 | [diff] [blame] | 934 | WA_CLR_BIT_MASKED(GEN9_HALF_SLICE_CHICKEN5, |
| 935 | GEN9_DG_MIRROR_FIX_ENABLE); |
Nick Hoath | 1de4582 | 2015-02-05 10:47:19 +0000 | [diff] [blame] | 936 | |
Jani Nikula | e87a005 | 2015-10-20 15:22:02 +0300 | [diff] [blame] | 937 | /* WaSetDisablePixMaskCammingAndRhwoInCommonSliceChicken:skl,bxt */ |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 938 | if (IS_SKL_REVID(dev_priv, 0, SKL_REVID_B0) || |
| 939 | IS_BXT_REVID(dev_priv, 0, BXT_REVID_A1)) { |
Damien Lespiau | 183c6da | 2015-02-09 19:33:11 +0000 | [diff] [blame] | 940 | WA_SET_BIT_MASKED(GEN7_COMMON_SLICE_CHICKEN1, |
| 941 | GEN9_RHWO_OPTIMIZATION_DISABLE); |
Arun Siluvery | 9b01435 | 2015-07-14 15:01:30 +0100 | [diff] [blame] | 942 | /* |
| 943 | * WA also requires GEN9_SLICE_COMMON_ECO_CHICKEN0[14:14] to be set |
| 944 | * but we do that in per ctx batchbuffer as there is an issue |
| 945 | * with this register not getting restored on ctx restore |
| 946 | */ |
Damien Lespiau | 183c6da | 2015-02-09 19:33:11 +0000 | [diff] [blame] | 947 | } |
| 948 | |
Mika Kuoppala | e5f81d6 | 2016-06-07 17:18:54 +0300 | [diff] [blame] | 949 | /* WaEnableYV12BugFixInHalfSliceChicken7:skl,bxt,kbl */ |
| 950 | /* WaEnableSamplerGPGPUPreemptionSupport:skl,bxt,kbl */ |
Tim Gore | bfd8ad4 | 2016-04-19 15:45:52 +0100 | [diff] [blame] | 951 | WA_SET_BIT_MASKED(GEN9_HALF_SLICE_CHICKEN7, |
| 952 | GEN9_ENABLE_YV12_BUGFIX | |
| 953 | GEN9_ENABLE_GPGPU_PREEMPTION); |
Nick Hoath | cac23df | 2015-02-05 10:47:22 +0000 | [diff] [blame] | 954 | |
Mika Kuoppala | e5f81d6 | 2016-06-07 17:18:54 +0300 | [diff] [blame] | 955 | /* Wa4x4STCOptimizationDisable:skl,bxt,kbl */ |
| 956 | /* WaDisablePartialResolveInVc:skl,bxt,kbl */ |
Arun Siluvery | 6029468 | 2015-09-25 14:33:37 +0100 | [diff] [blame] | 957 | WA_SET_BIT_MASKED(CACHE_MODE_1, (GEN8_4x4_STC_OPTIMIZATION_DISABLE | |
| 958 | GEN9_PARTIAL_RESOLVE_IN_VC_DISABLE)); |
Damien Lespiau | 9370cd9 | 2015-02-09 19:33:17 +0000 | [diff] [blame] | 959 | |
Mika Kuoppala | e5f81d6 | 2016-06-07 17:18:54 +0300 | [diff] [blame] | 960 | /* WaCcsTlbPrefetchDisable:skl,bxt,kbl */ |
Damien Lespiau | e2db707 | 2015-02-09 19:33:21 +0000 | [diff] [blame] | 961 | WA_CLR_BIT_MASKED(GEN9_HALF_SLICE_CHICKEN5, |
| 962 | GEN9_CCS_TLB_PREFETCH_ENABLE); |
| 963 | |
Imre Deak | 5a2ae95 | 2015-05-19 15:04:59 +0300 | [diff] [blame] | 964 | /* WaDisableMaskBasedCammingInRCC:skl,bxt */ |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 965 | if (IS_SKL_REVID(dev_priv, SKL_REVID_C0, SKL_REVID_C0) || |
| 966 | IS_BXT_REVID(dev_priv, 0, BXT_REVID_A1)) |
Ben Widawsky | 38a39a7 | 2015-03-11 10:54:53 +0200 | [diff] [blame] | 967 | WA_SET_BIT_MASKED(SLICE_ECO_CHICKEN0, |
| 968 | PIXEL_MASK_CAMMING_DISABLE); |
| 969 | |
Mika Kuoppala | 5b0e365 | 2016-06-07 17:18:57 +0300 | [diff] [blame] | 970 | /* WaForceContextSaveRestoreNonCoherent:skl,bxt,kbl */ |
| 971 | WA_SET_BIT_MASKED(HDC_CHICKEN0, |
| 972 | HDC_FORCE_CONTEXT_SAVE_RESTORE_NON_COHERENT | |
| 973 | HDC_FORCE_CSR_NON_COHERENT_OVR_DISABLE); |
Imre Deak | 8ea6f89 | 2015-05-19 17:05:42 +0300 | [diff] [blame] | 974 | |
Mika Kuoppala | bbaefe7 | 2016-06-07 17:18:58 +0300 | [diff] [blame] | 975 | /* WaForceEnableNonCoherent and WaDisableHDCInvalidation are |
| 976 | * both tied to WaForceContextSaveRestoreNonCoherent |
| 977 | * in some hsds for skl. We keep the tie for all gen9. The |
| 978 | * documentation is a bit hazy and so we want to get common behaviour, |
| 979 | * even though there is no clear evidence we would need both on kbl/bxt. |
| 980 | * This area has been source of system hangs so we play it safe |
| 981 | * and mimic the skl regardless of what bspec says. |
| 982 | * |
| 983 | * Use Force Non-Coherent whenever executing a 3D context. This |
| 984 | * is a workaround for a possible hang in the unlikely event |
| 985 | * a TLB invalidation occurs during a PSD flush. |
| 986 | */ |
| 987 | |
| 988 | /* WaForceEnableNonCoherent:skl,bxt,kbl */ |
| 989 | WA_SET_BIT_MASKED(HDC_CHICKEN0, |
| 990 | HDC_FORCE_NON_COHERENT); |
| 991 | |
| 992 | /* WaDisableHDCInvalidation:skl,bxt,kbl */ |
| 993 | I915_WRITE(GAM_ECOCHK, I915_READ(GAM_ECOCHK) | |
| 994 | BDW_DISABLE_HDC_INVALIDATION); |
| 995 | |
Mika Kuoppala | e5f81d6 | 2016-06-07 17:18:54 +0300 | [diff] [blame] | 996 | /* WaDisableSamplerPowerBypassForSOPingPong:skl,bxt,kbl */ |
| 997 | if (IS_SKYLAKE(dev_priv) || |
| 998 | IS_KABYLAKE(dev_priv) || |
| 999 | IS_BXT_REVID(dev_priv, 0, BXT_REVID_B0)) |
Arun Siluvery | 8c76160 | 2015-09-08 10:31:48 +0100 | [diff] [blame] | 1000 | WA_SET_BIT_MASKED(HALF_SLICE_CHICKEN3, |
| 1001 | GEN8_SAMPLER_POWER_BYPASS_DIS); |
Arun Siluvery | 8c76160 | 2015-09-08 10:31:48 +0100 | [diff] [blame] | 1002 | |
Mika Kuoppala | e5f81d6 | 2016-06-07 17:18:54 +0300 | [diff] [blame] | 1003 | /* WaDisableSTUnitPowerOptimization:skl,bxt,kbl */ |
Robert Beckett | 6b6d562 | 2015-09-08 10:31:52 +0100 | [diff] [blame] | 1004 | WA_SET_BIT_MASKED(HALF_SLICE_CHICKEN2, GEN8_ST_PO_DISABLE); |
| 1005 | |
Mika Kuoppala | e5f81d6 | 2016-06-07 17:18:54 +0300 | [diff] [blame] | 1006 | /* WaOCLCoherentLineFlush:skl,bxt,kbl */ |
Arun Siluvery | 6ecf56a | 2016-01-21 21:43:54 +0000 | [diff] [blame] | 1007 | I915_WRITE(GEN8_L3SQCREG4, (I915_READ(GEN8_L3SQCREG4) | |
| 1008 | GEN8_LQSC_FLUSH_COHERENT_LINES)); |
| 1009 | |
arun.siluvery@linux.intel.com | 6bb62855 | 2016-06-06 09:52:49 +0100 | [diff] [blame] | 1010 | /* WaVFEStateAfterPipeControlwithMediaStateClear:skl,bxt */ |
| 1011 | ret = wa_ring_whitelist_reg(engine, GEN9_CTX_PREEMPT_REG); |
| 1012 | if (ret) |
| 1013 | return ret; |
| 1014 | |
Mika Kuoppala | e5f81d6 | 2016-06-07 17:18:54 +0300 | [diff] [blame] | 1015 | /* WaEnablePreemptionGranularityControlByUMD:skl,bxt,kbl */ |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1016 | ret= wa_ring_whitelist_reg(engine, GEN8_CS_CHICKEN1); |
Arun Siluvery | e0f3fa0 | 2016-01-21 21:43:48 +0000 | [diff] [blame] | 1017 | if (ret) |
| 1018 | return ret; |
| 1019 | |
Mika Kuoppala | e5f81d6 | 2016-06-07 17:18:54 +0300 | [diff] [blame] | 1020 | /* WaAllowUMDToModifyHDCChicken1:skl,bxt,kbl */ |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1021 | ret = wa_ring_whitelist_reg(engine, GEN8_HDC_CHICKEN1); |
Arun Siluvery | 3669ab6 | 2016-01-21 21:43:49 +0000 | [diff] [blame] | 1022 | if (ret) |
| 1023 | return ret; |
| 1024 | |
Hoath, Nicholas | 3b10653 | 2015-02-05 10:47:16 +0000 | [diff] [blame] | 1025 | return 0; |
| 1026 | } |
| 1027 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1028 | static int skl_tune_iz_hashing(struct intel_engine_cs *engine) |
Damien Lespiau | 8d20549 | 2015-02-09 19:33:15 +0000 | [diff] [blame] | 1029 | { |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1030 | struct drm_i915_private *dev_priv = engine->i915; |
Damien Lespiau | b766879 | 2015-02-14 18:30:29 +0000 | [diff] [blame] | 1031 | u8 vals[3] = { 0, 0, 0 }; |
| 1032 | unsigned int i; |
| 1033 | |
| 1034 | for (i = 0; i < 3; i++) { |
| 1035 | u8 ss; |
| 1036 | |
| 1037 | /* |
| 1038 | * Only consider slices where one, and only one, subslice has 7 |
| 1039 | * EUs |
| 1040 | */ |
Zeng Zhaoxiu | a4d8a0f | 2015-12-06 18:26:30 +0800 | [diff] [blame] | 1041 | if (!is_power_of_2(dev_priv->info.subslice_7eu[i])) |
Damien Lespiau | b766879 | 2015-02-14 18:30:29 +0000 | [diff] [blame] | 1042 | continue; |
| 1043 | |
| 1044 | /* |
| 1045 | * subslice_7eu[i] != 0 (because of the check above) and |
| 1046 | * ss_max == 4 (maximum number of subslices possible per slice) |
| 1047 | * |
| 1048 | * -> 0 <= ss <= 3; |
| 1049 | */ |
| 1050 | ss = ffs(dev_priv->info.subslice_7eu[i]) - 1; |
| 1051 | vals[i] = 3 - ss; |
| 1052 | } |
| 1053 | |
| 1054 | if (vals[0] == 0 && vals[1] == 0 && vals[2] == 0) |
| 1055 | return 0; |
| 1056 | |
| 1057 | /* Tune IZ hashing. See intel_device_info_runtime_init() */ |
| 1058 | WA_SET_FIELD_MASKED(GEN7_GT_MODE, |
| 1059 | GEN9_IZ_HASHING_MASK(2) | |
| 1060 | GEN9_IZ_HASHING_MASK(1) | |
| 1061 | GEN9_IZ_HASHING_MASK(0), |
| 1062 | GEN9_IZ_HASHING(2, vals[2]) | |
| 1063 | GEN9_IZ_HASHING(1, vals[1]) | |
| 1064 | GEN9_IZ_HASHING(0, vals[0])); |
Damien Lespiau | 8d20549 | 2015-02-09 19:33:15 +0000 | [diff] [blame] | 1065 | |
Mika Kuoppala | 7225342 | 2014-10-07 17:21:26 +0300 | [diff] [blame] | 1066 | return 0; |
| 1067 | } |
| 1068 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1069 | static int skl_init_workarounds(struct intel_engine_cs *engine) |
Damien Lespiau | 8d20549 | 2015-02-09 19:33:15 +0000 | [diff] [blame] | 1070 | { |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1071 | struct drm_i915_private *dev_priv = engine->i915; |
Arun Siluvery | aa0011a | 2015-09-25 14:33:35 +0100 | [diff] [blame] | 1072 | int ret; |
Damien Lespiau | d0bbbc4f | 2015-02-09 19:33:16 +0000 | [diff] [blame] | 1073 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1074 | ret = gen9_init_workarounds(engine); |
Arun Siluvery | aa0011a | 2015-09-25 14:33:35 +0100 | [diff] [blame] | 1075 | if (ret) |
| 1076 | return ret; |
Damien Lespiau | 8d20549 | 2015-02-09 19:33:15 +0000 | [diff] [blame] | 1077 | |
Arun Siluvery | a78536e | 2016-01-21 21:43:53 +0000 | [diff] [blame] | 1078 | /* |
| 1079 | * Actual WA is to disable percontext preemption granularity control |
| 1080 | * until D0 which is the default case so this is equivalent to |
| 1081 | * !WaDisablePerCtxtPreemptionGranularityControl:skl |
| 1082 | */ |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1083 | if (IS_SKL_REVID(dev_priv, SKL_REVID_E0, REVID_FOREVER)) { |
Arun Siluvery | a78536e | 2016-01-21 21:43:53 +0000 | [diff] [blame] | 1084 | I915_WRITE(GEN7_FF_SLICE_CS_CHICKEN1, |
| 1085 | _MASKED_BIT_ENABLE(GEN9_FFSC_PERCTX_PREEMPT_CTRL)); |
| 1086 | } |
| 1087 | |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1088 | if (IS_SKL_REVID(dev_priv, 0, SKL_REVID_D0)) { |
Mika Kuoppala | 9c4cbf8 | 2015-10-12 13:20:59 +0300 | [diff] [blame] | 1089 | /* WaDisableChickenBitTSGBarrierAckForFFSliceCS:skl */ |
| 1090 | I915_WRITE(FF_SLICE_CS_CHICKEN2, |
| 1091 | _MASKED_BIT_ENABLE(GEN9_TSG_BARRIER_ACK_DISABLE)); |
| 1092 | } |
| 1093 | |
| 1094 | /* GEN8_L3SQCREG4 has a dependency with WA batch so any new changes |
| 1095 | * involving this register should also be added to WA batch as required. |
| 1096 | */ |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1097 | if (IS_SKL_REVID(dev_priv, 0, SKL_REVID_E0)) |
Mika Kuoppala | 9c4cbf8 | 2015-10-12 13:20:59 +0300 | [diff] [blame] | 1098 | /* WaDisableLSQCROPERFforOCL:skl */ |
| 1099 | I915_WRITE(GEN8_L3SQCREG4, I915_READ(GEN8_L3SQCREG4) | |
| 1100 | GEN8_LQSC_RO_PERF_DIS); |
| 1101 | |
| 1102 | /* WaEnableGapsTsvCreditFix:skl */ |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1103 | if (IS_SKL_REVID(dev_priv, SKL_REVID_C0, REVID_FOREVER)) { |
Mika Kuoppala | 9c4cbf8 | 2015-10-12 13:20:59 +0300 | [diff] [blame] | 1104 | I915_WRITE(GEN8_GARBCNTL, (I915_READ(GEN8_GARBCNTL) | |
| 1105 | GEN9_GAPS_TSV_CREDIT_DISABLE)); |
| 1106 | } |
| 1107 | |
Damien Lespiau | d0bbbc4f | 2015-02-09 19:33:16 +0000 | [diff] [blame] | 1108 | /* WaDisablePowerCompilerClockGating:skl */ |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1109 | if (IS_SKL_REVID(dev_priv, SKL_REVID_B0, SKL_REVID_B0)) |
Damien Lespiau | d0bbbc4f | 2015-02-09 19:33:16 +0000 | [diff] [blame] | 1110 | WA_SET_BIT_MASKED(HIZ_CHICKEN, |
| 1111 | BDW_HIZ_POWER_COMPILER_CLOCK_GATING_DISABLE); |
| 1112 | |
Jani Nikula | e87a005 | 2015-10-20 15:22:02 +0300 | [diff] [blame] | 1113 | /* WaBarrierPerformanceFixDisable:skl */ |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1114 | if (IS_SKL_REVID(dev_priv, SKL_REVID_C0, SKL_REVID_D0)) |
Ville Syrjälä | 5b6fd12 | 2015-06-02 15:37:35 +0300 | [diff] [blame] | 1115 | WA_SET_BIT_MASKED(HDC_CHICKEN0, |
| 1116 | HDC_FENCE_DEST_SLM_DISABLE | |
| 1117 | HDC_BARRIER_PERFORMANCE_DISABLE); |
| 1118 | |
Mika Kuoppala | 9bd9dfb | 2015-08-06 16:51:00 +0300 | [diff] [blame] | 1119 | /* WaDisableSbeCacheDispatchPortSharing:skl */ |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1120 | if (IS_SKL_REVID(dev_priv, 0, SKL_REVID_F0)) |
Mika Kuoppala | 9bd9dfb | 2015-08-06 16:51:00 +0300 | [diff] [blame] | 1121 | WA_SET_BIT_MASKED( |
| 1122 | GEN7_HALF_SLICE_CHICKEN1, |
| 1123 | GEN7_SBE_SS_CACHE_DISPATCH_PORT_SHARING_DISABLE); |
Mika Kuoppala | 9bd9dfb | 2015-08-06 16:51:00 +0300 | [diff] [blame] | 1124 | |
Mika Kuoppala | eee8efb | 2016-06-07 17:18:53 +0300 | [diff] [blame] | 1125 | /* WaDisableGafsUnitClkGating:skl */ |
| 1126 | WA_SET_BIT(GEN7_UCGCTL4, GEN8_EU_GAUNIT_CLOCK_GATE_DISABLE); |
| 1127 | |
Arun Siluvery | 6107497 | 2016-01-21 21:43:52 +0000 | [diff] [blame] | 1128 | /* WaDisableLSQCROPERFforOCL:skl */ |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1129 | ret = wa_ring_whitelist_reg(engine, GEN8_L3SQCREG4); |
Arun Siluvery | 6107497 | 2016-01-21 21:43:52 +0000 | [diff] [blame] | 1130 | if (ret) |
| 1131 | return ret; |
| 1132 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1133 | return skl_tune_iz_hashing(engine); |
Damien Lespiau | 8d20549 | 2015-02-09 19:33:15 +0000 | [diff] [blame] | 1134 | } |
| 1135 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1136 | static int bxt_init_workarounds(struct intel_engine_cs *engine) |
Nick Hoath | cae0437 | 2015-03-17 11:39:38 +0200 | [diff] [blame] | 1137 | { |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1138 | struct drm_i915_private *dev_priv = engine->i915; |
Arun Siluvery | aa0011a | 2015-09-25 14:33:35 +0100 | [diff] [blame] | 1139 | int ret; |
Nick Hoath | dfb601e | 2015-04-10 13:12:24 +0100 | [diff] [blame] | 1140 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1141 | ret = gen9_init_workarounds(engine); |
Arun Siluvery | aa0011a | 2015-09-25 14:33:35 +0100 | [diff] [blame] | 1142 | if (ret) |
| 1143 | return ret; |
Nick Hoath | cae0437 | 2015-03-17 11:39:38 +0200 | [diff] [blame] | 1144 | |
Mika Kuoppala | 9c4cbf8 | 2015-10-12 13:20:59 +0300 | [diff] [blame] | 1145 | /* WaStoreMultiplePTEenable:bxt */ |
| 1146 | /* This is a requirement according to Hardware specification */ |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1147 | if (IS_BXT_REVID(dev_priv, 0, BXT_REVID_A1)) |
Mika Kuoppala | 9c4cbf8 | 2015-10-12 13:20:59 +0300 | [diff] [blame] | 1148 | I915_WRITE(TILECTL, I915_READ(TILECTL) | TILECTL_TLBPF); |
| 1149 | |
| 1150 | /* WaSetClckGatingDisableMedia:bxt */ |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1151 | if (IS_BXT_REVID(dev_priv, 0, BXT_REVID_A1)) { |
Mika Kuoppala | 9c4cbf8 | 2015-10-12 13:20:59 +0300 | [diff] [blame] | 1152 | I915_WRITE(GEN7_MISCCPCTL, (I915_READ(GEN7_MISCCPCTL) & |
| 1153 | ~GEN8_DOP_CLOCK_GATE_MEDIA_ENABLE)); |
| 1154 | } |
| 1155 | |
Nick Hoath | dfb601e | 2015-04-10 13:12:24 +0100 | [diff] [blame] | 1156 | /* WaDisableThreadStallDopClockGating:bxt */ |
| 1157 | WA_SET_BIT_MASKED(GEN8_ROW_CHICKEN, |
| 1158 | STALL_DOP_GATING_DISABLE); |
| 1159 | |
Nick Hoath | 983b4b9 | 2015-04-10 13:12:25 +0100 | [diff] [blame] | 1160 | /* WaDisableSbeCacheDispatchPortSharing:bxt */ |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1161 | if (IS_BXT_REVID(dev_priv, 0, BXT_REVID_B0)) { |
Nick Hoath | 983b4b9 | 2015-04-10 13:12:25 +0100 | [diff] [blame] | 1162 | WA_SET_BIT_MASKED( |
| 1163 | GEN7_HALF_SLICE_CHICKEN1, |
| 1164 | GEN7_SBE_SS_CACHE_DISPATCH_PORT_SHARING_DISABLE); |
| 1165 | } |
| 1166 | |
Arun Siluvery | 2c8580e | 2016-01-21 21:43:50 +0000 | [diff] [blame] | 1167 | /* WaDisableObjectLevelPreemptionForTrifanOrPolygon:bxt */ |
| 1168 | /* WaDisableObjectLevelPreemptionForInstancedDraw:bxt */ |
| 1169 | /* WaDisableObjectLevelPreemtionForInstanceId:bxt */ |
Arun Siluvery | a786d53 | 2016-01-21 21:43:51 +0000 | [diff] [blame] | 1170 | /* WaDisableLSQCROPERFforOCL:bxt */ |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1171 | if (IS_BXT_REVID(dev_priv, 0, BXT_REVID_A1)) { |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1172 | ret = wa_ring_whitelist_reg(engine, GEN9_CS_DEBUG_MODE1); |
Arun Siluvery | 2c8580e | 2016-01-21 21:43:50 +0000 | [diff] [blame] | 1173 | if (ret) |
| 1174 | return ret; |
Arun Siluvery | a786d53 | 2016-01-21 21:43:51 +0000 | [diff] [blame] | 1175 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1176 | ret = wa_ring_whitelist_reg(engine, GEN8_L3SQCREG4); |
Arun Siluvery | a786d53 | 2016-01-21 21:43:51 +0000 | [diff] [blame] | 1177 | if (ret) |
| 1178 | return ret; |
Arun Siluvery | 2c8580e | 2016-01-21 21:43:50 +0000 | [diff] [blame] | 1179 | } |
| 1180 | |
Tim Gore | 050fc46 | 2016-04-22 09:46:01 +0100 | [diff] [blame] | 1181 | /* WaProgramL3SqcReg1DefaultForPerf:bxt */ |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1182 | if (IS_BXT_REVID(dev_priv, BXT_REVID_B0, REVID_FOREVER)) |
Imre Deak | 36579cb | 2016-05-03 15:54:20 +0300 | [diff] [blame] | 1183 | I915_WRITE(GEN8_L3SQCREG1, L3_GENERAL_PRIO_CREDITS(62) | |
| 1184 | L3_HIGH_PRIO_CREDITS(2)); |
Tim Gore | 050fc46 | 2016-04-22 09:46:01 +0100 | [diff] [blame] | 1185 | |
Mika Kuoppala | ad2bdb4 | 2016-06-07 17:19:07 +0300 | [diff] [blame] | 1186 | /* WaInsertDummyPushConstPs:bxt */ |
| 1187 | if (IS_BXT_REVID(dev_priv, 0, BXT_REVID_B0)) |
| 1188 | WA_SET_BIT_MASKED(COMMON_SLICE_CHICKEN2, |
| 1189 | GEN8_SBE_DISABLE_REPLAY_BUF_OPTIMIZATION); |
| 1190 | |
Nick Hoath | cae0437 | 2015-03-17 11:39:38 +0200 | [diff] [blame] | 1191 | return 0; |
| 1192 | } |
| 1193 | |
Mika Kuoppala | e5f81d6 | 2016-06-07 17:18:54 +0300 | [diff] [blame] | 1194 | static int kbl_init_workarounds(struct intel_engine_cs *engine) |
| 1195 | { |
Mika Kuoppala | e587f6c | 2016-06-07 17:18:59 +0300 | [diff] [blame] | 1196 | struct drm_i915_private *dev_priv = engine->i915; |
Mika Kuoppala | e5f81d6 | 2016-06-07 17:18:54 +0300 | [diff] [blame] | 1197 | int ret; |
| 1198 | |
| 1199 | ret = gen9_init_workarounds(engine); |
| 1200 | if (ret) |
| 1201 | return ret; |
| 1202 | |
Mika Kuoppala | e587f6c | 2016-06-07 17:18:59 +0300 | [diff] [blame] | 1203 | /* WaEnableGapsTsvCreditFix:kbl */ |
| 1204 | I915_WRITE(GEN8_GARBCNTL, (I915_READ(GEN8_GARBCNTL) | |
| 1205 | GEN9_GAPS_TSV_CREDIT_DISABLE)); |
| 1206 | |
Mika Kuoppala | c0b730d | 2016-06-07 17:19:06 +0300 | [diff] [blame] | 1207 | /* WaDisableDynamicCreditSharing:kbl */ |
| 1208 | if (IS_KBL_REVID(dev_priv, 0, KBL_REVID_B0)) |
| 1209 | WA_SET_BIT(GAMT_CHKN_BIT_REG, |
| 1210 | GAMT_CHKN_DISABLE_DYNAMIC_CREDIT_SHARING); |
| 1211 | |
Mika Kuoppala | 8401d42 | 2016-06-07 17:19:00 +0300 | [diff] [blame] | 1212 | /* WaDisableFenceDestinationToSLM:kbl (pre-prod) */ |
| 1213 | if (IS_KBL_REVID(dev_priv, KBL_REVID_A0, KBL_REVID_A0)) |
| 1214 | WA_SET_BIT_MASKED(HDC_CHICKEN0, |
| 1215 | HDC_FENCE_DEST_SLM_DISABLE); |
| 1216 | |
Mika Kuoppala | fe90581 | 2016-06-07 17:19:03 +0300 | [diff] [blame] | 1217 | /* GEN8_L3SQCREG4 has a dependency with WA batch so any new changes |
| 1218 | * involving this register should also be added to WA batch as required. |
| 1219 | */ |
| 1220 | if (IS_KBL_REVID(dev_priv, 0, KBL_REVID_E0)) |
| 1221 | /* WaDisableLSQCROPERFforOCL:kbl */ |
| 1222 | I915_WRITE(GEN8_L3SQCREG4, I915_READ(GEN8_L3SQCREG4) | |
| 1223 | GEN8_LQSC_RO_PERF_DIS); |
| 1224 | |
Mika Kuoppala | ad2bdb4 | 2016-06-07 17:19:07 +0300 | [diff] [blame] | 1225 | /* WaInsertDummyPushConstPs:kbl */ |
| 1226 | if (IS_KBL_REVID(dev_priv, 0, KBL_REVID_B0)) |
| 1227 | WA_SET_BIT_MASKED(COMMON_SLICE_CHICKEN2, |
| 1228 | GEN8_SBE_DISABLE_REPLAY_BUF_OPTIMIZATION); |
| 1229 | |
Mika Kuoppala | 4de5d7c | 2016-06-07 17:19:11 +0300 | [diff] [blame^] | 1230 | /* WaDisableGafsUnitClkGating:kbl */ |
| 1231 | WA_SET_BIT(GEN7_UCGCTL4, GEN8_EU_GAUNIT_CLOCK_GATE_DISABLE); |
| 1232 | |
Mika Kuoppala | fe90581 | 2016-06-07 17:19:03 +0300 | [diff] [blame] | 1233 | /* WaDisableLSQCROPERFforOCL:kbl */ |
| 1234 | ret = wa_ring_whitelist_reg(engine, GEN8_L3SQCREG4); |
| 1235 | if (ret) |
| 1236 | return ret; |
| 1237 | |
Mika Kuoppala | e5f81d6 | 2016-06-07 17:18:54 +0300 | [diff] [blame] | 1238 | return 0; |
| 1239 | } |
| 1240 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1241 | int init_workarounds_ring(struct intel_engine_cs *engine) |
Mika Kuoppala | 7225342 | 2014-10-07 17:21:26 +0300 | [diff] [blame] | 1242 | { |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1243 | struct drm_i915_private *dev_priv = engine->i915; |
Mika Kuoppala | 7225342 | 2014-10-07 17:21:26 +0300 | [diff] [blame] | 1244 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1245 | WARN_ON(engine->id != RCS); |
Mika Kuoppala | 7225342 | 2014-10-07 17:21:26 +0300 | [diff] [blame] | 1246 | |
| 1247 | dev_priv->workarounds.count = 0; |
Arun Siluvery | 33136b0 | 2016-01-21 21:43:47 +0000 | [diff] [blame] | 1248 | dev_priv->workarounds.hw_whitelist_count[RCS] = 0; |
Mika Kuoppala | 7225342 | 2014-10-07 17:21:26 +0300 | [diff] [blame] | 1249 | |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1250 | if (IS_BROADWELL(dev_priv)) |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1251 | return bdw_init_workarounds(engine); |
Mika Kuoppala | 7225342 | 2014-10-07 17:21:26 +0300 | [diff] [blame] | 1252 | |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1253 | if (IS_CHERRYVIEW(dev_priv)) |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1254 | return chv_init_workarounds(engine); |
Ville Syrjälä | 00e1e62 | 2014-08-27 17:33:12 +0300 | [diff] [blame] | 1255 | |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1256 | if (IS_SKYLAKE(dev_priv)) |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1257 | return skl_init_workarounds(engine); |
Nick Hoath | cae0437 | 2015-03-17 11:39:38 +0200 | [diff] [blame] | 1258 | |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1259 | if (IS_BROXTON(dev_priv)) |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1260 | return bxt_init_workarounds(engine); |
Hoath, Nicholas | 3b10653 | 2015-02-05 10:47:16 +0000 | [diff] [blame] | 1261 | |
Mika Kuoppala | e5f81d6 | 2016-06-07 17:18:54 +0300 | [diff] [blame] | 1262 | if (IS_KABYLAKE(dev_priv)) |
| 1263 | return kbl_init_workarounds(engine); |
| 1264 | |
Ville Syrjälä | 00e1e62 | 2014-08-27 17:33:12 +0300 | [diff] [blame] | 1265 | return 0; |
| 1266 | } |
| 1267 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1268 | static int init_render_ring(struct intel_engine_cs *engine) |
Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 1269 | { |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1270 | struct drm_i915_private *dev_priv = engine->i915; |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1271 | int ret = init_ring_common(engine); |
Konrad Zapalowicz | 9c33baa | 2014-06-19 19:07:15 +0200 | [diff] [blame] | 1272 | if (ret) |
| 1273 | return ret; |
Zhenyu Wang | a69ffdb | 2010-08-30 16:12:42 +0800 | [diff] [blame] | 1274 | |
Akash Goel | 61a563a | 2014-03-25 18:01:50 +0530 | [diff] [blame] | 1275 | /* WaTimedSingleVertexDispatch:cl,bw,ctg,elk,ilk,snb */ |
Tvrtko Ursulin | ac657f6 | 2016-05-10 10:57:08 +0100 | [diff] [blame] | 1276 | if (IS_GEN(dev_priv, 4, 6)) |
Daniel Vetter | 6b26c86 | 2012-04-24 14:04:12 +0200 | [diff] [blame] | 1277 | I915_WRITE(MI_MODE, _MASKED_BIT_ENABLE(VS_TIMER_DISPATCH)); |
Chris Wilson | 1c8c38c | 2013-01-20 16:11:20 +0000 | [diff] [blame] | 1278 | |
| 1279 | /* We need to disable the AsyncFlip performance optimisations in order |
| 1280 | * to use MI_WAIT_FOR_EVENT within the CS. It should already be |
| 1281 | * programmed to '1' on all products. |
Damien Lespiau | 8693a82 | 2013-05-03 18:48:11 +0100 | [diff] [blame] | 1282 | * |
Ville Syrjälä | 2441f87 | 2015-06-02 15:37:37 +0300 | [diff] [blame] | 1283 | * WaDisableAsyncFlipPerfMode:snb,ivb,hsw,vlv |
Chris Wilson | 1c8c38c | 2013-01-20 16:11:20 +0000 | [diff] [blame] | 1284 | */ |
Tvrtko Ursulin | ac657f6 | 2016-05-10 10:57:08 +0100 | [diff] [blame] | 1285 | if (IS_GEN(dev_priv, 6, 7)) |
Chris Wilson | 1c8c38c | 2013-01-20 16:11:20 +0000 | [diff] [blame] | 1286 | I915_WRITE(MI_MODE, _MASKED_BIT_ENABLE(ASYNC_FLIP_PERF_DISABLE)); |
| 1287 | |
Chris Wilson | f05bb0c | 2013-01-20 16:33:32 +0000 | [diff] [blame] | 1288 | /* Required for the hardware to program scanline values for waiting */ |
Akash Goel | 01fa030 | 2014-03-24 23:00:04 +0530 | [diff] [blame] | 1289 | /* WaEnableFlushTlbInvalidationMode:snb */ |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1290 | if (IS_GEN6(dev_priv)) |
Chris Wilson | f05bb0c | 2013-01-20 16:33:32 +0000 | [diff] [blame] | 1291 | I915_WRITE(GFX_MODE, |
Chris Wilson | aa83e30 | 2014-03-21 17:18:54 +0000 | [diff] [blame] | 1292 | _MASKED_BIT_ENABLE(GFX_TLB_INVALIDATE_EXPLICIT)); |
Chris Wilson | f05bb0c | 2013-01-20 16:33:32 +0000 | [diff] [blame] | 1293 | |
Akash Goel | 01fa030 | 2014-03-24 23:00:04 +0530 | [diff] [blame] | 1294 | /* WaBCSVCSTlbInvalidationMode:ivb,vlv,hsw */ |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1295 | if (IS_GEN7(dev_priv)) |
Chris Wilson | 1c8c38c | 2013-01-20 16:11:20 +0000 | [diff] [blame] | 1296 | I915_WRITE(GFX_MODE_GEN7, |
Akash Goel | 01fa030 | 2014-03-24 23:00:04 +0530 | [diff] [blame] | 1297 | _MASKED_BIT_ENABLE(GFX_TLB_INVALIDATE_EXPLICIT) | |
Chris Wilson | 1c8c38c | 2013-01-20 16:11:20 +0000 | [diff] [blame] | 1298 | _MASKED_BIT_ENABLE(GFX_REPLAY_MODE)); |
Chris Wilson | 78501ea | 2010-10-27 12:18:21 +0100 | [diff] [blame] | 1299 | |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1300 | if (IS_GEN6(dev_priv)) { |
Kenneth Graunke | 3a69ddd | 2012-04-27 12:44:41 -0700 | [diff] [blame] | 1301 | /* From the Sandybridge PRM, volume 1 part 3, page 24: |
| 1302 | * "If this bit is set, STCunit will have LRA as replacement |
| 1303 | * policy. [...] This bit must be reset. LRA replacement |
| 1304 | * policy is not supported." |
| 1305 | */ |
| 1306 | I915_WRITE(CACHE_MODE_0, |
Daniel Vetter | 5e13a0c | 2012-05-08 13:39:59 +0200 | [diff] [blame] | 1307 | _MASKED_BIT_DISABLE(CM0_STC_EVICT_DISABLE_LRA_SNB)); |
Ben Widawsky | 84f9f93 | 2011-12-12 19:21:58 -0800 | [diff] [blame] | 1308 | } |
| 1309 | |
Tvrtko Ursulin | ac657f6 | 2016-05-10 10:57:08 +0100 | [diff] [blame] | 1310 | if (IS_GEN(dev_priv, 6, 7)) |
Daniel Vetter | 6b26c86 | 2012-04-24 14:04:12 +0200 | [diff] [blame] | 1311 | I915_WRITE(INSTPM, _MASKED_BIT_ENABLE(INSTPM_FORCE_ORDERING)); |
Chris Wilson | c6df541 | 2010-12-15 09:56:50 +0000 | [diff] [blame] | 1312 | |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1313 | if (HAS_L3_DPF(dev_priv)) |
| 1314 | I915_WRITE_IMR(engine, ~GT_PARITY_ERROR(dev_priv)); |
Ben Widawsky | 15b9f80 | 2012-05-25 16:56:23 -0700 | [diff] [blame] | 1315 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1316 | return init_workarounds_ring(engine); |
Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 1317 | } |
| 1318 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1319 | static void render_ring_cleanup(struct intel_engine_cs *engine) |
Chris Wilson | c6df541 | 2010-12-15 09:56:50 +0000 | [diff] [blame] | 1320 | { |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1321 | struct drm_i915_private *dev_priv = engine->i915; |
Ben Widawsky | 3e78998 | 2014-06-30 09:53:37 -0700 | [diff] [blame] | 1322 | |
| 1323 | if (dev_priv->semaphore_obj) { |
| 1324 | i915_gem_object_ggtt_unpin(dev_priv->semaphore_obj); |
| 1325 | drm_gem_object_unreference(&dev_priv->semaphore_obj->base); |
| 1326 | dev_priv->semaphore_obj = NULL; |
| 1327 | } |
Daniel Vetter | b45305f | 2012-12-17 16:21:27 +0100 | [diff] [blame] | 1328 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1329 | intel_fini_pipe_control(engine); |
Chris Wilson | c6df541 | 2010-12-15 09:56:50 +0000 | [diff] [blame] | 1330 | } |
| 1331 | |
John Harrison | f716968 | 2015-05-29 17:44:05 +0100 | [diff] [blame] | 1332 | static int gen8_rcs_signal(struct drm_i915_gem_request *signaller_req, |
Ben Widawsky | 3e78998 | 2014-06-30 09:53:37 -0700 | [diff] [blame] | 1333 | unsigned int num_dwords) |
| 1334 | { |
| 1335 | #define MBOX_UPDATE_DWORDS 8 |
Tvrtko Ursulin | 4a570db | 2016-03-16 11:00:38 +0000 | [diff] [blame] | 1336 | struct intel_engine_cs *signaller = signaller_req->engine; |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1337 | struct drm_i915_private *dev_priv = signaller_req->i915; |
Ben Widawsky | 3e78998 | 2014-06-30 09:53:37 -0700 | [diff] [blame] | 1338 | struct intel_engine_cs *waiter; |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1339 | enum intel_engine_id id; |
| 1340 | int ret, num_rings; |
Ben Widawsky | 3e78998 | 2014-06-30 09:53:37 -0700 | [diff] [blame] | 1341 | |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1342 | num_rings = hweight32(INTEL_INFO(dev_priv)->ring_mask); |
Ben Widawsky | 3e78998 | 2014-06-30 09:53:37 -0700 | [diff] [blame] | 1343 | num_dwords += (num_rings-1) * MBOX_UPDATE_DWORDS; |
| 1344 | #undef MBOX_UPDATE_DWORDS |
| 1345 | |
John Harrison | 5fb9de1 | 2015-05-29 17:44:07 +0100 | [diff] [blame] | 1346 | ret = intel_ring_begin(signaller_req, num_dwords); |
Ben Widawsky | 3e78998 | 2014-06-30 09:53:37 -0700 | [diff] [blame] | 1347 | if (ret) |
| 1348 | return ret; |
| 1349 | |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1350 | for_each_engine_id(waiter, dev_priv, id) { |
John Harrison | 6259cea | 2014-11-24 18:49:29 +0000 | [diff] [blame] | 1351 | u32 seqno; |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1352 | u64 gtt_offset = signaller->semaphore.signal_ggtt[id]; |
Ben Widawsky | 3e78998 | 2014-06-30 09:53:37 -0700 | [diff] [blame] | 1353 | if (gtt_offset == MI_SEMAPHORE_SYNC_INVALID) |
| 1354 | continue; |
| 1355 | |
John Harrison | f716968 | 2015-05-29 17:44:05 +0100 | [diff] [blame] | 1356 | seqno = i915_gem_request_get_seqno(signaller_req); |
Ben Widawsky | 3e78998 | 2014-06-30 09:53:37 -0700 | [diff] [blame] | 1357 | intel_ring_emit(signaller, GFX_OP_PIPE_CONTROL(6)); |
| 1358 | intel_ring_emit(signaller, PIPE_CONTROL_GLOBAL_GTT_IVB | |
| 1359 | PIPE_CONTROL_QW_WRITE | |
Chris Wilson | f9a4ea3 | 2016-04-29 13:18:24 +0100 | [diff] [blame] | 1360 | PIPE_CONTROL_CS_STALL); |
Ben Widawsky | 3e78998 | 2014-06-30 09:53:37 -0700 | [diff] [blame] | 1361 | intel_ring_emit(signaller, lower_32_bits(gtt_offset)); |
| 1362 | intel_ring_emit(signaller, upper_32_bits(gtt_offset)); |
John Harrison | 6259cea | 2014-11-24 18:49:29 +0000 | [diff] [blame] | 1363 | intel_ring_emit(signaller, seqno); |
Ben Widawsky | 3e78998 | 2014-06-30 09:53:37 -0700 | [diff] [blame] | 1364 | intel_ring_emit(signaller, 0); |
| 1365 | intel_ring_emit(signaller, MI_SEMAPHORE_SIGNAL | |
Chris Wilson | 215a7e3 | 2016-04-29 13:18:23 +0100 | [diff] [blame] | 1366 | MI_SEMAPHORE_TARGET(waiter->hw_id)); |
Ben Widawsky | 3e78998 | 2014-06-30 09:53:37 -0700 | [diff] [blame] | 1367 | intel_ring_emit(signaller, 0); |
| 1368 | } |
| 1369 | |
| 1370 | return 0; |
| 1371 | } |
| 1372 | |
John Harrison | f716968 | 2015-05-29 17:44:05 +0100 | [diff] [blame] | 1373 | static int gen8_xcs_signal(struct drm_i915_gem_request *signaller_req, |
Ben Widawsky | 3e78998 | 2014-06-30 09:53:37 -0700 | [diff] [blame] | 1374 | unsigned int num_dwords) |
| 1375 | { |
| 1376 | #define MBOX_UPDATE_DWORDS 6 |
Tvrtko Ursulin | 4a570db | 2016-03-16 11:00:38 +0000 | [diff] [blame] | 1377 | struct intel_engine_cs *signaller = signaller_req->engine; |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1378 | struct drm_i915_private *dev_priv = signaller_req->i915; |
Ben Widawsky | 3e78998 | 2014-06-30 09:53:37 -0700 | [diff] [blame] | 1379 | struct intel_engine_cs *waiter; |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1380 | enum intel_engine_id id; |
| 1381 | int ret, num_rings; |
Ben Widawsky | 3e78998 | 2014-06-30 09:53:37 -0700 | [diff] [blame] | 1382 | |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1383 | num_rings = hweight32(INTEL_INFO(dev_priv)->ring_mask); |
Ben Widawsky | 3e78998 | 2014-06-30 09:53:37 -0700 | [diff] [blame] | 1384 | num_dwords += (num_rings-1) * MBOX_UPDATE_DWORDS; |
| 1385 | #undef MBOX_UPDATE_DWORDS |
| 1386 | |
John Harrison | 5fb9de1 | 2015-05-29 17:44:07 +0100 | [diff] [blame] | 1387 | ret = intel_ring_begin(signaller_req, num_dwords); |
Ben Widawsky | 3e78998 | 2014-06-30 09:53:37 -0700 | [diff] [blame] | 1388 | if (ret) |
| 1389 | return ret; |
| 1390 | |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1391 | for_each_engine_id(waiter, dev_priv, id) { |
John Harrison | 6259cea | 2014-11-24 18:49:29 +0000 | [diff] [blame] | 1392 | u32 seqno; |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1393 | u64 gtt_offset = signaller->semaphore.signal_ggtt[id]; |
Ben Widawsky | 3e78998 | 2014-06-30 09:53:37 -0700 | [diff] [blame] | 1394 | if (gtt_offset == MI_SEMAPHORE_SYNC_INVALID) |
| 1395 | continue; |
| 1396 | |
John Harrison | f716968 | 2015-05-29 17:44:05 +0100 | [diff] [blame] | 1397 | seqno = i915_gem_request_get_seqno(signaller_req); |
Ben Widawsky | 3e78998 | 2014-06-30 09:53:37 -0700 | [diff] [blame] | 1398 | intel_ring_emit(signaller, (MI_FLUSH_DW + 1) | |
| 1399 | MI_FLUSH_DW_OP_STOREDW); |
| 1400 | intel_ring_emit(signaller, lower_32_bits(gtt_offset) | |
| 1401 | MI_FLUSH_DW_USE_GTT); |
| 1402 | intel_ring_emit(signaller, upper_32_bits(gtt_offset)); |
John Harrison | 6259cea | 2014-11-24 18:49:29 +0000 | [diff] [blame] | 1403 | intel_ring_emit(signaller, seqno); |
Ben Widawsky | 3e78998 | 2014-06-30 09:53:37 -0700 | [diff] [blame] | 1404 | intel_ring_emit(signaller, MI_SEMAPHORE_SIGNAL | |
Chris Wilson | 215a7e3 | 2016-04-29 13:18:23 +0100 | [diff] [blame] | 1405 | MI_SEMAPHORE_TARGET(waiter->hw_id)); |
Ben Widawsky | 3e78998 | 2014-06-30 09:53:37 -0700 | [diff] [blame] | 1406 | intel_ring_emit(signaller, 0); |
| 1407 | } |
| 1408 | |
| 1409 | return 0; |
| 1410 | } |
| 1411 | |
John Harrison | f716968 | 2015-05-29 17:44:05 +0100 | [diff] [blame] | 1412 | static int gen6_signal(struct drm_i915_gem_request *signaller_req, |
Ben Widawsky | 024a43e | 2014-04-29 14:52:30 -0700 | [diff] [blame] | 1413 | unsigned int num_dwords) |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 1414 | { |
Tvrtko Ursulin | 4a570db | 2016-03-16 11:00:38 +0000 | [diff] [blame] | 1415 | struct intel_engine_cs *signaller = signaller_req->engine; |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1416 | struct drm_i915_private *dev_priv = signaller_req->i915; |
Oscar Mateo | a4872ba | 2014-05-22 14:13:33 +0100 | [diff] [blame] | 1417 | struct intel_engine_cs *useless; |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1418 | enum intel_engine_id id; |
| 1419 | int ret, num_rings; |
Ben Widawsky | 78325f2 | 2014-04-29 14:52:29 -0700 | [diff] [blame] | 1420 | |
Ben Widawsky | a1444b7 | 2014-06-30 09:53:35 -0700 | [diff] [blame] | 1421 | #define MBOX_UPDATE_DWORDS 3 |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1422 | num_rings = hweight32(INTEL_INFO(dev_priv)->ring_mask); |
Ben Widawsky | a1444b7 | 2014-06-30 09:53:35 -0700 | [diff] [blame] | 1423 | num_dwords += round_up((num_rings-1) * MBOX_UPDATE_DWORDS, 2); |
| 1424 | #undef MBOX_UPDATE_DWORDS |
Ben Widawsky | 024a43e | 2014-04-29 14:52:30 -0700 | [diff] [blame] | 1425 | |
John Harrison | 5fb9de1 | 2015-05-29 17:44:07 +0100 | [diff] [blame] | 1426 | ret = intel_ring_begin(signaller_req, num_dwords); |
Ben Widawsky | 024a43e | 2014-04-29 14:52:30 -0700 | [diff] [blame] | 1427 | if (ret) |
| 1428 | return ret; |
Ben Widawsky | 024a43e | 2014-04-29 14:52:30 -0700 | [diff] [blame] | 1429 | |
Dave Gordon | c3232b1 | 2016-03-23 18:19:53 +0000 | [diff] [blame] | 1430 | for_each_engine_id(useless, dev_priv, id) { |
| 1431 | i915_reg_t mbox_reg = signaller->semaphore.mbox.signal[id]; |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 1432 | |
| 1433 | if (i915_mmio_reg_valid(mbox_reg)) { |
John Harrison | f716968 | 2015-05-29 17:44:05 +0100 | [diff] [blame] | 1434 | u32 seqno = i915_gem_request_get_seqno(signaller_req); |
Ville Syrjälä | f0f59a0 | 2015-11-18 15:33:26 +0200 | [diff] [blame] | 1435 | |
Ben Widawsky | 78325f2 | 2014-04-29 14:52:29 -0700 | [diff] [blame] | 1436 | intel_ring_emit(signaller, MI_LOAD_REGISTER_IMM(1)); |
Ville Syrjälä | f92a916 | 2015-11-04 23:20:07 +0200 | [diff] [blame] | 1437 | intel_ring_emit_reg(signaller, mbox_reg); |
John Harrison | 6259cea | 2014-11-24 18:49:29 +0000 | [diff] [blame] | 1438 | intel_ring_emit(signaller, seqno); |
Ben Widawsky | 78325f2 | 2014-04-29 14:52:29 -0700 | [diff] [blame] | 1439 | } |
| 1440 | } |
Ben Widawsky | 024a43e | 2014-04-29 14:52:30 -0700 | [diff] [blame] | 1441 | |
Ben Widawsky | a1444b7 | 2014-06-30 09:53:35 -0700 | [diff] [blame] | 1442 | /* If num_dwords was rounded, make sure the tail pointer is correct */ |
| 1443 | if (num_rings % 2 == 0) |
| 1444 | intel_ring_emit(signaller, MI_NOOP); |
| 1445 | |
Ben Widawsky | 024a43e | 2014-04-29 14:52:30 -0700 | [diff] [blame] | 1446 | return 0; |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 1447 | } |
| 1448 | |
Ben Widawsky | c8c99b0 | 2011-09-14 20:32:47 -0700 | [diff] [blame] | 1449 | /** |
| 1450 | * gen6_add_request - Update the semaphore mailbox registers |
John Harrison | ee044a8 | 2015-05-29 17:44:00 +0100 | [diff] [blame] | 1451 | * |
| 1452 | * @request - request to write to the ring |
Ben Widawsky | c8c99b0 | 2011-09-14 20:32:47 -0700 | [diff] [blame] | 1453 | * |
| 1454 | * Update the mailbox registers in the *other* rings with the current seqno. |
| 1455 | * This acts like a signal in the canonical semaphore. |
| 1456 | */ |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 1457 | static int |
John Harrison | ee044a8 | 2015-05-29 17:44:00 +0100 | [diff] [blame] | 1458 | gen6_add_request(struct drm_i915_gem_request *req) |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 1459 | { |
Tvrtko Ursulin | 4a570db | 2016-03-16 11:00:38 +0000 | [diff] [blame] | 1460 | struct intel_engine_cs *engine = req->engine; |
Ben Widawsky | 024a43e | 2014-04-29 14:52:30 -0700 | [diff] [blame] | 1461 | int ret; |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 1462 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1463 | if (engine->semaphore.signal) |
| 1464 | ret = engine->semaphore.signal(req, 4); |
Ben Widawsky | 707d9cf | 2014-06-30 09:53:36 -0700 | [diff] [blame] | 1465 | else |
John Harrison | 5fb9de1 | 2015-05-29 17:44:07 +0100 | [diff] [blame] | 1466 | ret = intel_ring_begin(req, 4); |
Ben Widawsky | 707d9cf | 2014-06-30 09:53:36 -0700 | [diff] [blame] | 1467 | |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 1468 | if (ret) |
| 1469 | return ret; |
| 1470 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1471 | intel_ring_emit(engine, MI_STORE_DWORD_INDEX); |
| 1472 | intel_ring_emit(engine, |
| 1473 | I915_GEM_HWS_INDEX << MI_STORE_DWORD_INDEX_SHIFT); |
| 1474 | intel_ring_emit(engine, i915_gem_request_get_seqno(req)); |
| 1475 | intel_ring_emit(engine, MI_USER_INTERRUPT); |
| 1476 | __intel_ring_advance(engine); |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 1477 | |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 1478 | return 0; |
| 1479 | } |
| 1480 | |
Chris Wilson | a58c01a | 2016-04-29 13:18:21 +0100 | [diff] [blame] | 1481 | static int |
| 1482 | gen8_render_add_request(struct drm_i915_gem_request *req) |
| 1483 | { |
| 1484 | struct intel_engine_cs *engine = req->engine; |
| 1485 | int ret; |
| 1486 | |
| 1487 | if (engine->semaphore.signal) |
| 1488 | ret = engine->semaphore.signal(req, 8); |
| 1489 | else |
| 1490 | ret = intel_ring_begin(req, 8); |
| 1491 | if (ret) |
| 1492 | return ret; |
| 1493 | |
| 1494 | intel_ring_emit(engine, GFX_OP_PIPE_CONTROL(6)); |
| 1495 | intel_ring_emit(engine, (PIPE_CONTROL_GLOBAL_GTT_IVB | |
| 1496 | PIPE_CONTROL_CS_STALL | |
| 1497 | PIPE_CONTROL_QW_WRITE)); |
| 1498 | intel_ring_emit(engine, intel_hws_seqno_address(req->engine)); |
| 1499 | intel_ring_emit(engine, 0); |
| 1500 | intel_ring_emit(engine, i915_gem_request_get_seqno(req)); |
| 1501 | /* We're thrashing one dword of HWS. */ |
| 1502 | intel_ring_emit(engine, 0); |
| 1503 | intel_ring_emit(engine, MI_USER_INTERRUPT); |
| 1504 | intel_ring_emit(engine, MI_NOOP); |
| 1505 | __intel_ring_advance(engine); |
| 1506 | |
| 1507 | return 0; |
| 1508 | } |
| 1509 | |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1510 | static inline bool i915_gem_has_seqno_wrapped(struct drm_i915_private *dev_priv, |
Mika Kuoppala | f72b343 | 2012-12-10 15:41:48 +0200 | [diff] [blame] | 1511 | u32 seqno) |
| 1512 | { |
Mika Kuoppala | f72b343 | 2012-12-10 15:41:48 +0200 | [diff] [blame] | 1513 | return dev_priv->last_seqno < seqno; |
| 1514 | } |
| 1515 | |
Ben Widawsky | c8c99b0 | 2011-09-14 20:32:47 -0700 | [diff] [blame] | 1516 | /** |
| 1517 | * intel_ring_sync - sync the waiter to the signaller on seqno |
| 1518 | * |
| 1519 | * @waiter - ring that is waiting |
| 1520 | * @signaller - ring which has, or will signal |
| 1521 | * @seqno - seqno which the waiter will block on |
| 1522 | */ |
Ben Widawsky | 5ee426c | 2014-06-30 09:53:38 -0700 | [diff] [blame] | 1523 | |
| 1524 | static int |
John Harrison | 599d924 | 2015-05-29 17:44:04 +0100 | [diff] [blame] | 1525 | gen8_ring_sync(struct drm_i915_gem_request *waiter_req, |
Ben Widawsky | 5ee426c | 2014-06-30 09:53:38 -0700 | [diff] [blame] | 1526 | struct intel_engine_cs *signaller, |
| 1527 | u32 seqno) |
| 1528 | { |
Tvrtko Ursulin | 4a570db | 2016-03-16 11:00:38 +0000 | [diff] [blame] | 1529 | struct intel_engine_cs *waiter = waiter_req->engine; |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1530 | struct drm_i915_private *dev_priv = waiter_req->i915; |
Chris Wilson | 6ef48d7 | 2016-04-29 13:18:25 +0100 | [diff] [blame] | 1531 | struct i915_hw_ppgtt *ppgtt; |
Ben Widawsky | 5ee426c | 2014-06-30 09:53:38 -0700 | [diff] [blame] | 1532 | int ret; |
| 1533 | |
John Harrison | 5fb9de1 | 2015-05-29 17:44:07 +0100 | [diff] [blame] | 1534 | ret = intel_ring_begin(waiter_req, 4); |
Ben Widawsky | 5ee426c | 2014-06-30 09:53:38 -0700 | [diff] [blame] | 1535 | if (ret) |
| 1536 | return ret; |
| 1537 | |
| 1538 | intel_ring_emit(waiter, MI_SEMAPHORE_WAIT | |
| 1539 | MI_SEMAPHORE_GLOBAL_GTT | |
| 1540 | MI_SEMAPHORE_SAD_GTE_SDD); |
| 1541 | intel_ring_emit(waiter, seqno); |
| 1542 | intel_ring_emit(waiter, |
| 1543 | lower_32_bits(GEN8_WAIT_OFFSET(waiter, signaller->id))); |
| 1544 | intel_ring_emit(waiter, |
| 1545 | upper_32_bits(GEN8_WAIT_OFFSET(waiter, signaller->id))); |
| 1546 | intel_ring_advance(waiter); |
Chris Wilson | 6ef48d7 | 2016-04-29 13:18:25 +0100 | [diff] [blame] | 1547 | |
| 1548 | /* When the !RCS engines idle waiting upon a semaphore, they lose their |
| 1549 | * pagetables and we must reload them before executing the batch. |
| 1550 | * We do this on the i915_switch_context() following the wait and |
| 1551 | * before the dispatch. |
| 1552 | */ |
| 1553 | ppgtt = waiter_req->ctx->ppgtt; |
| 1554 | if (ppgtt && waiter_req->engine->id != RCS) |
| 1555 | ppgtt->pd_dirty_rings |= intel_engine_flag(waiter_req->engine); |
Ben Widawsky | 5ee426c | 2014-06-30 09:53:38 -0700 | [diff] [blame] | 1556 | return 0; |
| 1557 | } |
| 1558 | |
Ben Widawsky | c8c99b0 | 2011-09-14 20:32:47 -0700 | [diff] [blame] | 1559 | static int |
John Harrison | 599d924 | 2015-05-29 17:44:04 +0100 | [diff] [blame] | 1560 | gen6_ring_sync(struct drm_i915_gem_request *waiter_req, |
Oscar Mateo | a4872ba | 2014-05-22 14:13:33 +0100 | [diff] [blame] | 1561 | struct intel_engine_cs *signaller, |
Daniel Vetter | 686cb5f | 2012-04-11 22:12:52 +0200 | [diff] [blame] | 1562 | u32 seqno) |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 1563 | { |
Tvrtko Ursulin | 4a570db | 2016-03-16 11:00:38 +0000 | [diff] [blame] | 1564 | struct intel_engine_cs *waiter = waiter_req->engine; |
Ben Widawsky | c8c99b0 | 2011-09-14 20:32:47 -0700 | [diff] [blame] | 1565 | u32 dw1 = MI_SEMAPHORE_MBOX | |
| 1566 | MI_SEMAPHORE_COMPARE | |
| 1567 | MI_SEMAPHORE_REGISTER; |
Ben Widawsky | ebc348b | 2014-04-29 14:52:28 -0700 | [diff] [blame] | 1568 | u32 wait_mbox = signaller->semaphore.mbox.wait[waiter->id]; |
| 1569 | int ret; |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 1570 | |
Ben Widawsky | 1500f7e | 2012-04-11 11:18:21 -0700 | [diff] [blame] | 1571 | /* Throughout all of the GEM code, seqno passed implies our current |
| 1572 | * seqno is >= the last seqno executed. However for hardware the |
| 1573 | * comparison is strictly greater than. |
| 1574 | */ |
| 1575 | seqno -= 1; |
| 1576 | |
Ben Widawsky | ebc348b | 2014-04-29 14:52:28 -0700 | [diff] [blame] | 1577 | WARN_ON(wait_mbox == MI_SEMAPHORE_SYNC_INVALID); |
Daniel Vetter | 686cb5f | 2012-04-11 22:12:52 +0200 | [diff] [blame] | 1578 | |
John Harrison | 5fb9de1 | 2015-05-29 17:44:07 +0100 | [diff] [blame] | 1579 | ret = intel_ring_begin(waiter_req, 4); |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 1580 | if (ret) |
| 1581 | return ret; |
| 1582 | |
Mika Kuoppala | f72b343 | 2012-12-10 15:41:48 +0200 | [diff] [blame] | 1583 | /* If seqno wrap happened, omit the wait with no-ops */ |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1584 | if (likely(!i915_gem_has_seqno_wrapped(waiter_req->i915, seqno))) { |
Ben Widawsky | ebc348b | 2014-04-29 14:52:28 -0700 | [diff] [blame] | 1585 | intel_ring_emit(waiter, dw1 | wait_mbox); |
Mika Kuoppala | f72b343 | 2012-12-10 15:41:48 +0200 | [diff] [blame] | 1586 | intel_ring_emit(waiter, seqno); |
| 1587 | intel_ring_emit(waiter, 0); |
| 1588 | intel_ring_emit(waiter, MI_NOOP); |
| 1589 | } else { |
| 1590 | intel_ring_emit(waiter, MI_NOOP); |
| 1591 | intel_ring_emit(waiter, MI_NOOP); |
| 1592 | intel_ring_emit(waiter, MI_NOOP); |
| 1593 | intel_ring_emit(waiter, MI_NOOP); |
| 1594 | } |
Ben Widawsky | c8c99b0 | 2011-09-14 20:32:47 -0700 | [diff] [blame] | 1595 | intel_ring_advance(waiter); |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 1596 | |
| 1597 | return 0; |
| 1598 | } |
| 1599 | |
Chris Wilson | c6df541 | 2010-12-15 09:56:50 +0000 | [diff] [blame] | 1600 | #define PIPE_CONTROL_FLUSH(ring__, addr__) \ |
| 1601 | do { \ |
Kenneth Graunke | fcbc34e | 2011-10-11 23:41:08 +0200 | [diff] [blame] | 1602 | intel_ring_emit(ring__, GFX_OP_PIPE_CONTROL(4) | PIPE_CONTROL_QW_WRITE | \ |
| 1603 | PIPE_CONTROL_DEPTH_STALL); \ |
Chris Wilson | c6df541 | 2010-12-15 09:56:50 +0000 | [diff] [blame] | 1604 | intel_ring_emit(ring__, (addr__) | PIPE_CONTROL_GLOBAL_GTT); \ |
| 1605 | intel_ring_emit(ring__, 0); \ |
| 1606 | intel_ring_emit(ring__, 0); \ |
| 1607 | } while (0) |
| 1608 | |
| 1609 | static int |
John Harrison | ee044a8 | 2015-05-29 17:44:00 +0100 | [diff] [blame] | 1610 | pc_render_add_request(struct drm_i915_gem_request *req) |
Chris Wilson | c6df541 | 2010-12-15 09:56:50 +0000 | [diff] [blame] | 1611 | { |
Tvrtko Ursulin | 4a570db | 2016-03-16 11:00:38 +0000 | [diff] [blame] | 1612 | struct intel_engine_cs *engine = req->engine; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1613 | u32 scratch_addr = engine->scratch.gtt_offset + 2 * CACHELINE_BYTES; |
Chris Wilson | c6df541 | 2010-12-15 09:56:50 +0000 | [diff] [blame] | 1614 | int ret; |
| 1615 | |
| 1616 | /* For Ironlake, MI_USER_INTERRUPT was deprecated and apparently |
| 1617 | * incoherent with writes to memory, i.e. completely fubar, |
| 1618 | * so we need to use PIPE_NOTIFY instead. |
| 1619 | * |
| 1620 | * However, we also need to workaround the qword write |
| 1621 | * incoherence by flushing the 6 PIPE_NOTIFY buffers out to |
| 1622 | * memory before requesting an interrupt. |
| 1623 | */ |
John Harrison | 5fb9de1 | 2015-05-29 17:44:07 +0100 | [diff] [blame] | 1624 | ret = intel_ring_begin(req, 32); |
Chris Wilson | c6df541 | 2010-12-15 09:56:50 +0000 | [diff] [blame] | 1625 | if (ret) |
| 1626 | return ret; |
| 1627 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1628 | intel_ring_emit(engine, |
| 1629 | GFX_OP_PIPE_CONTROL(4) | PIPE_CONTROL_QW_WRITE | |
Kenneth Graunke | 9d971b3 | 2011-10-11 23:41:09 +0200 | [diff] [blame] | 1630 | PIPE_CONTROL_WRITE_FLUSH | |
| 1631 | PIPE_CONTROL_TEXTURE_CACHE_INVALIDATE); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1632 | intel_ring_emit(engine, |
| 1633 | engine->scratch.gtt_offset | PIPE_CONTROL_GLOBAL_GTT); |
| 1634 | intel_ring_emit(engine, i915_gem_request_get_seqno(req)); |
| 1635 | intel_ring_emit(engine, 0); |
| 1636 | PIPE_CONTROL_FLUSH(engine, scratch_addr); |
Chris Wilson | 18393f6 | 2014-04-09 09:19:40 +0100 | [diff] [blame] | 1637 | scratch_addr += 2 * CACHELINE_BYTES; /* write to separate cachelines */ |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1638 | PIPE_CONTROL_FLUSH(engine, scratch_addr); |
Chris Wilson | 18393f6 | 2014-04-09 09:19:40 +0100 | [diff] [blame] | 1639 | scratch_addr += 2 * CACHELINE_BYTES; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1640 | PIPE_CONTROL_FLUSH(engine, scratch_addr); |
Chris Wilson | 18393f6 | 2014-04-09 09:19:40 +0100 | [diff] [blame] | 1641 | scratch_addr += 2 * CACHELINE_BYTES; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1642 | PIPE_CONTROL_FLUSH(engine, scratch_addr); |
Chris Wilson | 18393f6 | 2014-04-09 09:19:40 +0100 | [diff] [blame] | 1643 | scratch_addr += 2 * CACHELINE_BYTES; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1644 | PIPE_CONTROL_FLUSH(engine, scratch_addr); |
Chris Wilson | 18393f6 | 2014-04-09 09:19:40 +0100 | [diff] [blame] | 1645 | scratch_addr += 2 * CACHELINE_BYTES; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1646 | PIPE_CONTROL_FLUSH(engine, scratch_addr); |
Chris Wilson | a71d8d9 | 2012-02-15 11:25:36 +0000 | [diff] [blame] | 1647 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1648 | intel_ring_emit(engine, |
| 1649 | GFX_OP_PIPE_CONTROL(4) | PIPE_CONTROL_QW_WRITE | |
Kenneth Graunke | 9d971b3 | 2011-10-11 23:41:09 +0200 | [diff] [blame] | 1650 | PIPE_CONTROL_WRITE_FLUSH | |
| 1651 | PIPE_CONTROL_TEXTURE_CACHE_INVALIDATE | |
Chris Wilson | c6df541 | 2010-12-15 09:56:50 +0000 | [diff] [blame] | 1652 | PIPE_CONTROL_NOTIFY); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1653 | intel_ring_emit(engine, |
| 1654 | engine->scratch.gtt_offset | PIPE_CONTROL_GLOBAL_GTT); |
| 1655 | intel_ring_emit(engine, i915_gem_request_get_seqno(req)); |
| 1656 | intel_ring_emit(engine, 0); |
| 1657 | __intel_ring_advance(engine); |
Chris Wilson | c6df541 | 2010-12-15 09:56:50 +0000 | [diff] [blame] | 1658 | |
Chris Wilson | c6df541 | 2010-12-15 09:56:50 +0000 | [diff] [blame] | 1659 | return 0; |
| 1660 | } |
| 1661 | |
Chris Wilson | c04e0f3 | 2016-04-09 10:57:54 +0100 | [diff] [blame] | 1662 | static void |
| 1663 | gen6_seqno_barrier(struct intel_engine_cs *engine) |
Daniel Vetter | 4cd53c0 | 2012-12-14 16:01:25 +0100 | [diff] [blame] | 1664 | { |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1665 | struct drm_i915_private *dev_priv = engine->i915; |
Chris Wilson | bcbdb6d | 2016-04-27 09:02:01 +0100 | [diff] [blame] | 1666 | |
Daniel Vetter | 4cd53c0 | 2012-12-14 16:01:25 +0100 | [diff] [blame] | 1667 | /* Workaround to force correct ordering between irq and seqno writes on |
| 1668 | * ivb (and maybe also on snb) by reading from a CS register (like |
Chris Wilson | 9b9ed30 | 2016-04-09 10:57:53 +0100 | [diff] [blame] | 1669 | * ACTHD) before reading the status page. |
| 1670 | * |
| 1671 | * Note that this effectively stalls the read by the time it takes to |
| 1672 | * do a memory transaction, which more or less ensures that the write |
| 1673 | * from the GPU has sufficient time to invalidate the CPU cacheline. |
| 1674 | * Alternatively we could delay the interrupt from the CS ring to give |
| 1675 | * the write time to land, but that would incur a delay after every |
| 1676 | * batch i.e. much more frequent than a delay when waiting for the |
| 1677 | * interrupt (with the same net latency). |
Chris Wilson | bcbdb6d | 2016-04-27 09:02:01 +0100 | [diff] [blame] | 1678 | * |
| 1679 | * Also note that to prevent whole machine hangs on gen7, we have to |
| 1680 | * take the spinlock to guard against concurrent cacheline access. |
Chris Wilson | 9b9ed30 | 2016-04-09 10:57:53 +0100 | [diff] [blame] | 1681 | */ |
Chris Wilson | bcbdb6d | 2016-04-27 09:02:01 +0100 | [diff] [blame] | 1682 | spin_lock_irq(&dev_priv->uncore.lock); |
Chris Wilson | c04e0f3 | 2016-04-09 10:57:54 +0100 | [diff] [blame] | 1683 | POSTING_READ_FW(RING_ACTHD(engine->mmio_base)); |
Chris Wilson | bcbdb6d | 2016-04-27 09:02:01 +0100 | [diff] [blame] | 1684 | spin_unlock_irq(&dev_priv->uncore.lock); |
Daniel Vetter | 4cd53c0 | 2012-12-14 16:01:25 +0100 | [diff] [blame] | 1685 | } |
| 1686 | |
| 1687 | static u32 |
Chris Wilson | c04e0f3 | 2016-04-09 10:57:54 +0100 | [diff] [blame] | 1688 | ring_get_seqno(struct intel_engine_cs *engine) |
Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 1689 | { |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1690 | return intel_read_status_page(engine, I915_GEM_HWS_INDEX); |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 1691 | } |
| 1692 | |
Mika Kuoppala | b70ec5b | 2012-12-19 11:13:05 +0200 | [diff] [blame] | 1693 | static void |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1694 | ring_set_seqno(struct intel_engine_cs *engine, u32 seqno) |
Mika Kuoppala | b70ec5b | 2012-12-19 11:13:05 +0200 | [diff] [blame] | 1695 | { |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1696 | intel_write_status_page(engine, I915_GEM_HWS_INDEX, seqno); |
Mika Kuoppala | b70ec5b | 2012-12-19 11:13:05 +0200 | [diff] [blame] | 1697 | } |
| 1698 | |
Chris Wilson | c6df541 | 2010-12-15 09:56:50 +0000 | [diff] [blame] | 1699 | static u32 |
Chris Wilson | c04e0f3 | 2016-04-09 10:57:54 +0100 | [diff] [blame] | 1700 | pc_render_get_seqno(struct intel_engine_cs *engine) |
Chris Wilson | c6df541 | 2010-12-15 09:56:50 +0000 | [diff] [blame] | 1701 | { |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1702 | return engine->scratch.cpu_page[0]; |
Chris Wilson | c6df541 | 2010-12-15 09:56:50 +0000 | [diff] [blame] | 1703 | } |
| 1704 | |
Mika Kuoppala | b70ec5b | 2012-12-19 11:13:05 +0200 | [diff] [blame] | 1705 | static void |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1706 | pc_render_set_seqno(struct intel_engine_cs *engine, u32 seqno) |
Mika Kuoppala | b70ec5b | 2012-12-19 11:13:05 +0200 | [diff] [blame] | 1707 | { |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1708 | engine->scratch.cpu_page[0] = seqno; |
Mika Kuoppala | b70ec5b | 2012-12-19 11:13:05 +0200 | [diff] [blame] | 1709 | } |
| 1710 | |
Chris Wilson | b13c2b9 | 2010-12-13 16:54:50 +0000 | [diff] [blame] | 1711 | static bool |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1712 | gen5_ring_get_irq(struct intel_engine_cs *engine) |
Daniel Vetter | e48d863 | 2012-04-11 22:12:54 +0200 | [diff] [blame] | 1713 | { |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1714 | struct drm_i915_private *dev_priv = engine->i915; |
Chris Wilson | 7338aef | 2012-04-24 21:48:47 +0100 | [diff] [blame] | 1715 | unsigned long flags; |
Daniel Vetter | e48d863 | 2012-04-11 22:12:54 +0200 | [diff] [blame] | 1716 | |
Daniel Vetter | 7cd512f | 2014-09-15 11:38:57 +0200 | [diff] [blame] | 1717 | if (WARN_ON(!intel_irqs_enabled(dev_priv))) |
Daniel Vetter | e48d863 | 2012-04-11 22:12:54 +0200 | [diff] [blame] | 1718 | return false; |
| 1719 | |
Chris Wilson | 7338aef | 2012-04-24 21:48:47 +0100 | [diff] [blame] | 1720 | spin_lock_irqsave(&dev_priv->irq_lock, flags); |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1721 | if (engine->irq_refcount++ == 0) |
| 1722 | gen5_enable_gt_irq(dev_priv, engine->irq_enable_mask); |
Chris Wilson | 7338aef | 2012-04-24 21:48:47 +0100 | [diff] [blame] | 1723 | spin_unlock_irqrestore(&dev_priv->irq_lock, flags); |
Daniel Vetter | e48d863 | 2012-04-11 22:12:54 +0200 | [diff] [blame] | 1724 | |
| 1725 | return true; |
| 1726 | } |
| 1727 | |
| 1728 | static void |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1729 | gen5_ring_put_irq(struct intel_engine_cs *engine) |
Daniel Vetter | e48d863 | 2012-04-11 22:12:54 +0200 | [diff] [blame] | 1730 | { |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1731 | struct drm_i915_private *dev_priv = engine->i915; |
Chris Wilson | 7338aef | 2012-04-24 21:48:47 +0100 | [diff] [blame] | 1732 | unsigned long flags; |
Daniel Vetter | e48d863 | 2012-04-11 22:12:54 +0200 | [diff] [blame] | 1733 | |
Chris Wilson | 7338aef | 2012-04-24 21:48:47 +0100 | [diff] [blame] | 1734 | spin_lock_irqsave(&dev_priv->irq_lock, flags); |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1735 | if (--engine->irq_refcount == 0) |
| 1736 | gen5_disable_gt_irq(dev_priv, engine->irq_enable_mask); |
Chris Wilson | 7338aef | 2012-04-24 21:48:47 +0100 | [diff] [blame] | 1737 | spin_unlock_irqrestore(&dev_priv->irq_lock, flags); |
Daniel Vetter | e48d863 | 2012-04-11 22:12:54 +0200 | [diff] [blame] | 1738 | } |
| 1739 | |
| 1740 | static bool |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1741 | i9xx_ring_get_irq(struct intel_engine_cs *engine) |
Eric Anholt | 62fdfea | 2010-05-21 13:26:39 -0700 | [diff] [blame] | 1742 | { |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1743 | struct drm_i915_private *dev_priv = engine->i915; |
Chris Wilson | 7338aef | 2012-04-24 21:48:47 +0100 | [diff] [blame] | 1744 | unsigned long flags; |
Eric Anholt | 62fdfea | 2010-05-21 13:26:39 -0700 | [diff] [blame] | 1745 | |
Daniel Vetter | 7cd512f | 2014-09-15 11:38:57 +0200 | [diff] [blame] | 1746 | if (!intel_irqs_enabled(dev_priv)) |
Chris Wilson | b13c2b9 | 2010-12-13 16:54:50 +0000 | [diff] [blame] | 1747 | return false; |
| 1748 | |
Chris Wilson | 7338aef | 2012-04-24 21:48:47 +0100 | [diff] [blame] | 1749 | spin_lock_irqsave(&dev_priv->irq_lock, flags); |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1750 | if (engine->irq_refcount++ == 0) { |
| 1751 | dev_priv->irq_mask &= ~engine->irq_enable_mask; |
Daniel Vetter | f637fde | 2012-04-11 22:12:59 +0200 | [diff] [blame] | 1752 | I915_WRITE(IMR, dev_priv->irq_mask); |
| 1753 | POSTING_READ(IMR); |
| 1754 | } |
Chris Wilson | 7338aef | 2012-04-24 21:48:47 +0100 | [diff] [blame] | 1755 | spin_unlock_irqrestore(&dev_priv->irq_lock, flags); |
Chris Wilson | b13c2b9 | 2010-12-13 16:54:50 +0000 | [diff] [blame] | 1756 | |
| 1757 | return true; |
Eric Anholt | 62fdfea | 2010-05-21 13:26:39 -0700 | [diff] [blame] | 1758 | } |
| 1759 | |
Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 1760 | static void |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1761 | i9xx_ring_put_irq(struct intel_engine_cs *engine) |
Eric Anholt | 62fdfea | 2010-05-21 13:26:39 -0700 | [diff] [blame] | 1762 | { |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1763 | struct drm_i915_private *dev_priv = engine->i915; |
Chris Wilson | 7338aef | 2012-04-24 21:48:47 +0100 | [diff] [blame] | 1764 | unsigned long flags; |
Eric Anholt | 62fdfea | 2010-05-21 13:26:39 -0700 | [diff] [blame] | 1765 | |
Chris Wilson | 7338aef | 2012-04-24 21:48:47 +0100 | [diff] [blame] | 1766 | spin_lock_irqsave(&dev_priv->irq_lock, flags); |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1767 | if (--engine->irq_refcount == 0) { |
| 1768 | dev_priv->irq_mask |= engine->irq_enable_mask; |
Daniel Vetter | f637fde | 2012-04-11 22:12:59 +0200 | [diff] [blame] | 1769 | I915_WRITE(IMR, dev_priv->irq_mask); |
| 1770 | POSTING_READ(IMR); |
| 1771 | } |
Chris Wilson | 7338aef | 2012-04-24 21:48:47 +0100 | [diff] [blame] | 1772 | spin_unlock_irqrestore(&dev_priv->irq_lock, flags); |
Eric Anholt | 62fdfea | 2010-05-21 13:26:39 -0700 | [diff] [blame] | 1773 | } |
| 1774 | |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 1775 | static bool |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1776 | i8xx_ring_get_irq(struct intel_engine_cs *engine) |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 1777 | { |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1778 | struct drm_i915_private *dev_priv = engine->i915; |
Chris Wilson | 7338aef | 2012-04-24 21:48:47 +0100 | [diff] [blame] | 1779 | unsigned long flags; |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 1780 | |
Daniel Vetter | 7cd512f | 2014-09-15 11:38:57 +0200 | [diff] [blame] | 1781 | if (!intel_irqs_enabled(dev_priv)) |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 1782 | return false; |
| 1783 | |
Chris Wilson | 7338aef | 2012-04-24 21:48:47 +0100 | [diff] [blame] | 1784 | spin_lock_irqsave(&dev_priv->irq_lock, flags); |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1785 | if (engine->irq_refcount++ == 0) { |
| 1786 | dev_priv->irq_mask &= ~engine->irq_enable_mask; |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 1787 | I915_WRITE16(IMR, dev_priv->irq_mask); |
| 1788 | POSTING_READ16(IMR); |
| 1789 | } |
Chris Wilson | 7338aef | 2012-04-24 21:48:47 +0100 | [diff] [blame] | 1790 | spin_unlock_irqrestore(&dev_priv->irq_lock, flags); |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 1791 | |
| 1792 | return true; |
| 1793 | } |
| 1794 | |
| 1795 | static void |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1796 | i8xx_ring_put_irq(struct intel_engine_cs *engine) |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 1797 | { |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1798 | struct drm_i915_private *dev_priv = engine->i915; |
Chris Wilson | 7338aef | 2012-04-24 21:48:47 +0100 | [diff] [blame] | 1799 | unsigned long flags; |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 1800 | |
Chris Wilson | 7338aef | 2012-04-24 21:48:47 +0100 | [diff] [blame] | 1801 | spin_lock_irqsave(&dev_priv->irq_lock, flags); |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1802 | if (--engine->irq_refcount == 0) { |
| 1803 | dev_priv->irq_mask |= engine->irq_enable_mask; |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 1804 | I915_WRITE16(IMR, dev_priv->irq_mask); |
| 1805 | POSTING_READ16(IMR); |
| 1806 | } |
Chris Wilson | 7338aef | 2012-04-24 21:48:47 +0100 | [diff] [blame] | 1807 | spin_unlock_irqrestore(&dev_priv->irq_lock, flags); |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 1808 | } |
| 1809 | |
Chris Wilson | b72f3ac | 2011-01-04 17:34:02 +0000 | [diff] [blame] | 1810 | static int |
John Harrison | a84c3ae | 2015-05-29 17:43:57 +0100 | [diff] [blame] | 1811 | bsd_ring_flush(struct drm_i915_gem_request *req, |
Chris Wilson | 78501ea | 2010-10-27 12:18:21 +0100 | [diff] [blame] | 1812 | u32 invalidate_domains, |
| 1813 | u32 flush_domains) |
Zou Nan hai | d1b851f | 2010-05-21 09:08:57 +0800 | [diff] [blame] | 1814 | { |
Tvrtko Ursulin | 4a570db | 2016-03-16 11:00:38 +0000 | [diff] [blame] | 1815 | struct intel_engine_cs *engine = req->engine; |
Chris Wilson | b72f3ac | 2011-01-04 17:34:02 +0000 | [diff] [blame] | 1816 | int ret; |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 1817 | |
John Harrison | 5fb9de1 | 2015-05-29 17:44:07 +0100 | [diff] [blame] | 1818 | ret = intel_ring_begin(req, 2); |
Chris Wilson | b72f3ac | 2011-01-04 17:34:02 +0000 | [diff] [blame] | 1819 | if (ret) |
| 1820 | return ret; |
| 1821 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1822 | intel_ring_emit(engine, MI_FLUSH); |
| 1823 | intel_ring_emit(engine, MI_NOOP); |
| 1824 | intel_ring_advance(engine); |
Chris Wilson | b72f3ac | 2011-01-04 17:34:02 +0000 | [diff] [blame] | 1825 | return 0; |
Zou Nan hai | d1b851f | 2010-05-21 09:08:57 +0800 | [diff] [blame] | 1826 | } |
| 1827 | |
Chris Wilson | 3cce469 | 2010-10-27 16:11:02 +0100 | [diff] [blame] | 1828 | static int |
John Harrison | ee044a8 | 2015-05-29 17:44:00 +0100 | [diff] [blame] | 1829 | i9xx_add_request(struct drm_i915_gem_request *req) |
Zou Nan hai | d1b851f | 2010-05-21 09:08:57 +0800 | [diff] [blame] | 1830 | { |
Tvrtko Ursulin | 4a570db | 2016-03-16 11:00:38 +0000 | [diff] [blame] | 1831 | struct intel_engine_cs *engine = req->engine; |
Chris Wilson | 3cce469 | 2010-10-27 16:11:02 +0100 | [diff] [blame] | 1832 | int ret; |
| 1833 | |
John Harrison | 5fb9de1 | 2015-05-29 17:44:07 +0100 | [diff] [blame] | 1834 | ret = intel_ring_begin(req, 4); |
Chris Wilson | 3cce469 | 2010-10-27 16:11:02 +0100 | [diff] [blame] | 1835 | if (ret) |
| 1836 | return ret; |
Chris Wilson | 6f392d5 | 2010-08-07 11:01:22 +0100 | [diff] [blame] | 1837 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1838 | intel_ring_emit(engine, MI_STORE_DWORD_INDEX); |
| 1839 | intel_ring_emit(engine, |
| 1840 | I915_GEM_HWS_INDEX << MI_STORE_DWORD_INDEX_SHIFT); |
| 1841 | intel_ring_emit(engine, i915_gem_request_get_seqno(req)); |
| 1842 | intel_ring_emit(engine, MI_USER_INTERRUPT); |
| 1843 | __intel_ring_advance(engine); |
Zou Nan hai | d1b851f | 2010-05-21 09:08:57 +0800 | [diff] [blame] | 1844 | |
Chris Wilson | 3cce469 | 2010-10-27 16:11:02 +0100 | [diff] [blame] | 1845 | return 0; |
Zou Nan hai | d1b851f | 2010-05-21 09:08:57 +0800 | [diff] [blame] | 1846 | } |
| 1847 | |
Chris Wilson | b13c2b9 | 2010-12-13 16:54:50 +0000 | [diff] [blame] | 1848 | static bool |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1849 | gen6_ring_get_irq(struct intel_engine_cs *engine) |
Chris Wilson | 0f46832 | 2011-01-04 17:35:21 +0000 | [diff] [blame] | 1850 | { |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1851 | struct drm_i915_private *dev_priv = engine->i915; |
Chris Wilson | 7338aef | 2012-04-24 21:48:47 +0100 | [diff] [blame] | 1852 | unsigned long flags; |
Chris Wilson | 0f46832 | 2011-01-04 17:35:21 +0000 | [diff] [blame] | 1853 | |
Daniel Vetter | 7cd512f | 2014-09-15 11:38:57 +0200 | [diff] [blame] | 1854 | if (WARN_ON(!intel_irqs_enabled(dev_priv))) |
| 1855 | return false; |
Chris Wilson | 0f46832 | 2011-01-04 17:35:21 +0000 | [diff] [blame] | 1856 | |
Chris Wilson | 7338aef | 2012-04-24 21:48:47 +0100 | [diff] [blame] | 1857 | spin_lock_irqsave(&dev_priv->irq_lock, flags); |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1858 | if (engine->irq_refcount++ == 0) { |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1859 | if (HAS_L3_DPF(dev_priv) && engine->id == RCS) |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1860 | I915_WRITE_IMR(engine, |
| 1861 | ~(engine->irq_enable_mask | |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1862 | GT_PARITY_ERROR(dev_priv))); |
Ben Widawsky | 15b9f80 | 2012-05-25 16:56:23 -0700 | [diff] [blame] | 1863 | else |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1864 | I915_WRITE_IMR(engine, ~engine->irq_enable_mask); |
| 1865 | gen5_enable_gt_irq(dev_priv, engine->irq_enable_mask); |
Chris Wilson | 0f46832 | 2011-01-04 17:35:21 +0000 | [diff] [blame] | 1866 | } |
Chris Wilson | 7338aef | 2012-04-24 21:48:47 +0100 | [diff] [blame] | 1867 | spin_unlock_irqrestore(&dev_priv->irq_lock, flags); |
Chris Wilson | 0f46832 | 2011-01-04 17:35:21 +0000 | [diff] [blame] | 1868 | |
| 1869 | return true; |
| 1870 | } |
| 1871 | |
| 1872 | static void |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1873 | gen6_ring_put_irq(struct intel_engine_cs *engine) |
Chris Wilson | 0f46832 | 2011-01-04 17:35:21 +0000 | [diff] [blame] | 1874 | { |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1875 | struct drm_i915_private *dev_priv = engine->i915; |
Chris Wilson | 7338aef | 2012-04-24 21:48:47 +0100 | [diff] [blame] | 1876 | unsigned long flags; |
Chris Wilson | 0f46832 | 2011-01-04 17:35:21 +0000 | [diff] [blame] | 1877 | |
Chris Wilson | 7338aef | 2012-04-24 21:48:47 +0100 | [diff] [blame] | 1878 | spin_lock_irqsave(&dev_priv->irq_lock, flags); |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1879 | if (--engine->irq_refcount == 0) { |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1880 | if (HAS_L3_DPF(dev_priv) && engine->id == RCS) |
| 1881 | I915_WRITE_IMR(engine, ~GT_PARITY_ERROR(dev_priv)); |
Ben Widawsky | 15b9f80 | 2012-05-25 16:56:23 -0700 | [diff] [blame] | 1882 | else |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1883 | I915_WRITE_IMR(engine, ~0); |
| 1884 | gen5_disable_gt_irq(dev_priv, engine->irq_enable_mask); |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 1885 | } |
Chris Wilson | 7338aef | 2012-04-24 21:48:47 +0100 | [diff] [blame] | 1886 | spin_unlock_irqrestore(&dev_priv->irq_lock, flags); |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 1887 | } |
| 1888 | |
Ben Widawsky | a19d293 | 2013-05-28 19:22:30 -0700 | [diff] [blame] | 1889 | static bool |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1890 | hsw_vebox_get_irq(struct intel_engine_cs *engine) |
Ben Widawsky | a19d293 | 2013-05-28 19:22:30 -0700 | [diff] [blame] | 1891 | { |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1892 | struct drm_i915_private *dev_priv = engine->i915; |
Ben Widawsky | a19d293 | 2013-05-28 19:22:30 -0700 | [diff] [blame] | 1893 | unsigned long flags; |
| 1894 | |
Daniel Vetter | 7cd512f | 2014-09-15 11:38:57 +0200 | [diff] [blame] | 1895 | if (WARN_ON(!intel_irqs_enabled(dev_priv))) |
Ben Widawsky | a19d293 | 2013-05-28 19:22:30 -0700 | [diff] [blame] | 1896 | return false; |
| 1897 | |
Daniel Vetter | 59cdb63 | 2013-07-04 23:35:28 +0200 | [diff] [blame] | 1898 | spin_lock_irqsave(&dev_priv->irq_lock, flags); |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1899 | if (engine->irq_refcount++ == 0) { |
| 1900 | I915_WRITE_IMR(engine, ~engine->irq_enable_mask); |
| 1901 | gen6_enable_pm_irq(dev_priv, engine->irq_enable_mask); |
Ben Widawsky | a19d293 | 2013-05-28 19:22:30 -0700 | [diff] [blame] | 1902 | } |
Daniel Vetter | 59cdb63 | 2013-07-04 23:35:28 +0200 | [diff] [blame] | 1903 | spin_unlock_irqrestore(&dev_priv->irq_lock, flags); |
Ben Widawsky | a19d293 | 2013-05-28 19:22:30 -0700 | [diff] [blame] | 1904 | |
| 1905 | return true; |
| 1906 | } |
| 1907 | |
| 1908 | static void |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1909 | hsw_vebox_put_irq(struct intel_engine_cs *engine) |
Ben Widawsky | a19d293 | 2013-05-28 19:22:30 -0700 | [diff] [blame] | 1910 | { |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1911 | struct drm_i915_private *dev_priv = engine->i915; |
Ben Widawsky | a19d293 | 2013-05-28 19:22:30 -0700 | [diff] [blame] | 1912 | unsigned long flags; |
| 1913 | |
Daniel Vetter | 59cdb63 | 2013-07-04 23:35:28 +0200 | [diff] [blame] | 1914 | spin_lock_irqsave(&dev_priv->irq_lock, flags); |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1915 | if (--engine->irq_refcount == 0) { |
| 1916 | I915_WRITE_IMR(engine, ~0); |
| 1917 | gen6_disable_pm_irq(dev_priv, engine->irq_enable_mask); |
Ben Widawsky | a19d293 | 2013-05-28 19:22:30 -0700 | [diff] [blame] | 1918 | } |
Daniel Vetter | 59cdb63 | 2013-07-04 23:35:28 +0200 | [diff] [blame] | 1919 | spin_unlock_irqrestore(&dev_priv->irq_lock, flags); |
Ben Widawsky | a19d293 | 2013-05-28 19:22:30 -0700 | [diff] [blame] | 1920 | } |
| 1921 | |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 1922 | static bool |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1923 | gen8_ring_get_irq(struct intel_engine_cs *engine) |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 1924 | { |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1925 | struct drm_i915_private *dev_priv = engine->i915; |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 1926 | unsigned long flags; |
| 1927 | |
Daniel Vetter | 7cd512f | 2014-09-15 11:38:57 +0200 | [diff] [blame] | 1928 | if (WARN_ON(!intel_irqs_enabled(dev_priv))) |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 1929 | return false; |
| 1930 | |
| 1931 | spin_lock_irqsave(&dev_priv->irq_lock, flags); |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1932 | if (engine->irq_refcount++ == 0) { |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1933 | if (HAS_L3_DPF(dev_priv) && engine->id == RCS) { |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1934 | I915_WRITE_IMR(engine, |
| 1935 | ~(engine->irq_enable_mask | |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 1936 | GT_RENDER_L3_PARITY_ERROR_INTERRUPT)); |
| 1937 | } else { |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1938 | I915_WRITE_IMR(engine, ~engine->irq_enable_mask); |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 1939 | } |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1940 | POSTING_READ(RING_IMR(engine->mmio_base)); |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 1941 | } |
| 1942 | spin_unlock_irqrestore(&dev_priv->irq_lock, flags); |
| 1943 | |
| 1944 | return true; |
| 1945 | } |
| 1946 | |
| 1947 | static void |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1948 | gen8_ring_put_irq(struct intel_engine_cs *engine) |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 1949 | { |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1950 | struct drm_i915_private *dev_priv = engine->i915; |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 1951 | unsigned long flags; |
| 1952 | |
| 1953 | spin_lock_irqsave(&dev_priv->irq_lock, flags); |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1954 | if (--engine->irq_refcount == 0) { |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 1955 | if (HAS_L3_DPF(dev_priv) && engine->id == RCS) { |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1956 | I915_WRITE_IMR(engine, |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 1957 | ~GT_RENDER_L3_PARITY_ERROR_INTERRUPT); |
| 1958 | } else { |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1959 | I915_WRITE_IMR(engine, ~0); |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 1960 | } |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 1961 | POSTING_READ(RING_IMR(engine->mmio_base)); |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 1962 | } |
| 1963 | spin_unlock_irqrestore(&dev_priv->irq_lock, flags); |
| 1964 | } |
| 1965 | |
Zou Nan hai | d1b851f | 2010-05-21 09:08:57 +0800 | [diff] [blame] | 1966 | static int |
John Harrison | 53fddaf | 2015-05-29 17:44:02 +0100 | [diff] [blame] | 1967 | i965_dispatch_execbuffer(struct drm_i915_gem_request *req, |
Ben Widawsky | 9bcb144 | 2014-04-28 19:29:25 -0700 | [diff] [blame] | 1968 | u64 offset, u32 length, |
John Harrison | 8e004ef | 2015-02-13 11:48:10 +0000 | [diff] [blame] | 1969 | unsigned dispatch_flags) |
Zou Nan hai | d1b851f | 2010-05-21 09:08:57 +0800 | [diff] [blame] | 1970 | { |
Tvrtko Ursulin | 4a570db | 2016-03-16 11:00:38 +0000 | [diff] [blame] | 1971 | struct intel_engine_cs *engine = req->engine; |
Chris Wilson | e1f99ce | 2010-10-27 12:45:26 +0100 | [diff] [blame] | 1972 | int ret; |
Chris Wilson | 78501ea | 2010-10-27 12:18:21 +0100 | [diff] [blame] | 1973 | |
John Harrison | 5fb9de1 | 2015-05-29 17:44:07 +0100 | [diff] [blame] | 1974 | ret = intel_ring_begin(req, 2); |
Chris Wilson | e1f99ce | 2010-10-27 12:45:26 +0100 | [diff] [blame] | 1975 | if (ret) |
| 1976 | return ret; |
| 1977 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1978 | intel_ring_emit(engine, |
Chris Wilson | 65f5687 | 2012-04-17 16:38:12 +0100 | [diff] [blame] | 1979 | MI_BATCH_BUFFER_START | |
| 1980 | MI_BATCH_GTT | |
John Harrison | 8e004ef | 2015-02-13 11:48:10 +0000 | [diff] [blame] | 1981 | (dispatch_flags & I915_DISPATCH_SECURE ? |
| 1982 | 0 : MI_BATCH_NON_SECURE_I965)); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1983 | intel_ring_emit(engine, offset); |
| 1984 | intel_ring_advance(engine); |
Chris Wilson | 78501ea | 2010-10-27 12:18:21 +0100 | [diff] [blame] | 1985 | |
Zou Nan hai | d1b851f | 2010-05-21 09:08:57 +0800 | [diff] [blame] | 1986 | return 0; |
| 1987 | } |
| 1988 | |
Daniel Vetter | b45305f | 2012-12-17 16:21:27 +0100 | [diff] [blame] | 1989 | /* Just userspace ABI convention to limit the wa batch bo to a resonable size */ |
| 1990 | #define I830_BATCH_LIMIT (256*1024) |
Chris Wilson | c4d69da | 2014-09-08 14:25:41 +0100 | [diff] [blame] | 1991 | #define I830_TLB_ENTRIES (2) |
| 1992 | #define I830_WA_SIZE max(I830_TLB_ENTRIES*4096, I830_BATCH_LIMIT) |
Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 1993 | static int |
John Harrison | 53fddaf | 2015-05-29 17:44:02 +0100 | [diff] [blame] | 1994 | i830_dispatch_execbuffer(struct drm_i915_gem_request *req, |
John Harrison | 8e004ef | 2015-02-13 11:48:10 +0000 | [diff] [blame] | 1995 | u64 offset, u32 len, |
| 1996 | unsigned dispatch_flags) |
Eric Anholt | 62fdfea | 2010-05-21 13:26:39 -0700 | [diff] [blame] | 1997 | { |
Tvrtko Ursulin | 4a570db | 2016-03-16 11:00:38 +0000 | [diff] [blame] | 1998 | struct intel_engine_cs *engine = req->engine; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 1999 | u32 cs_offset = engine->scratch.gtt_offset; |
Chris Wilson | c4e7a41 | 2010-11-30 14:10:25 +0000 | [diff] [blame] | 2000 | int ret; |
Eric Anholt | 62fdfea | 2010-05-21 13:26:39 -0700 | [diff] [blame] | 2001 | |
John Harrison | 5fb9de1 | 2015-05-29 17:44:07 +0100 | [diff] [blame] | 2002 | ret = intel_ring_begin(req, 6); |
Chris Wilson | c4d69da | 2014-09-08 14:25:41 +0100 | [diff] [blame] | 2003 | if (ret) |
| 2004 | return ret; |
Eric Anholt | 62fdfea | 2010-05-21 13:26:39 -0700 | [diff] [blame] | 2005 | |
Chris Wilson | c4d69da | 2014-09-08 14:25:41 +0100 | [diff] [blame] | 2006 | /* Evict the invalid PTE TLBs */ |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2007 | intel_ring_emit(engine, COLOR_BLT_CMD | BLT_WRITE_RGBA); |
| 2008 | intel_ring_emit(engine, BLT_DEPTH_32 | BLT_ROP_COLOR_COPY | 4096); |
| 2009 | intel_ring_emit(engine, I830_TLB_ENTRIES << 16 | 4); /* load each page */ |
| 2010 | intel_ring_emit(engine, cs_offset); |
| 2011 | intel_ring_emit(engine, 0xdeadbeef); |
| 2012 | intel_ring_emit(engine, MI_NOOP); |
| 2013 | intel_ring_advance(engine); |
Daniel Vetter | b45305f | 2012-12-17 16:21:27 +0100 | [diff] [blame] | 2014 | |
John Harrison | 8e004ef | 2015-02-13 11:48:10 +0000 | [diff] [blame] | 2015 | if ((dispatch_flags & I915_DISPATCH_PINNED) == 0) { |
Daniel Vetter | b45305f | 2012-12-17 16:21:27 +0100 | [diff] [blame] | 2016 | if (len > I830_BATCH_LIMIT) |
| 2017 | return -ENOSPC; |
| 2018 | |
John Harrison | 5fb9de1 | 2015-05-29 17:44:07 +0100 | [diff] [blame] | 2019 | ret = intel_ring_begin(req, 6 + 2); |
Daniel Vetter | b45305f | 2012-12-17 16:21:27 +0100 | [diff] [blame] | 2020 | if (ret) |
| 2021 | return ret; |
Chris Wilson | c4d69da | 2014-09-08 14:25:41 +0100 | [diff] [blame] | 2022 | |
| 2023 | /* Blit the batch (which has now all relocs applied) to the |
| 2024 | * stable batch scratch bo area (so that the CS never |
| 2025 | * stumbles over its tlb invalidation bug) ... |
| 2026 | */ |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2027 | intel_ring_emit(engine, SRC_COPY_BLT_CMD | BLT_WRITE_RGBA); |
| 2028 | intel_ring_emit(engine, |
| 2029 | BLT_DEPTH_32 | BLT_ROP_SRC_COPY | 4096); |
| 2030 | intel_ring_emit(engine, DIV_ROUND_UP(len, 4096) << 16 | 4096); |
| 2031 | intel_ring_emit(engine, cs_offset); |
| 2032 | intel_ring_emit(engine, 4096); |
| 2033 | intel_ring_emit(engine, offset); |
Chris Wilson | c4d69da | 2014-09-08 14:25:41 +0100 | [diff] [blame] | 2034 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2035 | intel_ring_emit(engine, MI_FLUSH); |
| 2036 | intel_ring_emit(engine, MI_NOOP); |
| 2037 | intel_ring_advance(engine); |
Daniel Vetter | b45305f | 2012-12-17 16:21:27 +0100 | [diff] [blame] | 2038 | |
| 2039 | /* ... and execute it. */ |
Chris Wilson | c4d69da | 2014-09-08 14:25:41 +0100 | [diff] [blame] | 2040 | offset = cs_offset; |
Daniel Vetter | b45305f | 2012-12-17 16:21:27 +0100 | [diff] [blame] | 2041 | } |
Chris Wilson | e1f99ce | 2010-10-27 12:45:26 +0100 | [diff] [blame] | 2042 | |
Ville Syrjälä | 9d611c0 | 2015-12-14 18:23:49 +0200 | [diff] [blame] | 2043 | ret = intel_ring_begin(req, 2); |
Chris Wilson | c4d69da | 2014-09-08 14:25:41 +0100 | [diff] [blame] | 2044 | if (ret) |
| 2045 | return ret; |
| 2046 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2047 | intel_ring_emit(engine, MI_BATCH_BUFFER_START | MI_BATCH_GTT); |
| 2048 | intel_ring_emit(engine, offset | (dispatch_flags & I915_DISPATCH_SECURE ? |
| 2049 | 0 : MI_BATCH_NON_SECURE)); |
| 2050 | intel_ring_advance(engine); |
Chris Wilson | c4d69da | 2014-09-08 14:25:41 +0100 | [diff] [blame] | 2051 | |
Daniel Vetter | fb3256d | 2012-04-11 22:12:56 +0200 | [diff] [blame] | 2052 | return 0; |
| 2053 | } |
| 2054 | |
| 2055 | static int |
John Harrison | 53fddaf | 2015-05-29 17:44:02 +0100 | [diff] [blame] | 2056 | i915_dispatch_execbuffer(struct drm_i915_gem_request *req, |
Ben Widawsky | 9bcb144 | 2014-04-28 19:29:25 -0700 | [diff] [blame] | 2057 | u64 offset, u32 len, |
John Harrison | 8e004ef | 2015-02-13 11:48:10 +0000 | [diff] [blame] | 2058 | unsigned dispatch_flags) |
Daniel Vetter | fb3256d | 2012-04-11 22:12:56 +0200 | [diff] [blame] | 2059 | { |
Tvrtko Ursulin | 4a570db | 2016-03-16 11:00:38 +0000 | [diff] [blame] | 2060 | struct intel_engine_cs *engine = req->engine; |
Daniel Vetter | fb3256d | 2012-04-11 22:12:56 +0200 | [diff] [blame] | 2061 | int ret; |
| 2062 | |
John Harrison | 5fb9de1 | 2015-05-29 17:44:07 +0100 | [diff] [blame] | 2063 | ret = intel_ring_begin(req, 2); |
Daniel Vetter | fb3256d | 2012-04-11 22:12:56 +0200 | [diff] [blame] | 2064 | if (ret) |
| 2065 | return ret; |
| 2066 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2067 | intel_ring_emit(engine, MI_BATCH_BUFFER_START | MI_BATCH_GTT); |
| 2068 | intel_ring_emit(engine, offset | (dispatch_flags & I915_DISPATCH_SECURE ? |
| 2069 | 0 : MI_BATCH_NON_SECURE)); |
| 2070 | intel_ring_advance(engine); |
Eric Anholt | 62fdfea | 2010-05-21 13:26:39 -0700 | [diff] [blame] | 2071 | |
Eric Anholt | 62fdfea | 2010-05-21 13:26:39 -0700 | [diff] [blame] | 2072 | return 0; |
| 2073 | } |
| 2074 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 2075 | static void cleanup_phys_status_page(struct intel_engine_cs *engine) |
Ville Syrjälä | 7d3fdff | 2016-01-11 20:48:32 +0200 | [diff] [blame] | 2076 | { |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 2077 | struct drm_i915_private *dev_priv = engine->i915; |
Ville Syrjälä | 7d3fdff | 2016-01-11 20:48:32 +0200 | [diff] [blame] | 2078 | |
| 2079 | if (!dev_priv->status_page_dmah) |
| 2080 | return; |
| 2081 | |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 2082 | drm_pci_free(dev_priv->dev, dev_priv->status_page_dmah); |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 2083 | engine->status_page.page_addr = NULL; |
Ville Syrjälä | 7d3fdff | 2016-01-11 20:48:32 +0200 | [diff] [blame] | 2084 | } |
| 2085 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 2086 | static void cleanup_status_page(struct intel_engine_cs *engine) |
Eric Anholt | 62fdfea | 2010-05-21 13:26:39 -0700 | [diff] [blame] | 2087 | { |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 2088 | struct drm_i915_gem_object *obj; |
Eric Anholt | 62fdfea | 2010-05-21 13:26:39 -0700 | [diff] [blame] | 2089 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 2090 | obj = engine->status_page.obj; |
Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 2091 | if (obj == NULL) |
Eric Anholt | 62fdfea | 2010-05-21 13:26:39 -0700 | [diff] [blame] | 2092 | return; |
Eric Anholt | 62fdfea | 2010-05-21 13:26:39 -0700 | [diff] [blame] | 2093 | |
Chris Wilson | 9da3da6 | 2012-06-01 15:20:22 +0100 | [diff] [blame] | 2094 | kunmap(sg_page(obj->pages->sgl)); |
Ben Widawsky | d7f46fc | 2013-12-06 14:10:55 -0800 | [diff] [blame] | 2095 | i915_gem_object_ggtt_unpin(obj); |
Chris Wilson | 05394f3 | 2010-11-08 19:18:58 +0000 | [diff] [blame] | 2096 | drm_gem_object_unreference(&obj->base); |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 2097 | engine->status_page.obj = NULL; |
Eric Anholt | 62fdfea | 2010-05-21 13:26:39 -0700 | [diff] [blame] | 2098 | } |
| 2099 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 2100 | static int init_status_page(struct intel_engine_cs *engine) |
Eric Anholt | 62fdfea | 2010-05-21 13:26:39 -0700 | [diff] [blame] | 2101 | { |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 2102 | struct drm_i915_gem_object *obj = engine->status_page.obj; |
Eric Anholt | 62fdfea | 2010-05-21 13:26:39 -0700 | [diff] [blame] | 2103 | |
Ville Syrjälä | 7d3fdff | 2016-01-11 20:48:32 +0200 | [diff] [blame] | 2104 | if (obj == NULL) { |
Chris Wilson | 1f767e0 | 2014-07-03 17:33:03 -0400 | [diff] [blame] | 2105 | unsigned flags; |
Chris Wilson | e3efda4 | 2014-04-09 09:19:41 +0100 | [diff] [blame] | 2106 | int ret; |
| 2107 | |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 2108 | obj = i915_gem_object_create(engine->i915->dev, 4096); |
Chris Wilson | fe3db79 | 2016-04-25 13:32:13 +0100 | [diff] [blame] | 2109 | if (IS_ERR(obj)) { |
Chris Wilson | e3efda4 | 2014-04-09 09:19:41 +0100 | [diff] [blame] | 2110 | DRM_ERROR("Failed to allocate status page\n"); |
Chris Wilson | fe3db79 | 2016-04-25 13:32:13 +0100 | [diff] [blame] | 2111 | return PTR_ERR(obj); |
Chris Wilson | e3efda4 | 2014-04-09 09:19:41 +0100 | [diff] [blame] | 2112 | } |
| 2113 | |
| 2114 | ret = i915_gem_object_set_cache_level(obj, I915_CACHE_LLC); |
| 2115 | if (ret) |
| 2116 | goto err_unref; |
| 2117 | |
Chris Wilson | 1f767e0 | 2014-07-03 17:33:03 -0400 | [diff] [blame] | 2118 | flags = 0; |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 2119 | if (!HAS_LLC(engine->i915)) |
Chris Wilson | 1f767e0 | 2014-07-03 17:33:03 -0400 | [diff] [blame] | 2120 | /* On g33, we cannot place HWS above 256MiB, so |
| 2121 | * restrict its pinning to the low mappable arena. |
| 2122 | * Though this restriction is not documented for |
| 2123 | * gen4, gen5, or byt, they also behave similarly |
| 2124 | * and hang if the HWS is placed at the top of the |
| 2125 | * GTT. To generalise, it appears that all !llc |
| 2126 | * platforms have issues with us placing the HWS |
| 2127 | * above the mappable region (even though we never |
| 2128 | * actualy map it). |
| 2129 | */ |
| 2130 | flags |= PIN_MAPPABLE; |
| 2131 | ret = i915_gem_obj_ggtt_pin(obj, 4096, flags); |
Chris Wilson | e3efda4 | 2014-04-09 09:19:41 +0100 | [diff] [blame] | 2132 | if (ret) { |
| 2133 | err_unref: |
| 2134 | drm_gem_object_unreference(&obj->base); |
| 2135 | return ret; |
| 2136 | } |
| 2137 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 2138 | engine->status_page.obj = obj; |
Eric Anholt | 62fdfea | 2010-05-21 13:26:39 -0700 | [diff] [blame] | 2139 | } |
Chris Wilson | e4ffd17 | 2011-04-04 09:44:39 +0100 | [diff] [blame] | 2140 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 2141 | engine->status_page.gfx_addr = i915_gem_obj_ggtt_offset(obj); |
| 2142 | engine->status_page.page_addr = kmap(sg_page(obj->pages->sgl)); |
| 2143 | memset(engine->status_page.page_addr, 0, PAGE_SIZE); |
Eric Anholt | 62fdfea | 2010-05-21 13:26:39 -0700 | [diff] [blame] | 2144 | |
Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 2145 | DRM_DEBUG_DRIVER("%s hws offset: 0x%08x\n", |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 2146 | engine->name, engine->status_page.gfx_addr); |
Eric Anholt | 62fdfea | 2010-05-21 13:26:39 -0700 | [diff] [blame] | 2147 | |
| 2148 | return 0; |
Eric Anholt | 62fdfea | 2010-05-21 13:26:39 -0700 | [diff] [blame] | 2149 | } |
| 2150 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 2151 | static int init_phys_status_page(struct intel_engine_cs *engine) |
Chris Wilson | 6b8294a | 2012-11-16 11:43:20 +0000 | [diff] [blame] | 2152 | { |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 2153 | struct drm_i915_private *dev_priv = engine->i915; |
Chris Wilson | 6b8294a | 2012-11-16 11:43:20 +0000 | [diff] [blame] | 2154 | |
| 2155 | if (!dev_priv->status_page_dmah) { |
| 2156 | dev_priv->status_page_dmah = |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 2157 | drm_pci_alloc(dev_priv->dev, PAGE_SIZE, PAGE_SIZE); |
Chris Wilson | 6b8294a | 2012-11-16 11:43:20 +0000 | [diff] [blame] | 2158 | if (!dev_priv->status_page_dmah) |
| 2159 | return -ENOMEM; |
| 2160 | } |
| 2161 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 2162 | engine->status_page.page_addr = dev_priv->status_page_dmah->vaddr; |
| 2163 | memset(engine->status_page.page_addr, 0, PAGE_SIZE); |
Chris Wilson | 6b8294a | 2012-11-16 11:43:20 +0000 | [diff] [blame] | 2164 | |
| 2165 | return 0; |
| 2166 | } |
| 2167 | |
Thomas Daniel | 7ba717c | 2014-11-13 10:28:56 +0000 | [diff] [blame] | 2168 | void intel_unpin_ringbuffer_obj(struct intel_ringbuffer *ringbuf) |
| 2169 | { |
Chris Wilson | 3d77e9b | 2016-04-28 09:56:40 +0100 | [diff] [blame] | 2170 | GEM_BUG_ON(ringbuf->vma == NULL); |
| 2171 | GEM_BUG_ON(ringbuf->virtual_start == NULL); |
| 2172 | |
Chris Wilson | def0c5f | 2015-10-08 13:39:54 +0100 | [diff] [blame] | 2173 | if (HAS_LLC(ringbuf->obj->base.dev) && !ringbuf->obj->stolen) |
Chris Wilson | 0a798eb | 2016-04-08 12:11:11 +0100 | [diff] [blame] | 2174 | i915_gem_object_unpin_map(ringbuf->obj); |
Chris Wilson | def0c5f | 2015-10-08 13:39:54 +0100 | [diff] [blame] | 2175 | else |
Chris Wilson | 3d77e9b | 2016-04-28 09:56:40 +0100 | [diff] [blame] | 2176 | i915_vma_unpin_iomap(ringbuf->vma); |
Dave Gordon | 8305216 | 2016-04-12 14:46:16 +0100 | [diff] [blame] | 2177 | ringbuf->virtual_start = NULL; |
Chris Wilson | 3d77e9b | 2016-04-28 09:56:40 +0100 | [diff] [blame] | 2178 | |
Thomas Daniel | 7ba717c | 2014-11-13 10:28:56 +0000 | [diff] [blame] | 2179 | i915_gem_object_ggtt_unpin(ringbuf->obj); |
Chris Wilson | 3d77e9b | 2016-04-28 09:56:40 +0100 | [diff] [blame] | 2180 | ringbuf->vma = NULL; |
Thomas Daniel | 7ba717c | 2014-11-13 10:28:56 +0000 | [diff] [blame] | 2181 | } |
| 2182 | |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 2183 | int intel_pin_and_map_ringbuffer_obj(struct drm_i915_private *dev_priv, |
Thomas Daniel | 7ba717c | 2014-11-13 10:28:56 +0000 | [diff] [blame] | 2184 | struct intel_ringbuffer *ringbuf) |
| 2185 | { |
Thomas Daniel | 7ba717c | 2014-11-13 10:28:56 +0000 | [diff] [blame] | 2186 | struct drm_i915_gem_object *obj = ringbuf->obj; |
Chris Wilson | a687a43 | 2016-04-13 17:35:11 +0100 | [diff] [blame] | 2187 | /* Ring wraparound at offset 0 sometimes hangs. No idea why. */ |
| 2188 | unsigned flags = PIN_OFFSET_BIAS | 4096; |
Dave Gordon | 8305216 | 2016-04-12 14:46:16 +0100 | [diff] [blame] | 2189 | void *addr; |
Thomas Daniel | 7ba717c | 2014-11-13 10:28:56 +0000 | [diff] [blame] | 2190 | int ret; |
| 2191 | |
Chris Wilson | def0c5f | 2015-10-08 13:39:54 +0100 | [diff] [blame] | 2192 | if (HAS_LLC(dev_priv) && !obj->stolen) { |
Chris Wilson | a687a43 | 2016-04-13 17:35:11 +0100 | [diff] [blame] | 2193 | ret = i915_gem_obj_ggtt_pin(obj, PAGE_SIZE, flags); |
Chris Wilson | def0c5f | 2015-10-08 13:39:54 +0100 | [diff] [blame] | 2194 | if (ret) |
| 2195 | return ret; |
Thomas Daniel | 7ba717c | 2014-11-13 10:28:56 +0000 | [diff] [blame] | 2196 | |
Chris Wilson | def0c5f | 2015-10-08 13:39:54 +0100 | [diff] [blame] | 2197 | ret = i915_gem_object_set_to_cpu_domain(obj, true); |
Chris Wilson | d2cad53 | 2016-04-08 12:11:10 +0100 | [diff] [blame] | 2198 | if (ret) |
| 2199 | goto err_unpin; |
Thomas Daniel | 7ba717c | 2014-11-13 10:28:56 +0000 | [diff] [blame] | 2200 | |
Dave Gordon | 8305216 | 2016-04-12 14:46:16 +0100 | [diff] [blame] | 2201 | addr = i915_gem_object_pin_map(obj); |
| 2202 | if (IS_ERR(addr)) { |
| 2203 | ret = PTR_ERR(addr); |
Chris Wilson | d2cad53 | 2016-04-08 12:11:10 +0100 | [diff] [blame] | 2204 | goto err_unpin; |
Chris Wilson | def0c5f | 2015-10-08 13:39:54 +0100 | [diff] [blame] | 2205 | } |
| 2206 | } else { |
Chris Wilson | a687a43 | 2016-04-13 17:35:11 +0100 | [diff] [blame] | 2207 | ret = i915_gem_obj_ggtt_pin(obj, PAGE_SIZE, |
| 2208 | flags | PIN_MAPPABLE); |
Chris Wilson | def0c5f | 2015-10-08 13:39:54 +0100 | [diff] [blame] | 2209 | if (ret) |
| 2210 | return ret; |
| 2211 | |
| 2212 | ret = i915_gem_object_set_to_gtt_domain(obj, true); |
Chris Wilson | d2cad53 | 2016-04-08 12:11:10 +0100 | [diff] [blame] | 2213 | if (ret) |
| 2214 | goto err_unpin; |
Chris Wilson | def0c5f | 2015-10-08 13:39:54 +0100 | [diff] [blame] | 2215 | |
Daniele Ceraolo Spurio | ff3dc08 | 2016-01-27 15:43:49 +0000 | [diff] [blame] | 2216 | /* Access through the GTT requires the device to be awake. */ |
| 2217 | assert_rpm_wakelock_held(dev_priv); |
| 2218 | |
Chris Wilson | 3d77e9b | 2016-04-28 09:56:40 +0100 | [diff] [blame] | 2219 | addr = i915_vma_pin_iomap(i915_gem_obj_to_ggtt(obj)); |
| 2220 | if (IS_ERR(addr)) { |
| 2221 | ret = PTR_ERR(addr); |
Chris Wilson | d2cad53 | 2016-04-08 12:11:10 +0100 | [diff] [blame] | 2222 | goto err_unpin; |
Chris Wilson | def0c5f | 2015-10-08 13:39:54 +0100 | [diff] [blame] | 2223 | } |
Thomas Daniel | 7ba717c | 2014-11-13 10:28:56 +0000 | [diff] [blame] | 2224 | } |
| 2225 | |
Dave Gordon | 8305216 | 2016-04-12 14:46:16 +0100 | [diff] [blame] | 2226 | ringbuf->virtual_start = addr; |
Tvrtko Ursulin | 0eb973d | 2016-01-15 15:10:28 +0000 | [diff] [blame] | 2227 | ringbuf->vma = i915_gem_obj_to_ggtt(obj); |
Thomas Daniel | 7ba717c | 2014-11-13 10:28:56 +0000 | [diff] [blame] | 2228 | return 0; |
Chris Wilson | d2cad53 | 2016-04-08 12:11:10 +0100 | [diff] [blame] | 2229 | |
| 2230 | err_unpin: |
| 2231 | i915_gem_object_ggtt_unpin(obj); |
| 2232 | return ret; |
Thomas Daniel | 7ba717c | 2014-11-13 10:28:56 +0000 | [diff] [blame] | 2233 | } |
| 2234 | |
Chris Wilson | 01101fa | 2015-09-03 13:01:39 +0100 | [diff] [blame] | 2235 | static void intel_destroy_ringbuffer_obj(struct intel_ringbuffer *ringbuf) |
Chris Wilson | e3efda4 | 2014-04-09 09:19:41 +0100 | [diff] [blame] | 2236 | { |
Oscar Mateo | 2919d29 | 2014-07-03 16:28:02 +0100 | [diff] [blame] | 2237 | drm_gem_object_unreference(&ringbuf->obj->base); |
| 2238 | ringbuf->obj = NULL; |
| 2239 | } |
| 2240 | |
Chris Wilson | 01101fa | 2015-09-03 13:01:39 +0100 | [diff] [blame] | 2241 | static int intel_alloc_ringbuffer_obj(struct drm_device *dev, |
| 2242 | struct intel_ringbuffer *ringbuf) |
Oscar Mateo | 2919d29 | 2014-07-03 16:28:02 +0100 | [diff] [blame] | 2243 | { |
Chris Wilson | e3efda4 | 2014-04-09 09:19:41 +0100 | [diff] [blame] | 2244 | struct drm_i915_gem_object *obj; |
Chris Wilson | e3efda4 | 2014-04-09 09:19:41 +0100 | [diff] [blame] | 2245 | |
| 2246 | obj = NULL; |
| 2247 | if (!HAS_LLC(dev)) |
Oscar Mateo | 93b0a4e | 2014-05-22 14:13:36 +0100 | [diff] [blame] | 2248 | obj = i915_gem_object_create_stolen(dev, ringbuf->size); |
Chris Wilson | e3efda4 | 2014-04-09 09:19:41 +0100 | [diff] [blame] | 2249 | if (obj == NULL) |
Dave Gordon | d37cd8a | 2016-04-22 19:14:32 +0100 | [diff] [blame] | 2250 | obj = i915_gem_object_create(dev, ringbuf->size); |
Chris Wilson | fe3db79 | 2016-04-25 13:32:13 +0100 | [diff] [blame] | 2251 | if (IS_ERR(obj)) |
| 2252 | return PTR_ERR(obj); |
Chris Wilson | e3efda4 | 2014-04-09 09:19:41 +0100 | [diff] [blame] | 2253 | |
Akash Goel | 24f3a8c | 2014-06-17 10:59:42 +0530 | [diff] [blame] | 2254 | /* mark ring buffers as read-only from GPU side by default */ |
| 2255 | obj->gt_ro = 1; |
| 2256 | |
Oscar Mateo | 93b0a4e | 2014-05-22 14:13:36 +0100 | [diff] [blame] | 2257 | ringbuf->obj = obj; |
Chris Wilson | e3efda4 | 2014-04-09 09:19:41 +0100 | [diff] [blame] | 2258 | |
Thomas Daniel | 7ba717c | 2014-11-13 10:28:56 +0000 | [diff] [blame] | 2259 | return 0; |
Chris Wilson | e3efda4 | 2014-04-09 09:19:41 +0100 | [diff] [blame] | 2260 | } |
| 2261 | |
Chris Wilson | 01101fa | 2015-09-03 13:01:39 +0100 | [diff] [blame] | 2262 | struct intel_ringbuffer * |
| 2263 | intel_engine_create_ringbuffer(struct intel_engine_cs *engine, int size) |
| 2264 | { |
| 2265 | struct intel_ringbuffer *ring; |
| 2266 | int ret; |
| 2267 | |
| 2268 | ring = kzalloc(sizeof(*ring), GFP_KERNEL); |
Chris Wilson | 608c1a5 | 2015-09-03 13:01:40 +0100 | [diff] [blame] | 2269 | if (ring == NULL) { |
| 2270 | DRM_DEBUG_DRIVER("Failed to allocate ringbuffer %s\n", |
| 2271 | engine->name); |
Chris Wilson | 01101fa | 2015-09-03 13:01:39 +0100 | [diff] [blame] | 2272 | return ERR_PTR(-ENOMEM); |
Chris Wilson | 608c1a5 | 2015-09-03 13:01:40 +0100 | [diff] [blame] | 2273 | } |
Chris Wilson | 01101fa | 2015-09-03 13:01:39 +0100 | [diff] [blame] | 2274 | |
Tvrtko Ursulin | 4a570db | 2016-03-16 11:00:38 +0000 | [diff] [blame] | 2275 | ring->engine = engine; |
Chris Wilson | 608c1a5 | 2015-09-03 13:01:40 +0100 | [diff] [blame] | 2276 | list_add(&ring->link, &engine->buffers); |
Chris Wilson | 01101fa | 2015-09-03 13:01:39 +0100 | [diff] [blame] | 2277 | |
| 2278 | ring->size = size; |
| 2279 | /* Workaround an erratum on the i830 which causes a hang if |
| 2280 | * the TAIL pointer points to within the last 2 cachelines |
| 2281 | * of the buffer. |
| 2282 | */ |
| 2283 | ring->effective_size = size; |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 2284 | if (IS_I830(engine->i915) || IS_845G(engine->i915)) |
Chris Wilson | 01101fa | 2015-09-03 13:01:39 +0100 | [diff] [blame] | 2285 | ring->effective_size -= 2 * CACHELINE_BYTES; |
| 2286 | |
| 2287 | ring->last_retired_head = -1; |
| 2288 | intel_ring_update_space(ring); |
| 2289 | |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 2290 | ret = intel_alloc_ringbuffer_obj(engine->i915->dev, ring); |
Chris Wilson | 01101fa | 2015-09-03 13:01:39 +0100 | [diff] [blame] | 2291 | if (ret) { |
Chris Wilson | 608c1a5 | 2015-09-03 13:01:40 +0100 | [diff] [blame] | 2292 | DRM_DEBUG_DRIVER("Failed to allocate ringbuffer %s: %d\n", |
| 2293 | engine->name, ret); |
| 2294 | list_del(&ring->link); |
Chris Wilson | 01101fa | 2015-09-03 13:01:39 +0100 | [diff] [blame] | 2295 | kfree(ring); |
| 2296 | return ERR_PTR(ret); |
| 2297 | } |
| 2298 | |
| 2299 | return ring; |
| 2300 | } |
| 2301 | |
| 2302 | void |
| 2303 | intel_ringbuffer_free(struct intel_ringbuffer *ring) |
| 2304 | { |
| 2305 | intel_destroy_ringbuffer_obj(ring); |
Chris Wilson | 608c1a5 | 2015-09-03 13:01:40 +0100 | [diff] [blame] | 2306 | list_del(&ring->link); |
Chris Wilson | 01101fa | 2015-09-03 13:01:39 +0100 | [diff] [blame] | 2307 | kfree(ring); |
| 2308 | } |
| 2309 | |
Ben Widawsky | c43b563 | 2012-04-16 14:07:40 -0700 | [diff] [blame] | 2310 | static int intel_init_ring_buffer(struct drm_device *dev, |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 2311 | struct intel_engine_cs *engine) |
Eric Anholt | 62fdfea | 2010-05-21 13:26:39 -0700 | [diff] [blame] | 2312 | { |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 2313 | struct drm_i915_private *dev_priv = to_i915(dev); |
Daniel Vetter | bfc882b | 2014-11-20 00:33:08 +0100 | [diff] [blame] | 2314 | struct intel_ringbuffer *ringbuf; |
Chris Wilson | dd785e3 | 2010-08-07 11:01:34 +0100 | [diff] [blame] | 2315 | int ret; |
| 2316 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 2317 | WARN_ON(engine->buffer); |
Daniel Vetter | bfc882b | 2014-11-20 00:33:08 +0100 | [diff] [blame] | 2318 | |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 2319 | engine->i915 = dev_priv; |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 2320 | INIT_LIST_HEAD(&engine->active_list); |
| 2321 | INIT_LIST_HEAD(&engine->request_list); |
| 2322 | INIT_LIST_HEAD(&engine->execlist_queue); |
| 2323 | INIT_LIST_HEAD(&engine->buffers); |
| 2324 | i915_gem_batch_pool_init(dev, &engine->batch_pool); |
| 2325 | memset(engine->semaphore.sync_seqno, 0, |
| 2326 | sizeof(engine->semaphore.sync_seqno)); |
Chris Wilson | 0dc79fb | 2011-01-05 10:32:24 +0000 | [diff] [blame] | 2327 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 2328 | init_waitqueue_head(&engine->irq_queue); |
Eric Anholt | 62fdfea | 2010-05-21 13:26:39 -0700 | [diff] [blame] | 2329 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 2330 | ringbuf = intel_engine_create_ringbuffer(engine, 32 * PAGE_SIZE); |
Dave Gordon | b0366a5 | 2015-12-08 15:02:36 +0000 | [diff] [blame] | 2331 | if (IS_ERR(ringbuf)) { |
| 2332 | ret = PTR_ERR(ringbuf); |
| 2333 | goto error; |
| 2334 | } |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 2335 | engine->buffer = ringbuf; |
Chris Wilson | 01101fa | 2015-09-03 13:01:39 +0100 | [diff] [blame] | 2336 | |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 2337 | if (I915_NEED_GFX_HWS(dev_priv)) { |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 2338 | ret = init_status_page(engine); |
Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 2339 | if (ret) |
Oscar Mateo | 8ee1497 | 2014-05-22 14:13:34 +0100 | [diff] [blame] | 2340 | goto error; |
Chris Wilson | 6b8294a | 2012-11-16 11:43:20 +0000 | [diff] [blame] | 2341 | } else { |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 2342 | WARN_ON(engine->id != RCS); |
| 2343 | ret = init_phys_status_page(engine); |
Chris Wilson | 6b8294a | 2012-11-16 11:43:20 +0000 | [diff] [blame] | 2344 | if (ret) |
Oscar Mateo | 8ee1497 | 2014-05-22 14:13:34 +0100 | [diff] [blame] | 2345 | goto error; |
Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 2346 | } |
Eric Anholt | 62fdfea | 2010-05-21 13:26:39 -0700 | [diff] [blame] | 2347 | |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 2348 | ret = intel_pin_and_map_ringbuffer_obj(dev_priv, ringbuf); |
Daniel Vetter | bfc882b | 2014-11-20 00:33:08 +0100 | [diff] [blame] | 2349 | if (ret) { |
| 2350 | DRM_ERROR("Failed to pin and map ringbuffer %s: %d\n", |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 2351 | engine->name, ret); |
Daniel Vetter | bfc882b | 2014-11-20 00:33:08 +0100 | [diff] [blame] | 2352 | intel_destroy_ringbuffer_obj(ringbuf); |
| 2353 | goto error; |
Eric Anholt | 62fdfea | 2010-05-21 13:26:39 -0700 | [diff] [blame] | 2354 | } |
Eric Anholt | 62fdfea | 2010-05-21 13:26:39 -0700 | [diff] [blame] | 2355 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 2356 | ret = i915_cmd_parser_init_ring(engine); |
Brad Volkin | 44e895a | 2014-05-10 14:10:43 -0700 | [diff] [blame] | 2357 | if (ret) |
Oscar Mateo | 8ee1497 | 2014-05-22 14:13:34 +0100 | [diff] [blame] | 2358 | goto error; |
Brad Volkin | 351e3db | 2014-02-18 10:15:46 -0800 | [diff] [blame] | 2359 | |
Oscar Mateo | 8ee1497 | 2014-05-22 14:13:34 +0100 | [diff] [blame] | 2360 | return 0; |
| 2361 | |
| 2362 | error: |
Tvrtko Ursulin | 117897f | 2016-03-16 11:00:40 +0000 | [diff] [blame] | 2363 | intel_cleanup_engine(engine); |
Oscar Mateo | 8ee1497 | 2014-05-22 14:13:34 +0100 | [diff] [blame] | 2364 | return ret; |
Eric Anholt | 62fdfea | 2010-05-21 13:26:39 -0700 | [diff] [blame] | 2365 | } |
| 2366 | |
Tvrtko Ursulin | 117897f | 2016-03-16 11:00:40 +0000 | [diff] [blame] | 2367 | void intel_cleanup_engine(struct intel_engine_cs *engine) |
Eric Anholt | 62fdfea | 2010-05-21 13:26:39 -0700 | [diff] [blame] | 2368 | { |
John Harrison | 6402c33 | 2014-10-31 12:00:26 +0000 | [diff] [blame] | 2369 | struct drm_i915_private *dev_priv; |
Chris Wilson | 33626e6 | 2010-10-29 16:18:36 +0100 | [diff] [blame] | 2370 | |
Tvrtko Ursulin | 117897f | 2016-03-16 11:00:40 +0000 | [diff] [blame] | 2371 | if (!intel_engine_initialized(engine)) |
Eric Anholt | 62fdfea | 2010-05-21 13:26:39 -0700 | [diff] [blame] | 2372 | return; |
| 2373 | |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 2374 | dev_priv = engine->i915; |
John Harrison | 6402c33 | 2014-10-31 12:00:26 +0000 | [diff] [blame] | 2375 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 2376 | if (engine->buffer) { |
Tvrtko Ursulin | 117897f | 2016-03-16 11:00:40 +0000 | [diff] [blame] | 2377 | intel_stop_engine(engine); |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 2378 | WARN_ON(!IS_GEN2(dev_priv) && (I915_READ_MODE(engine) & MODE_IDLE) == 0); |
Chris Wilson | 33626e6 | 2010-10-29 16:18:36 +0100 | [diff] [blame] | 2379 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 2380 | intel_unpin_ringbuffer_obj(engine->buffer); |
| 2381 | intel_ringbuffer_free(engine->buffer); |
| 2382 | engine->buffer = NULL; |
Dave Gordon | b0366a5 | 2015-12-08 15:02:36 +0000 | [diff] [blame] | 2383 | } |
Chris Wilson | 78501ea | 2010-10-27 12:18:21 +0100 | [diff] [blame] | 2384 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 2385 | if (engine->cleanup) |
| 2386 | engine->cleanup(engine); |
Zou Nan hai | 8d19215 | 2010-11-02 16:31:01 +0800 | [diff] [blame] | 2387 | |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 2388 | if (I915_NEED_GFX_HWS(dev_priv)) { |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 2389 | cleanup_status_page(engine); |
Ville Syrjälä | 7d3fdff | 2016-01-11 20:48:32 +0200 | [diff] [blame] | 2390 | } else { |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 2391 | WARN_ON(engine->id != RCS); |
| 2392 | cleanup_phys_status_page(engine); |
Ville Syrjälä | 7d3fdff | 2016-01-11 20:48:32 +0200 | [diff] [blame] | 2393 | } |
Brad Volkin | 44e895a | 2014-05-10 14:10:43 -0700 | [diff] [blame] | 2394 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 2395 | i915_cmd_parser_fini_ring(engine); |
| 2396 | i915_gem_batch_pool_fini(&engine->batch_pool); |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 2397 | engine->i915 = NULL; |
Eric Anholt | 62fdfea | 2010-05-21 13:26:39 -0700 | [diff] [blame] | 2398 | } |
| 2399 | |
Tvrtko Ursulin | 666796d | 2016-03-16 11:00:39 +0000 | [diff] [blame] | 2400 | int intel_engine_idle(struct intel_engine_cs *engine) |
Chris Wilson | 3e96050 | 2012-11-27 16:22:54 +0000 | [diff] [blame] | 2401 | { |
Daniel Vetter | a4b3a57 | 2014-11-26 14:17:05 +0100 | [diff] [blame] | 2402 | struct drm_i915_gem_request *req; |
Chris Wilson | 3e96050 | 2012-11-27 16:22:54 +0000 | [diff] [blame] | 2403 | |
Chris Wilson | 3e96050 | 2012-11-27 16:22:54 +0000 | [diff] [blame] | 2404 | /* Wait upon the last request to be completed */ |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 2405 | if (list_empty(&engine->request_list)) |
Chris Wilson | 3e96050 | 2012-11-27 16:22:54 +0000 | [diff] [blame] | 2406 | return 0; |
| 2407 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 2408 | req = list_entry(engine->request_list.prev, |
| 2409 | struct drm_i915_gem_request, |
| 2410 | list); |
Chris Wilson | 3e96050 | 2012-11-27 16:22:54 +0000 | [diff] [blame] | 2411 | |
Chris Wilson | b471618 | 2015-04-27 13:41:17 +0100 | [diff] [blame] | 2412 | /* Make sure we do not trigger any retires */ |
| 2413 | return __i915_wait_request(req, |
Chris Wilson | c19ae98 | 2016-04-13 17:35:03 +0100 | [diff] [blame] | 2414 | req->i915->mm.interruptible, |
Chris Wilson | b471618 | 2015-04-27 13:41:17 +0100 | [diff] [blame] | 2415 | NULL, NULL); |
Chris Wilson | 3e96050 | 2012-11-27 16:22:54 +0000 | [diff] [blame] | 2416 | } |
| 2417 | |
John Harrison | 6689cb2 | 2015-03-19 12:30:08 +0000 | [diff] [blame] | 2418 | int intel_ring_alloc_request_extras(struct drm_i915_gem_request *request) |
Chris Wilson | 9d773091 | 2012-11-27 16:22:52 +0000 | [diff] [blame] | 2419 | { |
Chris Wilson | 6310346 | 2016-04-28 09:56:49 +0100 | [diff] [blame] | 2420 | int ret; |
| 2421 | |
| 2422 | /* Flush enough space to reduce the likelihood of waiting after |
| 2423 | * we start building the request - in which case we will just |
| 2424 | * have to repeat work. |
| 2425 | */ |
Chris Wilson | a044246 | 2016-04-29 09:07:05 +0100 | [diff] [blame] | 2426 | request->reserved_space += LEGACY_REQUEST_SIZE; |
Chris Wilson | 6310346 | 2016-04-28 09:56:49 +0100 | [diff] [blame] | 2427 | |
Tvrtko Ursulin | 4a570db | 2016-03-16 11:00:38 +0000 | [diff] [blame] | 2428 | request->ringbuf = request->engine->buffer; |
Chris Wilson | 6310346 | 2016-04-28 09:56:49 +0100 | [diff] [blame] | 2429 | |
| 2430 | ret = intel_ring_begin(request, 0); |
| 2431 | if (ret) |
| 2432 | return ret; |
| 2433 | |
Chris Wilson | a044246 | 2016-04-29 09:07:05 +0100 | [diff] [blame] | 2434 | request->reserved_space -= LEGACY_REQUEST_SIZE; |
Chris Wilson | 6310346 | 2016-04-28 09:56:49 +0100 | [diff] [blame] | 2435 | return 0; |
Chris Wilson | 9d773091 | 2012-11-27 16:22:52 +0000 | [diff] [blame] | 2436 | } |
| 2437 | |
Chris Wilson | 987046a | 2016-04-28 09:56:46 +0100 | [diff] [blame] | 2438 | static int wait_for_space(struct drm_i915_gem_request *req, int bytes) |
Mika Kuoppala | cbcc80d | 2012-12-04 15:12:03 +0200 | [diff] [blame] | 2439 | { |
Chris Wilson | 987046a | 2016-04-28 09:56:46 +0100 | [diff] [blame] | 2440 | struct intel_ringbuffer *ringbuf = req->ringbuf; |
| 2441 | struct intel_engine_cs *engine = req->engine; |
| 2442 | struct drm_i915_gem_request *target; |
| 2443 | |
| 2444 | intel_ring_update_space(ringbuf); |
| 2445 | if (ringbuf->space >= bytes) |
| 2446 | return 0; |
| 2447 | |
| 2448 | /* |
| 2449 | * Space is reserved in the ringbuffer for finalising the request, |
| 2450 | * as that cannot be allowed to fail. During request finalisation, |
| 2451 | * reserved_space is set to 0 to stop the overallocation and the |
| 2452 | * assumption is that then we never need to wait (which has the |
| 2453 | * risk of failing with EINTR). |
| 2454 | * |
| 2455 | * See also i915_gem_request_alloc() and i915_add_request(). |
| 2456 | */ |
Chris Wilson | 0251a96 | 2016-04-28 09:56:47 +0100 | [diff] [blame] | 2457 | GEM_BUG_ON(!req->reserved_space); |
Chris Wilson | 987046a | 2016-04-28 09:56:46 +0100 | [diff] [blame] | 2458 | |
| 2459 | list_for_each_entry(target, &engine->request_list, list) { |
| 2460 | unsigned space; |
| 2461 | |
| 2462 | /* |
| 2463 | * The request queue is per-engine, so can contain requests |
| 2464 | * from multiple ringbuffers. Here, we must ignore any that |
| 2465 | * aren't from the ringbuffer we're considering. |
| 2466 | */ |
| 2467 | if (target->ringbuf != ringbuf) |
| 2468 | continue; |
| 2469 | |
| 2470 | /* Would completion of this request free enough space? */ |
| 2471 | space = __intel_ring_space(target->postfix, ringbuf->tail, |
| 2472 | ringbuf->size); |
| 2473 | if (space >= bytes) |
| 2474 | break; |
| 2475 | } |
| 2476 | |
| 2477 | if (WARN_ON(&target->list == &engine->request_list)) |
| 2478 | return -ENOSPC; |
| 2479 | |
| 2480 | return i915_wait_request(target); |
| 2481 | } |
| 2482 | |
| 2483 | int intel_ring_begin(struct drm_i915_gem_request *req, int num_dwords) |
| 2484 | { |
| 2485 | struct intel_ringbuffer *ringbuf = req->ringbuf; |
John Harrison | 79bbcc2 | 2015-06-30 12:40:55 +0100 | [diff] [blame] | 2486 | int remain_actual = ringbuf->size - ringbuf->tail; |
Chris Wilson | 987046a | 2016-04-28 09:56:46 +0100 | [diff] [blame] | 2487 | int remain_usable = ringbuf->effective_size - ringbuf->tail; |
| 2488 | int bytes = num_dwords * sizeof(u32); |
| 2489 | int total_bytes, wait_bytes; |
John Harrison | 79bbcc2 | 2015-06-30 12:40:55 +0100 | [diff] [blame] | 2490 | bool need_wrap = false; |
Mika Kuoppala | cbcc80d | 2012-12-04 15:12:03 +0200 | [diff] [blame] | 2491 | |
Chris Wilson | 0251a96 | 2016-04-28 09:56:47 +0100 | [diff] [blame] | 2492 | total_bytes = bytes + req->reserved_space; |
John Harrison | 29b1b41 | 2015-06-18 13:10:09 +0100 | [diff] [blame] | 2493 | |
John Harrison | 79bbcc2 | 2015-06-30 12:40:55 +0100 | [diff] [blame] | 2494 | if (unlikely(bytes > remain_usable)) { |
| 2495 | /* |
| 2496 | * Not enough space for the basic request. So need to flush |
| 2497 | * out the remainder and then wait for base + reserved. |
| 2498 | */ |
| 2499 | wait_bytes = remain_actual + total_bytes; |
| 2500 | need_wrap = true; |
Chris Wilson | 987046a | 2016-04-28 09:56:46 +0100 | [diff] [blame] | 2501 | } else if (unlikely(total_bytes > remain_usable)) { |
| 2502 | /* |
| 2503 | * The base request will fit but the reserved space |
| 2504 | * falls off the end. So we don't need an immediate wrap |
| 2505 | * and only need to effectively wait for the reserved |
| 2506 | * size space from the start of ringbuffer. |
| 2507 | */ |
Chris Wilson | 0251a96 | 2016-04-28 09:56:47 +0100 | [diff] [blame] | 2508 | wait_bytes = remain_actual + req->reserved_space; |
John Harrison | 79bbcc2 | 2015-06-30 12:40:55 +0100 | [diff] [blame] | 2509 | } else { |
Chris Wilson | 987046a | 2016-04-28 09:56:46 +0100 | [diff] [blame] | 2510 | /* No wrapping required, just waiting. */ |
| 2511 | wait_bytes = total_bytes; |
Mika Kuoppala | cbcc80d | 2012-12-04 15:12:03 +0200 | [diff] [blame] | 2512 | } |
| 2513 | |
Chris Wilson | 987046a | 2016-04-28 09:56:46 +0100 | [diff] [blame] | 2514 | if (wait_bytes > ringbuf->space) { |
| 2515 | int ret = wait_for_space(req, wait_bytes); |
Mika Kuoppala | cbcc80d | 2012-12-04 15:12:03 +0200 | [diff] [blame] | 2516 | if (unlikely(ret)) |
| 2517 | return ret; |
John Harrison | 79bbcc2 | 2015-06-30 12:40:55 +0100 | [diff] [blame] | 2518 | |
Chris Wilson | 987046a | 2016-04-28 09:56:46 +0100 | [diff] [blame] | 2519 | intel_ring_update_space(ringbuf); |
Chris Wilson | e075a32 | 2016-05-13 11:57:22 +0100 | [diff] [blame] | 2520 | if (unlikely(ringbuf->space < wait_bytes)) |
| 2521 | return -EAGAIN; |
Mika Kuoppala | cbcc80d | 2012-12-04 15:12:03 +0200 | [diff] [blame] | 2522 | } |
| 2523 | |
Chris Wilson | 987046a | 2016-04-28 09:56:46 +0100 | [diff] [blame] | 2524 | if (unlikely(need_wrap)) { |
| 2525 | GEM_BUG_ON(remain_actual > ringbuf->space); |
| 2526 | GEM_BUG_ON(ringbuf->tail + remain_actual > ringbuf->size); |
Mika Kuoppala | cbcc80d | 2012-12-04 15:12:03 +0200 | [diff] [blame] | 2527 | |
Chris Wilson | 987046a | 2016-04-28 09:56:46 +0100 | [diff] [blame] | 2528 | /* Fill the tail with MI_NOOP */ |
| 2529 | memset(ringbuf->virtual_start + ringbuf->tail, |
| 2530 | 0, remain_actual); |
| 2531 | ringbuf->tail = 0; |
| 2532 | ringbuf->space -= remain_actual; |
| 2533 | } |
Chris Wilson | 78501ea | 2010-10-27 12:18:21 +0100 | [diff] [blame] | 2534 | |
Chris Wilson | 987046a | 2016-04-28 09:56:46 +0100 | [diff] [blame] | 2535 | ringbuf->space -= bytes; |
| 2536 | GEM_BUG_ON(ringbuf->space < 0); |
Chris Wilson | 304d695 | 2014-01-02 14:32:35 +0000 | [diff] [blame] | 2537 | return 0; |
Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 2538 | } |
| 2539 | |
Ville Syrjälä | 753b1ad | 2014-02-11 19:52:05 +0200 | [diff] [blame] | 2540 | /* Align the ring tail to a cacheline boundary */ |
John Harrison | bba09b1 | 2015-05-29 17:44:06 +0100 | [diff] [blame] | 2541 | int intel_ring_cacheline_align(struct drm_i915_gem_request *req) |
Ville Syrjälä | 753b1ad | 2014-02-11 19:52:05 +0200 | [diff] [blame] | 2542 | { |
Tvrtko Ursulin | 4a570db | 2016-03-16 11:00:38 +0000 | [diff] [blame] | 2543 | struct intel_engine_cs *engine = req->engine; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2544 | int num_dwords = (engine->buffer->tail & (CACHELINE_BYTES - 1)) / sizeof(uint32_t); |
Ville Syrjälä | 753b1ad | 2014-02-11 19:52:05 +0200 | [diff] [blame] | 2545 | int ret; |
| 2546 | |
| 2547 | if (num_dwords == 0) |
| 2548 | return 0; |
| 2549 | |
Chris Wilson | 18393f6 | 2014-04-09 09:19:40 +0100 | [diff] [blame] | 2550 | num_dwords = CACHELINE_BYTES / sizeof(uint32_t) - num_dwords; |
John Harrison | 5fb9de1 | 2015-05-29 17:44:07 +0100 | [diff] [blame] | 2551 | ret = intel_ring_begin(req, num_dwords); |
Ville Syrjälä | 753b1ad | 2014-02-11 19:52:05 +0200 | [diff] [blame] | 2552 | if (ret) |
| 2553 | return ret; |
| 2554 | |
| 2555 | while (num_dwords--) |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2556 | intel_ring_emit(engine, MI_NOOP); |
Ville Syrjälä | 753b1ad | 2014-02-11 19:52:05 +0200 | [diff] [blame] | 2557 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2558 | intel_ring_advance(engine); |
Ville Syrjälä | 753b1ad | 2014-02-11 19:52:05 +0200 | [diff] [blame] | 2559 | |
| 2560 | return 0; |
| 2561 | } |
| 2562 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 2563 | void intel_ring_init_seqno(struct intel_engine_cs *engine, u32 seqno) |
Mika Kuoppala | 498d2ac | 2012-12-04 15:12:04 +0200 | [diff] [blame] | 2564 | { |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 2565 | struct drm_i915_private *dev_priv = engine->i915; |
Mika Kuoppala | 498d2ac | 2012-12-04 15:12:04 +0200 | [diff] [blame] | 2566 | |
Chris Wilson | 29dcb57 | 2016-04-07 07:29:13 +0100 | [diff] [blame] | 2567 | /* Our semaphore implementation is strictly monotonic (i.e. we proceed |
| 2568 | * so long as the semaphore value in the register/page is greater |
| 2569 | * than the sync value), so whenever we reset the seqno, |
| 2570 | * so long as we reset the tracking semaphore value to 0, it will |
| 2571 | * always be before the next request's seqno. If we don't reset |
| 2572 | * the semaphore value, then when the seqno moves backwards all |
| 2573 | * future waits will complete instantly (causing rendering corruption). |
| 2574 | */ |
Tvrtko Ursulin | 7e22dbb | 2016-05-10 10:57:06 +0100 | [diff] [blame] | 2575 | if (IS_GEN6(dev_priv) || IS_GEN7(dev_priv)) { |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 2576 | I915_WRITE(RING_SYNC_0(engine->mmio_base), 0); |
| 2577 | I915_WRITE(RING_SYNC_1(engine->mmio_base), 0); |
Chris Wilson | d04bce4 | 2016-04-07 07:29:12 +0100 | [diff] [blame] | 2578 | if (HAS_VEBOX(dev_priv)) |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 2579 | I915_WRITE(RING_SYNC_2(engine->mmio_base), 0); |
Chris Wilson | 78501ea | 2010-10-27 12:18:21 +0100 | [diff] [blame] | 2580 | } |
Chris Wilson | a058d93 | 2016-04-07 07:29:15 +0100 | [diff] [blame] | 2581 | if (dev_priv->semaphore_obj) { |
| 2582 | struct drm_i915_gem_object *obj = dev_priv->semaphore_obj; |
| 2583 | struct page *page = i915_gem_object_get_dirty_page(obj, 0); |
| 2584 | void *semaphores = kmap(page); |
| 2585 | memset(semaphores + GEN8_SEMAPHORE_OFFSET(engine->id, 0), |
| 2586 | 0, I915_NUM_ENGINES * gen8_semaphore_seqno_size); |
| 2587 | kunmap(page); |
| 2588 | } |
Chris Wilson | 29dcb57 | 2016-04-07 07:29:13 +0100 | [diff] [blame] | 2589 | memset(engine->semaphore.sync_seqno, 0, |
| 2590 | sizeof(engine->semaphore.sync_seqno)); |
Chris Wilson | 297b0c5 | 2010-10-22 17:02:41 +0100 | [diff] [blame] | 2591 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 2592 | engine->set_seqno(engine, seqno); |
Chris Wilson | 0134712 | 2016-04-07 07:29:16 +0100 | [diff] [blame] | 2593 | engine->last_submitted_seqno = seqno; |
Chris Wilson | 29dcb57 | 2016-04-07 07:29:13 +0100 | [diff] [blame] | 2594 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 2595 | engine->hangcheck.seqno = seqno; |
Chris Wilson | 549f736 | 2010-10-19 11:19:32 +0100 | [diff] [blame] | 2596 | } |
| 2597 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 2598 | static void gen6_bsd_ring_write_tail(struct intel_engine_cs *engine, |
Chris Wilson | ab6f8e3 | 2010-09-19 17:53:44 +0100 | [diff] [blame] | 2599 | u32 value) |
Xiang, Haihao | 881f47b | 2010-09-19 14:40:43 +0100 | [diff] [blame] | 2600 | { |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 2601 | struct drm_i915_private *dev_priv = engine->i915; |
Xiang, Haihao | 881f47b | 2010-09-19 14:40:43 +0100 | [diff] [blame] | 2602 | |
| 2603 | /* Every tail move must follow the sequence below */ |
Xiang, Haihao | 881f47b | 2010-09-19 14:40:43 +0100 | [diff] [blame] | 2604 | |
Chris Wilson | 12f5581 | 2012-07-05 17:14:01 +0100 | [diff] [blame] | 2605 | /* Disable notification that the ring is IDLE. The GT |
| 2606 | * will then assume that it is busy and bring it out of rc6. |
| 2607 | */ |
| 2608 | I915_WRITE(GEN6_BSD_SLEEP_PSMI_CONTROL, |
| 2609 | _MASKED_BIT_ENABLE(GEN6_BSD_SLEEP_MSG_DISABLE)); |
| 2610 | |
| 2611 | /* Clear the context id. Here be magic! */ |
| 2612 | I915_WRITE64(GEN6_BSD_RNCID, 0x0); |
| 2613 | |
| 2614 | /* Wait for the ring not to be idle, i.e. for it to wake up. */ |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 2615 | if (wait_for((I915_READ(GEN6_BSD_SLEEP_PSMI_CONTROL) & |
Chris Wilson | 12f5581 | 2012-07-05 17:14:01 +0100 | [diff] [blame] | 2616 | GEN6_BSD_SLEEP_INDICATOR) == 0, |
| 2617 | 50)) |
| 2618 | DRM_ERROR("timed out waiting for the BSD ring to wake up\n"); |
Xiang, Haihao | 881f47b | 2010-09-19 14:40:43 +0100 | [diff] [blame] | 2619 | |
Chris Wilson | 12f5581 | 2012-07-05 17:14:01 +0100 | [diff] [blame] | 2620 | /* Now that the ring is fully powered up, update the tail */ |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 2621 | I915_WRITE_TAIL(engine, value); |
| 2622 | POSTING_READ(RING_TAIL(engine->mmio_base)); |
Chris Wilson | 12f5581 | 2012-07-05 17:14:01 +0100 | [diff] [blame] | 2623 | |
| 2624 | /* Let the ring send IDLE messages to the GT again, |
| 2625 | * and so let it sleep to conserve power when idle. |
| 2626 | */ |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 2627 | I915_WRITE(GEN6_BSD_SLEEP_PSMI_CONTROL, |
Chris Wilson | 12f5581 | 2012-07-05 17:14:01 +0100 | [diff] [blame] | 2628 | _MASKED_BIT_DISABLE(GEN6_BSD_SLEEP_MSG_DISABLE)); |
Xiang, Haihao | 881f47b | 2010-09-19 14:40:43 +0100 | [diff] [blame] | 2629 | } |
| 2630 | |
John Harrison | a84c3ae | 2015-05-29 17:43:57 +0100 | [diff] [blame] | 2631 | static int gen6_bsd_ring_flush(struct drm_i915_gem_request *req, |
Ben Widawsky | ea25132 | 2013-05-28 19:22:21 -0700 | [diff] [blame] | 2632 | u32 invalidate, u32 flush) |
Xiang, Haihao | 881f47b | 2010-09-19 14:40:43 +0100 | [diff] [blame] | 2633 | { |
Tvrtko Ursulin | 4a570db | 2016-03-16 11:00:38 +0000 | [diff] [blame] | 2634 | struct intel_engine_cs *engine = req->engine; |
Chris Wilson | 71a77e0 | 2011-02-02 12:13:49 +0000 | [diff] [blame] | 2635 | uint32_t cmd; |
Chris Wilson | b72f3ac | 2011-01-04 17:34:02 +0000 | [diff] [blame] | 2636 | int ret; |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 2637 | |
John Harrison | 5fb9de1 | 2015-05-29 17:44:07 +0100 | [diff] [blame] | 2638 | ret = intel_ring_begin(req, 4); |
Chris Wilson | b72f3ac | 2011-01-04 17:34:02 +0000 | [diff] [blame] | 2639 | if (ret) |
| 2640 | return ret; |
| 2641 | |
Chris Wilson | 71a77e0 | 2011-02-02 12:13:49 +0000 | [diff] [blame] | 2642 | cmd = MI_FLUSH_DW; |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 2643 | if (INTEL_GEN(req->i915) >= 8) |
Ben Widawsky | 075b3bb | 2013-11-02 21:07:13 -0700 | [diff] [blame] | 2644 | cmd += 1; |
Chris Wilson | f0a1fb1 | 2015-01-22 13:42:00 +0000 | [diff] [blame] | 2645 | |
| 2646 | /* We always require a command barrier so that subsequent |
| 2647 | * commands, such as breadcrumb interrupts, are strictly ordered |
| 2648 | * wrt the contents of the write cache being flushed to memory |
| 2649 | * (and thus being coherent from the CPU). |
| 2650 | */ |
| 2651 | cmd |= MI_FLUSH_DW_STORE_INDEX | MI_FLUSH_DW_OP_STOREDW; |
| 2652 | |
Jesse Barnes | 9a28977 | 2012-10-26 09:42:42 -0700 | [diff] [blame] | 2653 | /* |
| 2654 | * Bspec vol 1c.5 - video engine command streamer: |
| 2655 | * "If ENABLED, all TLBs will be invalidated once the flush |
| 2656 | * operation is complete. This bit is only valid when the |
| 2657 | * Post-Sync Operation field is a value of 1h or 3h." |
| 2658 | */ |
Chris Wilson | 71a77e0 | 2011-02-02 12:13:49 +0000 | [diff] [blame] | 2659 | if (invalidate & I915_GEM_GPU_DOMAINS) |
Chris Wilson | f0a1fb1 | 2015-01-22 13:42:00 +0000 | [diff] [blame] | 2660 | cmd |= MI_INVALIDATE_TLB | MI_INVALIDATE_BSD; |
| 2661 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2662 | intel_ring_emit(engine, cmd); |
| 2663 | intel_ring_emit(engine, |
| 2664 | I915_GEM_HWS_SCRATCH_ADDR | MI_FLUSH_DW_USE_GTT); |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 2665 | if (INTEL_GEN(req->i915) >= 8) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2666 | intel_ring_emit(engine, 0); /* upper addr */ |
| 2667 | intel_ring_emit(engine, 0); /* value */ |
Ben Widawsky | 075b3bb | 2013-11-02 21:07:13 -0700 | [diff] [blame] | 2668 | } else { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2669 | intel_ring_emit(engine, 0); |
| 2670 | intel_ring_emit(engine, MI_NOOP); |
Ben Widawsky | 075b3bb | 2013-11-02 21:07:13 -0700 | [diff] [blame] | 2671 | } |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2672 | intel_ring_advance(engine); |
Chris Wilson | b72f3ac | 2011-01-04 17:34:02 +0000 | [diff] [blame] | 2673 | return 0; |
Xiang, Haihao | 881f47b | 2010-09-19 14:40:43 +0100 | [diff] [blame] | 2674 | } |
| 2675 | |
| 2676 | static int |
John Harrison | 53fddaf | 2015-05-29 17:44:02 +0100 | [diff] [blame] | 2677 | gen8_ring_dispatch_execbuffer(struct drm_i915_gem_request *req, |
Ben Widawsky | 9bcb144 | 2014-04-28 19:29:25 -0700 | [diff] [blame] | 2678 | u64 offset, u32 len, |
John Harrison | 8e004ef | 2015-02-13 11:48:10 +0000 | [diff] [blame] | 2679 | unsigned dispatch_flags) |
Ben Widawsky | 1c7a062 | 2013-11-02 21:07:12 -0700 | [diff] [blame] | 2680 | { |
Tvrtko Ursulin | 4a570db | 2016-03-16 11:00:38 +0000 | [diff] [blame] | 2681 | struct intel_engine_cs *engine = req->engine; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2682 | bool ppgtt = USES_PPGTT(engine->dev) && |
John Harrison | 8e004ef | 2015-02-13 11:48:10 +0000 | [diff] [blame] | 2683 | !(dispatch_flags & I915_DISPATCH_SECURE); |
Ben Widawsky | 1c7a062 | 2013-11-02 21:07:12 -0700 | [diff] [blame] | 2684 | int ret; |
| 2685 | |
John Harrison | 5fb9de1 | 2015-05-29 17:44:07 +0100 | [diff] [blame] | 2686 | ret = intel_ring_begin(req, 4); |
Ben Widawsky | 1c7a062 | 2013-11-02 21:07:12 -0700 | [diff] [blame] | 2687 | if (ret) |
| 2688 | return ret; |
| 2689 | |
| 2690 | /* FIXME(BDW): Address space and security selectors. */ |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2691 | intel_ring_emit(engine, MI_BATCH_BUFFER_START_GEN8 | (ppgtt<<8) | |
Abdiel Janulgue | 919032e | 2015-06-16 13:39:40 +0300 | [diff] [blame] | 2692 | (dispatch_flags & I915_DISPATCH_RS ? |
| 2693 | MI_BATCH_RESOURCE_STREAMER : 0)); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2694 | intel_ring_emit(engine, lower_32_bits(offset)); |
| 2695 | intel_ring_emit(engine, upper_32_bits(offset)); |
| 2696 | intel_ring_emit(engine, MI_NOOP); |
| 2697 | intel_ring_advance(engine); |
Ben Widawsky | 1c7a062 | 2013-11-02 21:07:12 -0700 | [diff] [blame] | 2698 | |
| 2699 | return 0; |
| 2700 | } |
| 2701 | |
| 2702 | static int |
John Harrison | 53fddaf | 2015-05-29 17:44:02 +0100 | [diff] [blame] | 2703 | hsw_ring_dispatch_execbuffer(struct drm_i915_gem_request *req, |
John Harrison | 8e004ef | 2015-02-13 11:48:10 +0000 | [diff] [blame] | 2704 | u64 offset, u32 len, |
| 2705 | unsigned dispatch_flags) |
Xiang, Haihao | 881f47b | 2010-09-19 14:40:43 +0100 | [diff] [blame] | 2706 | { |
Tvrtko Ursulin | 4a570db | 2016-03-16 11:00:38 +0000 | [diff] [blame] | 2707 | struct intel_engine_cs *engine = req->engine; |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 2708 | int ret; |
Chris Wilson | ab6f8e3 | 2010-09-19 17:53:44 +0100 | [diff] [blame] | 2709 | |
John Harrison | 5fb9de1 | 2015-05-29 17:44:07 +0100 | [diff] [blame] | 2710 | ret = intel_ring_begin(req, 2); |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 2711 | if (ret) |
| 2712 | return ret; |
Chris Wilson | e1f99ce | 2010-10-27 12:45:26 +0100 | [diff] [blame] | 2713 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2714 | intel_ring_emit(engine, |
Chris Wilson | 7707225 | 2014-09-10 12:18:27 +0100 | [diff] [blame] | 2715 | MI_BATCH_BUFFER_START | |
John Harrison | 8e004ef | 2015-02-13 11:48:10 +0000 | [diff] [blame] | 2716 | (dispatch_flags & I915_DISPATCH_SECURE ? |
Abdiel Janulgue | 919032e | 2015-06-16 13:39:40 +0300 | [diff] [blame] | 2717 | 0 : MI_BATCH_PPGTT_HSW | MI_BATCH_NON_SECURE_HSW) | |
| 2718 | (dispatch_flags & I915_DISPATCH_RS ? |
| 2719 | MI_BATCH_RESOURCE_STREAMER : 0)); |
Chris Wilson | d7d4eed | 2012-10-17 12:09:54 +0100 | [diff] [blame] | 2720 | /* bit0-7 is the length on GEN6+ */ |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2721 | intel_ring_emit(engine, offset); |
| 2722 | intel_ring_advance(engine); |
Chris Wilson | d7d4eed | 2012-10-17 12:09:54 +0100 | [diff] [blame] | 2723 | |
| 2724 | return 0; |
| 2725 | } |
| 2726 | |
| 2727 | static int |
John Harrison | 53fddaf | 2015-05-29 17:44:02 +0100 | [diff] [blame] | 2728 | gen6_ring_dispatch_execbuffer(struct drm_i915_gem_request *req, |
Ben Widawsky | 9bcb144 | 2014-04-28 19:29:25 -0700 | [diff] [blame] | 2729 | u64 offset, u32 len, |
John Harrison | 8e004ef | 2015-02-13 11:48:10 +0000 | [diff] [blame] | 2730 | unsigned dispatch_flags) |
Chris Wilson | d7d4eed | 2012-10-17 12:09:54 +0100 | [diff] [blame] | 2731 | { |
Tvrtko Ursulin | 4a570db | 2016-03-16 11:00:38 +0000 | [diff] [blame] | 2732 | struct intel_engine_cs *engine = req->engine; |
Chris Wilson | d7d4eed | 2012-10-17 12:09:54 +0100 | [diff] [blame] | 2733 | int ret; |
| 2734 | |
John Harrison | 5fb9de1 | 2015-05-29 17:44:07 +0100 | [diff] [blame] | 2735 | ret = intel_ring_begin(req, 2); |
Chris Wilson | d7d4eed | 2012-10-17 12:09:54 +0100 | [diff] [blame] | 2736 | if (ret) |
| 2737 | return ret; |
| 2738 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2739 | intel_ring_emit(engine, |
Chris Wilson | d7d4eed | 2012-10-17 12:09:54 +0100 | [diff] [blame] | 2740 | MI_BATCH_BUFFER_START | |
John Harrison | 8e004ef | 2015-02-13 11:48:10 +0000 | [diff] [blame] | 2741 | (dispatch_flags & I915_DISPATCH_SECURE ? |
| 2742 | 0 : MI_BATCH_NON_SECURE_I965)); |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 2743 | /* bit0-7 is the length on GEN6+ */ |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2744 | intel_ring_emit(engine, offset); |
| 2745 | intel_ring_advance(engine); |
Chris Wilson | ab6f8e3 | 2010-09-19 17:53:44 +0100 | [diff] [blame] | 2746 | |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 2747 | return 0; |
Xiang, Haihao | 881f47b | 2010-09-19 14:40:43 +0100 | [diff] [blame] | 2748 | } |
| 2749 | |
Chris Wilson | 549f736 | 2010-10-19 11:19:32 +0100 | [diff] [blame] | 2750 | /* Blitter support (SandyBridge+) */ |
| 2751 | |
John Harrison | a84c3ae | 2015-05-29 17:43:57 +0100 | [diff] [blame] | 2752 | static int gen6_ring_flush(struct drm_i915_gem_request *req, |
Ben Widawsky | ea25132 | 2013-05-28 19:22:21 -0700 | [diff] [blame] | 2753 | u32 invalidate, u32 flush) |
Zou Nan hai | 8d19215 | 2010-11-02 16:31:01 +0800 | [diff] [blame] | 2754 | { |
Tvrtko Ursulin | 4a570db | 2016-03-16 11:00:38 +0000 | [diff] [blame] | 2755 | struct intel_engine_cs *engine = req->engine; |
Chris Wilson | 71a77e0 | 2011-02-02 12:13:49 +0000 | [diff] [blame] | 2756 | uint32_t cmd; |
Chris Wilson | b72f3ac | 2011-01-04 17:34:02 +0000 | [diff] [blame] | 2757 | int ret; |
Chris Wilson | 1ec14ad | 2010-12-04 11:30:53 +0000 | [diff] [blame] | 2758 | |
John Harrison | 5fb9de1 | 2015-05-29 17:44:07 +0100 | [diff] [blame] | 2759 | ret = intel_ring_begin(req, 4); |
Chris Wilson | b72f3ac | 2011-01-04 17:34:02 +0000 | [diff] [blame] | 2760 | if (ret) |
| 2761 | return ret; |
| 2762 | |
Chris Wilson | 71a77e0 | 2011-02-02 12:13:49 +0000 | [diff] [blame] | 2763 | cmd = MI_FLUSH_DW; |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 2764 | if (INTEL_GEN(req->i915) >= 8) |
Ben Widawsky | 075b3bb | 2013-11-02 21:07:13 -0700 | [diff] [blame] | 2765 | cmd += 1; |
Chris Wilson | f0a1fb1 | 2015-01-22 13:42:00 +0000 | [diff] [blame] | 2766 | |
| 2767 | /* We always require a command barrier so that subsequent |
| 2768 | * commands, such as breadcrumb interrupts, are strictly ordered |
| 2769 | * wrt the contents of the write cache being flushed to memory |
| 2770 | * (and thus being coherent from the CPU). |
| 2771 | */ |
| 2772 | cmd |= MI_FLUSH_DW_STORE_INDEX | MI_FLUSH_DW_OP_STOREDW; |
| 2773 | |
Jesse Barnes | 9a28977 | 2012-10-26 09:42:42 -0700 | [diff] [blame] | 2774 | /* |
| 2775 | * Bspec vol 1c.3 - blitter engine command streamer: |
| 2776 | * "If ENABLED, all TLBs will be invalidated once the flush |
| 2777 | * operation is complete. This bit is only valid when the |
| 2778 | * Post-Sync Operation field is a value of 1h or 3h." |
| 2779 | */ |
Chris Wilson | 71a77e0 | 2011-02-02 12:13:49 +0000 | [diff] [blame] | 2780 | if (invalidate & I915_GEM_DOMAIN_RENDER) |
Chris Wilson | f0a1fb1 | 2015-01-22 13:42:00 +0000 | [diff] [blame] | 2781 | cmd |= MI_INVALIDATE_TLB; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2782 | intel_ring_emit(engine, cmd); |
| 2783 | intel_ring_emit(engine, |
| 2784 | I915_GEM_HWS_SCRATCH_ADDR | MI_FLUSH_DW_USE_GTT); |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 2785 | if (INTEL_GEN(req->i915) >= 8) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2786 | intel_ring_emit(engine, 0); /* upper addr */ |
| 2787 | intel_ring_emit(engine, 0); /* value */ |
Ben Widawsky | 075b3bb | 2013-11-02 21:07:13 -0700 | [diff] [blame] | 2788 | } else { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2789 | intel_ring_emit(engine, 0); |
| 2790 | intel_ring_emit(engine, MI_NOOP); |
Ben Widawsky | 075b3bb | 2013-11-02 21:07:13 -0700 | [diff] [blame] | 2791 | } |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2792 | intel_ring_advance(engine); |
Rodrigo Vivi | fd3da6c | 2013-06-06 16:58:16 -0300 | [diff] [blame] | 2793 | |
Chris Wilson | b72f3ac | 2011-01-04 17:34:02 +0000 | [diff] [blame] | 2794 | return 0; |
Zou Nan hai | 8d19215 | 2010-11-02 16:31:01 +0800 | [diff] [blame] | 2795 | } |
| 2796 | |
Xiang, Haihao | 5c1143b | 2010-09-16 10:43:11 +0800 | [diff] [blame] | 2797 | int intel_init_render_ring_buffer(struct drm_device *dev) |
| 2798 | { |
Jani Nikula | 4640c4f | 2014-03-31 14:27:19 +0300 | [diff] [blame] | 2799 | struct drm_i915_private *dev_priv = dev->dev_private; |
Tvrtko Ursulin | 4a570db | 2016-03-16 11:00:38 +0000 | [diff] [blame] | 2800 | struct intel_engine_cs *engine = &dev_priv->engine[RCS]; |
Ben Widawsky | 3e78998 | 2014-06-30 09:53:37 -0700 | [diff] [blame] | 2801 | struct drm_i915_gem_object *obj; |
| 2802 | int ret; |
Xiang, Haihao | 5c1143b | 2010-09-16 10:43:11 +0800 | [diff] [blame] | 2803 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2804 | engine->name = "render ring"; |
| 2805 | engine->id = RCS; |
| 2806 | engine->exec_id = I915_EXEC_RENDER; |
Chris Wilson | 215a7e3 | 2016-04-29 13:18:23 +0100 | [diff] [blame] | 2807 | engine->hw_id = 0; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2808 | engine->mmio_base = RENDER_RING_BASE; |
Daniel Vetter | 59465b5 | 2012-04-11 22:12:48 +0200 | [diff] [blame] | 2809 | |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 2810 | if (INTEL_GEN(dev_priv) >= 8) { |
| 2811 | if (i915_semaphore_is_enabled(dev_priv)) { |
Dave Gordon | d37cd8a | 2016-04-22 19:14:32 +0100 | [diff] [blame] | 2812 | obj = i915_gem_object_create(dev, 4096); |
Chris Wilson | fe3db79 | 2016-04-25 13:32:13 +0100 | [diff] [blame] | 2813 | if (IS_ERR(obj)) { |
Ben Widawsky | 3e78998 | 2014-06-30 09:53:37 -0700 | [diff] [blame] | 2814 | DRM_ERROR("Failed to allocate semaphore bo. Disabling semaphores\n"); |
| 2815 | i915.semaphores = 0; |
| 2816 | } else { |
| 2817 | i915_gem_object_set_cache_level(obj, I915_CACHE_LLC); |
| 2818 | ret = i915_gem_obj_ggtt_pin(obj, 0, PIN_NONBLOCK); |
| 2819 | if (ret != 0) { |
| 2820 | drm_gem_object_unreference(&obj->base); |
| 2821 | DRM_ERROR("Failed to pin semaphore bo. Disabling semaphores\n"); |
| 2822 | i915.semaphores = 0; |
| 2823 | } else |
| 2824 | dev_priv->semaphore_obj = obj; |
| 2825 | } |
| 2826 | } |
Mika Kuoppala | 7225342 | 2014-10-07 17:21:26 +0300 | [diff] [blame] | 2827 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2828 | engine->init_context = intel_rcs_ctx_init; |
Chris Wilson | a58c01a | 2016-04-29 13:18:21 +0100 | [diff] [blame] | 2829 | engine->add_request = gen8_render_add_request; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2830 | engine->flush = gen8_render_ring_flush; |
| 2831 | engine->irq_get = gen8_ring_get_irq; |
| 2832 | engine->irq_put = gen8_ring_put_irq; |
| 2833 | engine->irq_enable_mask = GT_RENDER_USER_INTERRUPT; |
Chris Wilson | c04e0f3 | 2016-04-09 10:57:54 +0100 | [diff] [blame] | 2834 | engine->get_seqno = ring_get_seqno; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2835 | engine->set_seqno = ring_set_seqno; |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 2836 | if (i915_semaphore_is_enabled(dev_priv)) { |
Ben Widawsky | 3e78998 | 2014-06-30 09:53:37 -0700 | [diff] [blame] | 2837 | WARN_ON(!dev_priv->semaphore_obj); |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2838 | engine->semaphore.sync_to = gen8_ring_sync; |
| 2839 | engine->semaphore.signal = gen8_rcs_signal; |
| 2840 | GEN8_RING_SEMAPHORE_INIT(engine); |
Ben Widawsky | 707d9cf | 2014-06-30 09:53:36 -0700 | [diff] [blame] | 2841 | } |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 2842 | } else if (INTEL_GEN(dev_priv) >= 6) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2843 | engine->init_context = intel_rcs_ctx_init; |
| 2844 | engine->add_request = gen6_add_request; |
| 2845 | engine->flush = gen7_render_ring_flush; |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 2846 | if (IS_GEN6(dev_priv)) |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2847 | engine->flush = gen6_render_ring_flush; |
| 2848 | engine->irq_get = gen6_ring_get_irq; |
| 2849 | engine->irq_put = gen6_ring_put_irq; |
| 2850 | engine->irq_enable_mask = GT_RENDER_USER_INTERRUPT; |
Chris Wilson | c04e0f3 | 2016-04-09 10:57:54 +0100 | [diff] [blame] | 2851 | engine->irq_seqno_barrier = gen6_seqno_barrier; |
| 2852 | engine->get_seqno = ring_get_seqno; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2853 | engine->set_seqno = ring_set_seqno; |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 2854 | if (i915_semaphore_is_enabled(dev_priv)) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2855 | engine->semaphore.sync_to = gen6_ring_sync; |
| 2856 | engine->semaphore.signal = gen6_signal; |
Ben Widawsky | 707d9cf | 2014-06-30 09:53:36 -0700 | [diff] [blame] | 2857 | /* |
| 2858 | * The current semaphore is only applied on pre-gen8 |
| 2859 | * platform. And there is no VCS2 ring on the pre-gen8 |
| 2860 | * platform. So the semaphore between RCS and VCS2 is |
| 2861 | * initialized as INVALID. Gen8 will initialize the |
| 2862 | * sema between VCS2 and RCS later. |
| 2863 | */ |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2864 | engine->semaphore.mbox.wait[RCS] = MI_SEMAPHORE_SYNC_INVALID; |
| 2865 | engine->semaphore.mbox.wait[VCS] = MI_SEMAPHORE_SYNC_RV; |
| 2866 | engine->semaphore.mbox.wait[BCS] = MI_SEMAPHORE_SYNC_RB; |
| 2867 | engine->semaphore.mbox.wait[VECS] = MI_SEMAPHORE_SYNC_RVE; |
| 2868 | engine->semaphore.mbox.wait[VCS2] = MI_SEMAPHORE_SYNC_INVALID; |
| 2869 | engine->semaphore.mbox.signal[RCS] = GEN6_NOSYNC; |
| 2870 | engine->semaphore.mbox.signal[VCS] = GEN6_VRSYNC; |
| 2871 | engine->semaphore.mbox.signal[BCS] = GEN6_BRSYNC; |
| 2872 | engine->semaphore.mbox.signal[VECS] = GEN6_VERSYNC; |
| 2873 | engine->semaphore.mbox.signal[VCS2] = GEN6_NOSYNC; |
Ben Widawsky | 707d9cf | 2014-06-30 09:53:36 -0700 | [diff] [blame] | 2874 | } |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 2875 | } else if (IS_GEN5(dev_priv)) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2876 | engine->add_request = pc_render_add_request; |
| 2877 | engine->flush = gen4_render_ring_flush; |
| 2878 | engine->get_seqno = pc_render_get_seqno; |
| 2879 | engine->set_seqno = pc_render_set_seqno; |
| 2880 | engine->irq_get = gen5_ring_get_irq; |
| 2881 | engine->irq_put = gen5_ring_put_irq; |
| 2882 | engine->irq_enable_mask = GT_RENDER_USER_INTERRUPT | |
Ben Widawsky | cc609d5 | 2013-05-28 19:22:29 -0700 | [diff] [blame] | 2883 | GT_RENDER_PIPECTL_NOTIFY_INTERRUPT; |
Daniel Vetter | 59465b5 | 2012-04-11 22:12:48 +0200 | [diff] [blame] | 2884 | } else { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2885 | engine->add_request = i9xx_add_request; |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 2886 | if (INTEL_GEN(dev_priv) < 4) |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2887 | engine->flush = gen2_render_ring_flush; |
Chris Wilson | 46f0f8d | 2012-04-18 11:12:11 +0100 | [diff] [blame] | 2888 | else |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2889 | engine->flush = gen4_render_ring_flush; |
| 2890 | engine->get_seqno = ring_get_seqno; |
| 2891 | engine->set_seqno = ring_set_seqno; |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 2892 | if (IS_GEN2(dev_priv)) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2893 | engine->irq_get = i8xx_ring_get_irq; |
| 2894 | engine->irq_put = i8xx_ring_put_irq; |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 2895 | } else { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2896 | engine->irq_get = i9xx_ring_get_irq; |
| 2897 | engine->irq_put = i9xx_ring_put_irq; |
Chris Wilson | c2798b1 | 2012-04-22 21:13:57 +0100 | [diff] [blame] | 2898 | } |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2899 | engine->irq_enable_mask = I915_USER_INTERRUPT; |
Xiang, Haihao | 5c1143b | 2010-09-16 10:43:11 +0800 | [diff] [blame] | 2900 | } |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2901 | engine->write_tail = ring_write_tail; |
Ben Widawsky | 707d9cf | 2014-06-30 09:53:36 -0700 | [diff] [blame] | 2902 | |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 2903 | if (IS_HASWELL(dev_priv)) |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2904 | engine->dispatch_execbuffer = hsw_ring_dispatch_execbuffer; |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 2905 | else if (IS_GEN8(dev_priv)) |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2906 | engine->dispatch_execbuffer = gen8_ring_dispatch_execbuffer; |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 2907 | else if (INTEL_GEN(dev_priv) >= 6) |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2908 | engine->dispatch_execbuffer = gen6_ring_dispatch_execbuffer; |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 2909 | else if (INTEL_GEN(dev_priv) >= 4) |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2910 | engine->dispatch_execbuffer = i965_dispatch_execbuffer; |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 2911 | else if (IS_I830(dev_priv) || IS_845G(dev_priv)) |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2912 | engine->dispatch_execbuffer = i830_dispatch_execbuffer; |
Daniel Vetter | fb3256d | 2012-04-11 22:12:56 +0200 | [diff] [blame] | 2913 | else |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2914 | engine->dispatch_execbuffer = i915_dispatch_execbuffer; |
| 2915 | engine->init_hw = init_render_ring; |
| 2916 | engine->cleanup = render_ring_cleanup; |
Daniel Vetter | 59465b5 | 2012-04-11 22:12:48 +0200 | [diff] [blame] | 2917 | |
Daniel Vetter | b45305f | 2012-12-17 16:21:27 +0100 | [diff] [blame] | 2918 | /* Workaround batchbuffer to combat CS tlb bug. */ |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 2919 | if (HAS_BROKEN_CS_TLB(dev_priv)) { |
Dave Gordon | d37cd8a | 2016-04-22 19:14:32 +0100 | [diff] [blame] | 2920 | obj = i915_gem_object_create(dev, I830_WA_SIZE); |
Chris Wilson | fe3db79 | 2016-04-25 13:32:13 +0100 | [diff] [blame] | 2921 | if (IS_ERR(obj)) { |
Daniel Vetter | b45305f | 2012-12-17 16:21:27 +0100 | [diff] [blame] | 2922 | DRM_ERROR("Failed to allocate batch bo\n"); |
Chris Wilson | fe3db79 | 2016-04-25 13:32:13 +0100 | [diff] [blame] | 2923 | return PTR_ERR(obj); |
Daniel Vetter | b45305f | 2012-12-17 16:21:27 +0100 | [diff] [blame] | 2924 | } |
| 2925 | |
Daniel Vetter | be1fa12 | 2014-02-14 14:01:14 +0100 | [diff] [blame] | 2926 | ret = i915_gem_obj_ggtt_pin(obj, 0, 0); |
Daniel Vetter | b45305f | 2012-12-17 16:21:27 +0100 | [diff] [blame] | 2927 | if (ret != 0) { |
| 2928 | drm_gem_object_unreference(&obj->base); |
| 2929 | DRM_ERROR("Failed to ping batch bo\n"); |
| 2930 | return ret; |
| 2931 | } |
| 2932 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2933 | engine->scratch.obj = obj; |
| 2934 | engine->scratch.gtt_offset = i915_gem_obj_ggtt_offset(obj); |
Daniel Vetter | b45305f | 2012-12-17 16:21:27 +0100 | [diff] [blame] | 2935 | } |
| 2936 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2937 | ret = intel_init_ring_buffer(dev, engine); |
Daniel Vetter | 99be1df | 2014-11-20 00:33:06 +0100 | [diff] [blame] | 2938 | if (ret) |
| 2939 | return ret; |
| 2940 | |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 2941 | if (INTEL_GEN(dev_priv) >= 5) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2942 | ret = intel_init_pipe_control(engine); |
Daniel Vetter | 99be1df | 2014-11-20 00:33:06 +0100 | [diff] [blame] | 2943 | if (ret) |
| 2944 | return ret; |
| 2945 | } |
| 2946 | |
| 2947 | return 0; |
Xiang, Haihao | 5c1143b | 2010-09-16 10:43:11 +0800 | [diff] [blame] | 2948 | } |
| 2949 | |
| 2950 | int intel_init_bsd_ring_buffer(struct drm_device *dev) |
| 2951 | { |
Jani Nikula | 4640c4f | 2014-03-31 14:27:19 +0300 | [diff] [blame] | 2952 | struct drm_i915_private *dev_priv = dev->dev_private; |
Tvrtko Ursulin | 4a570db | 2016-03-16 11:00:38 +0000 | [diff] [blame] | 2953 | struct intel_engine_cs *engine = &dev_priv->engine[VCS]; |
Xiang, Haihao | 5c1143b | 2010-09-16 10:43:11 +0800 | [diff] [blame] | 2954 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2955 | engine->name = "bsd ring"; |
| 2956 | engine->id = VCS; |
| 2957 | engine->exec_id = I915_EXEC_BSD; |
Chris Wilson | 215a7e3 | 2016-04-29 13:18:23 +0100 | [diff] [blame] | 2958 | engine->hw_id = 1; |
Daniel Vetter | 58fa383 | 2012-04-11 22:12:49 +0200 | [diff] [blame] | 2959 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2960 | engine->write_tail = ring_write_tail; |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 2961 | if (INTEL_GEN(dev_priv) >= 6) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2962 | engine->mmio_base = GEN6_BSD_RING_BASE; |
Daniel Vetter | 0fd2c20 | 2012-04-11 22:12:55 +0200 | [diff] [blame] | 2963 | /* gen6 bsd needs a special wa for tail updates */ |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 2964 | if (IS_GEN6(dev_priv)) |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2965 | engine->write_tail = gen6_bsd_ring_write_tail; |
| 2966 | engine->flush = gen6_bsd_ring_flush; |
| 2967 | engine->add_request = gen6_add_request; |
Chris Wilson | c04e0f3 | 2016-04-09 10:57:54 +0100 | [diff] [blame] | 2968 | engine->irq_seqno_barrier = gen6_seqno_barrier; |
| 2969 | engine->get_seqno = ring_get_seqno; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2970 | engine->set_seqno = ring_set_seqno; |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 2971 | if (INTEL_GEN(dev_priv) >= 8) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2972 | engine->irq_enable_mask = |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 2973 | GT_RENDER_USER_INTERRUPT << GEN8_VCS1_IRQ_SHIFT; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2974 | engine->irq_get = gen8_ring_get_irq; |
| 2975 | engine->irq_put = gen8_ring_put_irq; |
| 2976 | engine->dispatch_execbuffer = |
Ben Widawsky | 1c7a062 | 2013-11-02 21:07:12 -0700 | [diff] [blame] | 2977 | gen8_ring_dispatch_execbuffer; |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 2978 | if (i915_semaphore_is_enabled(dev_priv)) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2979 | engine->semaphore.sync_to = gen8_ring_sync; |
| 2980 | engine->semaphore.signal = gen8_xcs_signal; |
| 2981 | GEN8_RING_SEMAPHORE_INIT(engine); |
Ben Widawsky | 707d9cf | 2014-06-30 09:53:36 -0700 | [diff] [blame] | 2982 | } |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 2983 | } else { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2984 | engine->irq_enable_mask = GT_BSD_USER_INTERRUPT; |
| 2985 | engine->irq_get = gen6_ring_get_irq; |
| 2986 | engine->irq_put = gen6_ring_put_irq; |
| 2987 | engine->dispatch_execbuffer = |
Ben Widawsky | 1c7a062 | 2013-11-02 21:07:12 -0700 | [diff] [blame] | 2988 | gen6_ring_dispatch_execbuffer; |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 2989 | if (i915_semaphore_is_enabled(dev_priv)) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 2990 | engine->semaphore.sync_to = gen6_ring_sync; |
| 2991 | engine->semaphore.signal = gen6_signal; |
| 2992 | engine->semaphore.mbox.wait[RCS] = MI_SEMAPHORE_SYNC_VR; |
| 2993 | engine->semaphore.mbox.wait[VCS] = MI_SEMAPHORE_SYNC_INVALID; |
| 2994 | engine->semaphore.mbox.wait[BCS] = MI_SEMAPHORE_SYNC_VB; |
| 2995 | engine->semaphore.mbox.wait[VECS] = MI_SEMAPHORE_SYNC_VVE; |
| 2996 | engine->semaphore.mbox.wait[VCS2] = MI_SEMAPHORE_SYNC_INVALID; |
| 2997 | engine->semaphore.mbox.signal[RCS] = GEN6_RVSYNC; |
| 2998 | engine->semaphore.mbox.signal[VCS] = GEN6_NOSYNC; |
| 2999 | engine->semaphore.mbox.signal[BCS] = GEN6_BVSYNC; |
| 3000 | engine->semaphore.mbox.signal[VECS] = GEN6_VEVSYNC; |
| 3001 | engine->semaphore.mbox.signal[VCS2] = GEN6_NOSYNC; |
Ben Widawsky | 707d9cf | 2014-06-30 09:53:36 -0700 | [diff] [blame] | 3002 | } |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 3003 | } |
Daniel Vetter | 58fa383 | 2012-04-11 22:12:49 +0200 | [diff] [blame] | 3004 | } else { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3005 | engine->mmio_base = BSD_RING_BASE; |
| 3006 | engine->flush = bsd_ring_flush; |
| 3007 | engine->add_request = i9xx_add_request; |
| 3008 | engine->get_seqno = ring_get_seqno; |
| 3009 | engine->set_seqno = ring_set_seqno; |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 3010 | if (IS_GEN5(dev_priv)) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3011 | engine->irq_enable_mask = ILK_BSD_USER_INTERRUPT; |
| 3012 | engine->irq_get = gen5_ring_get_irq; |
| 3013 | engine->irq_put = gen5_ring_put_irq; |
Daniel Vetter | e48d863 | 2012-04-11 22:12:54 +0200 | [diff] [blame] | 3014 | } else { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3015 | engine->irq_enable_mask = I915_BSD_USER_INTERRUPT; |
| 3016 | engine->irq_get = i9xx_ring_get_irq; |
| 3017 | engine->irq_put = i9xx_ring_put_irq; |
Daniel Vetter | e48d863 | 2012-04-11 22:12:54 +0200 | [diff] [blame] | 3018 | } |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3019 | engine->dispatch_execbuffer = i965_dispatch_execbuffer; |
Daniel Vetter | 58fa383 | 2012-04-11 22:12:49 +0200 | [diff] [blame] | 3020 | } |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3021 | engine->init_hw = init_ring_common; |
Daniel Vetter | 58fa383 | 2012-04-11 22:12:49 +0200 | [diff] [blame] | 3022 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3023 | return intel_init_ring_buffer(dev, engine); |
Xiang, Haihao | 5c1143b | 2010-09-16 10:43:11 +0800 | [diff] [blame] | 3024 | } |
Chris Wilson | 549f736 | 2010-10-19 11:19:32 +0100 | [diff] [blame] | 3025 | |
Zhao Yakui | 845f74a | 2014-04-17 10:37:37 +0800 | [diff] [blame] | 3026 | /** |
Damien Lespiau | 6265992 | 2015-01-29 14:13:40 +0000 | [diff] [blame] | 3027 | * Initialize the second BSD ring (eg. Broadwell GT3, Skylake GT3) |
Zhao Yakui | 845f74a | 2014-04-17 10:37:37 +0800 | [diff] [blame] | 3028 | */ |
| 3029 | int intel_init_bsd2_ring_buffer(struct drm_device *dev) |
| 3030 | { |
| 3031 | struct drm_i915_private *dev_priv = dev->dev_private; |
Tvrtko Ursulin | 4a570db | 2016-03-16 11:00:38 +0000 | [diff] [blame] | 3032 | struct intel_engine_cs *engine = &dev_priv->engine[VCS2]; |
Zhao Yakui | 845f74a | 2014-04-17 10:37:37 +0800 | [diff] [blame] | 3033 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3034 | engine->name = "bsd2 ring"; |
| 3035 | engine->id = VCS2; |
| 3036 | engine->exec_id = I915_EXEC_BSD; |
Chris Wilson | 215a7e3 | 2016-04-29 13:18:23 +0100 | [diff] [blame] | 3037 | engine->hw_id = 4; |
Zhao Yakui | 845f74a | 2014-04-17 10:37:37 +0800 | [diff] [blame] | 3038 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3039 | engine->write_tail = ring_write_tail; |
| 3040 | engine->mmio_base = GEN8_BSD2_RING_BASE; |
| 3041 | engine->flush = gen6_bsd_ring_flush; |
| 3042 | engine->add_request = gen6_add_request; |
Chris Wilson | c04e0f3 | 2016-04-09 10:57:54 +0100 | [diff] [blame] | 3043 | engine->irq_seqno_barrier = gen6_seqno_barrier; |
| 3044 | engine->get_seqno = ring_get_seqno; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3045 | engine->set_seqno = ring_set_seqno; |
| 3046 | engine->irq_enable_mask = |
Zhao Yakui | 845f74a | 2014-04-17 10:37:37 +0800 | [diff] [blame] | 3047 | GT_RENDER_USER_INTERRUPT << GEN8_VCS2_IRQ_SHIFT; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3048 | engine->irq_get = gen8_ring_get_irq; |
| 3049 | engine->irq_put = gen8_ring_put_irq; |
| 3050 | engine->dispatch_execbuffer = |
Zhao Yakui | 845f74a | 2014-04-17 10:37:37 +0800 | [diff] [blame] | 3051 | gen8_ring_dispatch_execbuffer; |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 3052 | if (i915_semaphore_is_enabled(dev_priv)) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3053 | engine->semaphore.sync_to = gen8_ring_sync; |
| 3054 | engine->semaphore.signal = gen8_xcs_signal; |
| 3055 | GEN8_RING_SEMAPHORE_INIT(engine); |
Ben Widawsky | 3e78998 | 2014-06-30 09:53:37 -0700 | [diff] [blame] | 3056 | } |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3057 | engine->init_hw = init_ring_common; |
Zhao Yakui | 845f74a | 2014-04-17 10:37:37 +0800 | [diff] [blame] | 3058 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3059 | return intel_init_ring_buffer(dev, engine); |
Zhao Yakui | 845f74a | 2014-04-17 10:37:37 +0800 | [diff] [blame] | 3060 | } |
| 3061 | |
Chris Wilson | 549f736 | 2010-10-19 11:19:32 +0100 | [diff] [blame] | 3062 | int intel_init_blt_ring_buffer(struct drm_device *dev) |
| 3063 | { |
Jani Nikula | 4640c4f | 2014-03-31 14:27:19 +0300 | [diff] [blame] | 3064 | struct drm_i915_private *dev_priv = dev->dev_private; |
Tvrtko Ursulin | 4a570db | 2016-03-16 11:00:38 +0000 | [diff] [blame] | 3065 | struct intel_engine_cs *engine = &dev_priv->engine[BCS]; |
Chris Wilson | 549f736 | 2010-10-19 11:19:32 +0100 | [diff] [blame] | 3066 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3067 | engine->name = "blitter ring"; |
| 3068 | engine->id = BCS; |
| 3069 | engine->exec_id = I915_EXEC_BLT; |
Chris Wilson | 215a7e3 | 2016-04-29 13:18:23 +0100 | [diff] [blame] | 3070 | engine->hw_id = 2; |
Daniel Vetter | 3535d9d | 2012-04-11 22:12:50 +0200 | [diff] [blame] | 3071 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3072 | engine->mmio_base = BLT_RING_BASE; |
| 3073 | engine->write_tail = ring_write_tail; |
| 3074 | engine->flush = gen6_ring_flush; |
| 3075 | engine->add_request = gen6_add_request; |
Chris Wilson | c04e0f3 | 2016-04-09 10:57:54 +0100 | [diff] [blame] | 3076 | engine->irq_seqno_barrier = gen6_seqno_barrier; |
| 3077 | engine->get_seqno = ring_get_seqno; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3078 | engine->set_seqno = ring_set_seqno; |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 3079 | if (INTEL_GEN(dev_priv) >= 8) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3080 | engine->irq_enable_mask = |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 3081 | GT_RENDER_USER_INTERRUPT << GEN8_BCS_IRQ_SHIFT; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3082 | engine->irq_get = gen8_ring_get_irq; |
| 3083 | engine->irq_put = gen8_ring_put_irq; |
| 3084 | engine->dispatch_execbuffer = gen8_ring_dispatch_execbuffer; |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 3085 | if (i915_semaphore_is_enabled(dev_priv)) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3086 | engine->semaphore.sync_to = gen8_ring_sync; |
| 3087 | engine->semaphore.signal = gen8_xcs_signal; |
| 3088 | GEN8_RING_SEMAPHORE_INIT(engine); |
Ben Widawsky | 707d9cf | 2014-06-30 09:53:36 -0700 | [diff] [blame] | 3089 | } |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 3090 | } else { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3091 | engine->irq_enable_mask = GT_BLT_USER_INTERRUPT; |
| 3092 | engine->irq_get = gen6_ring_get_irq; |
| 3093 | engine->irq_put = gen6_ring_put_irq; |
| 3094 | engine->dispatch_execbuffer = gen6_ring_dispatch_execbuffer; |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 3095 | if (i915_semaphore_is_enabled(dev_priv)) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3096 | engine->semaphore.signal = gen6_signal; |
| 3097 | engine->semaphore.sync_to = gen6_ring_sync; |
Ben Widawsky | 707d9cf | 2014-06-30 09:53:36 -0700 | [diff] [blame] | 3098 | /* |
| 3099 | * The current semaphore is only applied on pre-gen8 |
| 3100 | * platform. And there is no VCS2 ring on the pre-gen8 |
| 3101 | * platform. So the semaphore between BCS and VCS2 is |
| 3102 | * initialized as INVALID. Gen8 will initialize the |
| 3103 | * sema between BCS and VCS2 later. |
| 3104 | */ |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3105 | engine->semaphore.mbox.wait[RCS] = MI_SEMAPHORE_SYNC_BR; |
| 3106 | engine->semaphore.mbox.wait[VCS] = MI_SEMAPHORE_SYNC_BV; |
| 3107 | engine->semaphore.mbox.wait[BCS] = MI_SEMAPHORE_SYNC_INVALID; |
| 3108 | engine->semaphore.mbox.wait[VECS] = MI_SEMAPHORE_SYNC_BVE; |
| 3109 | engine->semaphore.mbox.wait[VCS2] = MI_SEMAPHORE_SYNC_INVALID; |
| 3110 | engine->semaphore.mbox.signal[RCS] = GEN6_RBSYNC; |
| 3111 | engine->semaphore.mbox.signal[VCS] = GEN6_VBSYNC; |
| 3112 | engine->semaphore.mbox.signal[BCS] = GEN6_NOSYNC; |
| 3113 | engine->semaphore.mbox.signal[VECS] = GEN6_VEBSYNC; |
| 3114 | engine->semaphore.mbox.signal[VCS2] = GEN6_NOSYNC; |
Ben Widawsky | 707d9cf | 2014-06-30 09:53:36 -0700 | [diff] [blame] | 3115 | } |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 3116 | } |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3117 | engine->init_hw = init_ring_common; |
Chris Wilson | 549f736 | 2010-10-19 11:19:32 +0100 | [diff] [blame] | 3118 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3119 | return intel_init_ring_buffer(dev, engine); |
Chris Wilson | 549f736 | 2010-10-19 11:19:32 +0100 | [diff] [blame] | 3120 | } |
Chris Wilson | a7b9761 | 2012-07-20 12:41:08 +0100 | [diff] [blame] | 3121 | |
Ben Widawsky | 9a8a221 | 2013-05-28 19:22:23 -0700 | [diff] [blame] | 3122 | int intel_init_vebox_ring_buffer(struct drm_device *dev) |
| 3123 | { |
Jani Nikula | 4640c4f | 2014-03-31 14:27:19 +0300 | [diff] [blame] | 3124 | struct drm_i915_private *dev_priv = dev->dev_private; |
Tvrtko Ursulin | 4a570db | 2016-03-16 11:00:38 +0000 | [diff] [blame] | 3125 | struct intel_engine_cs *engine = &dev_priv->engine[VECS]; |
Ben Widawsky | 9a8a221 | 2013-05-28 19:22:23 -0700 | [diff] [blame] | 3126 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3127 | engine->name = "video enhancement ring"; |
| 3128 | engine->id = VECS; |
| 3129 | engine->exec_id = I915_EXEC_VEBOX; |
Chris Wilson | 215a7e3 | 2016-04-29 13:18:23 +0100 | [diff] [blame] | 3130 | engine->hw_id = 3; |
Ben Widawsky | 9a8a221 | 2013-05-28 19:22:23 -0700 | [diff] [blame] | 3131 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3132 | engine->mmio_base = VEBOX_RING_BASE; |
| 3133 | engine->write_tail = ring_write_tail; |
| 3134 | engine->flush = gen6_ring_flush; |
| 3135 | engine->add_request = gen6_add_request; |
Chris Wilson | c04e0f3 | 2016-04-09 10:57:54 +0100 | [diff] [blame] | 3136 | engine->irq_seqno_barrier = gen6_seqno_barrier; |
| 3137 | engine->get_seqno = ring_get_seqno; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3138 | engine->set_seqno = ring_set_seqno; |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 3139 | |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 3140 | if (INTEL_GEN(dev_priv) >= 8) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3141 | engine->irq_enable_mask = |
Daniel Vetter | 40c499f | 2013-11-07 21:40:39 -0800 | [diff] [blame] | 3142 | GT_RENDER_USER_INTERRUPT << GEN8_VECS_IRQ_SHIFT; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3143 | engine->irq_get = gen8_ring_get_irq; |
| 3144 | engine->irq_put = gen8_ring_put_irq; |
| 3145 | engine->dispatch_execbuffer = gen8_ring_dispatch_execbuffer; |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 3146 | if (i915_semaphore_is_enabled(dev_priv)) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3147 | engine->semaphore.sync_to = gen8_ring_sync; |
| 3148 | engine->semaphore.signal = gen8_xcs_signal; |
| 3149 | GEN8_RING_SEMAPHORE_INIT(engine); |
Ben Widawsky | 707d9cf | 2014-06-30 09:53:36 -0700 | [diff] [blame] | 3150 | } |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 3151 | } else { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3152 | engine->irq_enable_mask = PM_VEBOX_USER_INTERRUPT; |
| 3153 | engine->irq_get = hsw_vebox_get_irq; |
| 3154 | engine->irq_put = hsw_vebox_put_irq; |
| 3155 | engine->dispatch_execbuffer = gen6_ring_dispatch_execbuffer; |
Chris Wilson | c033666 | 2016-05-06 15:40:21 +0100 | [diff] [blame] | 3156 | if (i915_semaphore_is_enabled(dev_priv)) { |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3157 | engine->semaphore.sync_to = gen6_ring_sync; |
| 3158 | engine->semaphore.signal = gen6_signal; |
| 3159 | engine->semaphore.mbox.wait[RCS] = MI_SEMAPHORE_SYNC_VER; |
| 3160 | engine->semaphore.mbox.wait[VCS] = MI_SEMAPHORE_SYNC_VEV; |
| 3161 | engine->semaphore.mbox.wait[BCS] = MI_SEMAPHORE_SYNC_VEB; |
| 3162 | engine->semaphore.mbox.wait[VECS] = MI_SEMAPHORE_SYNC_INVALID; |
| 3163 | engine->semaphore.mbox.wait[VCS2] = MI_SEMAPHORE_SYNC_INVALID; |
| 3164 | engine->semaphore.mbox.signal[RCS] = GEN6_RVESYNC; |
| 3165 | engine->semaphore.mbox.signal[VCS] = GEN6_VVESYNC; |
| 3166 | engine->semaphore.mbox.signal[BCS] = GEN6_BVESYNC; |
| 3167 | engine->semaphore.mbox.signal[VECS] = GEN6_NOSYNC; |
| 3168 | engine->semaphore.mbox.signal[VCS2] = GEN6_NOSYNC; |
Ben Widawsky | 707d9cf | 2014-06-30 09:53:36 -0700 | [diff] [blame] | 3169 | } |
Ben Widawsky | abd58f0 | 2013-11-02 21:07:09 -0700 | [diff] [blame] | 3170 | } |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3171 | engine->init_hw = init_ring_common; |
Ben Widawsky | 9a8a221 | 2013-05-28 19:22:23 -0700 | [diff] [blame] | 3172 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3173 | return intel_init_ring_buffer(dev, engine); |
Ben Widawsky | 9a8a221 | 2013-05-28 19:22:23 -0700 | [diff] [blame] | 3174 | } |
| 3175 | |
Chris Wilson | a7b9761 | 2012-07-20 12:41:08 +0100 | [diff] [blame] | 3176 | int |
John Harrison | 4866d72 | 2015-05-29 17:43:55 +0100 | [diff] [blame] | 3177 | intel_ring_flush_all_caches(struct drm_i915_gem_request *req) |
Chris Wilson | a7b9761 | 2012-07-20 12:41:08 +0100 | [diff] [blame] | 3178 | { |
Tvrtko Ursulin | 4a570db | 2016-03-16 11:00:38 +0000 | [diff] [blame] | 3179 | struct intel_engine_cs *engine = req->engine; |
Chris Wilson | a7b9761 | 2012-07-20 12:41:08 +0100 | [diff] [blame] | 3180 | int ret; |
| 3181 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3182 | if (!engine->gpu_caches_dirty) |
Chris Wilson | a7b9761 | 2012-07-20 12:41:08 +0100 | [diff] [blame] | 3183 | return 0; |
| 3184 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3185 | ret = engine->flush(req, 0, I915_GEM_GPU_DOMAINS); |
Chris Wilson | a7b9761 | 2012-07-20 12:41:08 +0100 | [diff] [blame] | 3186 | if (ret) |
| 3187 | return ret; |
| 3188 | |
John Harrison | a84c3ae | 2015-05-29 17:43:57 +0100 | [diff] [blame] | 3189 | trace_i915_gem_ring_flush(req, 0, I915_GEM_GPU_DOMAINS); |
Chris Wilson | a7b9761 | 2012-07-20 12:41:08 +0100 | [diff] [blame] | 3190 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3191 | engine->gpu_caches_dirty = false; |
Chris Wilson | a7b9761 | 2012-07-20 12:41:08 +0100 | [diff] [blame] | 3192 | return 0; |
| 3193 | } |
| 3194 | |
| 3195 | int |
John Harrison | 2f20055 | 2015-05-29 17:43:53 +0100 | [diff] [blame] | 3196 | intel_ring_invalidate_all_caches(struct drm_i915_gem_request *req) |
Chris Wilson | a7b9761 | 2012-07-20 12:41:08 +0100 | [diff] [blame] | 3197 | { |
Tvrtko Ursulin | 4a570db | 2016-03-16 11:00:38 +0000 | [diff] [blame] | 3198 | struct intel_engine_cs *engine = req->engine; |
Chris Wilson | a7b9761 | 2012-07-20 12:41:08 +0100 | [diff] [blame] | 3199 | uint32_t flush_domains; |
| 3200 | int ret; |
| 3201 | |
| 3202 | flush_domains = 0; |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3203 | if (engine->gpu_caches_dirty) |
Chris Wilson | a7b9761 | 2012-07-20 12:41:08 +0100 | [diff] [blame] | 3204 | flush_domains = I915_GEM_GPU_DOMAINS; |
| 3205 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3206 | ret = engine->flush(req, I915_GEM_GPU_DOMAINS, flush_domains); |
Chris Wilson | a7b9761 | 2012-07-20 12:41:08 +0100 | [diff] [blame] | 3207 | if (ret) |
| 3208 | return ret; |
| 3209 | |
John Harrison | a84c3ae | 2015-05-29 17:43:57 +0100 | [diff] [blame] | 3210 | trace_i915_gem_ring_flush(req, I915_GEM_GPU_DOMAINS, flush_domains); |
Chris Wilson | a7b9761 | 2012-07-20 12:41:08 +0100 | [diff] [blame] | 3211 | |
Tvrtko Ursulin | e2f8039 | 2016-03-16 11:00:36 +0000 | [diff] [blame] | 3212 | engine->gpu_caches_dirty = false; |
Chris Wilson | a7b9761 | 2012-07-20 12:41:08 +0100 | [diff] [blame] | 3213 | return 0; |
| 3214 | } |
Chris Wilson | e3efda4 | 2014-04-09 09:19:41 +0100 | [diff] [blame] | 3215 | |
| 3216 | void |
Tvrtko Ursulin | 117897f | 2016-03-16 11:00:40 +0000 | [diff] [blame] | 3217 | intel_stop_engine(struct intel_engine_cs *engine) |
Chris Wilson | e3efda4 | 2014-04-09 09:19:41 +0100 | [diff] [blame] | 3218 | { |
| 3219 | int ret; |
| 3220 | |
Tvrtko Ursulin | 117897f | 2016-03-16 11:00:40 +0000 | [diff] [blame] | 3221 | if (!intel_engine_initialized(engine)) |
Chris Wilson | e3efda4 | 2014-04-09 09:19:41 +0100 | [diff] [blame] | 3222 | return; |
| 3223 | |
Tvrtko Ursulin | 666796d | 2016-03-16 11:00:39 +0000 | [diff] [blame] | 3224 | ret = intel_engine_idle(engine); |
Chris Wilson | f4457ae | 2016-04-13 17:35:08 +0100 | [diff] [blame] | 3225 | if (ret) |
Chris Wilson | e3efda4 | 2014-04-09 09:19:41 +0100 | [diff] [blame] | 3226 | DRM_ERROR("failed to quiesce %s whilst cleaning up: %d\n", |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 3227 | engine->name, ret); |
Chris Wilson | e3efda4 | 2014-04-09 09:19:41 +0100 | [diff] [blame] | 3228 | |
Tvrtko Ursulin | 0bc40be | 2016-03-16 11:00:37 +0000 | [diff] [blame] | 3229 | stop_ring(engine); |
Chris Wilson | e3efda4 | 2014-04-09 09:19:41 +0100 | [diff] [blame] | 3230 | } |