All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paulo Zanoni <przanoni@gmail.com>
To: intel-gfx@lists.freedesktop.org
Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>
Subject: [PATCH 3/6] drm/i915: reset eDP timestamps on resume
Date: Fri,  3 Jan 2014 17:46:40 -0200	[thread overview]
Message-ID: <1388778400-2079-1-git-send-email-przanoni@gmail.com> (raw)
In-Reply-To: <20131219093511.457a493d@jbarnes-t420>

From: Paulo Zanoni <paulo.r.zanoni@intel.com>

The eDP code records a few timestamps containing the last time we took
some actions, because we need to wait before doing some other actions.
The problem is that if we store a timestamp when suspending and then
look at it when resuming, we'll ignore the unknown amount of time we
actually were suspended.

This happens with the panel power cycle delay: it's 500ms on my
machine, and it's delaying the resume sequence by 200ms due to a
timestamp we recorded before suspending. This patch should solve this
problem by resetting the timestamps, creating encoder->resume()
callbacks.

Q: Why don't we use DRM's connector->reset() callback?
A: Because it is also called then the driver is loaded, and it's on a point
where we have already used the panel, so we can't just reset any of the
timtestamps there.

v2: - Fix the madatory jiffies/milliseconds bug.

Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
---
 drivers/gpu/drm/i915/i915_drv.c      |  2 ++
 drivers/gpu/drm/i915/intel_ddi.c     |  1 +
 drivers/gpu/drm/i915/intel_display.c | 11 +++++++++++
 drivers/gpu/drm/i915/intel_dp.c      | 22 ++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_drv.h     |  3 +++
 5 files changed, 39 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 61fb9fc..4aa42e5 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -649,6 +649,8 @@ static int __i915_drm_thaw(struct drm_device *dev, bool restore_gtt_mappings)
 
 		mutex_lock(&dev->struct_mutex);
 
+		intel_encoder_resume(dev);
+
 		error = i915_gem_init_hw(dev);
 		mutex_unlock(&dev->struct_mutex);
 
diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c
index 1488b28..527e89c 100644
--- a/drivers/gpu/drm/i915/intel_ddi.c
+++ b/drivers/gpu/drm/i915/intel_ddi.c
@@ -1606,6 +1606,7 @@ void intel_ddi_init(struct drm_device *dev, enum port port)
 	intel_encoder->post_disable = intel_ddi_post_disable;
 	intel_encoder->get_hw_state = intel_ddi_get_hw_state;
 	intel_encoder->get_config = intel_ddi_get_config;
+	intel_encoder->resume = intel_dp_resume;
 
 	intel_dig_port->port = port;
 	intel_dig_port->saved_port_bits = I915_READ(DDI_BUF_CTL(port)) &
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 4d1357a..869be78 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -11096,6 +11096,17 @@ void i915_redisable_vga(struct drm_device *dev)
 	}
 }
 
+void intel_encoder_resume(struct drm_device *dev)
+{
+	struct intel_encoder *encoder;
+
+	list_for_each_entry(encoder, &dev->mode_config.encoder_list,
+			    base.head) {
+		if (encoder->resume)
+			encoder->resume(encoder);
+	}
+}
+
 static void intel_modeset_readout_hw_state(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index 2f82af4..dafb204 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -3393,6 +3393,27 @@ intel_dp_add_properties(struct intel_dp *intel_dp, struct drm_connector *connect
 	}
 }
 
