drm/i915: Use min() instead of hand rolling it
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Tue, 4 Apr 2023 17:54:31 +0000 (20:54 +0300)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Thu, 13 Apr 2023 18:02:49 +0000 (21:02 +0300)
Most places in the vblank code use min() to clamp scanline
counters below vtotal. But we missed one in the gen3/4
pixel counter based codepath.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230404175431.23064-3-ville.syrjala@linux.intel.com
Reviewed-by: Mitul Golani <mitulkumar.ajitkumar.golani@intel.com>
drivers/gpu/drm/i915/display/intel_vblank.c

index 2e4f7de199d603a4d5fc3acbf3ddd3472d8be2ca..f5659ebd08eb291eeb705383bd8d115a8acfd623 100644 (file)
@@ -340,8 +340,7 @@ static bool i915_get_crtc_scanoutpos(struct drm_crtc *_crtc,
                 * matches how the scanline counter based position works since
                 * the scanline counter doesn't count the two half lines.
                 */
-               if (position >= vtotal)
-                       position = vtotal - 1;
+               position = min(position, vtotal - 1);
 
                /*
                 * Start of vblank interrupt is triggered at start of hsync,