libdrm atomic_add_unless() may reverse meaning of return value

Francois Tigeot ftigeot at wolfpond.org
Tue Apr 11 09:02:46 PDT 2017


On Mon, Mar 06, 2017 at 12:49:57AM -0800, David Shao wrote:
> For those who have frustrating glitches with applications
> such as glxgears on Intel integrated graphics, the
> following libdrm bug report may be of interest.
> 
> https://bugs.freedesktop.org/show_bug.cgi?id=100077
> "libdrm atomic_add_unless() may reverse return value meaning"
> 
> A one character patch allows glxgears to run on
> DragonFly using a hacked version of pkgsrc on an
> Intel IvyBridge integrated graphics machine.
> 
> --- xf86atomic.h.orig    2015-09-22 04:34:51.000000000 +0000
> +++ xf86atomic.h
> @@ -111,7 +111,7 @@ static inline int atomic_add_unless(atom
>      c = atomic_read(v);
>      while (c != unless && (old = atomic_cmpxchg(v, c, c + add)) != c)
>          c = old;
> -    return c == unless;
> +    return c != unless;
>  }

For what it's worth, an almost identical issue was fixed in the kernel version
of atomic_add_unless() by Yellow Rabbit back in 2015:
http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/f06b35bad17aecf317fc479c2289d2227795fe47

Now, I haven't heard reports of graphics glitches on i915 hardware which
could have been caused by this particular function.
Glxgears has also been operating perfectly fine on all the Intel GPU boxes
I had the chance to test it on.

I wonder what code paths common Linux distros use here; it could be useful
to do the same thing they do and just remove the broken function.

Thanks for the heads up though, I'll cook up a local dports patch.

-- 
Francois Tigeot


More information about the Users mailing list