drm/amdgpu: allocate PDs/PTs with no_gpu_wait in a page fault
authorChristian König <christian.koenig@amd.com>
Mon, 16 Sep 2019 15:35:53 +0000 (10:35 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 16 Sep 2019 15:42:55 +0000 (10:42 -0500)
While handling a page fault we can't wait for other ongoing GPU
operations or we can potentially run into deadlocks.

Signed-off-by: Christian König <christian.koenig@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_object.c
drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c

index 1fead0e8b8909d28e8fe5b2d5bfe6a59634c6b55..162e3849ff88a2d54437ca4de9d4f4dcb0f0311a 100644 (file)
@@ -451,7 +451,7 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev,
 {
        struct ttm_operation_ctx ctx = {
                .interruptible = (bp->type != ttm_bo_type_kernel),
-               .no_wait_gpu = false,
+               .no_wait_gpu = bp->no_wait_gpu,
                .resv = bp->resv,
                .flags = TTM_OPT_FLAG_ALLOW_RES_EVICT
        };
index 658f4c9779b704831c8ebe472ba343921da62429..314190c2c5c292a27c8403e97bbe28e23c875d70 100644 (file)
@@ -41,6 +41,7 @@ struct amdgpu_bo_param {
        u32                             preferred_domain;
        u64                             flags;
        enum ttm_bo_type                type;
+       bool                            no_wait_gpu;
        struct dma_resv *resv;
 };
 
index 6512501cb8065d16bc72522d36e48886b92570bb..5dc1e0b319fba1d5c349d08c7689e909239fdaa3 100644 (file)
@@ -821,7 +821,8 @@ static int amdgpu_vm_clear_bo(struct amdgpu_device *adev,
  * @bp: resulting BO allocation parameters
  */
 static void amdgpu_vm_bo_param(struct amdgpu_device *adev, struct amdgpu_vm *vm,
-                              int level, struct amdgpu_bo_param *bp)
+                              int level, bool direct,
+                              struct amdgpu_bo_param *bp)
 {
        memset(bp, 0, sizeof(*bp));
 
@@ -836,6 +837,7 @@ static void amdgpu_vm_bo_param(struct amdgpu_device *adev, struct amdgpu_vm *vm,
        else if (!vm->root.base.bo || vm->root.base.bo->shadow)
                bp->flags |= AMDGPU_GEM_CREATE_SHADOW;
        bp->type = ttm_bo_type_kernel;
+       bp->no_wait_gpu = direct;
        if (vm->root.base.bo)
                bp->resv = vm->root.base.bo->tbo.base.resv;
 }
@@ -877,7 +879,7 @@ static int amdgpu_vm_alloc_pts(struct amdgpu_device *adev,
        if (entry->base.bo)
                return 0;
 
-       amdgpu_vm_bo_param(adev, vm, cursor->level, &bp);
+       amdgpu_vm_bo_param(adev, vm, cursor->level, direct, &bp);
 
        r = amdgpu_bo_create(adev, &bp, &pt);
        if (r)
@@ -2714,7 +2716,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,
                vm->update_funcs = &amdgpu_vm_sdma_funcs;
        vm->last_update = NULL;
 
-       amdgpu_vm_bo_param(adev, vm, adev->vm_manager.root_level, &bp);
+       amdgpu_vm_bo_param(adev, vm, adev->vm_manager.root_level, false, &bp);
        if (vm_context == AMDGPU_VM_CONTEXT_COMPUTE)
                bp.flags &= ~AMDGPU_GEM_CREATE_SHADOW;
        r = amdgpu_bo_create(adev, &bp, &root);