drm/i915: Do vblank evasion correctly if vrr push has already been sent
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Wed, 17 Nov 2021 18:31:02 +0000 (20:31 +0200)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Thu, 18 Nov 2021 20:31:15 +0000 (22:31 +0200)
Let's adjust the vblank evasion to account for the case where
a push has already been sent. In that case the vblank exit will start
at vmin vblank start (as opposed to vmax vblank start when no push
has been sent).

This should minimize the effects of the tiny race between sampling
the frame counter vs. intel_vrr_send_push() during the previous frame.
This will also be required if we want to do mailbox style updates with
vrr since then we'd definitely do multiple commits per frame. Currently
mailbox updates are only used by the legacy cursor, but we don't do
vrr push for those.

Cc: Manasi Navare <manasi.d.navare@intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20211117183103.27418-2-ville.syrjala@linux.intel.com
Reviewed-by: Manasi Navare <manasi.d.navare@intel.com>
drivers/gpu/drm/i915/display/intel_crtc.c
drivers/gpu/drm/i915/display/intel_vrr.c
drivers/gpu/drm/i915/display/intel_vrr.h

index cf403be7736c2711be60adf171329b6ebcb46c20..eb5444f90e77cc25f38a26998a53dc22297918a8 100644 (file)
@@ -470,10 +470,14 @@ void intel_pipe_update_start(struct intel_crtc_state *new_crtc_state)
        if (intel_crtc_needs_vblank_work(new_crtc_state))
                intel_crtc_vblank_work_init(new_crtc_state);
 
-       if (new_crtc_state->vrr.enable)
-               vblank_start = intel_vrr_vmax_vblank_start(new_crtc_state);
-       else
+       if (new_crtc_state->vrr.enable) {
+               if (intel_vrr_is_push_sent(new_crtc_state))
+                       vblank_start = intel_vrr_vmin_vblank_start(new_crtc_state);
+               else
+                       vblank_start = intel_vrr_vmax_vblank_start(new_crtc_state);
+       } else {
                vblank_start = intel_mode_vblank_start(adjusted_mode);
+       }
 
        /* FIXME needs to be calibrated sensibly */
        min = vblank_start - intel_usecs_to_scanlines(adjusted_mode,
index c335b1dbafcf80171691865f55b46fcab77efcc0..db1c3902fc2d178dc7c6678b8da29e8059b72669 100644 (file)
@@ -193,6 +193,18 @@ void intel_vrr_send_push(const struct intel_crtc_state *crtc_state)
                       TRANS_PUSH_EN | TRANS_PUSH_SEND);
 }
 
+bool intel_vrr_is_push_sent(const struct intel_crtc_state *crtc_state)
+{
+       struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
+       struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
+       enum transcoder cpu_transcoder = crtc_state->cpu_transcoder;
+
+       if (!crtc_state->vrr.enable)
+               return false;
+
+       return intel_de_read(dev_priv, TRANS_PUSH(cpu_transcoder)) & TRANS_PUSH_SEND;
+}
+
 void intel_vrr_disable(const struct intel_crtc_state *old_crtc_state)
 {
        struct intel_crtc *crtc = to_intel_crtc(old_crtc_state->uapi.crtc);
index 96f9c9c27ab9f792e302562d8e2387e6141c6e65..1c2da572693d2b17eedb94cf79b4b8b3a1969706 100644 (file)
@@ -23,6 +23,7 @@ void intel_vrr_compute_config(struct intel_crtc_state *crtc_state,
 void intel_vrr_enable(struct intel_encoder *encoder,
                      const struct intel_crtc_state *crtc_state);
 void intel_vrr_send_push(const struct intel_crtc_state *crtc_state);
+bool intel_vrr_is_push_sent(const struct intel_crtc_state *crtc_state);
 void intel_vrr_disable(const struct intel_crtc_state *old_crtc_state);
 void intel_vrr_get_config(struct intel_crtc *crtc,
                          struct intel_crtc_state *crtc_state);