[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <158538232569.25292.15795048542441478192@build.alporthouse.com>
Date: Sat, 28 Mar 2020 07:58:45 +0000
From: Chris Wilson <chris@...is-wilson.co.uk>
To: "Jason A. Donenfeld" <Jason@...c4.com>,
dri-devel@...ts.freedesktop.org, intel-gfx@...ts.freedesktop.org,
linux-kernel@...r.kernel.org
Cc: "Jason A. Donenfeld" <Jason@...c4.com>
Subject: Re: [PATCH] drm/i915: check to see if the FPU is available before using it
Quoting Jason A. Donenfeld (2020-03-28 00:04:22)
> It's not safe to just grab the FPU willy nilly without first checking to
> see if it's available. This patch adds the usual call to may_use_simd()
> and falls back to boring memcpy if it's not available.
These instructions do not use the fpu, nor are these registers aliased
over the fpu stack. This description and the may_use_simd() do not
look like they express the right granularity as to which simd state are
included
> Signed-off-by: Jason A. Donenfeld <Jason@...c4.com>
> ---
> drivers/gpu/drm/i915/i915_memcpy.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/i915_memcpy.c b/drivers/gpu/drm/i915/i915_memcpy.c
> index fdd550405fd3..7c0e022586bc 100644
> --- a/drivers/gpu/drm/i915/i915_memcpy.c
> +++ b/drivers/gpu/drm/i915/i915_memcpy.c
> @@ -24,6 +24,7 @@
>
> #include <linux/kernel.h>
> #include <asm/fpu/api.h>
> +#include <asm/simd.h>
>
> #include "i915_memcpy.h"
>
> @@ -38,6 +39,12 @@ static DEFINE_STATIC_KEY_FALSE(has_movntdqa);
> #ifdef CONFIG_AS_MOVNTDQA
> static void __memcpy_ntdqa(void *dst, const void *src, unsigned long len)
> {
> + if (unlikely(!may_use_simd())) {
> + memcpy(dst, src, len);
> + return;
Look at caller, return the error and let them decide if they can avoid
the read from WC, which quite often they can. And no, this is not done
from interrupt context, we would be crucified if we did.
-Chris
Powered by blists - more mailing lists