[Mesa-dev] [PATCH] i965: don't require 64bit cmpxchg

Matt Turner mattst88 at gmail.com
Sun Mar 5 20:17:38 UTC 2017


On Sun, Mar 5, 2017 at 11:07 AM, Grazvydas Ignotas <notasas at gmail.com> wrote:
> There are still some distributions trying to support unfortunate people
> with old or exotic CPUs that don't have 64bit atomic operations. The
> only thing preventing compile of the Intel driver for them seems to be
> initialization of a debug variable.
>
> It is very unlikely to be set simultaneously by multiple threads that
> somehow manage to change the environment variable without affecting each
> other, so just provide a thread-unsafe fallback.
>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=93089
> Signed-off-by: Grazvydas Ignotas <notasas at gmail.com>
> ---
> no commit access
>
>  src/intel/common/gen_debug.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/src/intel/common/gen_debug.c b/src/intel/common/gen_debug.c
> index 858f04d..b206e8f 100644
> --- a/src/intel/common/gen_debug.c
> +++ b/src/intel/common/gen_debug.c
> @@ -105,5 +105,10 @@ void
>  brw_process_intel_debug_variable(void)
>  {
>     uint64_t intel_debug = parse_debug_string(getenv("INTEL_DEBUG"), debug_control);
> +#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8
>     (void) p_atomic_cmpxchg(&INTEL_DEBUG, 0, intel_debug);
> +#else
> +   if (!INTEL_DEBUG)
> +      INTEL_DEBUG = intel_debug;
> +#endif

I think I was probably overzealous in trying to quash warnings I saw
from helgrind when writing shader-db's threaded compiler. I definitely
know that the cute and typeless p_atomic* API was a bad idea...

Could you send a patch that makes use of the C11 call_once() function,
provided by include/c11/*?

Thanks for working on this.


More information about the mesa-dev mailing list