[Intel-gfx] [PATCH] drm/i915: Handle full s64 precision for wait-ioctl
Joonas Lahtinen
joonas.lahtinen at linux.intel.com
Fri Aug 11 07:18:04 UTC 2017
On la, 2017-08-05 at 20:47 +0100, Chris Wilson wrote:
> Quoting Chris Wilson (2017-08-05 20:19:24)
<SNIP>
> > +++ b/drivers/gpu/drm/i915/i915_drv.h
> > @@ -4144,6 +4144,12 @@ static inline unsigned long msecs_to_jiffies_timeout(const unsigned int m)
> >
> > static inline unsigned long nsecs_to_jiffies_timeout(const u64 n)
> > {
> > +#if NSEC_PER_SEC % HZ
> > + /* nsecs_to_jiffies64() does not guard against overflow */
> > + if (n >= (u64)MAX_JIFFY_OFFSET * NSEC_PER_SEC / HZ)
> > + return MAX_JIFFY_OFFSET;
>
> This still overflows, we need n / NSEC_PER_SEC >= MAX_JIFFY_OFFSET / HZ
> as MAX_JIFFY_OFFSET is ~LONG_MAX/2
>
> Hmm, so div_u64(n, NSEC_PER_SEC) >= MAX_JIFFY_OFFSET / HZ ?
This reflects the original test best.
Regards, Joonas
--
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
More information about the Intel-gfx
mailing list