Skip to contentSkip to conversation

drm/i915 : Added Programming of the MOCS

PATCH In review Peter Antoine 3 participants 3 messages Jun 30, 2015 – Jul 2, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v6 1/1 drm/i915 : Added Programming of the MOCS

This change adds the programming of the MOCS registers to the gen 9+ platforms. This change set programs the MOCS register values to a set of values that are defined to be optimal.

It creates a fixed register set that is programmed across the different engines so that all engines have the same table. This is done as the main RCS context only holds the registers for itself and the shared L3 values. By trying to keep the registers consistent across the different engines it should make the programming for the registers consistent.

v2:
-'static const' for private data structures and style changes.(Matt Turner) v3:
- Make the tables "slightly" more readable. (Damien Lespiau)
- Updated tables fix performance regression.
v4:
- Code formatting. (Chris Wilson)
- re-privatised mocs code. (Daniel Vetter)
v5:
- Changed the name of a function. (Chris Wilson)
v6:
- re-based
- Added Mesa table entry (skylake & broxton) (Francisco Jerez)
- Tidied up the readability defines (Francisco Jerez)
- NUMBER of entries defines wrong. (Jim Bish)
- Added comments to clear up the meaning of the tables (Jim Bish)

---
 drivers/gpu/drm/i915/Makefile     |   1 +
 drivers/gpu/drm/i915/i915_reg.h   |   9 +
 drivers/gpu/drm/i915/intel_lrc.c  |  11 +-
 drivers/gpu/drm/i915/intel_lrc.h  |   1 +
 drivers/gpu/drm/i915/intel_mocs.c | 381 ++++++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_mocs.h |  60 ++++++
 6 files changed, 461 insertions(+), 2 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/intel_mocs.c
 create mode 100644 drivers/gpu/drm/i915/intel_mocs.h
drivers/gpu/drm/i915/Makefile +1 -0
index de21965..e52e012 100644
@@ -36,6 +36,7 @@ i915-y += i915_cmd_parser.o \
 	  i915_trace_points.o \
 	  intel_hotplug.o \
 	  intel_lrc.o \
+	  intel_mocs.o \
 	  intel_ringbuffer.o \
 	  intel_uncore.o
 
