linux/drivers/gpu/drm
Chris Wilson f6cd7daecf drm: Release driver references to handle before making it available again
When userspace closes a handle, we remove it from the file->object_idr
and then tell the driver to drop its references to that file/handle.
However, as the file/handle is already available again for reuse, it may
be reallocated back to userspace and active on a new object before the
driver has had a chance to drop the old file/handle references.

Whilst calling back into the driver, we have to drop the
file->table_lock spinlock and so to prevent reusing the closed handle we
mark that handle as stale in the idr, perform the callback and then
remove the handle. We set the stale handle to point to the NULL object,
then any idr_find() whilst the driver is removing the handle will return
NULL, just as if the handle is already removed from idr.

Note: This will be used to have a direct handle -> vma lookup table,
instead of first a handle -> obj lookup, and then an (obj, vm) -> vma
lookup.

v2: Use NULL rather than an ERR_PTR to avoid having to adjust callers.
idr_alloc() tracks existing handles using an internal bitmap, so we are
free to use the NULL object as our stale identifier.
v3: Needed to update the return value check after changing from using
the stale error pointer to NULL.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: dri-devel@lists.freedesktop.org
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel.vetter@intel.com>
Cc: Rob Clark <robdclark@gmail.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Thierry Reding <treding@nvidia.com>
[danvet: Add note about the use-case.]
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1460721308-32405-1-git-send-email-chris@chris-wilson.co.uk
2016-04-15 14:39:18 +02:00
..
amd Merge tag 'topic/drm-misc-2016-04-01' of git://anongit.freedesktop.org/drm-intel into drm-next 2016-04-06 09:39:01 +10:00
arm drm: Add support for ARM's HDLCD controller. 2016-02-10 13:44:16 +00:00
armada
ast Merge tag 'topic/drm-misc-2016-04-01' of git://anongit.freedesktop.org/drm-intel into drm-next 2016-04-06 09:39:01 +10:00
atmel-hlcdc drm/atmel: Fixup drm_connector_/unplug/unregister/_all 2016-03-29 14:21:12 +02:00
bochs drm/bochs: Drop fake gamma support 2016-04-12 13:14:08 +02:00
bridge Merge branch 'drm-next-analogix-dp-v2' of github.com:yakir-Yang/linux into drm-next 2016-04-06 09:57:33 +10:00
cirrus Merge tag 'topic/drm-misc-2016-04-01' of git://anongit.freedesktop.org/drm-intel into drm-next 2016-04-06 09:39:01 +10:00
etnaviv Merge branch 'drm-next' of git://people.freedesktop.org/~airlied/linux 2016-03-21 13:48:00 -07:00
exynos drm: bridge: analogix/dp: fix some obvious code style 2016-04-05 10:13:01 +08:00
fsl-dcu drm/fsl-dcu: removed optional dummy crtc mode_fixup function. 2016-03-04 18:16:45 +01:00
gma500 drm/gma: removed optional dummy crtc mode_fixup function. 2016-03-04 17:58:34 +01:00
i2c Merge drm-fixes into drm-next. 2016-03-14 09:46:02 +10:00
i810
i915 drm/i915/dp/mst: Add source port info to debugfs output 2016-04-15 14:37:51 +02:00
imx Merge drm-fixes into drm-next. 2016-03-14 09:46:02 +10:00
mga
mgag200 vgacon: dummy implementation for vgacon_text_force 2016-03-30 17:37:57 +02:00
msm drm/msm: fix typo in the !COMMON_CLK case 2016-03-23 18:15:49 -04:00
nouveau Merge tag 'topic/drm-misc-2016-04-01' of git://anongit.freedesktop.org/drm-intel into drm-next 2016-04-06 09:39:01 +10:00
omapdrm Merge branch 'drm-next' of git://people.freedesktop.org/~airlied/linux 2016-03-25 08:48:31 -07:00
panel drm/panel: Changes for v4.6-rc1 2016-03-17 08:09:44 +10:00
qxl Merge tag 'topic/drm-misc-2016-04-01' of git://anongit.freedesktop.org/drm-intel into drm-next 2016-04-06 09:39:01 +10:00
r128
radeon Merge tag 'topic/drm-misc-2016-04-01' of git://anongit.freedesktop.org/drm-intel into drm-next 2016-04-06 09:39:01 +10:00
rcar-du drm: Rename drm_connector_unplug_all() to drm_connector_unregister_all() 2016-03-29 10:14:15 +02:00
rockchip Merge branch 'drm-next-analogix-dp-v2' of github.com:yakir-Yang/linux into drm-next 2016-04-06 09:57:33 +10:00
savage
shmobile drm/shmobile: removed optional dummy crtc mode_fixup function. 2016-03-04 17:59:44 +01:00
sis
sti Merge branch 'drm-next' of git://people.freedesktop.org/~airlied/linux 2016-03-21 13:48:00 -07:00
tdfx
tegra Merge branch 'drm-next' of git://people.freedesktop.org/~airlied/linux 2016-03-21 13:48:00 -07:00
tilcdc drm/tilcdc: Use devm_kzalloc() and devm_kcalloc() for private data 2016-02-25 16:39:47 +02:00
ttm drm/ttm: Remove TTM_HAS_AGP 2016-03-30 17:20:43 +02:00
udl Merge tag 'topic/drm-misc-2016-04-01' of git://anongit.freedesktop.org/drm-intel into drm-next 2016-04-06 09:39:01 +10:00
vc4 Merge branch 'drm-next' of git://people.freedesktop.org/~airlied/linux 2016-03-21 13:48:00 -07:00
vgem
via mm/gup: Switch all callers of get_user_pages() to not pass tsk/mm 2016-02-16 10:11:12 +01:00
virtio drm/virtio: Drop dummy gamma table support 2016-04-12 13:14:29 +02:00
vmwgfx Merge tag 'topic/drm-misc-2016-04-01' of git://anongit.freedesktop.org/drm-intel into drm-next 2016-04-06 09:39:01 +10:00
ati_pcigart.c
drm_agpsupport.c
drm_atomic_helper.c Merge tag 'topic/drm-misc-2016-04-01' of git://anongit.freedesktop.org/drm-intel into drm-next 2016-04-06 09:39:01 +10:00
drm_atomic.c Merge tag 'topic/drm-misc-2016-03-22' of git://anongit.freedesktop.org/drm-intel into drm-next 2016-03-24 08:41:59 +10:00
drm_auth.c
drm_bridge.c drm: bridge: Make (pre/post) enable/disable callbacks optional 2016-03-29 08:34:05 +02:00
drm_bufs.c
drm_cache.c
drm_context.c
drm_crtc_helper.c drm/crtc_helper: Reset empty plane state in drm_helper_crtc_mode_set_base() 2016-04-14 08:18:15 +02:00
drm_crtc_internal.h
drm_crtc.c drm/core: Fix ordering in drm_mode_config_cleanup. 2016-04-12 12:43:26 +02:00
drm_debugfs.c
drm_dma.c
drm_dp_aux_dev.c drm/dp: Add a drm_aux-dev module for reading/writing dpcd registers. 2016-02-12 14:22:40 +01:00
drm_dp_helper.c drm/dp: move hw_mutex up the call stack 2016-04-01 13:17:36 +10:00
drm_dp_mst_topology.c drm/dp/mst: Enhance DP MST debugfs output 2016-04-15 14:37:45 +02:00
drm_drv.c
drm_edid_load.c drm/edid: convert to use match_string() helper 2016-03-17 15:09:34 -07:00
drm_edid.c drm/edid: Add drm_edid_get_monitor_name() 2016-04-15 14:37:39 +02:00
drm_encoder_slave.c drm: fixes when i2c encoder slave mode_fixup is null. 2016-02-10 15:14:49 +01:00
drm_fb_cma_helper.c
drm_fb_helper.c drm/fb_helper: Use add_one_connector in add_all_connectors. 2016-02-15 14:56:46 +01:00
drm_flip_work.c
drm_fops.c drm: Nuke vblank event file cleanup code 2016-02-08 09:55:47 +01:00
drm_gem_cma_helper.c dma, mm/pat: Rename dma_*_writecombine() to dma_*_wc() 2016-03-09 14:57:51 +01:00
drm_gem.c drm: Release driver references to handle before making it available again 2016-04-15 14:39:18 +02:00
drm_global.c
drm_hashtab.c
drm_info.c
drm_internal.h
drm_ioc32.c
drm_ioctl.c
drm_irq.c Merge tag 'topic/drm-misc-2016-04-01' of git://anongit.freedesktop.org/drm-intel into drm-next 2016-04-06 09:39:01 +10:00
drm_kms_helper_common.c drm/dp: Add a drm_aux-dev module for reading/writing dpcd registers. 2016-02-12 14:22:40 +01:00
drm_legacy.h
drm_lock.c
drm_memory.c
drm_mipi_dsi.c drm/dsi: Get DSI host by DT device node 2016-03-02 17:02:54 +01:00
drm_mm.c
drm_modes.c drm: modes: add missing [drm] to message printing 2016-02-09 16:34:44 +01:00
drm_modeset_lock.c
drm_of.c drm: add drm_of_encoder_active_endpoint helpers 2016-02-10 14:19:21 +01:00
drm_panel.c
drm_pci.c
drm_plane_helper.c
drm_platform.c
drm_prime.c drm: prime: Honour O_RDWR during prime-handle-to-fd 2016-02-09 09:25:12 +01:00
drm_probe_helper.c
drm_rect.c
drm_scatter.c
drm_sysfs.c drm/sysfs: Nuke TV/DVI property files 2016-03-30 17:21:36 +02:00
drm_trace_points.c
drm_trace.h
drm_vm.c
drm_vma_manager.c
Kconfig Merge branch 'drm-next-4.6' of git://people.freedesktop.org/~agd5f/linux into drm-next 2016-02-19 11:13:01 +10:00
Makefile Merge tag 'topic/drm-misc-2016-02-18' of git://anongit.freedesktop.org/drm-intel into drm-next 2016-02-19 10:57:44 +10:00