]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/i915/vblank: Add helper to get correct vblank length
authorAnkit Nautiyal <ankit.k.nautiyal@intel.com>
Thu, 16 Oct 2025 05:54:08 +0000 (11:24 +0530)
committerAnkit Nautiyal <ankit.k.nautiyal@intel.com>
Thu, 16 Oct 2025 13:57:37 +0000 (19:27 +0530)
Currently crtc_vblank_start is assumed to be the vblank_start for the fixed
refresh rate case. That value can be different from the variable refresh
rate case whenever always_use_vrr_tg()==false. On icl/tgl it's always
different due to the extra vblank delay, and also on adl+ it could be
different if we were to use an optimized guardband.

So places where crtc_vblank_start is used to compute vblank length needs
change so as to account for cases where vrr is enabled. Specifically
with vrr.enable the effective vblank length is actually guardband.

Add a helper to get the correct vblank length for both vrr and fixed
refresh rate cases. Use this helper where vblank_start is used to
compute the vblank length.

Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://lore.kernel.org/r/20251016055415.2101347-5-ankit.k.nautiyal@intel.com
drivers/gpu/drm/i915/display/intel_vblank.c
drivers/gpu/drm/i915/display/intel_vblank.h
drivers/gpu/drm/i915/display/skl_watermark.c

index 0b7fcc05e64c3c530238ba96524698dd8f977f36..2fc0c1c0bb87605b709df57b712b8517227b2e1e 100644 (file)
@@ -767,3 +767,13 @@ int intel_vblank_evade(struct intel_vblank_evade_ctx *evade)
 
        return scanline;
 }
+
+int intel_crtc_vblank_length(const struct intel_crtc_state *crtc_state)
+{
+       const struct drm_display_mode *adjusted_mode = &crtc_state->hw.adjusted_mode;
+
+       if (crtc_state->vrr.enable)
+               return crtc_state->vrr.guardband;
+       else
+               return adjusted_mode->crtc_vtotal - adjusted_mode->crtc_vblank_start;
+}
index 21fbb08d61d5d1ff9f481992ec8f36f6627c9e09..98d04cacd65f871eaf651f98fef5c8c1a1bc9d6f 100644 (file)
@@ -48,4 +48,6 @@ const struct intel_crtc_state *
 intel_pre_commit_crtc_state(struct intel_atomic_state *state,
                            struct intel_crtc *crtc);
 
+int intel_crtc_vblank_length(const struct intel_crtc_state *crtc_state);
+
 #endif /* __INTEL_VBLANK_H__ */
index 9df9ee137bf90b2d9a1d3a334ef6bd63e1eeadcc..06e5e6c77d2ede42635618f448d49848c4d561af 100644 (file)
@@ -28,6 +28,7 @@
 #include "intel_flipq.h"
 #include "intel_pcode.h"
 #include "intel_plane.h"
+#include "intel_vblank.h"
 #include "intel_wm.h"
 #include "skl_universal_plane_regs.h"
 #include "skl_watermark.h"
@@ -2241,7 +2242,7 @@ skl_is_vblank_too_short(const struct intel_crtc_state *crtc_state,
                scaler_prefill_latency(crtc_state) +
                dsc_prefill_latency(crtc_state) +
                wm0_lines >
-               adjusted_mode->crtc_vtotal - adjusted_mode->crtc_vblank_start;
+               intel_crtc_vblank_length(crtc_state);
 }
 
 static int skl_max_wm0_lines(const struct intel_crtc_state *crtc_state)