]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-6.6/drm-fix-drm_fixp2int_round-making-it-add-0.5.patch
Fixes for 6.6
[thirdparty/kernel/stable-queue.git] / queue-6.6 / drm-fix-drm_fixp2int_round-making-it-add-0.5.patch
1 From e3a1169aed4af60c2871cd9cd7ca65719002a597 Mon Sep 17 00:00:00 2001
2 From: Sasha Levin <sashal@kernel.org>
3 Date: Sat, 16 Mar 2024 13:25:20 -0300
4 Subject: drm: Fix drm_fixp2int_round() making it add 0.5
5
6 From: Arthur Grillo <arthurgrillo@riseup.net>
7
8 [ Upstream commit 807f96abdf14c80f534c78f2d854c2590963345c ]
9
10 As well noted by Pekka[1], the rounding of drm_fixp2int_round is wrong.
11 To round a number, you need to add 0.5 to the number and floor that,
12 drm_fixp2int_round() is adding 0.0000076. Make it add 0.5.
13
14 [1]: https://lore.kernel.org/all/20240301135327.22efe0dd.pekka.paalanen@collabora.com/
15
16 Fixes: 8b25320887d7 ("drm: Add fixed-point helper to get rounded integer values")
17 Suggested-by: Pekka Paalanen <pekka.paalanen@collabora.com>
18 Reviewed-by: Harry Wentland <harry.wentland@amd.com>
19 Reviewed-by: Melissa Wen <mwen@igalia.com>
20 Signed-off-by: Arthur Grillo <arthurgrillo@riseup.net>
21 Signed-off-by: Melissa Wen <melissa.srw@gmail.com>
22 Link: https://patchwork.freedesktop.org/patch/msgid/20240316-drm_fixed-v2-1-c1bc2665b5ed@riseup.net
23 Signed-off-by: Sasha Levin <sashal@kernel.org>
24 ---
25 include/drm/drm_fixed.h | 3 +--
26 1 file changed, 1 insertion(+), 2 deletions(-)
27
28 diff --git a/include/drm/drm_fixed.h b/include/drm/drm_fixed.h
29 index 0c9f917a4d4be..81572d32db0c2 100644
30 --- a/include/drm/drm_fixed.h
31 +++ b/include/drm/drm_fixed.h
32 @@ -71,7 +71,6 @@ static inline u32 dfixed_div(fixed20_12 A, fixed20_12 B)
33 }
34
35 #define DRM_FIXED_POINT 32
36 -#define DRM_FIXED_POINT_HALF 16
37 #define DRM_FIXED_ONE (1ULL << DRM_FIXED_POINT)
38 #define DRM_FIXED_DECIMAL_MASK (DRM_FIXED_ONE - 1)
39 #define DRM_FIXED_DIGITS_MASK (~DRM_FIXED_DECIMAL_MASK)
40 @@ -90,7 +89,7 @@ static inline int drm_fixp2int(s64 a)
41
42 static inline int drm_fixp2int_round(s64 a)
43 {
44 - return drm_fixp2int(a + (1 << (DRM_FIXED_POINT_HALF - 1)));
45 + return drm_fixp2int(a + DRM_FIXED_ONE / 2);
46 }
47
48 static inline int drm_fixp2int_ceil(s64 a)
49 --
50 2.43.0
51