[linux-mmotm] i915_gem_userptr_get_pages: possible circular locking dependency detected

From: Sergey Senozhatsky
Date: Tue Mar 14 2017 - 09:22:26 EST


Hello,

[ 530.698622] ======================================================
[ 530.698623] WARNING: possible circular locking dependency detected
[ 530.698626] 4.11.0-rc2-mm1-dbg-00167-gdb8a9941614c-dirty #222 Not tainted
[ 530.698627] ------------------------------------------------------
[ 530.698628] Xorg/343 is trying to acquire lock:
[ 530.698630] (&mm->mmap_sem){++++++}, at: [<ffffffffa057e085>] i915_gem_userptr_get_pages+0x60/0x29c [i915]
[ 530.698702]
but task is already holding lock:
[ 530.698703] (&obj->mm.lock){+.+.+.}, at: [<ffffffffa0572d78>] __i915_gem_object_get_pages+0x21/0x62 [i915]
[ 530.698763]
which lock already depends on the new lock.

[ 530.698764]
the existing dependency chain (in reverse order) is:
[ 530.698766]
-> #1 (&obj->mm.lock){+.+.+.}:
[ 530.698779] lock_acquire+0x130/0x1c4
[ 530.698822] i915_gem_fault+0x138/0x531 [i915]
[ 530.698826] __do_fault+0x1e/0xb4
[ 530.698831] __handle_mm_fault+0x897/0xe37
[ 530.698834] handle_mm_fault+0x93/0xd2
[ 530.698839] __do_page_fault+0x20c/0x3db
[ 530.698843] do_page_fault+0xc/0xe
[ 530.698848] page_fault+0x22/0x30
[ 530.698849]
-> #0 (&mm->mmap_sem){++++++}:
[ 530.698858] __lock_acquire+0xf49/0x1548
[ 530.698861] lock_acquire+0x130/0x1c4
[ 530.698866] down_read+0x3e/0x62
[ 530.698910] i915_gem_userptr_get_pages+0x60/0x29c [i915]
[ 530.698951] ____i915_gem_object_get_pages+0x3f/0x57 [i915]
[ 530.698993] __i915_gem_object_get_pages+0x41/0x62 [i915]
[ 530.699035] i915_gem_set_domain_ioctl+0x1f6/0x2b0 [i915]
[ 530.699057] drm_ioctl+0x248/0x363 [drm]
[ 530.699061] vfs_ioctl+0x18/0x34
[ 530.699064] do_vfs_ioctl+0x5a2/0x64d
[ 530.699067] SyS_ioctl+0x43/0x61
[ 530.699070] entry_SYSCALL_64_fastpath+0x18/0xad
[ 530.699072]
other info that might help us debug this:

[ 530.699073] Possible unsafe locking scenario:

[ 530.699075] CPU0 CPU1
[ 530.699076] ---- ----
[ 530.699077] lock(&obj->mm.lock);
[ 530.699081] lock(&mm->mmap_sem);
[ 530.699084] lock(&obj->mm.lock);
[ 530.699087] lock(&mm->mmap_sem);
[ 530.699090]
*** DEADLOCK ***

[ 530.699092] 1 lock held by Xorg/343:
[ 530.699094] #0: (&obj->mm.lock){+.+.+.}, at: [<ffffffffa0572d78>] __i915_gem_object_get_pages+0x21/0x62 [i915]
[ 530.699141]
stack backtrace:
[ 530.699144] CPU: 6 PID: 343 Comm: Xorg Not tainted 4.11.0-rc2-mm1-dbg-00167-gdb8a9941614c-dirty #222
[ 530.699146] Call Trace:
[ 530.699152] dump_stack+0x68/0x92
[ 530.699158] print_circular_bug+0x286/0x294
[ 530.699163] __lock_acquire+0xf49/0x1548
[ 530.699168] ? lock_acquire+0x130/0x1c4
[ 530.699173] lock_acquire+0x130/0x1c4
[ 530.699177] ? lock_acquire+0x130/0x1c4
[ 530.699223] ? i915_gem_userptr_get_pages+0x60/0x29c [i915]
[ 530.699228] down_read+0x3e/0x62
[ 530.699273] ? i915_gem_userptr_get_pages+0x60/0x29c [i915]
[ 530.699318] i915_gem_userptr_get_pages+0x60/0x29c [i915]
[ 530.699361] ____i915_gem_object_get_pages+0x3f/0x57 [i915]
[ 530.699403] __i915_gem_object_get_pages+0x41/0x62 [i915]
[ 530.699446] i915_gem_set_domain_ioctl+0x1f6/0x2b0 [i915]
[ 530.699463] drm_ioctl+0x248/0x363 [drm]
[ 530.699506] ? i915_gem_obj_prepare_shmem_write+0x1ba/0x1ba [i915]
[ 530.699511] vfs_ioctl+0x18/0x34
[ 530.699514] do_vfs_ioctl+0x5a2/0x64d
[ 530.699517] ? __fget+0x182/0x194
[ 530.699521] SyS_ioctl+0x43/0x61
[ 530.699524] entry_SYSCALL_64_fastpath+0x18/0xad
[ 530.699527] RIP: 0033:0x7fa1bb3150d7
[ 530.699529] RSP: 002b:00007ffe1f1fbc48 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
[ 530.699534] RAX: ffffffffffffffda RBX: 00000000e0000000 RCX: 00007fa1bb3150d7
[ 530.699536] RDX: 00007ffe1f1fbc70 RSI: 00000000400c645f RDI: 000000000000000b
[ 530.699538] RBP: 00000000a1fcd537 R08: 00000000000000ff R09: 0000000001c564d8
[ 530.699540] R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000015
[ 530.699542] R13: 0000000001c474b0 R14: 00000000000001f2 R15: 0000000001c43488


-ss