+void intel_dp_resume(struct intel_encoder *encoder)
+{
+	struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base);
+	unsigned long tmp_jiffies = jiffies;
+
+	if (!is_edp(intel_dp))
+		return;
+
+	/*
+	 * Reset everything, otherwise when suspend/resume gets very fast, we
+	 * delay the resume based on the values that were set when we were still
+	 * suspending.
+	 */
+	intel_dp->last_power_on = tmp_jiffies -
+			msecs_to_jiffies(intel_dp->backlight_on_delay);
+	intel_dp->last_power_cycle = tmp_jiffies -
+			msecs_to_jiffies(intel_dp->panel_power_cycle_delay);
+	intel_dp->last_backlight_off = tmp_jiffies -
+			msecs_to_jiffies(intel_dp->backlight_off_delay);
+}
+
 static void
 intel_dp_init_panel_power_sequencer(struct drm_device *dev,
 				    struct intel_dp *intel_dp,
@@ -3784,6 +3805,7 @@ intel_dp_init(struct drm_device *dev, int output_reg, enum port port)
 	intel_encoder->post_disable = intel_post_disable_dp;
 	intel_encoder->get_hw_state = intel_dp_get_hw_state;
 	intel_encoder->get_config = intel_dp_get_config;
+	intel_encoder->resume = intel_dp_resume;
 	if (IS_VALLEYVIEW(dev)) {
 		intel_encoder->pre_pll_enable = vlv_dp_pre_pll_enable;
 		intel_encoder->pre_enable = vlv_pre_enable_dp;
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 92de688..8fb6dbe 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -149,6 +149,7 @@ struct intel_encoder {
 	 * be set correctly before calling this function. */
 	void (*get_config)(struct intel_encoder *,
 			   struct intel_crtc_config *pipe_config);
+	void (*resume)(struct intel_encoder *);
 	int crtc_mask;
 	enum hpd_pin hpd_pin;
 };
@@ -711,6 +712,7 @@ void hsw_enable_ips(struct intel_crtc *crtc);
 void hsw_disable_ips(struct intel_crtc *crtc);
 void intel_display_set_init_power(struct drm_device *dev, bool enable);
 int valleyview_get_vco(struct drm_i915_private *dev_priv);
+void intel_encoder_resume(struct drm_device *dev);
 
 /* intel_dp.c */
 void intel_dp_init(struct drm_device *dev, int output_reg, enum port port);
@@ -734,6 +736,7 @@ void ironlake_edp_panel_vdd_off(struct intel_dp *intel_dp, bool sync);
 void intel_edp_psr_enable(struct intel_dp *intel_dp);
 void intel_edp_psr_disable(struct intel_dp *intel_dp);
 void intel_edp_psr_update(struct drm_device *dev);
+void intel_dp_resume(struct intel_encoder *encoder);
 
 
 /* intel_dsi.c */
-- 
1.8.4.2

  reply	other threads:[~2014-01-03 19:46 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-19 16:29 [PATCH 0/6] eDP panel power sequencing optimizations Paulo Zanoni
2013-12-19 16:29 ` [PATCH 1/6] drm/i915: init the DP panel power seq variables earlier Paulo Zanoni
2013-12-19 17:24   ` Jesse Barnes
2013-12-19 16:29 ` [PATCH 2/6] drm/i915: save some time when waiting the eDP timings Paulo Zanoni
2013-12-19 17:32   ` Jesse Barnes
2013-12-20  9:30   ` Jani Nikula
2013-12-20 14:24     ` Daniel Vetter
2014-01-03 18:27     ` Paulo Zanoni
2014-01-03 19:45       ` Paulo Zanoni
2014-01-17 13:09   ` Jani Nikula
2014-01-17 13:29     ` Daniel Vetter
2014-01-17 13:53       ` Daniel Vetter
2013-12-19 16:29 ` [PATCH 3/6] drm/i915: reset eDP timestamps on resume Paulo Zanoni
2013-12-19 17:35   ` Jesse Barnes
2014-01-03 19:46     ` Paulo Zanoni [this message]
2014-01-15 18:21       ` Jesse Barnes
2014-01-15 23:36         ` Daniel Vetter
2014-01-16 14:26           ` Paulo Zanoni
2014-01-17 20:17             ` Paulo Zanoni
2014-01-17 20:22               ` Chris Wilson
2014-01-17 21:11                 ` Paulo Zanoni
2014-01-17 21:21                   ` Chris Wilson
2014-01-17 21:34                     ` Daniel Vetter
2014-01-20 15:47                       ` Paulo Zanoni
2014-01-20 16:10                         ` Daniel Vetter
2013-12-19 16:29 ` [PATCH 4/6] drm/i915: remove a column of zeros from the eDP wait definitions Paulo Zanoni
2013-12-19 17:36   ` Jesse Barnes
2013-12-19 16:29 ` [PATCH 5/6] drm/i915: don't wait for power cycle when waiting for power off Paulo Zanoni
2013-12-19 17:38   ` Jesse Barnes
2013-12-19 18:34     ` Jesse Barnes
2013-12-19 16:29 ` [PATCH 6/6] drm/i915: set the backlight panel delays registers to 1 Paulo Zanoni
2013-12-19 17:39   ` Jesse Barnes
2014-01-17 13:57     ` Daniel Vetter
2014-01-20 16:12       ` Daniel Vetter
2014-01-28  7:57   ` Jani Nikula
2014-01-28  8:02     ` Daniel Vetter
2014-01-28  8:23       ` Jani Nikula

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1388778400-2079-1-git-send-email-przanoni@gmail.com \
    --to=przanoni@gmail.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=paulo.r.zanoni@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.