Program EDP_PSR_DEBUG_CTL (PSR_MASK) to enable system
to go to deep sleep while in psr2.PSR2_STATUS bit 31:28
should report value 8 , if system enters deep sleep state.

Also, EDP_FRAMES_BEFORE_SU_ENTRY is set 1 , if not set,
flickering is observed on psr2 panel.

v2: (Ilia Mirkin)
- Remove duplicate bit definition 25:27

v3: rebase

Cc: Rodrigo Vivi <rodrigo.vivi at intel.com>
Cc: Jim Bride <jim.bride at linux.intel.com>
Signed-off-by: Vathsala Nagaraju <vathsala.nagaraju at intel.com>
Signed-off-by: Patil Deepti <deepti.patil at intel.com>
Reviewed-by: Jim Bride <jim.bride at linux.intel.com>
---
 drivers/gpu/drm/i915/i915_reg.h  | 10 +++++++---
 drivers/gpu/drm/i915/intel_psr.c | 22 ++++++++++++++++++++--
 2 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 5ca506a..272a283 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -3597,9 +3597,12 @@ enum {
 #define   EDP_PSR_PERF_CNT_MASK                0xffffff

 #define EDP_PSR_DEBUG_CTL              _MMIO(dev_priv->psr_mmio_base + 0x60)
-#define   EDP_PSR_DEBUG_MASK_LPSP      (1<<27)
-#define   EDP_PSR_DEBUG_MASK_MEMUP     (1<<26)
-#define   EDP_PSR_DEBUG_MASK_HPD       (1<<25)
+#define   EDP_PSR_DEBUG_MASK_MAX_SLEEP         (1<<28)
+#define   EDP_PSR_DEBUG_MASK_LPSP              (1<<27)
+#define   EDP_PSR_DEBUG_MASK_MEMUP             (1<<26)
+#define   EDP_PSR_DEBUG_MASK_HPD               (1<<25)
+#define   EDP_PSR_DEBUG_MASK_DISP_REG_WRITE    (1<<16)
+#define   EDP_PSR_DEBUG_EXIT_ON_PIXEL_UNDERRUN (1<<15)

 #define EDP_PSR2_CTL                   _MMIO(0x6f900)
 #define   EDP_PSR2_ENABLE              (1<<31)
@@ -3614,6 +3617,7 @@ enum {
 #define   EDP_PSR2_FRAME_BEFORE_SU_SHIFT 4
 #define   EDP_PSR2_FRAME_BEFORE_SU_MASK        (0xf<<4)
 #define   EDP_PSR2_IDLE_MASK           0xf
+#define   EDP_FRAMES_BEFORE_SU_ENTRY   (1<<4)

 #define EDP_PSR2_STATUS_CTL            _MMIO(0x6f940)
 #define EDP_PSR2_STATUS_STATE_MASK     (0xf<<28)
diff --git a/drivers/gpu/drm/i915/intel_psr.c b/drivers/gpu/drm/i915/intel_psr.c
index bcfe0db..05efd4e 100644
--- a/drivers/gpu/drm/i915/intel_psr.c
+++ b/drivers/gpu/drm/i915/intel_psr.c
@@ -338,8 +338,9 @@ static void intel_enable_source_psr2(struct intel_dp 
*intel_dp)
        /* FIXME: selective update is probably totally broken because it doesn't
         * mesh at all with our frontbuffer tracking. And the hw alone isn't
         * good enough. */
-       val |= EDP_PSR2_ENABLE | EDP_SU_TRACK_ENABLE;
-
+       val |= EDP_PSR2_ENABLE |
+               EDP_SU_TRACK_ENABLE |
+               EDP_FRAMES_BEFORE_SU_ENTRY;
        if (dev_priv->vbt.psr.tp2_tp3_wakeup_time > 5)
                val |= EDP_PSR2_TP2_TIME_2500;
        else if (dev_priv->vbt.psr.tp2_tp3_wakeup_time > 1)
@@ -512,9 +513,26 @@ void intel_psr_enable(struct intel_dp *intel_dp)
                        /* Set CHICKEN_TRANS_BIT12 for programable header */
                        chicken_trans = chicken_trans | CHICKEN_TRANS_BIT12;
                        I915_WRITE(CHICKEN_TRANS(TRANS_EDP), chicken_trans);
+                       I915_WRITE(EDP_PSR_DEBUG_CTL,
+                                  EDP_PSR_DEBUG_MASK_MEMUP |
+                                  EDP_PSR_DEBUG_MASK_HPD |
+                                  EDP_PSR_DEBUG_MASK_LPSP |
+                                  EDP_PSR_DEBUG_MASK_MAX_SLEEP |
+                                  EDP_PSR_DEBUG_MASK_DISP_REG_WRITE);
                } else {
                        /* set up vsc header for psr1 */
                        hsw_psr_setup_vsc(intel_dp);
+                       /*
+                        * Per Spec: Avoid continuous PSR exit by masking MEMUP
+                        * and HPD. also mask LPSP to avoid dependency on other
+                        * drivers that might block runtime_pm besides
+                        * preventing  other hw tracking issues now we can rely
+                        * on frontbuffer tracking.
+                        */
+                       I915_WRITE(EDP_PSR_DEBUG_CTL,
+                                  EDP_PSR_DEBUG_MASK_MEMUP |
+                                  EDP_PSR_DEBUG_MASK_HPD |
+                                  EDP_PSR_DEBUG_MASK_LPSP);
                }
                /*
                 * Per Spec: Avoid continuous PSR exit by masking MEMUP and HPD.
-- 
1.9.1

Reply via email to