linux/drivers/gpu/drm
Chris Wilson ad46cb533d drm/i915: Prevent recursive deadlock on releasing a busy userptr
During release of the GEM object we hold the struct_mutex. As the
object may be holding onto the last reference for the task->mm,
calling mmput() may trigger exit_mmap() which close the vma
which will call drm_gem_vm_close() and attempt to reacquire
the struct_mutex. In order to avoid that recursion, we have
to defer the mmput() until after we drop the struct_mutex,
i.e. we need to schedule a worker to do the clean up. A further issue
spotted by Tvrtko was caused when we took a GTT mmapping of a userptr
buffer object. In that case, we would never call mmput as the object
would be cyclically referenced by the GTT mmapping and not freed upon
process exit - keeping the entire process mm alive after the process
task was reaped. The fix employed is to replace the mm_users/mmput()
reference handling to mm_count/mmdrop() for the shared i915_mm_struct.

   INFO: task test_surfaces:1632 blocked for more than 120 seconds.
         Tainted: GF          O 3.14.5+ #1
   "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
   test_surfaces   D 0000000000000000     0  1632   1590 0x00000082
    ffff88014914baa8 0000000000000046 0000000000000000 ffff88014914a010
    0000000000012c40 0000000000012c40 ffff8800a0058210 ffff88014784b010
    ffff88014914a010 ffff880037b1c820 ffff8800a0058210 ffff880037b1c824
   Call Trace:
    [<ffffffff81582499>] schedule+0x29/0x70
    [<ffffffff815825fe>] schedule_preempt_disabled+0xe/0x10
    [<ffffffff81583b93>] __mutex_lock_slowpath+0x183/0x220
    [<ffffffff81583c53>] mutex_lock+0x23/0x40
    [<ffffffffa005c2a3>] drm_gem_vm_close+0x33/0x70 [drm]
    [<ffffffff8115a483>] remove_vma+0x33/0x70
    [<ffffffff8115a5dc>] exit_mmap+0x11c/0x170
    [<ffffffff8104d6eb>] mmput+0x6b/0x100
    [<ffffffffa00f44b9>] i915_gem_userptr_release+0x89/0xc0 [i915]
    [<ffffffffa00e6706>] i915_gem_free_object+0x126/0x250 [i915]
    [<ffffffffa005c06a>] drm_gem_object_free+0x2a/0x40 [drm]
    [<ffffffffa005cc32>] drm_gem_object_handle_unreference_unlocked+0xe2/0x120 [drm]
    [<ffffffffa005ccd4>] drm_gem_object_release_handle+0x64/0x90 [drm]
    [<ffffffff8127ffeb>] idr_for_each+0xab/0x100
    [<ffffffffa005cc70>] ?  drm_gem_object_handle_unreference_unlocked+0x120/0x120 [drm]
    [<ffffffff81583c46>] ? mutex_lock+0x16/0x40
    [<ffffffffa005c354>] drm_gem_release+0x24/0x40 [drm]
    [<ffffffffa005b82b>] drm_release+0x3fb/0x480 [drm]
    [<ffffffff8118d482>] __fput+0xb2/0x260
    [<ffffffff8118d6de>] ____fput+0xe/0x10
    [<ffffffff8106f27f>] task_work_run+0x8f/0xf0
    [<ffffffff81052228>] do_exit+0x1a8/0x480
    [<ffffffff81052551>] do_group_exit+0x51/0xc0
    [<ffffffff810525d7>] SyS_exit_group+0x17/0x20
    [<ffffffff8158e092>] system_call_fastpath+0x16/0x1b

v2: Incorporate feedback from Tvrtko and remove the unnessary mm
referencing when creating the i915_mm_struct and improve some of the
function names and comments.

