[PATCH 2/4] drm/amdgpu: create shadow bo using amdgpu_bo_create_shadow()

Christian König christian.koenig at amd.com
Thu Apr 22 07:08:48 UTC 2021


Am 21.04.21 um 18:35 schrieb Nirmoy Das:
> Shadow BOs are only needed for vm code so call amdgpu_bo_create_shadow()
> directly instead of depending on amdgpu_bo_create().

As far as I can see that won't work correctly.

Now you only create the shadow for the root BO, but not for anything else.

Christian.

>
> Signed-off-by: Nirmoy Das <nirmoy.das at amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 19 +++++++++++++++----
>   1 file changed, 15 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> index f95bcda8463f..bc302548dfba 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> @@ -873,8 +873,7 @@ static void amdgpu_vm_bo_param(struct amdgpu_device *adev, struct amdgpu_vm *vm,
>   	bp->bo_ptr_size = sizeof(struct amdgpu_bo);
>   	if (vm->use_cpu_for_update)
>   		bp->flags |= AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED;
> -	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 = immediate;
>   	if (vm->root.base.bo)
> @@ -2844,12 +2843,24 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,
>   	vm->evicting = false;
>   
>   	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);
>   	if (r)
>   		goto error_free_delayed;
>   
> +	if (!(vm_context == AMDGPU_VM_CONTEXT_COMPUTE) &&
> +	    (!vm->root.base.bo || vm->root.base.bo->shadow)) {
> +		if (!bp.resv)
> +			WARN_ON(dma_resv_lock(root->tbo.base.resv,
> +					      NULL));
> +		r = amdgpu_bo_create_shadow(adev, bp.size, root);
> +
> +		if (!bp.resv)
> +			dma_resv_unlock(root->tbo.base.resv);
> +
> +		if (r)
> +			amdgpu_bo_unref(&root);
> +	}
> +
>   	r = amdgpu_bo_reserve(root, true);
>   	if (r)
>   		goto error_free_root;



More information about the amd-gfx mailing list