Skip to content

Commit 669c285

Browse files
committed
drm/msm: Avoid rounding up to one jiffy
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: 4969bcc ("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/
1 parent ef24989 commit 669c285

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

drivers/gpu/drm/msm/msm_drv.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -537,15 +537,12 @@ static inline int align_pitch(int width, int bpp)
537537
static inline unsigned long timeout_to_jiffies(const ktime_t *timeout)
538538
{
539539
ktime_t now = ktime_get();
540-
s64 remaining_jiffies;
541540

542-
if (ktime_compare(*timeout, now) < 0) {
543-
remaining_jiffies = 0;
544-
} else {
545-
ktime_t rem = ktime_sub(*timeout, now);
546-
remaining_jiffies = ktime_divns(rem, NSEC_PER_SEC / HZ);
547-
}
541+
if (ktime_compare(*timeout, now) <= 0)
542+
return 0;
548543

544+
ktime_t rem = ktime_sub(*timeout, now);
545+
s64 remaining_jiffies = ktime_divns(rem, NSEC_PER_SEC / HZ);
549546
return clamp(remaining_jiffies, 1LL, (s64)INT_MAX);
550547
}
551548

0 commit comments

Comments
 (0)