Reported-by: Jacek Danecki <jacek.danecki@intel.com>
Test-case: igt/gem_userptr_blits/process-exit*
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Tested-by: "Gong, Zhipeng" <zhipeng.gong@intel.com>
Cc: Jacek Danecki <jacek.danecki@intel.com>
Cc: "Ursulin, Tvrtko" <tvrtko.ursulin@intel.com>
Reviewed-by: "Ursulin, Tvrtko" <tvrtko.ursulin@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: stable@vger.kernel.org # hold off until 3.17 ships for additional testing
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
2014-09-08 08:38:49 +03:00
..
armada Merge branch 'drm-next' of git://people.freedesktop.org/~airlied/linux 2014-08-07 17:36:12 -07:00
ast drm/ast: Add missing entry to dclk_table[] 2014-08-28 12:26:42 +10:00
bochs PCI: Remove DEFINE_PCI_DEVICE_TABLE macro use 2014-08-12 12:15:14 -06:00
bridge
cirrus PCI: Remove DEFINE_PCI_DEVICE_TABLE macro use 2014-08-12 12:15:14 -06:00
exynos Merge branch 'drm-next' of git://people.freedesktop.org/~airlied/linux 2014-08-07 17:36:12 -07:00
gma500 PCI: Remove DEFINE_PCI_DEVICE_TABLE macro use 2014-08-12 12:15:14 -06:00
i2c drm/tda998x: update for new drm connector APIs. 2014-08-05 10:34:33 +10:00
i810 i810: use pci_zalloc_consistent 2014-08-08 15:57:28 -07:00
i915 drm/i915: Prevent recursive deadlock on releasing a busy userptr 2014-09-08 08:38:49 +03:00
mga
mgag200 PCI: Remove DEFINE_PCI_DEVICE_TABLE macro use 2014-08-12 12:15:14 -06:00
msm drm/msm: Fix missing unlock on error in msm_fbdev_create() 2014-08-26 10:43:31 -04:00
nouveau Merge branch 'linux-3.17' of git://anongit.freedesktop.org/git/nouveau/linux-2.6 into drm-fixes 2014-09-05 09:27:33 +10:00
omapdrm fbdev changes for 3.17 2014-08-08 18:09:33 -07:00
panel drm/panel: simple: Use devm_gpiod_get_optional() 2014-08-07 09:35:27 +02:00
qxl PCI: Remove DEFINE_PCI_DEVICE_TABLE macro use 2014-08-12 12:15:14 -06:00
r128
radeon radeon: Test for PCI root bus before assuming bus->self 2014-08-27 17:54:50 -04:00
rcar-du drm/rcar-du: Fix maximum frame buffer pitch computation 2014-07-30 11:08:24 +10:00
savage
shmobile drm: shmobile: fix warnings 2014-07-22 11:31:35 +10:00
sis
sti drm: sti: Add missing dependency on RESET_CONTROLLER 2014-08-26 14:17:02 +02:00
tdfx
tegra ARM: SoC cleanups for 3.17 2014-08-08 11:00:26 -07:00
tilcdc drm/tilcdc: Fix build breakage 2014-07-10 12:01:38 +10:00
ttm Merge branch 'linux-3.17' of git://anongit.freedesktop.org/git/nouveau/linux-2.6 2014-08-09 17:46:39 -07:00
udl drm/udl: use helpers 2014-07-18 14:24:49 +10:00
via
vmwgfx drm/vmwgfx: Fix a potential infinite spin waiting for fifo idle 2014-09-01 12:31:24 +02:00
ati_pcigart.c
drm_agpsupport.c
drm_auth.c
drm_buffer.c drivers/gpu/drm/drm_buffer.c: remove unnecessary null test before kfree 2014-07-18 15:39:27 +02:00
drm_bufs.c drm: remove unused "struct drm_freelist" 2014-08-02 06:43:10 +10:00
drm_cache.c
drm_context.c drm: mark drm_context support as legacy 2014-08-05 19:38:12 +02:00
drm_crtc_helper.c drm/crtc-helper: use drm_framebuffer flags 2014-07-08 11:18:47 +10:00
drm_crtc_internal.h
drm_crtc.c drm: fix division-by-zero on dumb_create() 2014-08-28 11:38:04 +10:00
drm_debugfs.c
drm_dma.c
drm_dp_helper.c
drm_dp_mst_topology.c drm/dp: Staticize a couple of DP utility functions 2014-07-22 10:58:28 +10:00
drm_drv.c Revert "drm: drop redundant drm_file->is_master" 2014-08-08 07:30:53 +10:00
drm_edid_load.c
drm_edid.c Merge remote-tracking branch 'airlied/drm-next' into drm-intel-next 2014-07-29 20:49:36 +02:00
drm_encoder_slave.c
drm_fb_cma_helper.c drm: Introduce drm_fb_helper_prepare() 2014-07-08 11:31:28 +10:00
drm_fb_helper.c drm/fb_helper: allow adding/removing connectors later 2014-07-08 11:39:45 +10:00
drm_flip_work.c
drm_fops.c Revert "drm: drop redundant drm_file->is_master" 2014-08-08 07:30:53 +10:00
drm_gem_cma_helper.c drm: gem_cma: Use ERR_CAST helper 2014-07-21 14:36:45 +10:00
drm_gem.c drm/gem: remove misleading gfp parameter to get_pages() 2014-07-08 00:29:53 +02:00
drm_global.c
drm_hashtab.c list: fix order of arguments for hlist_add_after(_rcu) 2014-08-06 18:01:24 -07:00
drm_info.c drm: remove unused "struct drm_freelist" 2014-08-02 06:43:10 +10:00
drm_ioc32.c
drm_ioctl.c Revert "drm: drop redundant drm_file->is_master" 2014-08-08 07:30:53 +10:00
drm_irq.c drm: Use ktime_mono_to_real() 2014-07-23 10:18:03 -07:00
drm_legacy.h drm: mark drm_context support as legacy 2014-08-05 19:38:12 +02:00
drm_lock.c Revert "drm: drop redundant drm_file->is_master" 2014-08-08 07:30:53 +10:00
drm_memory.c
drm_mipi_dsi.c drm/dsi: Use peripheral's channel for DCS commands 2014-07-22 09:06:32 +02:00
drm_mm.c
drm_modes.c
drm_modeset_lock.c
drm_of.c drm: add of_graph endpoint helper to find possible CRTCs 2014-07-11 15:38:28 +01:00
drm_panel.c
drm_pci.c
drm_plane_helper.c drm/plane-helper: Use proper plane init function 2014-07-18 15:39:28 +02:00
drm_platform.c
drm_prime.c dma-buf: use reservation objects 2014-07-08 13:03:20 -07:00
drm_probe_helper.c
drm_rect.c drm: Add drm_rect rotation functions 2014-07-11 23:44:12 +02:00
drm_scatter.c
drm_sysfs.c drm: make sysfs device always available for minors 2014-08-05 16:08:21 +02:00
drm_trace_points.c
drm_trace.h
drm_usb.c
drm_vm.c
drm_vma_manager.c
Kconfig drm/radeon: use an intervall tree to manage the VMA v2 2014-08-05 08:53:51 -04:00
Makefile drm: move drm_stub.c to drm_drv.c 2014-08-06 19:10:44 +10:00
README.drm

