]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
drm/amdgpu: Use preemptible placement for KFD
authorFelix Kuehling <Felix.Kuehling@amd.com>
Wed, 19 May 2021 01:46:02 +0000 (21:46 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 21 May 2021 22:00:05 +0000 (18:00 -0400)
KFD userptr BOs and SG BOs used for DMA mappings can be preempted with
CWSR. Therefore we can use preemptible placement and avoid unwanted
evictions due to GTT accounting.

Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c

index 928e8d57cd08632dad8fd1d18f777916589ee3bb..2b8b8953519886dfb489b3a14162fcd5e0a08cf8 100644 (file)
@@ -621,8 +621,8 @@ kfd_mem_attach_userptr(struct amdgpu_device *adev, struct kgd_mem *mem,
 
        ret = amdgpu_gem_object_create(adev, bo_size, 1,
                                       AMDGPU_GEM_DOMAIN_CPU,
-                                      0, ttm_bo_type_sg,
-                                      mem->bo->tbo.base.resv,
+                                      AMDGPU_GEM_CREATE_PREEMPTIBLE,
+                                      ttm_bo_type_sg, mem->bo->tbo.base.resv,
                                       &gobj);
        if (ret)
                return ret;
@@ -662,6 +662,7 @@ kfd_mem_attach_dmabuf(struct amdgpu_device *adev, struct kgd_mem *mem,
        dma_buf_put(mem->dmabuf);
 
        *bo = gem_to_amdgpu_bo(gobj);
+       (*bo)->flags |= AMDGPU_GEM_CREATE_PREEMPTIBLE;
        (*bo)->parent = amdgpu_bo_ref(mem->bo);
 
        return 0;
@@ -1410,7 +1411,7 @@ int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu(
        } else if (flags & KFD_IOC_ALLOC_MEM_FLAGS_USERPTR) {
                domain = AMDGPU_GEM_DOMAIN_GTT;
                alloc_domain = AMDGPU_GEM_DOMAIN_CPU;
-               alloc_flags = 0;
+               alloc_flags = AMDGPU_GEM_CREATE_PREEMPTIBLE;
                if (!offset || !*offset)
                        return -EINVAL;
                user_addr = untagged_addr(*offset);