From: Rob Clark Date: Fri, 24 Mar 2023 22:00:13 +0000 (-0700) Subject: drm/msm: Avoid rounding down to zero jiffies X-Git-Tag: v6.6.17~3937^2~4^2~243 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4969bccd5f4e9d59e9aca7e873834be9519be013;p=platform%2Fkernel%2Flinux-rpi.git drm/msm: Avoid rounding down to zero jiffies If userspace asked for a timeout greater than zero, but less than a jiffy, they clearly weren't planning on spinning. So it is better to round up to one. This fixes an issue with supertuxkart that was (for some reason) spinning on a gl sync with 1ms timeout. CPU time for a demo lap drops from: 15.83user 20.98system 0:47.46elapsed 77%CPU drops to: 8.84user 2.30system 0:46.67elapsed 23%CPU Signed-off-by: Rob Clark Reviewed-by: Dmitry Baryshkov Patchwork: https://patchwork.freedesktop.org/patch/528725/ Link: https://lore.kernel.org/r/20230324220013.191795-1-robdclark@gmail.com Signed-off-by: Dmitry Baryshkov --- diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h index 9f0c184..7936aa6 100644 --- a/drivers/gpu/drm/msm/msm_drv.h +++ b/drivers/gpu/drm/msm/msm_drv.h @@ -548,7 +548,7 @@ static inline unsigned long timeout_to_jiffies(const ktime_t *timeout) remaining_jiffies = ktime_divns(rem, NSEC_PER_SEC / HZ); } - return clamp(remaining_jiffies, 0LL, (s64)INT_MAX); + return clamp(remaining_jiffies, 1LL, (s64)INT_MAX); } /* Driver helpers */