Skip to contentSkip to conversation

drm/i915/mocs: Program MOCS for all engines on init

PATCH Superseded Peter Antoine 3 participants 4 messages Mar 11, 2016 – Mar 14, 2016

Subsystems (2)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 drm/i915/mocs: Program MOCS for all engines on init

Allow for the MOCS to be programmed for all engines. Currently we program the MOCS when the first render batch goes through. This works on most platforms but fails on platforms that do not run a render batch early,
i.e. headless servers. The patch now programs all initialised engines on init and the RCS is programmed again within the initial batch. This is done for predictable consistency with regards to the hardware context.

Hardware context loading sets the values of the MOCS for RCS and L3CC. Programming them from within the batch makes sure that the render context is valid, no matter what the previous state of the saved-context was.

v2: posted correct version to the mailing list.
v3: moved programming to within engine->init_hw() (Chris Wilson)

---
 drivers/gpu/drm/i915/i915_gem.c   |   3 +
 drivers/gpu/drm/i915/intel_lrc.c  |   4 ++
 drivers/gpu/drm/i915/intel_mocs.c | 120 +++++++++++++++++++++++++++++++++-----
 drivers/gpu/drm/i915/intel_mocs.h |   2 +
 4 files changed, 114 insertions(+), 15 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +3 -0
index b854af2..3e18cbd 100644
@@ -32,6 +32,7 @@
 #include "i915_vgpu.h"
 #include "i915_trace.h"
 #include "intel_drv.h"
+#include "intel_mocs.h"
 #include <linux/shmem_fs.h>
 #include <linux/slab.h>
 #include <linux/swap.h>
@@ -4882,6 +4883,8 @@ i915_gem_init_hw(struct drm_device *dev)
 			goto out;
 	}
 
+	program_mocs_l3cc_table(dev);
+
 	/* We can't enable contexts until all firmware is loaded */
 	if (HAS_GUC_UCODE(dev)) {
 		ret = intel_guc_ucode_load(dev);
drivers/gpu/drm/i915/intel_lrc.c +4 -0
index 27c9ee3..2ef7a161 100644
@@ -1603,6 +1603,8 @@ static int gen8_init_common_ring(struct intel_engine_cs *ring)
 
 	memset(&ring->hangcheck, 0, sizeof(ring->hangcheck));
 
+	program_mocs_control_table(ring);
+
 	return 0;
 }
 
@@ -2151,6 +2153,8 @@ static int logical_render_ring_init(struct drm_device *dev)
 			  ret);
 	}
 
