libdrm atomic_add_unless may reverse meaning
Jan Beich
jbeich at freebsd.org
Mon Mar 6 22:53:41 UTC 2017
David Shao <davshao at gmail.com> writes:
> 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;
> }
>
> #endif
glxgears works fine here on drm-next (i915kms, Skylake, SNA) but the
patch in question breaks it. Perhaps, DragonFly semantics differ.
$ glxgears
drm_intel_gem_bo_unreference(): atomic_add_unless(1, -1, 1)
drm_intel_gem_bo_unreference(): atomic_add_unless(2, -1, 1)
Running synchronized to the vertical refresh. The framerate should be
approximately the same as the monitor refresh rate.
drm_intel_gem_bo_unreference(): atomic_add_unless(2, -1, 1)
drm_intel_gem_bo_unreference(): atomic_add_unless(2, -1, 1)
Assertion failed: (atomic_read(&bo_gem->refcount) > 0), function drm_intel_gem_bo_unreference, file intel_bufmgr_gem.c, line 1436.
(lldb) bt
* thread #1, stop reason = signal SIGABRT
* frame #0: libc.so.7`thr_kill at thr_kill.S:3
frame #1: libc.so.7`__raise(s=6) at raise.c:52
frame #2: libc.so.7`abort at abort.c:65
frame #3: libc.so.7`__assert(func=<unavailable>, file=<unavailable>, line=<unavailable>, failedexpr=<unavailable>) at assert.c:51
frame #4: libdrm_intel.so.1`drm_intel_gem_bo_unreference(bo=0x000000080549dd80) at intel_bufmgr_gem.c:1436
frame #5: libdrm_intel.so.1`drm_intel_bo_unreference(bo=0x000000080549dd80) at intel_bufmgr.c:99
frame #6: 0x0000000805aa9ca1 i965_dri.so`intel_miptree_release + 81
frame #7: 0x0000000805aa7b9d i965_dri.so`intel_alloc_private_renderbuffer_storage + 141
frame #8: 0x000000080578dfbf i965_dri.so`_mesa_resize_framebuffer + 79
frame #9: 0x0000000805a70fa3 i965_dri.so`intel_update_renderbuffers + 1507
frame #10: 0x0000000805a708c6 i965_dri.so`intel_prepare_render + 54
frame #11: 0x0000000805a67ba9 i965_dri.so`brw_clear + 153
frame #12: 0x000000000040366e glxgears`draw + 14
frame #13: 0x00000000004027fd glxgears`main + 2909
frame #14: glxgears`_start(ap=<unavailable>, cleanup=<unavailable>) at crt1.c:72
(lldb) f 4
frame #4: libdrm_intel.so.1`drm_intel_gem_bo_unreference(bo=0x000000080549dd80) at intel_bufmgr_gem.c:1436
1433 {
1434 drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *) bo;
1435
-> 1436 assert(atomic_read(&bo_gem->refcount) > 0);
1437
1438 if (atomic_add_unless(&bo_gem->refcount, -1, 1)) {
1439 drm_intel_bufmgr_gem *bufmgr_gem =
More information about the freebsd-x11
mailing list