i965: fix export of GEM handles
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>
Sat, 2 May 2020 13:59:19 +0000 (16:59 +0300)
committerMarge Bot <eric+marge@anholt.net>
Thu, 4 Jun 2020 07:31:38 +0000 (07:31 +0000)
commit57e4d0aa1c16d3be36ccee4065c55901cb6fad43
tree2d9b7a31ada39f4d37e42652c091a9ab70b6bee7
parentaba3aed96e4394a213e188f2f71ef045803a27c5
i965: fix export of GEM handles

We reuse DRM file descriptors internally. Therefore when we export a
GEM handle we must do so in the file descriptor used externally.

v2: Fix dmabuf leak
    Fix GEM handle leaks by tracking exported handles

v3: Check os_same_file_description error (Michel)
    Don't create multiple exports for a given GEM table

v4: Add WARN_ONCE (Ken)

v5: Remove blank line (Ian)
    Remove unused field (Ian)

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2882
Fixes: 4094558e8643 ("i965: share buffer managers across screens")
Tested-by: Eric Engestrom <eric@engestrom.ch>
Tested-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4861>
src/mesa/drivers/dri/i965/brw_bufmgr.c
src/mesa/drivers/dri/i965/brw_bufmgr.h
src/mesa/drivers/dri/i965/intel_batchbuffer.c
src/mesa/drivers/dri/i965/intel_screen.c