+	program_mocs_control_table(ring);
+
 	ret = logical_ring_init(dev, ring);
 	if (ret) {
 		lrc_destroy_wa_ctx_obj(ring);
drivers/gpu/drm/i915/intel_mocs.c +105 -15

157 lines not on this page · raw message

drivers/gpu/drm/i915/intel_mocs.h +2 -0
index 76e45b1..db6b459 100644
@@ -53,5 +53,7 @@
 #include "i915_drv.h"
 
 int intel_rcs_context_init_mocs(struct drm_i915_gem_request *req);
+void program_mocs_l3cc_table(struct drm_device *dev);
+int program_mocs_control_table(struct intel_engine_cs *ring);
 
 #endif
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

✗ Fi.CI.BAT: failure for drm/i915/mocs: Program MOCS for all engines on init (rev5)

== Series Details ==

== Series Details ==

Series: drm/i915/mocs: Program MOCS for all engines on init (rev5)
URL : https://patchwork.freedesktop.org/series/4310/
State : failure

== Summary ==

Series 4310v5 drm/i915/mocs: Program MOCS for all engines on init
http://patchwork.freedesktop.org/api/1.0/series/4310/revisions/5/mbox/

Test core_prop_blob:

        Subgroup basic:
                incomplete -> PASS       (bsw-nuc-2)
Test gem_ctx_param_basic:
        Subgroup invalid-param-get:
                incomplete -> PASS       (bsw-nuc-2)
        Subgroup invalid-size-set:
                incomplete -> PASS       (bsw-nuc-2)
Test gem_exec_basic:
        Subgroup gtt-bsd1:
                incomplete -> SKIP       (bsw-nuc-2)
        Subgroup readonly-bsd:
                incomplete -> PASS       (bsw-nuc-2)
Test gem_flink_basic:
        Subgroup flink-lifetime:
                incomplete -> PASS       (bsw-nuc-2)
Test gem_mmap_gtt:
        Subgroup basic-small-copy-xy:
                incomplete -> PASS       (bsw-nuc-2)
Test gem_ringfill:
        Subgroup basic-default-hang:
                incomplete -> PASS       (bsw-nuc-2)
        Subgroup basic-default-s3:
                pass       -> INCOMPLETE (hsw-gt2)
Test gem_storedw_loop:
        Subgroup basic-bsd1:
                incomplete -> SKIP       (bsw-nuc-2)
Test gem_sync:
        Subgroup basic-blt:
                incomplete -> PASS       (bsw-nuc-2)
Test gem_tiled_blits:
        Subgroup basic:
                incomplete -> PASS       (bsw-nuc-2)
Test kms_addfb_basic:
        Subgroup basic:
                incomplete -> PASS       (bsw-nuc-2)
        Subgroup basic-x-tiled:
                incomplete -> PASS       (bsw-nuc-2)
        Subgroup bo-too-small-due-to-tiling:
                incomplete -> PASS       (bsw-nuc-2)
        Subgroup clobberred-modifier:
                incomplete -> PASS       (bsw-nuc-2)
Test kms_pipe_crc_basic:
        Subgroup bad-pipe:
                incomplete -> PASS       (bsw-nuc-2)
        Subgroup nonblocking-crc-pipe-a:
                incomplete -> SKIP       (bsw-nuc-2)
        Subgroup nonblocking-crc-pipe-a-frame-sequence:
                incomplete -> SKIP       (bsw-nuc-2)
        Subgroup nonblocking-crc-pipe-b:
                incomplete -> SKIP       (bsw-nuc-2)
        Subgroup suspend-read-crc-pipe-c:
                pass       -> DMESG-WARN (bsw-nuc-2)
Test kms_sink_crc_basic:
                incomplete -> SKIP       (bsw-nuc-2)
Test pm_rpm:
        Subgroup basic-pci-d3-state:
                dmesg-fail -> FAIL       (snb-x220t)
                incomplete -> DMESG-WARN (bsw-nuc-2)
                pass       -> DMESG-WARN (snb-dellxps)
                dmesg-warn -> PASS       (byt-nuc)
        Subgroup basic-rte:
                pass       -> DMESG-WARN (snb-x220t)
                dmesg-warn -> PASS       (snb-dellxps)
Test prime_self_import:
        Subgroup basic-llseek-size:
                incomplete -> PASS       (bsw-nuc-2)
bdw-nuci7        total:194  pass:182  dwarn:0   dfail:0   fail:0   skip:12 
bdw-ultra        total:194  pass:173  dwarn:0   dfail:0   fail:0   skip:21 
bsw-nuc-2        total:194  pass:155  dwarn:2   dfail:0   fail:0   skip:37 
byt-nuc          total:194  pass:155  dwarn:4   dfail:0   fail:0   skip:35 
hsw-brixbox      total:194  pass:171  dwarn:1   dfail:0   fail:0   skip:22 
hsw-gt2          total:106  pass:94   dwarn:0   dfail:0   fail:0   skip:11 
ivb-t430s        total:194  pass:169  dwarn:0   dfail:0   fail:0   skip:25 
skl-i5k-2        total:194  pass:171  dwarn:0   dfail:0   fail:0   skip:23 
skl-i7k-2        total:194  pass:171  dwarn:0   dfail:0   fail:0   skip:23 
skl-nuci5        total:194  pass:183  dwarn:0   dfail:0   fail:0   skip:11 
snb-dellxps      total:194  pass:159  dwarn:1   dfail:0   fail:0   skip:34 
snb-x220t        total:194  pass:159  dwarn:1   dfail:0   fail:1   skip:33 

Results at /archive/results/CI_IGT_test/Patchwork_1580/

571147d0be8b04cbbe99db761e82ef105c6f82ad drm-intel-nightly: 2016y-03m-11d-13h-31m-03s UTC integration manifest 5f3ffda498305c5168a6a08b361f12b46fc0a9ca drm/i915/mocs: Program MOCS for all engines on init

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#2 lore raw
In reply to Peter Antoine
Quoted 38 lines · Peter Antoine

Allow for the MOCS to be programmed for all engines. Currently we program the MOCS when the first render batch goes through. This works on most platforms but fails on platforms that do not run a render batch early,
i.e. headless servers. The patch now programs all initialised engines on init and the RCS is programmed again within the initial batch. This is done for predictable consistency with regards to the hardware context.

Hardware context loading sets the values of the MOCS for RCS and L3CC. Programming them from within the batch makes sure that the render context is valid, no matter what the previous state of the saved-context was.

v2: posted correct version to the mailing list.
v3: moved programming to within engine->init_hw() (Chris Wilson)

---
 drivers/gpu/drm/i915/i915_gem.c   |   3 +
 drivers/gpu/drm/i915/intel_lrc.c  |   4 ++
 drivers/gpu/drm/i915/intel_mocs.c | 120 +++++++++++++++++++++++++++++++++-----
 drivers/gpu/drm/i915/intel_mocs.h |   2 +
 4 files changed, 114 insertions(+), 15 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +1 -0
index b854af2..3e18cbd 100644
@@ -32,6 +32,7 @@
 #include "i915_vgpu.h"
 #include "i915_trace.h"
 #include "intel_drv.h"
+#include "intel_mocs.h"
 #include <linux/shmem_fs.h>
 #include <linux/slab.h>
 #include <linux/swap.h>

drivers/gpu/drm/i915/i915_gem.c i915_gem_init_hw(struct drm_device *dev) · line 4886

Quoted 4 lines
drivers/gpu/drm/i915/i915_gem.c +1 -0
@@ -4882,6 +4883,8 @@ i915_gem_init_hw(struct drm_device *dev)
 			goto out;
 	}
 
+	program_mocs_l3cc_table(dev);

intel_mocs_init_l3cc_table(dev_priv);

drivers/gpu/drm/i915/intel_lrc.c static int gen8_init_common_ring(struct intel_engine_cs *ring) · line 1606

Quoted 13 lines
drivers/gpu/drm/i915/i915_gem.c +1 -0
+
 	/* We can't enable contexts until all firmware is loaded */
 	if (HAS_GUC_UCODE(dev)) {
 		ret = intel_guc_ucode_load(dev);
drivers/gpu/drm/i915/intel_lrc.c +1 -0
index 27c9ee3..2ef7a161 100644
@@ -1603,6 +1603,8 @@ static int gen8_init_common_ring(struct intel_engine_cs *ring)
 
 	memset(&ring->hangcheck, 0, sizeof(ring->hangcheck));
 
+	program_mocs_control_table(ring);

ret = intel_mocs_init_engine(ring);

Check and propagate the errors!

drivers/gpu/drm/i915/intel_lrc.c static int logical_render_ring_init(struct drm_device *dev) · line 2156

Quoted 9 lines
drivers/gpu/drm/i915/intel_lrc.c +2 -0
+
 	return 0;
 }
 
@@ -2151,6 +2153,8 @@ static int logical_render_ring_init(struct drm_device *dev)
 			  ret);
 	}
 
+	program_mocs_control_table(ring);

Due to the splitting inside intel_lrc, it actually makes sense to do a ret = engine->init_hw(engine) call here. But for the time being, adding the setup here is redundant.

