aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorJesse Barnes <jbarnes@virtuousgeek.org>2011-01-05 15:01:26 -0500
committerChris Wilson <chris@chris-wilson.co.uk>2011-01-11 15:43:59 -0500
commitd5bb081b027b520f9e59b4fb8faea83a136ec15e (patch)
tree5ff85d01f3763d0e4be1ae7934ef673db2b9c604 /drivers/gpu
parent1daed3fb8324d517a1f9da43f1a1d3619d1b0ddc (diff)
drm/i915: cleanup rc6 code
Cleanup several aspects of the rc6 code: - misnamed intel_disable_clock_gating function (was only about rc6) - remove commented call to intel_disable_clock_gating - rc6 enabling code belongs in its own function (allows us to move the actual clock gating enable call back into restore_state) - allocate power & render contexts up front, only free on unload (avoids ugly lazy init at rc6 enable time) Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org> [ickle: checkpatch cleanup] Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/i915/i915_drv.c6
-rw-r--r--drivers/gpu/drm/i915/i915_drv.h1
-rw-r--r--drivers/gpu/drm/i915/i915_suspend.c7
-rw-r--r--drivers/gpu/drm/i915/intel_display.c107
4 files changed, 75 insertions, 46 deletions
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 02fce7fbcd8a..0de75a23f8e7 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -355,10 +355,10 @@ static int i915_drm_thaw(struct drm_device *dev)
355 355
356 /* Resume the modeset for every activated CRTC */ 356 /* Resume the modeset for every activated CRTC */
357 drm_helper_resume_force_mode(dev); 357 drm_helper_resume_force_mode(dev);
358 }
359 358
360 /* Clock gating state */ 359 if (dev_priv->renderctx && dev_priv->pwrctx)
361 intel_enable_clock_gating(dev); 360 ironlake_enable_rc6(dev);
361 }
362 362
363 intel_opregion_init(dev); 363 intel_opregion_init(dev);
364 364
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 1f77d8c6c6a2..455260067ff7 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1260,6 +1260,7 @@ extern void intel_disable_fbc(struct drm_device *dev);
1260extern void intel_enable_fbc(struct drm_crtc *crtc, unsigned long interval); 1260extern void intel_enable_fbc(struct drm_crtc *crtc, unsigned long interval);
1261extern bool intel_fbc_enabled(struct drm_device *dev); 1261extern bool intel_fbc_enabled(struct drm_device *dev);
1262extern bool ironlake_set_drps(struct drm_device *dev, u8 val); 1262extern bool ironlake_set_drps(struct drm_device *dev, u8 val);
1263extern void ironlake_enable_rc6(struct drm_device *dev);
1263extern void gen6_set_rps(struct drm_device *dev, u8 val); 1264extern void gen6_set_rps(struct drm_device *dev, u8 val);
1264extern void intel_detect_pch (struct drm_device *dev); 1265extern void intel_detect_pch (struct drm_device *dev);
1265extern int intel_trans_dp_port_sel (struct drm_crtc *crtc); 1266extern int intel_trans_dp_port_sel (struct drm_crtc *crtc);
diff --git a/drivers/gpu/drm/i915/i915_suspend.c b/drivers/gpu/drm/i915/i915_suspend.c
index 147cd9666700..0521ecf26017 100644
--- a/drivers/gpu/drm/i915/i915_suspend.c
+++ b/drivers/gpu/drm/i915/i915_suspend.c
@@ -822,10 +822,6 @@ int i915_save_state(struct drm_device *dev)
822 if (IS_GEN6(dev)) 822 if (IS_GEN6(dev))
823 gen6_disable_rps(dev); 823 gen6_disable_rps(dev);
824 824
825 /* XXX disabling the clock gating breaks suspend on gm45
826 intel_disable_clock_gating(dev);
827 */
828
829 /* Cache mode state */ 825 /* Cache mode state */
830 dev_priv->saveCACHE_MODE_0 = I915_READ(CACHE_MODE_0); 826 dev_priv->saveCACHE_MODE_0 = I915_READ(CACHE_MODE_0);
831 827
@@ -868,6 +864,9 @@ int i915_restore_state(struct drm_device *dev)
868 I915_WRITE (IMR, dev_priv->saveIMR); 864 I915_WRITE (IMR, dev_priv->saveIMR);
869 } 865 }
870 866
867 /* Clock gating state */
868 intel_enable_clock_gating(dev);
869
871 if (IS_IRONLAKE_M(dev)) { 870 if (IS_IRONLAKE_M(dev)) {
872 ironlake_enable_drps(dev); 871 ironlake_enable_drps(dev);
873 intel_init_emon(dev); 872 intel_init_emon(dev);
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index f3c0525d5328..1190efa390bd 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -6415,44 +6415,6 @@ void intel_enable_clock_gating(struct drm_device *dev)
6415 } else if (IS_I830(dev)) { 6415 } else if (IS_I830(dev)) {
6416 I915_WRITE(DSPCLK_GATE_D, OVRUNIT_CLOCK_GATE_DISABLE); 6416 I915_WRITE(DSPCLK_GATE_D, OVRUNIT_CLOCK_GATE_DISABLE);
6417 } 6417 }
6418
6419 /*
6420 * GPU can automatically power down the render unit if given a page
6421 * to save state.
6422 */
6423 if (IS_IRONLAKE_M(dev)) {
6424 if (dev_priv->renderctx == NULL)
6425 dev_priv->renderctx = intel_alloc_context_page(dev);
6426 if (dev_priv->renderctx) {
6427 struct drm_i915_gem_object *obj = dev_priv->renderctx;
6428 if (BEGIN_LP_RING(6) != 0) {
6429 i915_gem_object_unpin(obj);
6430 drm_gem_object_unreference(&obj->base);
6431 dev_priv->renderctx = NULL;
6432 return;
6433 }
6434 OUT_RING(MI_SUSPEND_FLUSH | MI_SUSPEND_FLUSH_EN);
6435 OUT_RING(MI_SET_CONTEXT);
6436 OUT_RING(obj->gtt_offset |
6437 MI_MM_SPACE_GTT |
6438 MI_SAVE_EXT_STATE_EN |
6439 MI_RESTORE_EXT_STATE_EN |
6440 MI_RESTORE_INHIBIT);
6441 OUT_RING(MI_SUSPEND_FLUSH);
6442 OUT_RING(MI_NOOP);
6443 OUT_RING(MI_FLUSH);
6444 ADVANCE_LP_RING();
6445 } else
6446 DRM_DEBUG_KMS("Failed to allocate render context."
6447 "Disable RC6\n");
6448
6449 if (dev_priv->pwrctx == NULL)
6450 dev_priv->pwrctx = intel_alloc_context_page(dev);
6451 if (dev_priv->pwrctx) {
6452 struct drm_i915_gem_object *obj = dev_priv->pwrctx;
6453 I915_WRITE(PWRCTXA, obj->gtt_offset | PWRCTX_EN);
6454 }
6455 }
6456} 6418}
6457 6419
6458void intel_disable_clock_gating(struct drm_device *dev) 6420void intel_disable_clock_gating(struct drm_device *dev)
@@ -6482,6 +6444,57 @@ void intel_disable_clock_gating(struct drm_device *dev)
6482 } 6444 }
6483} 6445}
6484 6446
6447static void ironlake_disable_rc6(struct drm_device *dev)
6448{
6449 struct drm_i915_private *dev_priv = dev->dev_private;
6450
6451 /* Wake the GPU, prevent RC6, then restore RSTDBYCTL */
6452 I915_WRITE(RSTDBYCTL, I915_READ(RSTDBYCTL) | RCX_SW_EXIT);
6453 wait_for(((I915_READ(RSTDBYCTL) & RSX_STATUS_MASK) == RSX_STATUS_ON),
6454 10);
6455 POSTING_READ(CCID);
6456 I915_WRITE(PWRCTXA, 0);
6457 POSTING_READ(PWRCTXA);
6458 I915_WRITE(RSTDBYCTL, I915_READ(RSTDBYCTL) & ~RCX_SW_EXIT);
6459 POSTING_READ(RSTDBYCTL);
6460 i915_gem_object_unpin(dev_priv->renderctx);
6461 drm_gem_object_unreference(&dev_priv->renderctx->base);
6462 dev_priv->renderctx = NULL;
6463 i915_gem_object_unpin(dev_priv->pwrctx);
6464 drm_gem_object_unreference(&dev_priv->pwrctx->base);
6465 dev_priv->pwrctx = NULL;
6466}
6467
6468void ironlake_enable_rc6(struct drm_device *dev)
6469{
6470 struct drm_i915_private *dev_priv = dev->dev_private;
6471 int ret;
6472
6473 /*
6474 * GPU can automatically power down the render unit if given a page
6475 * to save state.
6476 */
6477 ret = BEGIN_LP_RING(6);
6478 if (ret) {
6479 ironlake_disable_rc6(dev);
6480 return;
6481 }
6482 OUT_RING(MI_SUSPEND_FLUSH | MI_SUSPEND_FLUSH_EN);
6483 OUT_RING(MI_SET_CONTEXT);
6484 OUT_RING(dev_priv->renderctx->gtt_offset |
6485 MI_MM_SPACE_GTT |
6486 MI_SAVE_EXT_STATE_EN |
6487 MI_RESTORE_EXT_STATE_EN |
6488 MI_RESTORE_INHIBIT);
6489 OUT_RING(MI_SUSPEND_FLUSH);
6490 OUT_RING(MI_NOOP);
6491 OUT_RING(MI_FLUSH);
6492 ADVANCE_LP_RING();
6493
6494 I915_WRITE(PWRCTXA, dev_priv->pwrctx->gtt_offset | PWRCTX_EN);
6495 I915_WRITE(RSTDBYCTL, I915_READ(RSTDBYCTL) & ~RCX_SW_EXIT);
6496}
6497
6485/* Set up chip specific display functions */ 6498/* Set up chip specific display functions */
6486static void intel_init_display(struct drm_device *dev) 6499static void intel_init_display(struct drm_device *dev)
6487{ 6500{
@@ -6724,6 +6737,21 @@ void intel_modeset_init(struct drm_device *dev)
6724 if (IS_GEN6(dev)) 6737 if (IS_GEN6(dev))
6725 gen6_enable_rps(dev_priv); 6738 gen6_enable_rps(dev_priv);
6726 6739
6740 if (IS_IRONLAKE_M(dev)) {
6741 dev_priv->renderctx = intel_alloc_context_page(dev);
6742 if (!dev_priv->renderctx)
6743 goto skip_rc6;
6744 dev_priv->pwrctx = intel_alloc_context_page(dev);
6745 if (!dev_priv->pwrctx) {
6746 i915_gem_object_unpin(dev_priv->renderctx);
6747 drm_gem_object_unreference(&dev_priv->renderctx->base);
6748 dev_priv->renderctx = NULL;
6749 goto skip_rc6;
6750 }
6751 ironlake_enable_rc6(dev);
6752 }
6753
6754skip_rc6:
6727 INIT_WORK(&dev_priv->idle_work, intel_idle_update); 6755 INIT_WORK(&dev_priv->idle_work, intel_idle_update);
6728 setup_timer(&dev_priv->idle_timer, intel_gpu_idle_timer, 6756 setup_timer(&dev_priv->idle_timer, intel_gpu_idle_timer,
6729 (unsigned long)dev); 6757 (unsigned long)dev);
@@ -6760,7 +6788,8 @@ void intel_modeset_cleanup(struct drm_device *dev)
6760 if (IS_GEN6(dev)) 6788 if (IS_GEN6(dev))
6761 gen6_disable_rps(dev); 6789 gen6_disable_rps(dev);
6762 6790
6763 intel_disable_clock_gating(dev); 6791 if (IS_IRONLAKE_M(dev))
6792 ironlake_disable_rc6(dev);
6764 6793
6765 mutex_unlock(&dev->struct_mutex); 6794 mutex_unlock(&dev->struct_mutex);
6766 6795