Merge tag 'amd-drm-next-5.14-2021-06-02' of https://gitlab.freedesktop.org/agd5f...
[linux-2.6-microblaze.git] / drivers / gpu / drm / amd / amdgpu / amdgpu_amdkfd_gpuvm.c
index 928e8d5..141cd29 100644 (file)
@@ -621,14 +621,13 @@ 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);
+       amdgpu_bo_unreserve(mem->bo);
        if (ret)
                return ret;
 
-       amdgpu_bo_unreserve(mem->bo);
-
        *bo = gem_to_amdgpu_bo(gobj);
        (*bo)->parent = amdgpu_bo_ref(mem->bo);
 
@@ -640,14 +639,16 @@ kfd_mem_attach_dmabuf(struct amdgpu_device *adev, struct kgd_mem *mem,
                      struct amdgpu_bo **bo)
 {
        struct drm_gem_object *gobj;
+       int ret;
 
        if (!mem->dmabuf) {
                mem->dmabuf = amdgpu_gem_prime_export(&mem->bo->tbo.base,
                        mem->alloc_flags & KFD_IOC_ALLOC_MEM_FLAGS_WRITABLE ?
                                DRM_RDWR : 0);
                if (IS_ERR(mem->dmabuf)) {
+                       ret = PTR_ERR(mem->dmabuf);
                        mem->dmabuf = NULL;
-                       return PTR_ERR(mem->dmabuf);
+                       return ret;
                }
        }
 
@@ -662,6 +663,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 +1412,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);