igt@gem_mmap_gtt@fault-concurrent - dmesg-warn - is trying to acquire lock at: unmap_mapping_pages, but task is already holding lock at: i915_vma_unbind
<6> [367.379594] Console: switching to colour dummy device 80x25
<6> [367.379662] [IGT] gem_mmap_gtt: executing
<6> [367.384336] [IGT] gem_mmap_gtt: starting subtest fault-concurrent
<4> [369.199391]
<4> [369.199397] ======================================================
<4> [369.199401] WARNING: possible circular locking dependency detected
<4> [369.199407] 5.8.0-rc4-CI-CI_DRM_8729+ #1 Not tainted
<4> [369.199412] ------------------------------------------------------
<4> [369.199416] gem_mmap_gtt/1915 is trying to acquire lock:
<4> [369.199421] ffff8883e1909cf8 (&mapping->i_mmap_rwsem){++++}-{3:3}, at: unmap_mapping_pages+0x48/0x130
<4> [369.199434]
but task is already holding lock:
<4> [369.199439] ffff8883e09a9de8 (&vm->mutex/1){+.+.}-{3:3}, at: i915_vma_unbind+0x64/0x120 [i915]
<4> [369.199536]
which lock already depends on the new lock.
<4> [369.199542]
the existing dependency chain (in reverse order) is:
<4> [369.199547]
-> #2 (&vm->mutex/1){+.+.}-{3:3}:
<4> [369.199558] __mutex_lock+0x9a/0x9c0
<4> [369.199642] i915_vma_unbind+0x64/0x120 [i915]
<4> [369.199722] i915_gem_object_unbind+0x1d0/0x450 [i915]
<4> [369.199799] userptr_mn_invalidate_range_start+0xdf/0x190 [i915]
<4> [369.199806] __mmu_notifier_invalidate_range_start+0xad/0x240
<4> [369.199812] unmap_vmas+0x13e/0x150
<4> [369.199816] unmap_region+0xa3/0x100
<4> [369.199820] __do_munmap+0x26d/0x490
<4> [369.199825] __vm_munmap+0x66/0xc0
<4> [369.199829] __x64_sys_munmap+0x12/0x20
<4> [369.199835] do_syscall_64+0x56/0xe0
<4> [369.199840] entry_SYSCALL_64_after_hwframe+0x44/0xa9
<4> [369.199844]
-> #1 (mmu_notifier_invalidate_range_start){+.+.}-{0:0}:
<4> [369.199853] page_mkclean_one+0xe4/0x220
<4> [369.199857] rmap_walk_file+0x18e/0x3a0
<4> [369.199862] page_mkclean+0xb4/0xe0
<4> [369.199867] clear_page_dirty_for_io+0xd4/0x3b0
<4> [369.199873] mpage_submit_page+0x1a/0x70
<4> [369.199878] mpage_process_page_bufs+0x111/0x130
<4> [369.199883] mpage_prepare_extent_to_map+0x223/0x370
<4> [369.199888] ext4_writepages+0x516/0x1120
<4> [369.199893] do_writepages+0x46/0xe0
<4> [369.199898] __filemap_fdatawrite_range+0xc6/0x100
<4> [369.199904] file_write_and_wait_range+0x3c/0x90
<4> [369.199910] ext4_sync_file+0x1a2/0x490
<4> [369.199916] do_fsync+0x33/0x60
<4> [369.199920] __x64_sys_fsync+0xb/0x10
<4> [369.199924] do_syscall_64+0x56/0xe0
<4> [369.199929] entry_SYSCALL_64_after_hwframe+0x44/0xa9
<4> [369.199933]
-> #0 (&mapping->i_mmap_rwsem){++++}-{3:3}:
<4> [369.199942] __lock_acquire+0x196f/0x1f50
<4> [369.199947] lock_acquire+0xb5/0x3c0
<4> [369.199952] down_write+0x33/0x70
<4> [369.199957] unmap_mapping_pages+0x48/0x130
<4> [369.200034] i915_vma_revoke_mmap.part.38+0x59/0x120 [i915]
<4> [369.200111] __i915_vma_evict+0x167/0x3f0 [i915]
<4> [369.200185] __i915_vma_unbind+0x59/0x110 [i915]
<4> [369.200259] i915_vma_unbind+0x70/0x120 [i915]
<4> [369.200333] i915_gem_object_ggtt_pin+0x1bb/0x320 [i915]
<4> [369.200403] vm_fault_gtt+0x7bf/0x990 [i915]
<4> [369.200408] __do_fault+0x45/0x100
<4> [369.200413] handle_mm_fault+0xf5d/0x1770
<4> [369.200418] exc_page_fault+0x3a4/0x6d0
<4> [369.200423] asm_exc_page_fault+0x1e/0x30
<4> [369.200427]
other info that might help us debug this:
<4> [369.200433] Chain exists of:
&mapping->i_mmap_rwsem --> mmu_notifier_invalidate_range_start --> &vm->mutex/1
<4> [369.200443] Possible unsafe locking scenario:
<4> [369.200448] CPU0 CPU1
<4> [369.200452] ---- ----
<4> [369.200455] lock(&vm->mutex/1);
<4> [369.200459] lock(mmu_notifier_invalidate_range_start);
<4> [369.200466] lock(&vm->mutex/1);
<4> [369.200471] lock(&mapping->i_mmap_rwsem);
<4> [369.200475]
*** DEADLOCK ***
Edited by LAKSHMINARAYANA VUDUM