Make the code a bit clearer by using a switch-case to check the tiling
mode in skl_compute_plane_wm(), because all the possible states and
the calculations they use are explicitly handled.

v2: - Remove useless comment (Gustavo)
    - Move the default case above linear as a fallthrough (Gustavo)

Signed-off-by: Luca Coelho <[email protected]>
---
 drivers/gpu/drm/i915/display/skl_watermark.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/skl_watermark.c 
b/drivers/gpu/drm/i915/display/skl_watermark.c
index dc00b5cd3ff7..a9d1bc432f75 100644
--- a/drivers/gpu/drm/i915/display/skl_watermark.c
+++ b/drivers/gpu/drm/i915/display/skl_watermark.c
@@ -1817,12 +1817,23 @@ static void skl_compute_plane_wm(const struct 
intel_crtc_state *crtc_state,
                                 latency,
                                 wp->plane_blocks_per_line);
 
-       if (wp->tiling == WM_TILING_Y_FAMILY) {
+       switch (wp->tiling) {
+       case WM_TILING_Y_FAMILY:
                selected_result = max_fixed16(method2, wp->y_tile_minimum);
-       } else {
+               break;
+
+       default:
+               MISSING_CASE(wp->tiling);
+               fallthrough;
+       case WM_TILING_LINEAR:
+       case WM_TILING_X_TILED:
+               /*
+                * Special case for unrealistically small horizontal
+                * total with plane downscaling.
+                */
                if ((wp->cpp * crtc_state->hw.pipe_mode.crtc_htotal /
                     wp->dbuf_block_size < 1) &&
-                    (wp->plane_bytes_per_line / wp->dbuf_block_size < 1)) {
+                   (wp->plane_bytes_per_line / wp->dbuf_block_size < 1)) {
                        selected_result = method2;
                } else if (latency >= wp->linetime_us) {
                        if (DISPLAY_VER(display) == 9)
@@ -1830,8 +1841,11 @@ static void skl_compute_plane_wm(const struct 
intel_crtc_state *crtc_state,
                        else
                                selected_result = method2;
                } else {
+                       /* everything else with linear/X-tiled uses method 1 */
                        selected_result = method1;
                }
+               break;
+
        }
 
        blocks = fixed16_to_u32_round_up(selected_result);
-- 
2.51.0

Reply via email to