commit df043a729bc7098bd27663d4639951e1e8409369 Author: Fabrice Bellet Date: Sun Feb 28 23:55:57 2016 +0100 intel: use the same bufmgr when opening the same device Relocation when bo use a different bufmgr are not accepted in the intel drm driver. This happens when two GL contexts are created, one from cogl, and one from vaapi for example. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=71759 diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c index 0a4012b..cb463be 100644 --- a/intel/intel_bufmgr_gem.c +++ b/intel/intel_bufmgr_gem.c @@ -3268,13 +3268,24 @@ drm_intel_bufmgr_gem_set_aub_annotations(drm_intel_bo *bo, static pthread_mutex_t bufmgr_list_mutex = PTHREAD_MUTEX_INITIALIZER; static drmMMListHead bufmgr_list = { &bufmgr_list, &bufmgr_list }; +static int +compare_file_descriptor(int fd1, int fd2) { + struct stat stat1, stat2; + if (fstat (fd1, &stat1) < 0) + return -1; + if (fstat (fd2, &stat2) < 0) + return -1; + return (stat1.st_dev == stat2.st_dev) && (stat1.st_ino == stat2.st_ino); +} + static drm_intel_bufmgr_gem * drm_intel_bufmgr_gem_find(int fd) { drm_intel_bufmgr_gem *bufmgr_gem; DRMLISTFOREACHENTRY(bufmgr_gem, &bufmgr_list, managers) { - if (bufmgr_gem->fd == fd) { + if (bufmgr_gem->fd == fd || + compare_file_descriptor (bufmgr_gem->fd, fd)) { atomic_inc(&bufmgr_gem->refcount); return bufmgr_gem; }