************************************************************
* For the very latest on DRI development, please see:      *
*     http://dri.freedesktop.org/                          *
************************************************************

The Direct Rendering Manager (drm) is a device-independent kernel-level
device driver that provides support for the XFree86 Direct Rendering
Infrastructure (DRI).

The DRM supports the Direct Rendering Infrastructure (DRI) in four major
ways:

    1. The DRM provides synchronized access to the graphics hardware via
       the use of an optimized two-tiered lock.

    2. The DRM enforces the DRI security policy for access to the graphics
       hardware by only allowing authenticated X11 clients access to
       restricted regions of memory.

    3. The DRM provides a generic DMA engine, complete with multiple
       queues and the ability to detect the need for an OpenGL context
       switch.

    4. The DRM is extensible via the use of small device-specific modules
       that rely extensively on the API exported by the DRM module.


Documentation on the DRI is available from:
    http://dri.freedesktop.org/wiki/Documentation
    http://sourceforge.net/project/showfiles.php?group_id=387
    http://dri.sourceforge.net/doc/

For specific information about kernel-level support, see:

    The Direct Rendering Manager, Kernel Support for the Direct Rendering
    Infrastructure
    http://dri.sourceforge.net/doc/drm_low_level.html

    Hardware Locking for the Direct Rendering Infrastructure
    http://dri.sourceforge.net/doc/hardware_locking_low_level.html

    A Security Analysis of the Direct Rendering Infrastructure
    http://dri.sourceforge.net/doc/security_low_level.html