From patchwork Thu Dec 19 16:29:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Zanoni X-Patchwork-Id: 3383401 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id BFCB4C0D4A for ; Thu, 19 Dec 2013 16:30:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5E850206B5 for ; Thu, 19 Dec 2013 16:30:28 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id A1F97206A6 for ; Thu, 19 Dec 2013 16:30:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4363810E4EB; Thu, 19 Dec 2013 08:30:20 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-qa0-f46.google.com (mail-qa0-f46.google.com [209.85.216.46]) by gabe.freedesktop.org (Postfix) with ESMTP id D4506FC9F5 for ; Thu, 19 Dec 2013 08:30:01 -0800 (PST) Received: by mail-qa0-f46.google.com with SMTP id f11so4959390qae.12 for ; Thu, 19 Dec 2013 08:30:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3aHqZ5S4maw4W8KlFAjTIf8YVq93vnf7E6d/kbsdDmo=; b=d8Jsigw2UX43KNw6Fm1pFfkR8IKjbnRG8Bm57MxfvsI6p4ulOAUbmT7/HbUgLNxdJi wyU/sir/EeveOkRkqclPIyGWSjDgBF5DpRbQpAAM5raiHHnJB5DiP1kCuarxExhFJZjS iwvpTG6DXOgFNj65kgVXj+E+BTb2d+30+CDZEB5k2MCPttx7nM/fIdjUtJRjKlklYY0t /uB/KuCVV59ptX6GwKgPNcCS5Uv5a1PTtatgYp1T/4w3S05Kqhx+F73c9QqYmjx0rzLf FcYwqaRve6rELklcxYRSVOTPNk5K5MhYqRFhTPTY7kPb60d4P5whPWsTZJCTI0wXBlz7 kp6w== X-Received: by 10.224.32.133 with SMTP id c5mr4580555qad.54.1387470601498; Thu, 19 Dec 2013 08:30:01 -0800 (PST) Received: from localhost.localdomain ([177.40.41.2]) by mx.google.com with ESMTPSA id gf3sm1215892qeb.17.2013.12.19.08.29.59 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Dec 2013 08:30:00 -0800 (PST) From: Paulo Zanoni To: intel-gfx@lists.freedesktop.org Date: Thu, 19 Dec 2013 14:29:41 -0200 Message-Id: <1387470584-1662-4-git-send-email-przanoni@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1387470584-1662-1-git-send-email-przanoni@gmail.com> References: <1387470584-1662-1-git-send-email-przanoni@gmail.com> Cc: Paulo Zanoni Subject: [Intel-gfx] [PATCH 3/6] drm/i915: reset eDP timestamps on resume X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Paulo Zanoni 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. Signed-off-by: Paulo Zanoni --- 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 | 21 +++++++++++++++++++++ drivers/gpu/drm/i915/intel_drv.h | 3 +++ 5 files changed, 38 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..a291977 100644 --- a/drivers/gpu/drm/i915/intel_dp.c +++ b/drivers/gpu/drm/i915/intel_dp.c @@ -3393,6 +3393,26 @@ 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 - intel_dp->backlight_on_delay; + intel_dp->last_power_cycle = tmp_jiffies - + intel_dp->panel_power_cycle_delay; + intel_dp->last_backlight_off = tmp_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 +3804,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 */