lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 2 Dec 2014 16:35:06 +0000
From:	Chris Wilson <chris@...is-wilson.co.uk>
To:	Daniel Vetter <daniel.vetter@...ll.ch>
Cc:	Intel Graphics Development <intel-gfx@...ts.freedesktop.org>,
	LKML <linux-kernel@...r.kernel.org>,
	John Stultz <john.stultz@...aro.org>,
	Daniel Vetter <daniel.vetter@...el.com>,
	Thomas Gleixner <tglx@...utronix.de>
Subject: Re: [Intel-gfx] [PATCH] drm/i915: compute wait_ioctl timeout
 correctly

On Tue, Dec 02, 2014 at 04:36:22PM +0100, Daniel Vetter wrote:
> We've lost the +1 required for correct timeouts in
> 
> commit 5ed0bdf21a85d78e04f89f15ccf227562177cbd9
> Author: Thomas Gleixner <tglx@...utronix.de>
> Date:   Wed Jul 16 21:05:06 2014 +0000
> 
>     drm: i915: Use nsec based interfaces
> 
>     Use ktime_get_raw_ns() and get rid of the back and forth timespec
>     conversions.
> 
>     Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
>     Acked-by: Daniel Vetter <daniel.vetter@...ll.ch>
>     Signed-off-by: John Stultz <john.stultz@...aro.org>
> 
> So fix this up by reinstating our handrolled _timeout function. While
> at it bother with handling MAX_JIFFIES.
> 
> v2: Convert to usecs (we don't care about the accuracy anyway) first
> to avoid overflow issues Dave Gordon spotted.
> 
> v3: Drop the explicit MAX_JIFFY_OFFSET check, usecs_to_jiffies should
> take care of that already. It might be a bit too enthusiastic about it
> though.
> 
> Cc: Dave Gordon <david.s.gordon@...el.com>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=82749
> Cc: Thomas Gleixner <tglx@...utronix.de>
> Cc: John Stultz <john.stultz@...aro.org>
> Signed-off-by: Daniel Vetter <daniel.vetter@...el.com>
> ---
>  drivers/gpu/drm/i915/i915_drv.h | 8 ++++++++
>  drivers/gpu/drm/i915/i915_gem.c | 3 ++-
>  2 files changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index 049482f5d9ac..4ea14a8c31f7 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -3097,6 +3097,14 @@ static inline unsigned long msecs_to_jiffies_timeout(const unsigned int m)
>  	return min_t(unsigned long, MAX_JIFFY_OFFSET, j + 1);
>  }
>  
> +static inline unsigned long nsecs_to_jiffies_timeout(const u64 m)
> +{
> +	u64 usecs = div_u64(m + 999, 1000);
> +	unsigned long j = usecs_to_jiffies(usecs);
> +
> +	return min_t(unsigned long, MAX_JIFFY_OFFSET, j + 1);

Or more concisely and review friendly:

static inline unsigned long nsecs_to_jiffies_timeout(const u64 n)
{
	return min_t(u64, MAX_JIFFY_OFFSET, nsecs_to_jiffies64(n) + 1);
}
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