blob: 77e9871a8c9ac87ca4d2360262d7d815cd8270b0 [file] [log] [blame]
Peter Antoine3bbaba02015-07-10 20:13:11 +03001/*
2 * Copyright (c) 2015 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 * The above copyright notice and this permission notice (including the next
11 * paragraph) shall be included in all copies or substantial portions of the
12 * Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 * SOFTWARE.
21 */
22
23#include "intel_mocs.h"
24#include "intel_lrc.h"
25#include "intel_ringbuffer.h"
26
27/* structures required */
28struct drm_i915_mocs_entry {
29 u32 control_value;
30 u16 l3cc_value;
31};
32
33struct drm_i915_mocs_table {
34 u32 size;
35 const struct drm_i915_mocs_entry *table;
36};
37
38/* Defines for the tables (XXX_MOCS_0 - XXX_MOCS_63) */
39#define LE_CACHEABILITY(value) ((value) << 0)
40#define LE_TGT_CACHE(value) ((value) << 2)
41#define LE_LRUM(value) ((value) << 4)
42#define LE_AOM(value) ((value) << 6)
43#define LE_RSC(value) ((value) << 7)
44#define LE_SCC(value) ((value) << 8)
45#define LE_PFM(value) ((value) << 11)
46#define LE_SCF(value) ((value) << 14)
47
48/* Defines for the tables (LNCFMOCS0 - LNCFMOCS31) - two entries per word */
49#define L3_ESC(value) ((value) << 0)
50#define L3_SCC(value) ((value) << 1)
51#define L3_CACHEABILITY(value) ((value) << 4)
52
53/* Helper defines */
54#define GEN9_NUM_MOCS_ENTRIES 62 /* 62 out of 64 - 63 & 64 are reserved. */
55
56/* (e)LLC caching options */
57#define LE_PAGETABLE 0
58#define LE_UC 1
59#define LE_WT 2
60#define LE_WB 3
61
62/* L3 caching options */
63#define L3_DIRECT 0
64#define L3_UC 1
65#define L3_RESERVED 2
66#define L3_WB 3
67
68/* Target cache */
Imre Deake4198992016-07-01 16:40:04 +030069#define LE_TC_PAGETABLE 0
70#define LE_TC_LLC 1
71#define LE_TC_LLC_ELLC 2
72#define LE_TC_LLC_ELLC_ALT 3
Peter Antoine3bbaba02015-07-10 20:13:11 +030073
74/*
75 * MOCS tables
76 *
77 * These are the MOCS tables that are programmed across all the rings.
78 * The control value is programmed to all the rings that support the
79 * MOCS registers. While the l3cc_values are only programmed to the
80 * LNCFCMOCS0 - LNCFCMOCS32 registers.
81 *
82 * These tables are intended to be kept reasonably consistent across
83 * platforms. However some of the fields are not applicable to all of
84 * them.
85 *
86 * Entries not part of the following tables are undefined as far as
87 * userspace is concerned and shouldn't be relied upon. For the time
88 * being they will be implicitly initialized to the strictest caching
89 * configuration (uncached) to guarantee forwards compatibility with
90 * userspace programs written against more recent kernels providing
91 * additional MOCS entries.
92 *
93 * NOTE: These tables MUST start with being uncached and the length
94 * MUST be less than 63 as the last two registers are reserved
95 * by the hardware. These tables are part of the kernel ABI and
96 * may only be updated incrementally by adding entries at the
97 * end.
98 */
99static const struct drm_i915_mocs_entry skylake_mocs_table[] = {
Imre Deak3373ce22016-07-01 17:32:08 +0300100 [I915_MOCS_UNCACHED] = {
101 /* 0x00000009 */
Imre Deake4198992016-07-01 16:40:04 +0300102 .control_value = LE_CACHEABILITY(LE_UC) |
103 LE_TGT_CACHE(LE_TC_LLC_ELLC) |
104 LE_LRUM(0) | LE_AOM(0) | LE_RSC(0) | LE_SCC(0) |
105 LE_PFM(0) | LE_SCF(0),
106
107 /* 0x0010 */
108 .l3cc_value = L3_ESC(0) | L3_SCC(0) | L3_CACHEABILITY(L3_UC),
109 },
Imre Deak3373ce22016-07-01 17:32:08 +0300110 [I915_MOCS_PTE] = {
Imre Deake4198992016-07-01 16:40:04 +0300111 /* 0x00000038 */
112 .control_value = LE_CACHEABILITY(LE_PAGETABLE) |
113 LE_TGT_CACHE(LE_TC_LLC_ELLC) |
114 LE_LRUM(3) | LE_AOM(0) | LE_RSC(0) | LE_SCC(0) |
115 LE_PFM(0) | LE_SCF(0),
116 /* 0x0030 */
117 .l3cc_value = L3_ESC(0) | L3_SCC(0) | L3_CACHEABILITY(L3_WB),
118 },
Imre Deak3373ce22016-07-01 17:32:08 +0300119 [I915_MOCS_CACHED] = {
Imre Deake4198992016-07-01 16:40:04 +0300120 /* 0x0000003b */
121 .control_value = LE_CACHEABILITY(LE_WB) |
122 LE_TGT_CACHE(LE_TC_LLC_ELLC) |
123 LE_LRUM(3) | LE_AOM(0) | LE_RSC(0) | LE_SCC(0) |
124 LE_PFM(0) | LE_SCF(0),
125 /* 0x0030 */
126 .l3cc_value = L3_ESC(0) | L3_SCC(0) | L3_CACHEABILITY(L3_WB),
127 },
Peter Antoine3bbaba02015-07-10 20:13:11 +0300128};
129
130/* NOTE: the LE_TGT_CACHE is not used on Broxton */
131static const struct drm_i915_mocs_entry broxton_mocs_table[] = {
Imre Deak3373ce22016-07-01 17:32:08 +0300132 [I915_MOCS_UNCACHED] = {
Imre Deake4198992016-07-01 16:40:04 +0300133 /* 0x00000009 */
134 .control_value = LE_CACHEABILITY(LE_UC) |
135 LE_TGT_CACHE(LE_TC_LLC_ELLC) |
136 LE_LRUM(0) | LE_AOM(0) | LE_RSC(0) | LE_SCC(0) |
137 LE_PFM(0) | LE_SCF(0),
138
139 /* 0x0010 */
140 .l3cc_value = L3_ESC(0) | L3_SCC(0) | L3_CACHEABILITY(L3_UC),
141 },
Imre Deak3373ce22016-07-01 17:32:08 +0300142 [I915_MOCS_PTE] = {
Imre Deake4198992016-07-01 16:40:04 +0300143 /* 0x00000038 */
144 .control_value = LE_CACHEABILITY(LE_PAGETABLE) |
145 LE_TGT_CACHE(LE_TC_LLC_ELLC) |
146 LE_LRUM(3) | LE_AOM(0) | LE_RSC(0) | LE_SCC(0) |
147 LE_PFM(0) | LE_SCF(0),
148
149 /* 0x0030 */
150 .l3cc_value = L3_ESC(0) | L3_SCC(0) | L3_CACHEABILITY(L3_WB),
151 },
Imre Deak3373ce22016-07-01 17:32:08 +0300152 [I915_MOCS_CACHED] = {
Imre Deak6bee14ed2016-07-01 16:40:05 +0300153 /* 0x00000039 */
154 .control_value = LE_CACHEABILITY(LE_UC) |
Imre Deake4198992016-07-01 16:40:04 +0300155 LE_TGT_CACHE(LE_TC_LLC_ELLC) |
156 LE_LRUM(3) | LE_AOM(0) | LE_RSC(0) | LE_SCC(0) |
157 LE_PFM(0) | LE_SCF(0),
158
159 /* 0x0030 */
160 .l3cc_value = L3_ESC(0) | L3_SCC(0) | L3_CACHEABILITY(L3_WB),
161 },
Peter Antoine3bbaba02015-07-10 20:13:11 +0300162};
163
164/**
165 * get_mocs_settings()
Peter Antoine0ccdacf2016-04-13 15:03:25 +0100166 * @dev_priv: i915 device.
Peter Antoine3bbaba02015-07-10 20:13:11 +0300167 * @table: Output table that will be made to point at appropriate
Peter Antoine0ccdacf2016-04-13 15:03:25 +0100168 * MOCS values for the device.
Peter Antoine3bbaba02015-07-10 20:13:11 +0300169 *
170 * This function will return the values of the MOCS table that needs to
171 * be programmed for the platform. It will return the values that need
172 * to be programmed and if they need to be programmed.
173 *
174 * Return: true if there are applicable MOCS settings for the device.
175 */
Peter Antoine0ccdacf2016-04-13 15:03:25 +0100176static bool get_mocs_settings(struct drm_i915_private *dev_priv,
Peter Antoine3bbaba02015-07-10 20:13:11 +0300177 struct drm_i915_mocs_table *table)
178{
179 bool result = false;
180
Tomasz Lis74ba22e2018-05-02 15:31:42 -0700181 if (IS_GEN9_BC(dev_priv) || IS_CANNONLAKE(dev_priv) ||
182 IS_ICELAKE(dev_priv)) {
Peter Antoine3bbaba02015-07-10 20:13:11 +0300183 table->size = ARRAY_SIZE(skylake_mocs_table);
184 table->table = skylake_mocs_table;
185 result = true;
Ander Conselvan de Oliveiracc3f90f2016-12-02 10:23:49 +0200186 } else if (IS_GEN9_LP(dev_priv)) {
Peter Antoine3bbaba02015-07-10 20:13:11 +0300187 table->size = ARRAY_SIZE(broxton_mocs_table);
188 table->table = broxton_mocs_table;
189 result = true;
190 } else {
Tvrtko Ursulinc56b89f2018-02-09 21:58:46 +0000191 WARN_ONCE(INTEL_GEN(dev_priv) >= 9,
Peter Antoine3bbaba02015-07-10 20:13:11 +0300192 "Platform that should have a MOCS table does not.\n");
193 }
194
Ander Conselvan de Oliveira9fb50262017-01-26 11:16:58 +0200195 /* WaDisableSkipCaching:skl,bxt,kbl,glk */
Mika Kuoppala6fc29132016-06-07 17:19:08 +0300196 if (IS_GEN9(dev_priv)) {
197 int i;
198
199 for (i = 0; i < table->size; i++)
200 if (WARN_ON(table->table[i].l3cc_value &
Dan Carpenter030daa02016-06-13 09:54:22 +0300201 (L3_ESC(1) | L3_SCC(0x7))))
Mika Kuoppala6fc29132016-06-07 17:19:08 +0300202 return false;
203 }
204
Peter Antoine3bbaba02015-07-10 20:13:11 +0300205 return result;
206}
207
Dave Gordon38a0f2d2016-07-20 18:16:06 +0100208static i915_reg_t mocs_register(enum intel_engine_id engine_id, int index)
Ville Syrjäläe6c4c762015-11-05 14:13:53 +0200209{
Dave Gordon38a0f2d2016-07-20 18:16:06 +0100210 switch (engine_id) {
Ville Syrjäläe6c4c762015-11-05 14:13:53 +0200211 case RCS:
212 return GEN9_GFX_MOCS(index);
213 case VCS:
214 return GEN9_MFX0_MOCS(index);
215 case BCS:
216 return GEN9_BLT_MOCS(index);
217 case VECS:
218 return GEN9_VEBOX_MOCS(index);
219 case VCS2:
220 return GEN9_MFX1_MOCS(index);
Tomasz Lis74ba22e2018-05-02 15:31:42 -0700221 case VCS3:
222 return GEN11_MFX2_MOCS(index);
Ville Syrjäläe6c4c762015-11-05 14:13:53 +0200223 default:
Dave Gordon38a0f2d2016-07-20 18:16:06 +0100224 MISSING_CASE(engine_id);
Ville Syrjäläf0f59a02015-11-18 15:33:26 +0200225 return INVALID_MMIO_REG;
Ville Syrjäläe6c4c762015-11-05 14:13:53 +0200226 }
227}
228
Peter Antoine3bbaba02015-07-10 20:13:11 +0300229/**
Peter Antoine0ccdacf2016-04-13 15:03:25 +0100230 * intel_mocs_init_engine() - emit the mocs control table
231 * @engine: The engine for whom to emit the registers.
232 *
233 * This function simply emits a MI_LOAD_REGISTER_IMM command for the
234 * given table starting at the given address.
Peter Antoine0ccdacf2016-04-13 15:03:25 +0100235 */
Chris Wilson805615d2018-08-15 19:42:51 +0100236void intel_mocs_init_engine(struct intel_engine_cs *engine)
Peter Antoine0ccdacf2016-04-13 15:03:25 +0100237{
Chris Wilsonc0336662016-05-06 15:40:21 +0100238 struct drm_i915_private *dev_priv = engine->i915;
Peter Antoine0ccdacf2016-04-13 15:03:25 +0100239 struct drm_i915_mocs_table table;
240 unsigned int index;
241
242 if (!get_mocs_settings(dev_priv, &table))
Chris Wilson805615d2018-08-15 19:42:51 +0100243 return;
Peter Antoine0ccdacf2016-04-13 15:03:25 +0100244
Chris Wilson805615d2018-08-15 19:42:51 +0100245 GEM_BUG_ON(table.size > GEN9_NUM_MOCS_ENTRIES);
Peter Antoine0ccdacf2016-04-13 15:03:25 +0100246
247 for (index = 0; index < table.size; index++)
248 I915_WRITE(mocs_register(engine->id, index),
249 table.table[index].control_value);
250
251 /*
252 * Ok, now set the unused entries to uncached. These entries
253 * are officially undefined and no contract for the contents
254 * and settings is given for these entries.
255 *
256 * Entry 0 in the table is uncached - so we are just writing
257 * that value to all the used entries.
258 */
259 for (; index < GEN9_NUM_MOCS_ENTRIES; index++)
260 I915_WRITE(mocs_register(engine->id, index),
261 table.table[0].control_value);
Peter Antoine0ccdacf2016-04-13 15:03:25 +0100262}
263
264/**
Peter Antoine3bbaba02015-07-10 20:13:11 +0300265 * emit_mocs_control_table() - emit the mocs control table
Chris Wilsone61e0f52018-02-21 09:56:36 +0000266 * @rq: Request to set up the MOCS table for.
Peter Antoine3bbaba02015-07-10 20:13:11 +0300267 * @table: The values to program into the control regs.
Peter Antoine3bbaba02015-07-10 20:13:11 +0300268 *
269 * This function simply emits a MI_LOAD_REGISTER_IMM command for the
270 * given table starting at the given address.
271 *
272 * Return: 0 on success, otherwise the error status.
273 */
Chris Wilsone61e0f52018-02-21 09:56:36 +0000274static int emit_mocs_control_table(struct i915_request *rq,
Peter Antoine0ccdacf2016-04-13 15:03:25 +0100275 const struct drm_i915_mocs_table *table)
Peter Antoine3bbaba02015-07-10 20:13:11 +0300276{
Chris Wilsone61e0f52018-02-21 09:56:36 +0000277 enum intel_engine_id engine = rq->engine->id;
Peter Antoine3bbaba02015-07-10 20:13:11 +0300278 unsigned int index;
Tvrtko Ursulin73dec952017-02-14 11:32:42 +0000279 u32 *cs;
Peter Antoine3bbaba02015-07-10 20:13:11 +0300280
281 if (WARN_ON(table->size > GEN9_NUM_MOCS_ENTRIES))
282 return -ENODEV;
283
Chris Wilsone61e0f52018-02-21 09:56:36 +0000284 cs = intel_ring_begin(rq, 2 + 2 * GEN9_NUM_MOCS_ENTRIES);
Tvrtko Ursulin73dec952017-02-14 11:32:42 +0000285 if (IS_ERR(cs))
286 return PTR_ERR(cs);
Peter Antoine3bbaba02015-07-10 20:13:11 +0300287
Tvrtko Ursulin73dec952017-02-14 11:32:42 +0000288 *cs++ = MI_LOAD_REGISTER_IMM(GEN9_NUM_MOCS_ENTRIES);
Peter Antoine3bbaba02015-07-10 20:13:11 +0300289
290 for (index = 0; index < table->size; index++) {
Tvrtko Ursulin73dec952017-02-14 11:32:42 +0000291 *cs++ = i915_mmio_reg_offset(mocs_register(engine, index));
292 *cs++ = table->table[index].control_value;
Peter Antoine3bbaba02015-07-10 20:13:11 +0300293 }
294
295 /*
296 * Ok, now set the unused entries to uncached. These entries
297 * are officially undefined and no contract for the contents
298 * and settings is given for these entries.
299 *
300 * Entry 0 in the table is uncached - so we are just writing
301 * that value to all the used entries.
302 */
303 for (; index < GEN9_NUM_MOCS_ENTRIES; index++) {
Tvrtko Ursulin73dec952017-02-14 11:32:42 +0000304 *cs++ = i915_mmio_reg_offset(mocs_register(engine, index));
305 *cs++ = table->table[0].control_value;
Peter Antoine3bbaba02015-07-10 20:13:11 +0300306 }
307
Tvrtko Ursulin73dec952017-02-14 11:32:42 +0000308 *cs++ = MI_NOOP;
Chris Wilsone61e0f52018-02-21 09:56:36 +0000309 intel_ring_advance(rq, cs);
Peter Antoine3bbaba02015-07-10 20:13:11 +0300310
311 return 0;
312}
313
Peter Antoine0ccdacf2016-04-13 15:03:25 +0100314static inline u32 l3cc_combine(const struct drm_i915_mocs_table *table,
315 u16 low,
316 u16 high)
317{
318 return table->table[low].l3cc_value |
319 table->table[high].l3cc_value << 16;
320}
321
Peter Antoine3bbaba02015-07-10 20:13:11 +0300322/**
323 * emit_mocs_l3cc_table() - emit the mocs control table
Chris Wilsone61e0f52018-02-21 09:56:36 +0000324 * @rq: Request to set up the MOCS table for.
Peter Antoine3bbaba02015-07-10 20:13:11 +0300325 * @table: The values to program into the control regs.
326 *
327 * This function simply emits a MI_LOAD_REGISTER_IMM command for the
328 * given table starting at the given address. This register set is
329 * programmed in pairs.
330 *
331 * Return: 0 on success, otherwise the error status.
332 */
Chris Wilsone61e0f52018-02-21 09:56:36 +0000333static int emit_mocs_l3cc_table(struct i915_request *rq,
Peter Antoine3bbaba02015-07-10 20:13:11 +0300334 const struct drm_i915_mocs_table *table)
335{
Peter Antoine3bbaba02015-07-10 20:13:11 +0300336 unsigned int i;
Tvrtko Ursulin73dec952017-02-14 11:32:42 +0000337 u32 *cs;
Peter Antoine3bbaba02015-07-10 20:13:11 +0300338
339 if (WARN_ON(table->size > GEN9_NUM_MOCS_ENTRIES))
340 return -ENODEV;
341
Chris Wilsone61e0f52018-02-21 09:56:36 +0000342 cs = intel_ring_begin(rq, 2 + GEN9_NUM_MOCS_ENTRIES);
Tvrtko Ursulin73dec952017-02-14 11:32:42 +0000343 if (IS_ERR(cs))
344 return PTR_ERR(cs);
Peter Antoine3bbaba02015-07-10 20:13:11 +0300345
Tvrtko Ursulin73dec952017-02-14 11:32:42 +0000346 *cs++ = MI_LOAD_REGISTER_IMM(GEN9_NUM_MOCS_ENTRIES / 2);
Peter Antoine3bbaba02015-07-10 20:13:11 +0300347
Peter Antoine0ccdacf2016-04-13 15:03:25 +0100348 for (i = 0; i < table->size/2; i++) {
Tvrtko Ursulin73dec952017-02-14 11:32:42 +0000349 *cs++ = i915_mmio_reg_offset(GEN9_LNCFCMOCS(i));
350 *cs++ = l3cc_combine(table, 2 * i, 2 * i + 1);
Peter Antoine3bbaba02015-07-10 20:13:11 +0300351 }
352
353 if (table->size & 0x01) {
354 /* Odd table size - 1 left over */
Tvrtko Ursulin73dec952017-02-14 11:32:42 +0000355 *cs++ = i915_mmio_reg_offset(GEN9_LNCFCMOCS(i));
356 *cs++ = l3cc_combine(table, 2 * i, 0);
Peter Antoine0ccdacf2016-04-13 15:03:25 +0100357 i++;
358 }
Peter Antoine3bbaba02015-07-10 20:13:11 +0300359
360 /*
361 * Now set the rest of the table to uncached - use entry 0 as
362 * this will be uncached. Leave the last pair uninitialised as
363 * they are reserved by the hardware.
364 */
365 for (; i < GEN9_NUM_MOCS_ENTRIES / 2; i++) {
Tvrtko Ursulin73dec952017-02-14 11:32:42 +0000366 *cs++ = i915_mmio_reg_offset(GEN9_LNCFCMOCS(i));
367 *cs++ = l3cc_combine(table, 0, 0);
Peter Antoine3bbaba02015-07-10 20:13:11 +0300368 }
369
Tvrtko Ursulin73dec952017-02-14 11:32:42 +0000370 *cs++ = MI_NOOP;
Chris Wilsone61e0f52018-02-21 09:56:36 +0000371 intel_ring_advance(rq, cs);
Peter Antoine3bbaba02015-07-10 20:13:11 +0300372
373 return 0;
374}
375
376/**
Peter Antoine0ccdacf2016-04-13 15:03:25 +0100377 * intel_mocs_init_l3cc_table() - program the mocs control table
Tvrtko Ursulinbf9e8422016-12-01 14:16:38 +0000378 * @dev_priv: i915 device private
Peter Antoine0ccdacf2016-04-13 15:03:25 +0100379 *
380 * This function simply programs the mocs registers for the given table
381 * starting at the given address. This register set is programmed in pairs.
382 *
383 * These registers may get programmed more than once, it is simpler to
384 * re-program 32 registers than maintain the state of when they were programmed.
385 * We are always reprogramming with the same values and this only on context
386 * start.
387 *
388 * Return: Nothing.
389 */
Tvrtko Ursulinbf9e8422016-12-01 14:16:38 +0000390void intel_mocs_init_l3cc_table(struct drm_i915_private *dev_priv)
Peter Antoine0ccdacf2016-04-13 15:03:25 +0100391{
Peter Antoine0ccdacf2016-04-13 15:03:25 +0100392 struct drm_i915_mocs_table table;
393 unsigned int i;
394
395 if (!get_mocs_settings(dev_priv, &table))
396 return;
397
398 for (i = 0; i < table.size/2; i++)
399 I915_WRITE(GEN9_LNCFCMOCS(i), l3cc_combine(&table, 2*i, 2*i+1));
400
401 /* Odd table size - 1 left over */
402 if (table.size & 0x01) {
403 I915_WRITE(GEN9_LNCFCMOCS(i), l3cc_combine(&table, 2*i, 0));
404 i++;
405 }
406
407 /*
408 * Now set the rest of the table to uncached - use entry 0 as
409 * this will be uncached. Leave the last pair as initialised as
410 * they are reserved by the hardware.
411 */
412 for (; i < (GEN9_NUM_MOCS_ENTRIES / 2); i++)
413 I915_WRITE(GEN9_LNCFCMOCS(i), l3cc_combine(&table, 0, 0));
414}
415
416/**
Peter Antoine3bbaba02015-07-10 20:13:11 +0300417 * intel_rcs_context_init_mocs() - program the MOCS register.
Chris Wilsone61e0f52018-02-21 09:56:36 +0000418 * @rq: Request to set up the MOCS tables for.
Peter Antoine3bbaba02015-07-10 20:13:11 +0300419 *
420 * This function will emit a batch buffer with the values required for
421 * programming the MOCS register values for all the currently supported
422 * rings.
423 *
424 * These registers are partially stored in the RCS context, so they are
425 * emitted at the same time so that when a context is created these registers
426 * are set up. These registers have to be emitted into the start of the
427 * context as setting the ELSP will re-init some of these registers back
428 * to the hw values.
429 *
430 * Return: 0 on success, otherwise the error status.
431 */
Chris Wilsone61e0f52018-02-21 09:56:36 +0000432int intel_rcs_context_init_mocs(struct i915_request *rq)
Peter Antoine3bbaba02015-07-10 20:13:11 +0300433{
434 struct drm_i915_mocs_table t;
435 int ret;
436
Chris Wilsone61e0f52018-02-21 09:56:36 +0000437 if (get_mocs_settings(rq->i915, &t)) {
Peter Antoine0ccdacf2016-04-13 15:03:25 +0100438 /* Program the RCS control registers */
Chris Wilsone61e0f52018-02-21 09:56:36 +0000439 ret = emit_mocs_control_table(rq, &t);
Peter Antoine0ccdacf2016-04-13 15:03:25 +0100440 if (ret)
441 return ret;
Peter Antoine3bbaba02015-07-10 20:13:11 +0300442
443 /* Now program the l3cc registers */
Chris Wilsone61e0f52018-02-21 09:56:36 +0000444 ret = emit_mocs_l3cc_table(rq, &t);
Peter Antoine3bbaba02015-07-10 20:13:11 +0300445 if (ret)
446 return ret;
447 }
448
449 return 0;
450}