drm/amdkfd: Fixed kfd_process cleanup on module exit.
authorDavid Belanger <david.belanger@amd.com>
Tue, 28 Feb 2023 19:11:24 +0000 (14:11 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 6 Apr 2023 10:10:40 +0000 (12:10 +0200)
commitb969838c9554a0e9aab3c3cadfcd23d246bc2abe
treebc8870a078d4b2af300b4963966175d946649a3b
parente437554b145296fef09a52d7111b137566e434ba
drm/amdkfd: Fixed kfd_process cleanup on module exit.

[ Upstream commit 20bc9f76b6a2455c6b54b91ae7634f147f64987f ]

Handle case when module is unloaded (kfd_exit) before a process space
(mm_struct) is released.

v2: Fixed potential race conditions by removing all kfd_process from
the process table first, then working on releasing the resources.

v3: Fixed loop element access / synchronization.  Fixed extra empty lines.

Signed-off-by: David Belanger <david.belanger@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_module.c
drivers/gpu/drm/amd/amdkfd/kfd_priv.h
drivers/gpu/drm/amd/amdkfd/kfd_process.c