]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm/msm: Avoid rounding up to one jiffy
authorRob Clark <robdclark@chromium.org>
Mon, 13 Jan 2025 15:48:41 +0000 (07:48 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 27 Feb 2025 12:34:17 +0000 (04:34 -0800)
[ Upstream commit 669c285620231786fffe9d87ab432e08a6ed922b ]

If userspace is trying to achieve a timeout of zero, let 'em have it.
Only round up if the timeout is greater than zero.

Fixes: 4969bccd5f4e ("drm/msm: Avoid rounding down to zero jiffies")
Signed-off-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Akhil P Oommen <quic_akhilpo@quicinc.com>
Patchwork: https://patchwork.freedesktop.org/patch/632264/
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/msm/msm_drv.h

index d8c9a1b192632d3e29ff125bd7bb2d0bb491275d..f15962cfb373c50b6d0db9358f9dbcef0f0e6986 100644 (file)
@@ -530,15 +530,12 @@ static inline int align_pitch(int width, int bpp)
 static inline unsigned long timeout_to_jiffies(const ktime_t *timeout)
 {
        ktime_t now = ktime_get();
-       s64 remaining_jiffies;
 
-       if (ktime_compare(*timeout, now) < 0) {
-               remaining_jiffies = 0;
-       } else {
-               ktime_t rem = ktime_sub(*timeout, now);
-               remaining_jiffies = ktime_divns(rem, NSEC_PER_SEC / HZ);
-       }
+       if (ktime_compare(*timeout, now) <= 0)
+               return 0;
 
+       ktime_t rem = ktime_sub(*timeout, now);
+       s64 remaining_jiffies = ktime_divns(rem, NSEC_PER_SEC / HZ);
        return clamp(remaining_jiffies, 1LL, (s64)INT_MAX);
 }