[PATCH 3/6] drm/i915: reset eDP timestamps on resume

Paulo Zanoni
2014-01-17T20:17:54Z

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.

v2: - Fix the madatory jiffies/milliseconds bug.
v3: - We can use drm_connector->reset after Daniel's recent refactor.

Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
---
drivers/gpu/drm/i915/intel_dp.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)

diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index 55c43cf..001fb06 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -3302,12 +3302,34 @@ void intel_dp_encoder_destroy(struct drm_encoder *encoder)
kfree(intel_dig_port);
}

+void intel_dp_reset(struct drm_connector *connector)
+{
+ struct intel_dp *intel_dp = intel_attached_dp(connector);
+ 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 const struct drm_connector_funcs intel_dp_connector_funcs = {
.dpms = intel_connector_dpms,
.detect = intel_dp_detect,
.fill_modes = drm_helper_probe_single_connector_modes,
.set_property = intel_dp_set_property,
.destroy = intel_dp_connector_destroy,
+ .reset = intel_dp_reset,
};

static const struct drm_connector_helper_funcs intel_dp_connector_helper_funcs = {
--
1.8.4.2