drm/amdkfd: Fix circular lock in nocpsch path
authorAmber Lin <Amber.Lin@amd.com>
Mon, 7 Jun 2021 18:46:21 +0000 (14:46 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 19 Jul 2021 07:44:50 +0000 (09:44 +0200)
commit0e72b151e394106ad3e3d5bebd1118952970047a
tree07f32cd777eab9829d7c0ffd04bb8ecb4c0c5457
parentcd29db48bb65e53efe4b05c75e575c5f1af5ddaf
drm/amdkfd: Fix circular lock in nocpsch path

[ Upstream commit a7b2451d31cfa2e8aeccf3b35612ce33f02371fc ]

Calling free_mqd inside of destroy_queue_nocpsch_locked can cause a
circular lock. destroy_queue_nocpsch_locked is called under a DQM lock,
which is taken in MMU notifiers, potentially in FS reclaim context.
Taking another lock, which is BO reservation lock from free_mqd, while
causing an FS reclaim inside the DQM lock creates a problematic circular
lock dependency. Therefore move free_mqd out of
destroy_queue_nocpsch_locked and call it after unlocking DQM.

Signed-off-by: Amber Lin <Amber.Lin@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c