<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <br>
    <br>
    <div class="moz-cite-prefix">On 1/12/2016 5:57 PM, Kumar, Abhay
      wrote:<br>
    </div>
    <blockquote
      cite="mid:1452650255-11125-1-git-send-email-abhay.kumar@intel.com"
      type="cite">
      <pre wrap="">From: Abhay Kumar <a class="moz-txt-link-rfc2396E" href="mailto:abhay.kumar@intel.com"><abhay.kumar@intel.com></a>

Make resume/on codepath not to wait for panel_power_cycle_delay(t11_t12)
if this time is already spent in suspend/poweron time.

v2: Use CLOCK_BOOTTIME and remove jiffies for panel power cycle
    delay calculation(Ville).

v3: Addressed below comments
    1. Tracking time from where last powercycle is initiated.
    2. Used ktime_get_bootime() wrapper for boottime clock.
    3. Used ktime_ms_delta() to get time difference.

v4: Updated v3 change log in detail.

Cc: Ville Syrjälä <a class="moz-txt-link-rfc2396E" href="mailto:ville.syrjala@linux.intel.com"><ville.syrjala@linux.intel.com></a>
Signed-off-by: Abhay Kumar <a class="moz-txt-link-rfc2396E" href="mailto:abhay.kumar@intel.com"><abhay.kumar@intel.com></a>
---
 drivers/gpu/drm/i915/intel_dp.c  | 19 ++++++++++++++-----
 drivers/gpu/drm/i915/intel_drv.h |  2 +-
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index 796e3d3..0042693 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -1812,12 +1812,21 @@ static void wait_panel_off(struct intel_dp *intel_dp)
 
 static void wait_panel_power_cycle(struct intel_dp *intel_dp)
 {
+       static ktime_t panel_power_on_time;
+       s64 panel_power_off_duration;
+
        DRM_DEBUG_KMS("Wait for panel power cycle\n");
 
+       /* take the difference of currrent time and panel power off time
+        * and then make panel wait for t11_t12 if needed. */
+       panel_power_on_time = ktime_get_boottime();
+       panel_power_off_duration = ktime_ms_delta(panel_power_on_time, intel_dp->panel_power_off_time);
+
        /* When we disable the VDD override bit last we have to do the manual
         * wait. */
-       wait_remaining_ms_from_jiffies(intel_dp->last_power_cycle,
-                                      intel_dp->panel_power_cycle_delay);
+       if (panel_power_off_duration < (s64)intel_dp->panel_power_cycle_delay)
+               wait_remaining_ms_from_jiffies(jiffies,
+                                      intel_dp->panel_power_cycle_delay - panel_power_off_duration);
 
        wait_panel_status(intel_dp, IDLE_CYCLE_MASK, IDLE_CYCLE_VALUE);
 }
@@ -1969,7 +1978,7 @@ static void edp_panel_vdd_off_sync(struct intel_dp *intel_dp)
        I915_READ(pp_stat_reg), I915_READ(pp_ctrl_reg));
 
        if ((pp & POWER_TARGET_ON) == 0)
-               intel_dp->last_power_cycle = jiffies;
+               intel_dp->panel_power_off_time = ktime_get_boottime();
 
        power_domain = intel_display_port_aux_power_domain(intel_encoder);
        intel_display_power_put(dev_priv, power_domain);
@@ -2118,7 +2127,7 @@ static void edp_panel_off(struct intel_dp *intel_dp)
        I915_WRITE(pp_ctrl_reg, pp);
        POSTING_READ(pp_ctrl_reg);
 
-       intel_dp->last_power_cycle = jiffies;
+       intel_dp->panel_power_off_time = ktime_get_boottime();
        wait_panel_off(intel_dp);
 
        /* We got a reference when we enabled the VDD. */
@@ -5122,7 +5131,7 @@ intel_dp_add_properties(struct intel_dp *intel_dp, struct drm_connector *connect
 
 static void intel_dp_init_panel_power_timestamps(struct intel_dp *intel_dp)
 {
-       intel_dp->last_power_cycle = jiffies;
+       intel_dp->panel_power_off_time = ktime_get_boottime();
        intel_dp->last_power_on = jiffies;
        intel_dp->last_backlight_off = jiffies;
 }
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index bdfe403..06b37b8 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -793,9 +793,9 @@ struct intel_dp {
        int backlight_off_delay;
        struct delayed_work panel_vdd_work;
        bool want_panel_vdd;
-       unsigned long last_power_cycle;
        unsigned long last_power_on;
        unsigned long last_backlight_off;
+       ktime_t panel_power_off_time;
 
        struct notifier_block edp_notifier;
 
</pre>
    </blockquote>
    <br>
    Since this is already reviewed. Can we please get this <span
      style="color: rgb(34, 34, 34); font-family: arial, sans-serif;
      font-size: 12.8px; font-style: normal; font-variant: normal;
      font-weight: normal; letter-spacing: normal; line-height: normal;
      orphans: auto; text-align: start; text-indent: 0px;
      text-transform: none; white-space: normal; widows: 1;
      word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline
      !important; float: none; background-color: rgb(255, 255, 255);">Queued
      for -next ?<br>
      <br>
      Regards,<br>
      Abhay Kumar<br>
      <br>
    </span>
  </body>
</html>