[PATCH 2/3] drm/amdgpu: Use preemptible domain for KFD

Felix Kuehling Felix.Kuehling at amd.com
Wed May 19 05:45:35 UTC 2021


KFD userptr BOs and SG BOs used for DMA mappings can be preempted with
CWSR. Therefore we can place them in the preemptible domain and avoid
unwanted evictions.

Signed-off-by: Felix Kuehling <Felix.Kuehling at amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
index 928e8d57cd08..2856ca1032db 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
@@ -511,7 +511,7 @@ kfd_mem_dmamap_userptr(struct kgd_mem *mem,
 	drm_prime_sg_to_dma_addr_array(ttm->sg, ttm->dma_address,
 				       ttm->num_pages);
 
-	amdgpu_bo_placement_from_domain(bo, AMDGPU_GEM_DOMAIN_GTT);
+	amdgpu_bo_placement_from_domain(bo, AMDGPU_GEM_DOMAIN_PREEMPT);
 	ret = ttm_bo_validate(&bo->tbo, &bo->placement, &ctx);
 	if (ret)
 		goto unmap_sg;
@@ -535,7 +535,7 @@ kfd_mem_dmamap_dmabuf(struct kfd_mem_attachment *attachment)
 	struct ttm_operation_ctx ctx = {.interruptible = true};
 	struct amdgpu_bo *bo = attachment->bo_va->base.bo;
 
-	amdgpu_bo_placement_from_domain(bo, AMDGPU_GEM_DOMAIN_GTT);
+	amdgpu_bo_placement_from_domain(bo, AMDGPU_GEM_DOMAIN_PREEMPT);
 	return ttm_bo_validate(&bo->tbo, &bo->placement, &ctx);
 }
 
@@ -1408,7 +1408,7 @@ int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu(
 		domain = alloc_domain = AMDGPU_GEM_DOMAIN_GTT;
 		alloc_flags = 0;
 	} else if (flags & KFD_IOC_ALLOC_MEM_FLAGS_USERPTR) {
-		domain = AMDGPU_GEM_DOMAIN_GTT;
+		domain = AMDGPU_GEM_DOMAIN_PREEMPT;
 		alloc_domain = AMDGPU_GEM_DOMAIN_CPU;
 		alloc_flags = 0;
 		if (!offset || !*offset)
-- 
2.31.1



More information about the amd-gfx mailing list