Skip to contentSkip to conversation

drm/i915 enable RC6 on Ironlake platform

PATCH In review Zou Nan hai 2 participants 5 messages Jun 25, 2010 – Aug 2, 2010

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

cover drm/i915 enable RC6 on Ironlake platform

The patch series enable RC6 on Ironlake platform.
With those patch, we got about 1W idle power save on Ironlake laptops.

We did performance regession tests on those patches, no regression found.

Thanks Zhao Yakui to debug and resolve the RC6 issues.

Zou Nan hai (3):
drm/i915 save power context on ironlake
drm/i915 save render context on Ironlake
drm/i915 invalidate indirect state pointers at end of ring exec

 drivers/gpu/drm/i915/i915_dma.c         |    7 ++++
 drivers/gpu/drm/i915/i915_drv.h         |    1 +
 drivers/gpu/drm/i915/i915_reg.h         |   14 +++++++-
 drivers/gpu/drm/i915/intel_display.c    |   56 +++++++++++++++++++++++++------
 drivers/gpu/drm/i915/intel_ringbuffer.c |    9 +++++
 5 files changed, 75 insertions(+), 12 deletions(-)
#1 lore raw

PATCH 1/3 drm/i915 save power context on ironlake

RC6 need power context to be saved

---
 drivers/gpu/drm/i915/intel_display.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/gpu/drm/i915/intel_display.c +2 -1
index 88a1ab7..c3c9feb 100644
@@ -5299,7 +5299,8 @@ void intel_init_clock_gating(struct drm_device *dev)
 					(I915_READ(DISP_ARB_CTL) |
 						DISP_FBC_WM_DIS));
 		}
