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

2017-03-05 Thread Matt Turner
On Sun, Mar 5, 2017 at 1:23 PM, Grazvydas Ignotas  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.
>
> v2: use call_once() instead of unsafe code, as suggested by Matt Turner
>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=93089
> Signed-off-by: Grazvydas Ignotas 
> ---
> no commit access
>
>  src/intel/common/gen_debug.c | 14 +++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/src/intel/common/gen_debug.c b/src/intel/common/gen_debug.c
> index 858f04d..96efdab 100644
> --- a/src/intel/common/gen_debug.c
> +++ b/src/intel/common/gen_debug.c
> @@ -33,8 +33,8 @@
>
>  #include "common/gen_debug.h"
>  #include "util/macros.h"
> -#include "util/u_atomic.h" /* for p_atomic_cmpxchg */
>  #include "util/debug.h"
> +#include "c11/threads.h"
>
>  uint64_t INTEL_DEBUG = 0;
>
> @@ -101,9 +101,17 @@ intel_debug_flag_for_shader_stage(gl_shader_stage stage)
> return flags[stage];
>  }
>
> +static void
> +brw_process_intel_debug_variable_once(void)
> +{
> +   INTEL_DEBUG = parse_debug_string(getenv("INTEL_DEBUG"), debug_control);
> +}
> +
>  void
>  brw_process_intel_debug_variable(void)
>  {
> -   uint64_t intel_debug = parse_debug_string(getenv("INTEL_DEBUG"), 
> debug_control);
> -   (void) p_atomic_cmpxchg(_DEBUG, 0, intel_debug);
> +   static once_flag process_intel_debug_variable_flag = ONCE_FLAG_INIT;
> +
> +   call_once(_intel_debug_variable_flag,
> + brw_process_intel_debug_variable_once);
>  }

Thank you. That looks great.

Reviewed-by: Matt Turner 

I'll commit it tomorrow morning, if there are no further comments.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


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

2017-03-05 Thread Grazvydas Ignotas
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.

v2: use call_once() instead of unsafe code, as suggested by Matt Turner

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=93089
Signed-off-by: Grazvydas Ignotas 
---
no commit access

 src/intel/common/gen_debug.c | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/intel/common/gen_debug.c b/src/intel/common/gen_debug.c
index 858f04d..96efdab 100644
--- a/src/intel/common/gen_debug.c
+++ b/src/intel/common/gen_debug.c
@@ -33,8 +33,8 @@
 
 #include "common/gen_debug.h"
 #include "util/macros.h"
-#include "util/u_atomic.h" /* for p_atomic_cmpxchg */
 #include "util/debug.h"
+#include "c11/threads.h"
 
 uint64_t INTEL_DEBUG = 0;
 
@@ -101,9 +101,17 @@ intel_debug_flag_for_shader_stage(gl_shader_stage stage)
return flags[stage];
 }
 
+static void
+brw_process_intel_debug_variable_once(void)
+{
+   INTEL_DEBUG = parse_debug_string(getenv("INTEL_DEBUG"), debug_control);
+}
+
 void
 brw_process_intel_debug_variable(void)
 {
-   uint64_t intel_debug = parse_debug_string(getenv("INTEL_DEBUG"), 
debug_control);
-   (void) p_atomic_cmpxchg(_DEBUG, 0, intel_debug);
+   static once_flag process_intel_debug_variable_flag = ONCE_FLAG_INIT;
+
+   call_once(_intel_debug_variable_flag,
+ brw_process_intel_debug_variable_once);
 }
-- 
2.7.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev