Shadow BOs are only needed by VM code so create it
directly within the vm code.

Signed-off-by: Nirmoy Das <nirmoy....@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index 2c97d67d9cfc..04cabcc3dc3d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -872,6 +872,8 @@ static int amdgpu_vm_pt_create(struct amdgpu_device *adev,
 {
        struct amdgpu_bo_param bp;
        struct amdgpu_bo *bo;
+       struct amdgpu_bo *shadow_bo;
+       struct dma_resv *resv;
        int r;
 
        memset(&bp, 0, sizeof(bp));
@@ -902,9 +904,19 @@ static int amdgpu_vm_pt_create(struct amdgpu_device *adev,
        if (!bp.resv)
                WARN_ON(dma_resv_lock(bo->tbo.base.resv,
                                      NULL));
-       r = amdgpu_bo_create_shadow(adev, bp.size, bo);
+       resv = bp.resv;
+       memset(&bp, 0, sizeof(bp));
+       bp.size = amdgpu_vm_bo_size(adev, level);
+       bp.domain = AMDGPU_GEM_DOMAIN_GTT;
+       bp.flags = AMDGPU_GEM_CREATE_CPU_GTT_USWC;
+       bp.type = ttm_bo_type_kernel;
+       bp.resv = bo->tbo.base.resv;
+       bp.bo_ptr_size = sizeof(struct amdgpu_bo);
 
-       if (!bp.resv)
+       r = amdgpu_bo_create(adev, &bp, &shadow_bo);
+
+
+       if (!resv)
                dma_resv_unlock(bo->tbo.base.resv);
 
        if (r) {
@@ -912,6 +924,12 @@ static int amdgpu_vm_pt_create(struct amdgpu_device *adev,
                return r;
        }
 
+       shadow_bo->parent = amdgpu_bo_ref(bo);
+       mutex_lock(&adev->shadow_list_lock);
+       list_add_tail(&shadow_bo->shadow_list, &adev->shadow_list);
+       mutex_unlock(&adev->shadow_list_lock);
+       bo->shadow = shadow_bo;
+
        return 0;
 }
 
-- 
2.31.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Reply via email to