]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/amd/display: Fix unit test failure
authorSamson Tam <Samson.Tam@amd.com>
Tue, 7 Jan 2025 19:17:15 +0000 (14:17 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 25 Feb 2025 16:44:02 +0000 (11:44 -0500)
[Why]
Some of unit tests use large scaling ratio such that when we
 calculate optimal number of taps, max_taps is negative.
 Then in recent change, we changed max_taps to uint instead
 of int so now max_taps wraps and is positive.  This change
 changed the behaviour from returning back false to return
 true and breaks unit test check

[How]
Add check to prevent max_taps from wrapping and set to 0
 instead

Signed-off-by: Samson Tam <Samson.Tam@amd.com>
Reviewed-by: Alvin Lee <alvin.lee2@amd.com>
Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/sspl/dc_spl.c

index 047f05ab01810200ddb7f785cb0779661d2b3489..ad77cef57ac7bc1698ebb1e5910c8c00d5e91f11 100644 (file)
@@ -1026,12 +1026,18 @@ static bool spl_get_optimal_number_of_taps(
                        lb_config, &num_part_y, &num_part_c);
        /* MAX_V_TAPS = MIN (NUM_LINES - MAX(CEILING(V_RATIO,1)-2, 0), 8) */
        if (spl_fixpt_ceil(spl_scratch->scl_data.ratios.vert) > 2)
-               max_taps_y = num_part_y - (spl_fixpt_ceil(spl_scratch->scl_data.ratios.vert) - 2);
+               if ((spl_fixpt_ceil(spl_scratch->scl_data.ratios.vert) - 2) > num_part_y)
+                       max_taps_y = 0;
+               else
+                       max_taps_y = num_part_y - (spl_fixpt_ceil(spl_scratch->scl_data.ratios.vert) - 2);
        else
                max_taps_y = num_part_y;
 
        if (spl_fixpt_ceil(spl_scratch->scl_data.ratios.vert_c) > 2)
-               max_taps_c = num_part_c - (spl_fixpt_ceil(spl_scratch->scl_data.ratios.vert_c) - 2);
+               if ((spl_fixpt_ceil(spl_scratch->scl_data.ratios.vert_c) - 2) > num_part_c)
+                       max_taps_c = 0;
+               else
+                       max_taps_c = num_part_c - (spl_fixpt_ceil(spl_scratch->scl_data.ratios.vert_c) - 2);
        else
                max_taps_c = num_part_c;