drm/i915: Check PSR setup time vs. vblank length
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Wed, 18 May 2016 08:34:38 +0000 (11:34 +0300)
committerDave Airlie <airlied@redhat.com>
Tue, 2 Aug 2016 21:06:41 +0000 (07:06 +1000)
Bspec says:
"Restriction : SRD must not be enabled when the PSR Setup time from DPCD
00071h is greater than the time for vertical blank minus one line."

Let's check for that and disallow PSR if we exceed the limit.

Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/i915/intel_drv.h
drivers/gpu/drm/i915/intel_psr.c
drivers/gpu/drm/i915/intel_sprite.c

index 3329fc6a95f488b9e74b8f7a6deea457976a92b6..cc937a19b1ba09486bf9ce04688ecba5a5c123ab 100644 (file)
@@ -1730,6 +1730,8 @@ bool intel_sdvo_init(struct drm_device *dev,
 
 
 /* intel_sprite.c */
+int intel_usecs_to_scanlines(const struct drm_display_mode *adjusted_mode,
+                            int usecs);
 int intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane);
 int intel_sprite_set_colorkey(struct drm_device *dev, void *data,
                              struct drm_file *file_priv);
index 68bd0bb34817fa17e3ad6da0ab19d90fe5e4a19a..2b0d1baf15b3cc6c2b57db06e91fe774be4d99ea 100644 (file)
@@ -327,6 +327,9 @@ static bool intel_psr_match_conditions(struct intel_dp *intel_dp)
        struct drm_i915_private *dev_priv = to_i915(dev);
        struct drm_crtc *crtc = dig_port->base.base.crtc;
        struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+       const struct drm_display_mode *adjusted_mode =
+               &intel_crtc->config->base.adjusted_mode;
+       int psr_setup_time;
 
        lockdep_assert_held(&dev_priv->psr.lock);
        WARN_ON(!drm_modeset_is_locked(&dev->mode_config.connection_mutex));
@@ -365,11 +368,25 @@ static bool intel_psr_match_conditions(struct intel_dp *intel_dp)
        }
 
        if (IS_HASWELL(dev) &&
-           intel_crtc->config->base.adjusted_mode.flags & DRM_MODE_FLAG_INTERLACE) {
+           adjusted_mode->flags & DRM_MODE_FLAG_INTERLACE) {
                DRM_DEBUG_KMS("PSR condition failed: Interlaced is Enabled\n");
                return false;
        }
 
+       psr_setup_time = drm_dp_psr_setup_time(intel_dp->psr_dpcd);
+       if (psr_setup_time < 0) {
+               DRM_DEBUG_KMS("PSR condition failed: Invalid PSR setup time (0x%02x)\n",
+                             intel_dp->psr_dpcd[1]);
+               return false;
+       }
+
+       if (intel_usecs_to_scanlines(adjusted_mode, psr_setup_time) >
+           adjusted_mode->crtc_vtotal - adjusted_mode->crtc_vdisplay - 1) {
+               DRM_DEBUG_KMS("PSR condition failed: PSR setup time (%d us) too long\n",
+                             psr_setup_time);
+               return false;
+       }
+
        dev_priv->psr.source_ok = true;
        return true;
 }
index 0de935ad01c2ae78f4e6c0bbfc77860e191b876d..7c08e4f29032306e3ae98fb158c74f2217982190 100644 (file)
@@ -53,8 +53,8 @@ format_is_yuv(uint32_t format)
        }
 }
 
-static int usecs_to_scanlines(const struct drm_display_mode *adjusted_mode,
-                             int usecs)
+int intel_usecs_to_scanlines(const struct drm_display_mode *adjusted_mode,
+                            int usecs)
 {
        /* paranoia */
        if (!adjusted_mode->crtc_htotal)
@@ -91,7 +91,7 @@ void intel_pipe_update_start(struct intel_crtc *crtc)
                vblank_start = DIV_ROUND_UP(vblank_start, 2);
 
        /* FIXME needs to be calibrated sensibly */
-       min = vblank_start - usecs_to_scanlines(adjusted_mode, 100);
+       min = vblank_start - intel_usecs_to_scanlines(adjusted_mode, 100);
        max = vblank_start - 1;
 
        local_irq_disable();