-		return;
+		if (IS_GEN6(dev))
+			return;
 	} else if (IS_G4X(dev)) {
 		uint32_t dspclk_gate;
 		I915_WRITE(RENCLK_GATE_D1, 0);
Signature · 1 line
1.7.1
#2 lore raw

PATCH 2/3 drm/i915 save render context on Ironlake

In reply to Zou Nan hai

RC6 requires setup logical render context

---
 drivers/gpu/drm/i915/i915_drv.h      |    1 +
 drivers/gpu/drm/i915/i915_reg.h      |   13 +++++++-
 drivers/gpu/drm/i915/intel_display.c |   53 +++++++++++++++++++++++++++------
 3 files changed, 56 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
index 9ed8ecd..cbc8cae 100644
@@ -245,6 +245,7 @@ typedef struct drm_i915_private {
 	drm_local_map_t hws_map;
 	struct drm_gem_object *seqno_obj;
 	struct drm_gem_object *pwrctx;
+	struct drm_gem_object *renderctx;
 
 	struct resource mch_res;
 
drivers/gpu/drm/i915/i915_reg.h +12 -1
index 64b0a3a..96103ae 100644
@@ -176,9 +176,15 @@
 #define   MI_OVERLAY_CONTINUE	(0x0<<21)
 #define   MI_OVERLAY_ON		(0x1<<21)
 #define   MI_OVERLAY_OFF	(0x2<<21)
+#define   MI_DISPLAY_FLIP_PLANE(n) ((n) << 20)
 #define MI_LOAD_SCAN_LINES_INCL MI_INSTR(0x12, 0)
 #define MI_DISPLAY_FLIP		MI_INSTR(0x14, 2)
-#define   MI_DISPLAY_FLIP_PLANE(n) ((n) << 20)
+#define MI_SET_CONTEXT		MI_INSTR(0x18, 0)
+#define   MI_MM_SPACE_GTT		(1<<8)
+#define   MI_MM_SPACE_PHYSICAL		(0<<8)
+#define   MI_SAVE_EXT_STATE_EN		(1<<3)
+#define   MI_RESTORE_EXT_STATE_EN	(1<<2)
+#define   MI_RESTORE_INHIBIT		(1<<0)
 #define MI_STORE_DWORD_IMM	MI_INSTR(0x20, 1)
 #define   MI_MEM_VIRTUAL	(1 << 22) /* 965+ only */
 #define MI_STORE_DWORD_INDEX	MI_INSTR(0x21, 1)
@@ -1042,6 +1048,11 @@
 #define DDRMPLL1		0X12c20
 #define PEG_BAND_GAP_DATA	0x14d68
 
+/*
+ * Logical Context regs
+ */
+#define CCID			0x2180
+#define   CCID_EN		(1<<0)
 /*
  * Overlay regs
  */
drivers/gpu/drm/i915/intel_display.c +43 -10

99 lines not on this page · raw message

Signature · 1 line
1.7.1
#3 lore raw

Re: [PATCH 2/3] drm/i915 save render context on Ironlake

Quoted 116 lines · Zou Nan hai

RC6 requires setup logical render context

---
 drivers/gpu/drm/i915/i915_drv.h      |    1 +
 drivers/gpu/drm/i915/i915_reg.h      |   13 +++++++-
 drivers/gpu/drm/i915/intel_display.c |   53 +++++++++++++++++++++++++++------
 3 files changed, 56 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
index 9ed8ecd..cbc8cae 100644
@@ -245,6 +245,7 @@ typedef struct drm_i915_private {
 	drm_local_map_t hws_map;
 	struct drm_gem_object *seqno_obj;
 	struct drm_gem_object *pwrctx;
+	struct drm_gem_object *renderctx;
 
 	struct resource mch_res;
 
drivers/gpu/drm/i915/i915_reg.h +12 -1
index 64b0a3a..96103ae 100644
@@ -176,9 +176,15 @@
 #define   MI_OVERLAY_CONTINUE	(0x0<<21)
 #define   MI_OVERLAY_ON		(0x1<<21)
 #define   MI_OVERLAY_OFF	(0x2<<21)
+#define   MI_DISPLAY_FLIP_PLANE(n) ((n) << 20)
 #define MI_LOAD_SCAN_LINES_INCL MI_INSTR(0x12, 0)
 #define MI_DISPLAY_FLIP		MI_INSTR(0x14, 2)
-#define   MI_DISPLAY_FLIP_PLANE(n) ((n) << 20)
+#define MI_SET_CONTEXT		MI_INSTR(0x18, 0)
+#define   MI_MM_SPACE_GTT		(1<<8)
+#define   MI_MM_SPACE_PHYSICAL		(0<<8)
+#define   MI_SAVE_EXT_STATE_EN		(1<<3)
+#define   MI_RESTORE_EXT_STATE_EN	(1<<2)
+#define   MI_RESTORE_INHIBIT		(1<<0)
 #define MI_STORE_DWORD_IMM	MI_INSTR(0x20, 1)
 #define   MI_MEM_VIRTUAL	(1 << 22) /* 965+ only */
 #define MI_STORE_DWORD_INDEX	MI_INSTR(0x21, 1)
@@ -1042,6 +1048,11 @@
 #define DDRMPLL1		0X12c20
 #define PEG_BAND_GAP_DATA	0x14d68
 
+/*
+ * Logical Context regs
+ */
+#define CCID			0x2180
+#define   CCID_EN		(1<<0)
 /*
  * Overlay regs
  */
drivers/gpu/drm/i915/intel_display.c +16 -9
index c3c9feb..efcfda9 100644
@@ -5026,37 +5026,37 @@ static const struct drm_mode_config_funcs intel_mode_funcs = {
 };
 
 static struct drm_gem_object *
-intel_alloc_power_context(struct drm_device *dev)
+intel_alloc_context_page(struct drm_device *dev)
 {
-	struct drm_gem_object *pwrctx;
+	struct drm_gem_object *ctx;
 	int ret;
 
-	pwrctx = i915_gem_alloc_object(dev, 4096);
-	if (!pwrctx) {
+	ctx = i915_gem_alloc_object(dev, 4096);
+	if (!ctx) {
 		DRM_DEBUG("failed to alloc power context, RC6 disabled\n");
 		return NULL;
 	}
 
 	mutex_lock(&dev->struct_mutex);
-	ret = i915_gem_object_pin(pwrctx, 4096);
+	ret = i915_gem_object_pin(ctx, 4096);
 	if (ret) {
 		DRM_ERROR("failed to pin power context: %d\n", ret);
 		goto err_unref;
 	}
 
-	ret = i915_gem_object_set_to_gtt_domain(pwrctx, 1);
+	ret = i915_gem_object_set_to_gtt_domain(ctx, 1);
 	if (ret) {
 		DRM_ERROR("failed to set-domain on power context: %d\n", ret);
 		goto err_unpin;
 	}
 	mutex_unlock(&dev->struct_mutex);
 
-	return pwrctx;
+	return ctx;
 
 err_unpin:
-	i915_gem_object_unpin(pwrctx);
+	i915_gem_object_unpin(ctx);
 err_unref:
-	drm_gem_object_unreference(pwrctx);
+	drm_gem_object_unreference(ctx);
 	mutex_unlock(&dev->struct_mutex);
 	return NULL;
 }
@@ -5343,6 +5343,29 @@ void intel_init_clock_gating(struct drm_device *dev)
 	 * GPU can automatically power down the render unit if given a page
 	 * to save state.
 	 */
+	if (IS_IRONLAKE_M(dev)) {
+		if (dev_priv->renderctx == NULL)
+			dev_priv->renderctx = intel_alloc_context_page(dev);
+		if (dev_priv->renderctx) {
+			struct drm_i915_gem_object *obj_priv;
+			obj_priv = to_intel_bo(dev_priv->renderctx);
+			if (obj_priv) {

drivers/gpu/drm/i915/intel_display.c void intel_init_clock_gating(struct drm_device *dev) · line 5362

Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +10 -0
+				BEGIN_LP_RING(4);
+				OUT_RING(MI_SET_CONTEXT);
+				OUT_RING(obj_priv->gtt_offset |
+						MI_MM_SPACE_GTT |
+						MI_SAVE_EXT_STATE_EN |
+						MI_RESTORE_EXT_STATE_EN |
+						MI_RESTORE_INHIBIT);
+				OUT_RING(MI_NOOP);
+				OUT_RING(MI_FLUSH);
+				ADVANCE_LP_RING();

I don't think you mean SAVE_EXT_STATE_EN here -- doesn't that mean store the current state to the current context (but we haven't set a context up yet)?

The following patch to fix hangs with this patch in place needs to come before this patch in the series, or you'll break bisects.

(looks like my other concern wasn't a problem -- init_clock_gating() is called again at resume time, and we don't have any 3D state we need saved across s/r so we don't need to restore out of the context or anything).

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

#4 lore raw

PATCH 3/3 drm/i915 invalidate indirect state pointers at end of ring exec

In reply to Zou Nan hai

this is required by spec, without this patch.
some 3D programs will hang after resume from RC6.

---
 drivers/gpu/drm/i915/i915_dma.c         |    7 +++++++
 drivers/gpu/drm/i915/i915_reg.h         |    1 +
 drivers/gpu/drm/i915/intel_ringbuffer.c |    9 +++++++++
 3 files changed, 17 insertions(+), 0 deletions(-)
drivers/gpu/drm/i915/i915_dma.c +7 -0
index 84ce956..0bc5f0f 100644
@@ -494,6 +494,13 @@ static int i915_dispatch_batchbuffer(struct drm_device * dev,
 		}
 	}
 
+
+	if (IS_G4X(dev) || IS_IRONLAKE(dev)) {
+		BEGIN_LP_RING(2);
+		OUT_RING(MI_FLUSH | MI_NO_WRITE_FLUSH | MI_INVALIDATE_ISP);
+		OUT_RING(MI_NOOP);
+		ADVANCE_LP_RING();
+	}
 	i915_emit_breadcrumb(dev);
 
 	return 0;
drivers/gpu/drm/i915/i915_reg.h +1 -0
index 96103ae..e7eca57 100644
@@ -170,6 +170,7 @@
 #define   MI_NO_WRITE_FLUSH	(1 << 2)
 #define   MI_SCENE_COUNT	(1 << 3) /* just increment scene count */
 #define   MI_END_SCENE		(1 << 4) /* flush binner and incr scene count */
+#define   MI_INVALIDATE_ISP	(1 << 5) /* invalidate indirect state pointers */
 #define MI_BATCH_BUFFER_END	MI_INSTR(0x0a, 0)
 #define MI_REPORT_HEAD		MI_INSTR(0x07, 0)
 #define MI_OVERLAY_FLIP		MI_INSTR(0x11,0)
drivers/gpu/drm/i915/intel_ringbuffer.c +9 -0
index cea4f1a..1530698 100644
@@ -515,7 +515,16 @@ render_ring_dispatch_gem_execbuffer(struct drm_device *dev,
 		intel_ring_advance(dev, ring);
 	}
 
+	if (IS_G4X(dev) || IS_IRONLAKE(dev)) {
+		intel_ring_begin(dev, ring, 2);
+		intel_ring_emit(dev, ring, MI_FLUSH |
+				MI_NO_WRITE_FLUSH |
+				MI_INVALIDATE_ISP );
+		intel_ring_emit(dev, ring, MI_NOOP);
+		intel_ring_advance(dev, ring);
+	}
 	/* XXX breadcrumb */
+
 	return 0;
 }
 
Signature · 1 line
1.7.1