Quoted 7 lines
drivers/gpu/drm/i915/intel_lrc.c +6 -0
 /**
+ * program_mocs_control_table() - emit the mocs control table
+ * @ring:	The engine for whom to emit the registers.
+ *
+ * This function simply emits a MI_LOAD_REGISTER_IMM command for the
+ * given table starting at the given address.
+ *

drivers/gpu/drm/i915/intel_lrc.c static int logical_render_ring_init(struct drm_device *dev)

Quoted 10 lines
drivers/gpu/drm/i915/intel_lrc.c +10 -0
+ * Return: 0 on success, otherwise the error status.
+ */
+int program_mocs_control_table(struct intel_engine_cs *ring)
+{
+	struct drm_device *dev = ring->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct drm_i915_mocs_table table;
+	unsigned int index;
+
+	if (get_mocs_settings(dev, &table)) {

if (!get_mocs_setttings())

	return 0;

And then we can lose one level of indentation.

drivers/gpu/drm/i915/intel_lrc.c

Quoted 6 lines
drivers/gpu/drm/i915/intel_lrc.c +6 -0
+		if (WARN_ON(table.size > GEN9_NUM_MOCS_ENTRIES))
+			return -ENODEV;
+
+		for (index = 0; index < table.size; index++) {
+			I915_WRITE(mocs_register(ring->id, index),
+				table.table[index].control_value);

Whitespace makes this easier to read. Please align continuation lines with the opening bracket.

drivers/gpu/drm/i915/intel_lrc.c

Quoted 13 lines
drivers/gpu/drm/i915/intel_lrc.c +13 -0
+		}
+
+		/*
+		 * Ok, now set the unused entries to uncached. These entries
+		 * are officially undefined and no contract for the contents
+		 * and settings is given for these entries.
+		 *
+		 * Entry 0 in the table is uncached - so we are just writing
+		 * that value to all the used entries.
+		 */
+		for (; index < GEN9_NUM_MOCS_ENTRIES; index++) {
+			I915_WRITE(mocs_register(ring->id, index),
+						table.table[0].control_value);

Especially here.

Quoted 21 lines
drivers/gpu/drm/i915/intel_lrc.c +9 -1
+		}
+	}
+
+	return 0;
+}
+
+/**
  * emit_mocs_control_table() - emit the mocs control table
  * @req:	Request to set up the MOCS table for.
  * @table:	The values to program into the control regs.
@@ -210,7 +252,8 @@ static int emit_mocs_control_table(struct drm_i915_gem_request *req,
 				MI_LOAD_REGISTER_IMM(GEN9_NUM_MOCS_ENTRIES));
 
 	for (index = 0; index < table->size; index++) {
-		intel_logical_ring_emit_reg(ringbuf, mocs_register(ring, index));
+		intel_logical_ring_emit_reg(ringbuf,
+					mocs_register(ring, index));
 		intel_logical_ring_emit(ringbuf,
 					table->table[index].control_value);
 	}

drivers/gpu/drm/i915/intel_lrc.c static int emit_mocs_control_table(struct drm_i915_gem_request *req, · line 274

Quoted 10 lines
drivers/gpu/drm/i915/intel_lrc.c +4 -2
@@ -224,8 +267,10 @@ static int emit_mocs_control_table(struct drm_i915_gem_request *req,
 	 * that value to all the used entries.
 	 */
 	for (; index < GEN9_NUM_MOCS_ENTRIES; index++) {
-		intel_logical_ring_emit_reg(ringbuf, mocs_register(ring, index));
-		intel_logical_ring_emit(ringbuf, table->table[0].control_value);
+		intel_logical_ring_emit_reg(ringbuf,
+						mocs_register(ring, index));
+		intel_logical_ring_emit(ringbuf,
+						table->table[0].control_value);
 	}

I'll pretend I never saw these spurious chunks.

Quoted 19 lines
drivers/gpu/drm/i915/intel_lrc.c +13 -0
 	intel_logical_ring_emit(ringbuf, MI_NOOP);
