lockdep detecting a possible deadlock on kernel 5.13.0-rc6
This is with Fedora userspace: xorg-x11-drv-nouveau-1.0.17-1.fc33.x86_64
[ 42.215138] ======================================================
[ 42.215139] WARNING: possible circular locking dependency detected
[ 42.215140] 5.13.0-rc6-guest-debug+ #282 Not tainted
[ 42.215141] ------------------------------------------------------
[ 42.215142] kworker/0:2/141 is trying to acquire lock:
[ 42.215143] ffff88810f9ec518 (&cli->mutex){+.+.}-{3:3}, at: nouveau_bo_move+0x14a/0x860 [nouveau]
[ 42.215224]
but task is already holding lock:
[ 42.215224] ffff88810264c5a0 (reservation_ww_class_mutex){+.+.}-{3:3}, at: ttm_bo_evict_swapout_allowable.isra.0+0x1a/0x70
[ 42.215230]
which lock already depends on the new lock.
[ 42.215231]
the existing dependency chain (in reverse order) is:
[ 42.215232]
-> #1 (reservation_ww_class_mutex){+.+.}-{3:3}:
[ 42.215234] __ww_mutex_lock.constprop.0+0xb0/0xef0
[ 42.215238] nouveau_bo_pin+0x40/0x3d0 [nouveau]
[ 42.215299] nouveau_channel_prep+0x12b/0x300 [nouveau]
[ 42.215355] nouveau_channel_new+0x60/0x740 [nouveau]
[ 42.215409] nouveau_abi16_ioctl_channel_alloc+0xed/0x380 [nouveau]
[ 42.215462] drm_ioctl_kernel+0xad/0x100
[ 42.215464] drm_ioctl+0x202/0x3b0
[ 42.215465] nouveau_drm_ioctl+0x55/0xa0 [nouveau]
[ 42.215523] __x64_sys_ioctl+0x83/0xb0
[ 42.215525] do_syscall_64+0x40/0x80
[ 42.215528] entry_SYSCALL_64_after_hwframe+0x44/0xae
[ 42.215530]
-> #0 (&cli->mutex){+.+.}-{3:3}:
[ 42.215533] __lock_acquire+0x118a/0x1ee0
[ 42.215535] lock_acquire+0xb9/0x380
[ 42.215536] __mutex_lock+0x89/0x7e0
[ 42.215539] nouveau_bo_move+0x14a/0x860 [nouveau]
[ 42.215596] ttm_bo_handle_move_mem+0x90/0x170
[ 42.215599] ttm_bo_evict+0x149/0x1d0
[ 42.215600] ttm_mem_evict_first+0x11c/0x4f0
[ 42.215602] ttm_resource_manager_evict_all+0xa2/0x1c0
[ 42.215604] nouveau_do_suspend+0x82/0x180 [nouveau]
[ 42.215661] nouveau_pmops_runtime_suspend+0x3b/0xb0 [nouveau]
[ 42.215717] pci_pm_runtime_suspend+0x5e/0x170
[ 42.215720] __rpm_callback+0x7b/0x130
[ 42.215722] rpm_callback+0x1f/0x70
[ 42.215724] rpm_suspend+0x14a/0x700
[ 42.215725] pm_runtime_work+0xa0/0xb0
[ 42.215727] process_one_work+0x272/0x590
[ 42.215729] worker_thread+0x52/0x3f0
[ 42.215731] kthread+0x137/0x150
[ 42.215733] ret_from_fork+0x22/0x30
[ 42.215735]
other info that might help us debug this:
[ 42.215736] Possible unsafe locking scenario:
[ 42.215737] CPU0 CPU1
[ 42.215737] ---- ----
[ 42.215738] lock(reservation_ww_class_mutex);
[ 42.215739] lock(&cli->mutex);
[ 42.215741] lock(reservation_ww_class_mutex);
[ 42.215742] lock(&cli->mutex);
[ 42.215743]
*** DEADLOCK ***
[ 42.215744] 3 locks held by kworker/0:2/141:
[ 42.215745] #0: ffff8881014ebd38 ((wq_completion)pm){+.+.}-{0:0}, at: process_one_work+0x1f2/0x590
[ 42.215750] #1: ffffc900014abe70 ((work_completion)(&dev->power.work)){+.+.}-{0:0}, at: process_one_work+0x1f2/0x590
[ 42.215754] #2: ffff88810264c5a0 (reservation_ww_class_mutex){+.+.}-{3:3}, at: ttm_bo_evict_swapout_allowable.isra.0+0x1a/0x70
[ 42.215758]
stack backtrace:
[ 42.215759] CPU: 0 PID: 141 Comm: kworker/0:2 Not tainted 5.13.0-rc6-guest-debug+ #282
[ 42.215761] Hardware name: LENOVO 20MDCTO1WW/20MDCTO1WW, BIOS N2EET39W (1.21 ) 04/15/2019
[ 42.215763] Workqueue: pm pm_runtime_work
[ 42.215765] Call Trace:
[ 42.215767] dump_stack+0x6d/0x89
[ 42.215771] check_noncircular+0xf2/0x110
[ 42.215773] ? nvkm_uvmm_mthd+0x77d/0x7b0 [nouveau]
[ 42.215828] __lock_acquire+0x118a/0x1ee0
[ 42.215831] lock_acquire+0xb9/0x380
[ 42.215833] ? nouveau_bo_move+0x14a/0x860 [nouveau]
[ 42.215891] ? lock_is_held_type+0x98/0x110
[ 42.215894] __mutex_lock+0x89/0x7e0
[ 42.215896] ? nouveau_bo_move+0x14a/0x860 [nouveau]
[ 42.215954] ? nouveau_bo_move+0x14a/0x860 [nouveau]
[ 42.216012] nouveau_bo_move+0x14a/0x860 [nouveau]
[ 42.216070] ttm_bo_handle_move_mem+0x90/0x170
[ 42.216073] ttm_bo_evict+0x149/0x1d0
[ 42.216076] ? ttm_bo_init_reserved+0x335/0x390
[ 42.216079] ttm_mem_evict_first+0x11c/0x4f0
[ 42.216082] ttm_resource_manager_evict_all+0xa2/0x1c0
[ 42.216085] nouveau_do_suspend+0x82/0x180 [nouveau]
[ 42.216142] nouveau_pmops_runtime_suspend+0x3b/0xb0 [nouveau]
[ 42.216198] pci_pm_runtime_suspend+0x5e/0x170
[ 42.216200] ? _raw_spin_unlock_irq+0x24/0x30
[ 42.216202] ? pci_dev_put+0x20/0x20
[ 42.216204] ? pci_dev_put+0x20/0x20
[ 42.216206] __rpm_callback+0x7b/0x130
[ 42.216208] ? pci_dev_put+0x20/0x20
[ 42.216210] rpm_callback+0x1f/0x70
[ 42.216211] ? pci_dev_put+0x20/0x20
[ 42.216213] rpm_suspend+0x14a/0x700
[ 42.216214] ? process_one_work+0x1f2/0x590
[ 42.216218] pm_runtime_work+0xa0/0xb0
[ 42.216219] process_one_work+0x272/0x590
[ 42.216222] worker_thread+0x52/0x3f0
[ 42.216225] ? process_one_work+0x590/0x590
[ 42.216227] kthread+0x137/0x150
[ 42.216229] ? __kthread_bind_mask+0x60/0x60
[ 42.216231] ret_from_fork+0x22/0x30