drivers/gpu/drm/i915/i915_reg.h +9 -0
index ac985c5..ef8ba3d 100644
@@ -7861,4 +7861,13 @@ enum skl_disp_power_wells {
 #define _PALETTE_A (dev_priv->info.display_mmio_offset + 0xa000)
 #define _PALETTE_B (dev_priv->info.display_mmio_offset + 0xa800)
 
+/* MOCS (Memory Object Control State) registers */
+#define GEN9_LNCFCMOCS0		(0xB020)	/* L3 Cache Control base */
+
+#define GEN9_GFX_MOCS_0		(0xc800)	/* Graphics MOCS base register*/
+#define GEN9_MFX0_MOCS_0	(0xc900)	/* Media 0 MOCS base register*/
+#define GEN9_MFX1_MOCS_0	(0xcA00)	/* Media 1 MOCS base register*/
+#define GEN9_VEBOX_MOCS_0	(0xcB00)	/* Video MOCS base register*/
+#define GEN9_BLT_MOCS_0		(0xcc00)	/* Blitter MOCS base register*/
+
 #endif /* _I915_REG_H_ */
drivers/gpu/drm/i915/intel_lrc.c +9 -2
index e87d74c..a727f79 100644
@@ -135,6 +135,7 @@
 #include <drm/drmP.h>
 #include <drm/i915_drm.h>
 #include "i915_drv.h"
+#include "intel_mocs.h"
 
 #define GEN9_LR_CONTEXT_RENDER_SIZE (22 * PAGE_SIZE)
 #define GEN8_LR_CONTEXT_RENDER_SIZE (20 * PAGE_SIZE)
@@ -792,8 +793,7 @@ static int logical_ring_prepare(struct drm_i915_gem_request *req, int bytes)
  *
  * Return: non-zero if the ringbuffer is not ready to be written to.
  */
-static int intel_logical_ring_begin(struct drm_i915_gem_request *req,
-				    int num_dwords)
+int intel_logical_ring_begin(struct drm_i915_gem_request *req, int num_dwords)
 {
 	struct drm_i915_private *dev_priv;
 	int ret;
@@ -1658,6 +1658,13 @@ static int gen8_init_rcs_context(struct drm_i915_gem_request *req)
 	if (ret)
 		return ret;
 
+	/*
+	 * Failing to program the MOCS is non-fatal.The system will not
+	 * run at peak performance. So generate a warning and carry on.
+	 */
+	if (intel_rcs_context_init_mocs(req) != 0)
+		DRM_ERROR("MOCS failed to program: expect performance issues.");
+
 	return intel_lr_context_render_state_init(req);
 }
 
drivers/gpu/drm/i915/intel_lrc.h +1 -0
index f59940a..19cc8ee 100644
@@ -41,6 +41,7 @@ int intel_logical_ring_reserve_space(struct drm_i915_gem_request *request);
 void intel_logical_ring_stop(struct intel_engine_cs *ring);
 void intel_logical_ring_cleanup(struct intel_engine_cs *ring);
 int intel_logical_rings_init(struct drm_device *dev);
+int intel_logical_ring_begin(struct drm_i915_gem_request *req, int num_dwords);
 
 int logical_ring_flush_all_caches(struct drm_i915_gem_request *req);
 /**
drivers/gpu/drm/i915/intel_mocs.c new file +381 -0

381 lines not on this page · raw message

drivers/gpu/drm/i915/intel_mocs.h new file +60 -0

60 lines not on this page · raw message

Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw
Quoted 18 lines · Peter Antoine
drivers/gpu/drm/i915/intel_mocs.c new file +18 -0
+int intel_rcs_context_init_mocs(struct drm_i915_gem_request *req)
+{
+	int ret = 0;
+	struct drm_i915_mocs_table t;
+
+	if (get_mocs_settings(req->ring->dev, &t)) {
+		u32 table_size;
+
+		/*
+		 * OK. For each supported ring:
+		 *  number of mocs entries * 2 dwords for each control_value
+		 *  plus number of mocs entries /2 dwords for l3cc values.
+		 *
+		 *  Plus 1 for the load command and 1 for the NOOP per ring
+		 *  and the l3cc programming.
+		 */
+		table_size = GEN9_NUM_MOCS_RINGS *
+				((2 * GEN9_NUM_MOCS_ENTRIES) + 2) +

drivers/gpu/drm/i915/intel_mocs.c line 363

Quoted 10 lines
drivers/gpu/drm/i915/intel_mocs.c new file +10 -0
+				GEN9_NUM_MOCS_ENTRIES + 2;
+
+		ret = intel_logical_ring_begin(req, table_size);
+		if (ret) {
+			DRM_DEBUG("intel_logical_ring_begin failed %d\n", ret);
+			return ret;
+		}
+
+		/* program the control registers */
+		emit_mocs_control_table(req->ringbuf, &t, GEN9_GFX_MOCS_0);

I wanted the ring_begin pushed down a level so that I didn't need a pen and paper to review your calculations of space required, and reduce it down a notch from trying to immediately reserve almost the entire skl ring buffer for itself.
-Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Tested-by on v6 1/1
#2 lore raw
In reply to Peter Antoine

Task id: 6686 -------------------------------------Summary-------------------------------------
Platform Delta drm-intel-nightly Series Applied

ILK                                  302/302              302/302
SNB                                  312/316              312/316
IVB                                  343/343              343/343

BYT -1 287/287 286/287
HSW 380/380 380/380
-------------------------------------Detailed-------------------------------------
Platform Test drm-intel-nightly Series Applied
*BYT igt@gem_partial_pwrite_pread@reads-display PASS(1) FAIL(1)
Note: You need to pay more attention to line start with '*'
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx