[PATCH 1/4] drm/i915: Split resume time display HW readout and modeset

Imre Deak imre.deak at intel.com
Mon Oct 8 13:18:16 UTC 2018


Signed-off-by: Imre Deak <imre.deak at intel.com>
---
 drivers/gpu/drm/i915/i915_drv.c      |  1 +
 drivers/gpu/drm/i915/i915_drv.h      |  1 +
 drivers/gpu/drm/i915/intel_display.c | 36 +++++++++++++++++++++++++++++++++---
 3 files changed, 35 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 1b028f429e92..37a0d54ccba4 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -2068,6 +2068,7 @@ static int i915_drm_resume(struct drm_device *dev)
 
 	intel_dp_mst_resume(dev_priv);
 
+	intel_display_readout_hw_state(dev_priv);
 	intel_display_resume(dev);
 
 	drm_kms_helper_poll_enable(dev);
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index b672ed0cac24..5b099a89adf7 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -3493,6 +3493,7 @@ extern int intel_connector_register(struct drm_connector *);
 extern void intel_connector_unregister(struct drm_connector *);
 extern int intel_modeset_vga_set_state(struct drm_i915_private *dev_priv,
 				       bool state);
+extern void intel_display_readout_hw_state(struct drm_i915_private *dev_priv);
 extern void intel_display_resume(struct drm_device *dev);
 extern void i915_redisable_vga(struct drm_i915_private *dev_priv);
 extern void i915_redisable_vga_power_on(struct drm_i915_private *dev_priv);
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 650e01f0c197..99c3f04a4d4e 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -3733,9 +3733,6 @@ __intel_display_resume(struct drm_device *dev,
 	struct drm_crtc *crtc;
 	int i, ret;
 
-	intel_modeset_setup_hw_state(dev, ctx);
-	i915_redisable_vga(to_i915(dev));
-
 	if (!state)
 		return 0;
 
@@ -3825,6 +3822,13 @@ void intel_prepare_reset(struct drm_i915_private *dev_priv)
 	state->acquire_ctx = ctx;
 }
 
+static void __intel_modeset_setup_hw_state(struct drm_i915_private *dev_priv,
+					   struct drm_modeset_acquire_ctx *ctx)
+{
+	intel_modeset_setup_hw_state(&dev_priv->drm, ctx);
+	i915_redisable_vga(dev_priv);
+}
+
 void intel_finish_reset(struct drm_i915_private *dev_priv)
 {
 	struct drm_device *dev = &dev_priv->drm;
@@ -3843,6 +3847,7 @@ void intel_finish_reset(struct drm_i915_private *dev_priv)
 	/* reset doesn't touch the display */
 	if (!gpu_reset_clobbers_display(dev_priv)) {
 		/* for testing only restore the display */
+		__intel_modeset_setup_hw_state(dev_priv, ctx);
 		ret = __intel_display_resume(dev, state, ctx);
 		if (ret)
 			DRM_ERROR("Restoring old state failed with %i\n", ret);
@@ -3863,6 +3868,7 @@ void intel_finish_reset(struct drm_i915_private *dev_priv)
 			dev_priv->display.hpd_irq_setup(dev_priv);
 		spin_unlock_irq(&dev_priv->irq_lock);
 
+		__intel_modeset_setup_hw_state(dev_priv, ctx);
 		ret = __intel_display_resume(dev, state, ctx);
 		if (ret)
 			DRM_ERROR("Restoring old state failed with %i\n", ret);
@@ -15965,6 +15971,30 @@ intel_modeset_setup_hw_state(struct drm_device *dev,
 	intel_fbc_init_pipe_state(dev_priv);
 }
 
+void intel_display_readout_hw_state(struct drm_i915_private *dev_priv)
+{
+	struct drm_modeset_acquire_ctx ctx;
+	int ret;
+
+	drm_modeset_acquire_init(&ctx, 0);
+	while (1) {
+		ret = drm_modeset_lock_all_ctx(&dev_priv->drm, &ctx);
+		if (ret != -EDEADLK)
+			break;
+
+		drm_modeset_backoff(&ctx);
+	}
+
+	if (!ret)
+		__intel_modeset_setup_hw_state(dev_priv, &ctx);
+
+	drm_modeset_drop_locks(&ctx);
+	drm_modeset_acquire_fini(&ctx);
+
+	if (ret)
+		DRM_ERROR("Reading out display HW state failed with %i\n", ret);
+}
+
 void intel_display_resume(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = to_i915(dev);
-- 
2.13.2



More information about the Intel-gfx-trybot mailing list