@@ -302,6 +347,57 @@ static int emit_mocs_l3cc_table(struct drm_i915_gem_request *req,
 }
 
 /**
+ * program_mocs_l3cc_table() - program the mocs control table
+ * @dev:      The the device to be programmed.
+ * @table:    The values to program into the control regs.
+ *
+ * This function simply programs the mocs registers for the given table
+ * starting at the given address. This register set is  programmed in pairs.
+ *
+ * These registers may get programmed more than once, it is simpler to
+ * re-program 32 registers than maintain the state of when they were programmed.
+ * We are always reprogramming with the same values and this only on context
+ * start.
+ *
+ * Return: Nothing.

drivers/gpu/drm/i915/intel_lrc.c static int emit_mocs_l3cc_table(struct drm_i915_gem_request *req, · line 372

Quoted 10 lines
drivers/gpu/drm/i915/intel_lrc.c +10 -0
+ */
+void program_mocs_l3cc_table(struct drm_device *dev)
+{
+	unsigned int count;
+	unsigned int i;
+	u32 value;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct drm_i915_mocs_table table;
+
+	if (get_mocs_settings(dev, &table)) {

Indentation, whitespace, passing around dev but using dev_priv

drivers/gpu/drm/i915/intel_lrc.c static int emit_mocs_l3cc_table(struct drm_i915_gem_request *req, · line 374

Quoted 2 lines
drivers/gpu/drm/i915/intel_lrc.c +2 -0
+		u32 filler = (table.table[0].l3cc_value & 0xffff) |
+				((table.table[0].l3cc_value & 0xffff) << 16);

l3cc_value is 16bit so the masking is garbage.

static inline u32 l3cc_combine(u16 lower, u16 upper)

{
	return lower | upper << 16;
}

for (i = 0; i < table.size/2; i++)

	I915_WRITE(GEN9_LNCFCMOCS(i),
		   l3cc_combine(table.table[2*i].l3cc_value,
				table.table[2*i+1].l3cc_value));
if (table.size & 1) {
	I915_WRITE(GEN9_LNCFCMOCS(i),
		   l3cc_combine(table.table[2*i].l3cc_value,
				table.table[0].l3cc_value));
	i++;
}

drivers/gpu/drm/i915/intel_lrc.c static int emit_mocs_l3cc_table(struct drm_i915_gem_request *req, · line 379

Quoted 5 lines
drivers/gpu/drm/i915/intel_lrc.c +5 -0
+		/*
+		 * Now set the rest of the table to uncached - use entry 0 as
+		 * this will be uncached. Leave the last pair as initialised as
+		 * they are reserved by the hardware.
+		 */
for (; i < GEN9_NUM_MOCS_ENTRIES / 2; i++) {
	I915_WRITE(GEN9_LNCFCMOCS(i),
		   l3cc_combine(table.table[0].l3cc_value,
				table.table[0].l3cc_value));

is easier on the eyes.
-Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw
Quoted 42 lines · Chris Wilson
Quoted 41 lines · Peter Antoine

Allow for the MOCS to be programmed for all engines. Currently we program the MOCS when the first render batch goes through. This works on most platforms but fails on platforms that do not run a render batch early,
i.e. headless servers. The patch now programs all initialised engines on init and the RCS is programmed again within the initial batch. This is done for predictable consistency with regards to the hardware context.

Hardware context loading sets the values of the MOCS for RCS and L3CC. Programming them from within the batch makes sure that the render context is valid, no matter what the previous state of the saved-context was.

v2: posted correct version to the mailing list.
v3: moved programming to within engine->init_hw() (Chris Wilson)

---
 drivers/gpu/drm/i915/i915_gem.c   |   3 +
 drivers/gpu/drm/i915/intel_lrc.c  |   4 ++
 drivers/gpu/drm/i915/intel_mocs.c | 120 +++++++++++++++++++++++++++++++++-----
 drivers/gpu/drm/i915/intel_mocs.h |   2 +
 4 files changed, 114 insertions(+), 15 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +1 -0
index b854af2..3e18cbd 100644
@@ -32,6 +32,7 @@
 #include "i915_vgpu.h"
 #include "i915_trace.h"
 #include "intel_drv.h"
+#include "intel_mocs.h"
 #include <linux/shmem_fs.h>
 #include <linux/slab.h>
 #include <linux/swap.h>
@@ -4882,6 +4883,8 @@ i915_gem_init_hw(struct drm_device *dev)
 			goto out;
 	}
 
Quoted 3 lines

drivers/gpu/drm/i915/i915_gem.c i915_gem_init_hw(struct drm_device *dev) · line 4886

Quoted 1 line
drivers/gpu/drm/i915/i915_gem.c +1 -0
+	program_mocs_l3cc_table(dev);

intel_mocs_init_l3cc_table(dev_priv);

Changed.

Quoted 11 lines
Quoted 11 lines
drivers/gpu/drm/i915/i915_gem.c +1 -0
+
 	/* We can't enable contexts until all firmware is loaded */
 	if (HAS_GUC_UCODE(dev)) {
 		ret = intel_guc_ucode_load(dev);
drivers/gpu/drm/i915/intel_lrc.c +0 -0
index 27c9ee3..2ef7a161 100644
@@ -1603,6 +1603,8 @@ static int gen8_init_common_ring(struct intel_engine_cs *ring)
 
Quoted 7 lines

drivers/gpu/drm/i915/intel_lrc.c static int gen8_init_common_ring(struct intel_engine_cs *ring) · line 1606

Quoted 3 lines
drivers/gpu/drm/i915/intel_lrc.c +1 -0
 	memset(&ring->hangcheck, 0, sizeof(ring->hangcheck));
 
+	program_mocs_control_table(ring);

ret = intel_mocs_init_engine(ring);

Check and propagate the errors!

Ok.

Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/i915/intel_lrc.c +1 -0
+
 	return 0;
 }
 
@@ -2151,6 +2153,8 @@ static int logical_render_ring_init(struct drm_device *dev)
 			  ret);
 	}
 
Quoted 6 lines

drivers/gpu/drm/i915/intel_lrc.c static int logical_render_ring_init(struct drm_device *dev) · line 2156

Quoted 1 line
drivers/gpu/drm/i915/intel_lrc.c +1 -0
+	program_mocs_control_table(ring);

Due to the splitting inside intel_lrc, it actually makes sense to do a ret = engine->init_hw(engine) call here. But for the time being, adding the setup here is redundant.

This call is not required and has been removed.

Quoted 19 lines
Quoted 7 lines
drivers/gpu/drm/i915/intel_lrc.c +6 -0
 /**
+ * program_mocs_control_table() - emit the mocs control table
+ * @ring:	The engine for whom to emit the registers.
+ *
+ * This function simply emits a MI_LOAD_REGISTER_IMM command for the
+ * given table starting at the given address.
+ *

drivers/gpu/drm/i915/intel_lrc.c static int logical_render_ring_init(struct drm_device *dev)

Quoted 10 lines
drivers/gpu/drm/i915/intel_lrc.c +10 -0
+ * Return: 0 on success, otherwise the error status.
+ */
+int program_mocs_control_table(struct intel_engine_cs *ring)
+{
+	struct drm_device *dev = ring->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct drm_i915_mocs_table table;
+	unsigned int index;
+
+	if (get_mocs_settings(dev, &table)) {

if (!get_mocs_setttings())

Quoted 3 lines
	return 0;

And then we can lose one level of indentation.

Ok. I like the indentation I find it easier to read. But will change.

Quoted 10 lines

drivers/gpu/drm/i915/intel_lrc.c

Quoted 7 lines
drivers/gpu/drm/i915/intel_lrc.c +6 -0
+		if (WARN_ON(table.size > GEN9_NUM_MOCS_ENTRIES))
+			return -ENODEV;
+
+		for (index = 0; index < table.size; index++) {
+			I915_WRITE(mocs_register(ring->id, index),
+				table.table[index].control_value);

Whitespace makes this easier to read. Please align continuation lines with the opening bracket.

Ok.

Quoted 16 lines
Quoted 4 lines
drivers/gpu/drm/i915/intel_lrc.c +3 -0
+		}
+
+		/*

drivers/gpu/drm/i915/intel_lrc.c

Quoted 10 lines
drivers/gpu/drm/i915/intel_lrc.c +10 -0
+		 * Ok, now set the unused entries to uncached. These entries
+		 * are officially undefined and no contract for the contents
+		 * and settings is given for these entries.
+		 *
+		 * Entry 0 in the table is uncached - so we are just writing
+		 * that value to all the used entries.
+		 */
+		for (; index < GEN9_NUM_MOCS_ENTRIES; index++) {
+			I915_WRITE(mocs_register(ring->id, index),
+						table.table[0].control_value);

Especially here.

done.

Quoted 26 lines
Quoted 26 lines
drivers/gpu/drm/i915/intel_lrc.c +9 -2
+		}
+	}
+
+	return 0;
+}
+
+/**
  * emit_mocs_control_table() - emit the mocs control table
  * @req:	Request to set up the MOCS table for.
  * @table:	The values to program into the control regs.
@@ -210,7 +252,8 @@ static int emit_mocs_control_table(struct drm_i915_gem_request *req,
 				MI_LOAD_REGISTER_IMM(GEN9_NUM_MOCS_ENTRIES));
 
 	for (index = 0; index < table->size; index++) {
-		intel_logical_ring_emit_reg(ringbuf, mocs_register(ring, index));
+		intel_logical_ring_emit_reg(ringbuf,
+					mocs_register(ring, index));
 		intel_logical_ring_emit(ringbuf,
 					table->table[index].control_value);
 	}
@@ -224,8 +267,10 @@ static int emit_mocs_control_table(struct drm_i915_gem_request *req,
 	 * that value to all the used entries.
 	 */
 	for (; index < GEN9_NUM_MOCS_ENTRIES; index++) {
-		intel_logical_ring_emit_reg(ringbuf, mocs_register(ring, index));
Quoted 8 lines

drivers/gpu/drm/i915/intel_lrc.c static int emit_mocs_control_table(struct drm_i915_gem_request *req, · line 274

Quoted 6 lines
drivers/gpu/drm/i915/intel_lrc.c +4 -1
-		intel_logical_ring_emit(ringbuf, table->table[0].control_value);
+		intel_logical_ring_emit_reg(ringbuf,
+						mocs_register(ring, index));
+		intel_logical_ring_emit(ringbuf,
+						table->table[0].control_value);
 	}

I'll pretend I never saw these spurious chunks.

removed (well un-removed)

Quoted 24 lines
Quoted 24 lines
drivers/gpu/drm/i915/intel_lrc.c +17 -0
 	intel_logical_ring_emit(ringbuf, MI_NOOP);
@@ -302,6 +347,57 @@ static int emit_mocs_l3cc_table(struct drm_i915_gem_request *req,
 }
 
 /**
+ * program_mocs_l3cc_table() - program the mocs control table
+ * @dev:      The the device to be programmed.
+ * @table:    The values to program into the control regs.
+ *
+ * This function simply programs the mocs registers for the given table
+ * starting at the given address. This register set is  programmed in pairs.
+ *
+ * These registers may get programmed more than once, it is simpler to
+ * re-program 32 registers than maintain the state of when they were programmed.
+ * We are always reprogramming with the same values and this only on context
+ * start.
+ *
+ * Return: Nothing.
+ */
+void program_mocs_l3cc_table(struct drm_device *dev)
+{
+	unsigned int count;
Quoted 8 lines

drivers/gpu/drm/i915/intel_lrc.c static int emit_mocs_l3cc_table(struct drm_i915_gem_request *req, · line 372

Quoted 6 lines
drivers/gpu/drm/i915/intel_lrc.c +6 -0
+	unsigned int i;
+	u32 value;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct drm_i915_mocs_table table;
+
+	if (get_mocs_settings(dev, &table)) {

Indentation, whitespace, passing around dev but using dev_priv

Get_mocs_settings() uses dev.
Done the rest.

Quoted 33 lines

drivers/gpu/drm/i915/intel_lrc.c static int emit_mocs_l3cc_table(struct drm_i915_gem_request *req, · line 374

Quoted 3 lines
drivers/gpu/drm/i915/intel_lrc.c +2 -0
+		u32 filler = (table.table[0].l3cc_value & 0xffff) |
+				((table.table[0].l3cc_value & 0xffff) << 16);

l3cc_value is 16bit so the masking is garbage.

static inline u32 l3cc_combine(u16 lower, u16 upper)

{
	return lower | upper << 16;
}

for (i = 0; i < table.size/2; i++)

	I915_WRITE(GEN9_LNCFCMOCS(i),
		   l3cc_combine(table.table[2*i].l3cc_value,
				table.table[2*i+1].l3cc_value));
if (table.size & 1) {
	I915_WRITE(GEN9_LNCFCMOCS(i),
		   l3cc_combine(table.table[2*i].l3cc_value,
				table.table[0].l3cc_value));
	i++;
}

drivers/gpu/drm/i915/intel_lrc.c static int emit_mocs_l3cc_table(struct drm_i915_gem_request *req, · line 379

Quoted 5 lines
drivers/gpu/drm/i915/intel_lrc.c +5 -0
+		/*
+		 * Now set the rest of the table to uncached - use entry 0 as
+		 * this will be uncached. Leave the last pair as initialised as
+		 * they are reserved by the hardware.
+		 */
for (; i < GEN9_NUM_MOCS_ENTRIES / 2; i++) {
	I915_WRITE(GEN9_LNCFCMOCS(i),
		   l3cc_combine(table.table[0].l3cc_value,
				table.table[0].l3cc_value));
Quoted 1 line

is easier on the eyes.

Have re-worked that function and the emit, might as well make them the same. it does look better.

Peter.

Quoted 3 lines

-Chris

--
Peter Antoine (Android Graphics Driver Software Engineer)
---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ VAT No: 860 2173 47
_______________________________________________
Intel-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx