]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/amd/display: fix math_mod() using arg1 instead of arg2
authorWenjing Liu <wenjing.liu@amd.com>
Thu, 26 Mar 2026 16:00:34 +0000 (12:00 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 17 Apr 2026 19:23:49 +0000 (15:23 -0400)
[Why]
math_mod() multiplied by arg1 instead of arg2, returning a wrong
result for any non-trivial modulo operation.

[How]
Replace arg1 with arg2 in the subtraction term to correctly
implement fmod(arg1, arg2).

Cc: Mario Limonciello <mario.limonciello@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
Reviewed-by: Dillon Varone <dillon.varone@amd.com>
Signed-off-by: Wenjing Liu <wenjing.liu@amd.com>
Signed-off-by: Aurabindo Pillai <aurabindo.pillai@amd.com>
Tested-by: Dan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_standalone_libraries/lib_float_math.c

index e17b5ceba4471e7517793b5faa58f17702d4c8fd..dc5bc649f3ac975e7a1b3268698f58b67fcfd88a 100644 (file)
@@ -23,7 +23,7 @@ double math_mod(const double arg1, const double arg2)
                return arg2;
        if (isNaN(arg2))
                return arg1;
-       return arg1 - arg1 * ((int)(arg1 / arg2));
+       return arg1 - arg2 * ((int)(arg1 / arg2));
 }
 
 double math_min2(const double arg1, const double arg2)