drm/amdkfd: Move dma unmapping after TLB flush
authorPhilip Yang <Philip.Yang@amd.com>
Mon, 11 Sep 2023 18:44:22 +0000 (14:44 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 26 Sep 2023 20:55:10 +0000 (16:55 -0400)
commit101b8104307eac734f2dfa4d3511430b0b631c73
treefecf30c97b52f2fcd0f9b7cc18fa18f158688ee5
parent08abccc9a7a7ff51cb10948042360448ea30d413
drm/amdkfd: Move dma unmapping after TLB flush

Otherwise GPU may access the stale mapping and generate IOMMU
IO_PAGE_FAULT.

Move this to inside p->mutex to prevent multiple threads mapping and
unmapping concurrently race condition.

After kfd_mem_dmaunmap_attachment is removed from unmap_bo_from_gpuvm,
kfd_mem_dmaunmap_attachment is called if failed to map to GPUs, and
before free the mem attachment in case failed to unmap from GPUs.

Signed-off-by: Philip Yang <Philip.Yang@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c