]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/i915: Make sure wm block/lines are non-decreasing
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Fri, 19 Sep 2025 19:30:00 +0000 (22:30 +0300)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Tue, 23 Sep 2025 15:12:46 +0000 (18:12 +0300)
The watermark algorithm sometimes produces results where higher
watermark levels have smaller blocks/lines watermarks than the lower
levels. That doesn't really make sense as the corresponding latencies
are supposed to be non-decreasing. It's unclear how the hardware
responds to such watermark values, so it seems better to avoid that
case and just make sure the values are always non-decreasing.

Here's an example how things change for such a case on a GLK NUC:
 [PLANE:70:cursor A]   level  wm0, wm1, wm2, wm3, wm4, wm5, wm6, wm7, twm, swm, stwm -> *wm0,*wm1,*wm2,*wm3,*wm4,*wm5,*wm6,*wm7,*twm, swm, stwm
 [PLANE:70:cursor A]   lines    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,    0 ->    4,   4,   4,   2,   2,   2,   2,   2,   0,   0,    0
 [PLANE:70:cursor A]  blocks    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,    0 ->   11,  11,  12,   7,   7,   7,   7,   7,  25,   0,    0
 [PLANE:70:cursor A] min_ddb    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,    0 ->   12,  12,  13,   8,   8,   8,   8,   8,  26,   0,    0
->
 [PLANE:70:cursor A]   level  wm0, wm1, wm2, wm3, wm4, wm5, wm6, wm7, twm, swm, stwm -> *wm0,*wm1,*wm2,*wm3,*wm4,*wm5,*wm6,*wm7,*twm, swm, stwm
 [PLANE:70:cursor A]   lines    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,    0 ->    4,   4,   4,   4,   4,   4,   4,   4,   0,   0,    0
 [PLANE:70:cursor A]  blocks    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,    0 ->   11,  11,  12,  12,  12,  12,  12,  12,  25,   0,    0
 [PLANE:70:cursor A] min_ddb    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,    0 ->   12,  12,  13,  13,  13,  13,  13,  13,  26,   0,    0

Whether this actually helps on any display blinking issues is unclear.

Reviewed-by: Luca Coelho <luciano.coelho@intel.com>
References: https://gitlab.freedesktop.org/drm/intel/-/issues/8683
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250919193000.17665-14-ville.syrjala@linux.intel.com
drivers/gpu/drm/i915/display/skl_watermark.c

index 9d58c28d3bdfa67d1619955a7eebc0504491031a..9eb28d9357571204e738f9b47d533501d345a121 100644 (file)
@@ -1878,18 +1878,21 @@ static void skl_compute_plane_wm(const struct intel_crtc_state *crtc_state,
                        } else {
                                blocks++;
                        }
-
-                       /*
-                        * Make sure result blocks for higher latency levels are
-                        * at least as high as level below the current level.
-                        * Assumption in DDB algorithm optimization for special
-                        * cases. Also covers Display WA #1125 for RC.
-                        */
-                       if (result_prev->blocks > blocks)
-                               blocks = result_prev->blocks;
                }
        }
 
+       /*
+        * Make sure result blocks for higher latency levels are
+        * at least as high as level below the current level.
+        * Assumption in DDB algorithm optimization for special
+        * cases. Also covers Display WA #1125 for RC.
+        *
+        * Let's always do this as the algorithm can give non
+        * monotonic results on any platform.
+        */
+       blocks = max_t(u32, blocks, result_prev->blocks);
+       lines = max_t(u32, lines, result_prev->lines);
+
        if (DISPLAY_VER(display) >= 11) {
                if (wp->y_tiled) {
                        int extra_lines;