]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
drm/amdkfd: Fix mode1 reset crash issue
authorPhilip Yang <Philip.Yang@amd.com>
Thu, 6 Feb 2025 22:50:13 +0000 (17:50 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 25 Apr 2025 08:43:33 +0000 (10:43 +0200)
commit57c9dabda80ac167de8cd71231baae37cc2f442d
treeb7807501d5dbed439ab27f066bb6b28487aa32fe
parent82b6aaa867bd4dcb0c639b4739802a62cc12896a
drm/amdkfd: Fix mode1 reset crash issue

[ Upstream commit f0b4440cdc1807bb6ec3dce0d6de81170803569b ]

If HW scheduler hangs and mode1 reset is used to recover GPU, KFD signal
user space to abort the processes. After process abort exit, user queues
still use the GPU to access system memory before h/w is reset while KFD
cleanup worker free system memory and free VRAM.

There is use-after-free race bug that KFD allocate and reuse the freed
system memory, and user queue write to the same system memory to corrupt
the data structure and cause driver crash.

To fix this race, KFD cleanup worker terminate user queues, then flush
reset_domain wq to wait for any GPU ongoing reset complete, and then
free outstanding BOs.

Signed-off-by: Philip Yang <Philip.Yang@amd.com>
Reviewed-by: Lijo Lazar <lijo.lazar@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_process.c