drm/intel
Rafał Sapała cf40cf05a4 intel: Serialize drmPrimeFDToHandle with struct_mutex
It is possible to hit a race condition in create_from_prime, when trying
to import a BO that's currently being freed. In case of prime sharing
we'll succesfully get a handle, but fail on get_tiling call, potentially
confusing the caller (and requiring different locking scheme than with
sharing using flink). Wrap fd_to_handle with struct_mutex to force
a more consistent behaviour between prime/flink, convert fprintf to DBG
when handling errors.

(From Chris:
  The race is that the kernel returns us the same file-private handle as
  the first thread, but that first thread is about to call gem_close
  (thereby removing the handle from the file completely) and does so
  between us acquiring the handle and taking the mutex. If we take
  the mutex, then we acquire the refcnt on the bo prior to the first
  thread completing its unref (and so preventing the early close). Or we
  acquire the handle after the earlier close, in which case we are the new
  owner.
)

Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Testcase: igt/drm_import_export/import-close-race-prime
Signed-off-by: Rafał Sapała <rafal.a.sapala@intel.com>
Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
2015-08-21 14:43:23 +01:00
..
tests intel-decode: Fix gen6 HIER_DEPTH_BUFFER decoding 2013-04-04 09:59:20 +02:00
.gitignore intel: Add a regression test program for intel_decode.c. 2012-01-04 14:49:44 -08:00
Android.mk android: remove explicit include to libpciaccess 2015-03-26 20:37:10 +00:00
Makefile.am configure: request/set the compiler in C99 mode 2015-04-28 11:20:52 +01:00
Makefile.sources libdrm, freedreno, intel, nouveau, radeon: add Makefile.sources 2014-09-01 16:06:01 +01:00
intel-symbol-check intel: add symbols test 2015-04-28 11:19:15 +01:00
intel_aub.h intel/aub: Sync the AUB defines with mesa's 2013-06-10 17:51:17 +01:00
intel_bufmgr.c drm: remove drm_public macro 2015-04-28 11:19:15 +01:00
intel_bufmgr.h intel: wrap intel_bufmgr.h C code for C++ compilation/linking 2015-08-10 11:26:16 +03:00
intel_bufmgr_fake.c drm: use c99 __func__ over __FUNCTION__ 2015-04-28 11:21:02 +01:00
intel_bufmgr_gem.c intel: Serialize drmPrimeFDToHandle with struct_mutex 2015-08-21 14:43:23 +01:00
intel_bufmgr_priv.h intel: Add support for userptr objects 2014-09-17 12:15:57 +01:00
intel_chipset.h intel: Add the Broxton PCI IDs 2015-05-18 16:24:21 +01:00
intel_debug.h intel: shared header for shader debugging 2011-08-01 14:44:58 -07:00
intel_decode.c drm: remove drm_public macro 2015-04-28 11:19:15 +01:00
libdrm_intel.pc.in intel: Update package name and description in libdrm_intel.pc 2013-08-30 12:10:50 -04:00
mm.c drm: rename libdrm{,_macros}.h 2015-04-28 11:19:15 +01:00
mm.h drm: rename libdrm{,_macros}.h 2015-04-28 11:19:15 +01:00
test_decode.c Consistently check the fd value 2015-07-16 16:41:53 +01:00