[PATCH] drm/amdgpu: make sure userptr ttm is allocated

Michel Dänzer michel at daenzer.net
Fri Aug 7 09:10:41 UTC 2020


On 2020-08-06 2:56 p.m., Christian König wrote:
> We need to allocate that manually now.
> 
> Signed-off-by: Christian König <christian.koenig at amd.com>
> Fixes: 2ddef17678bc (HEAD) drm/ttm: make TT creation purely optional v3
> ---
>  .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c    |  2 +-
>  drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c         |  2 +-
>  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c         | 17 +++++++++++------
>  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h         |  4 ++--
>  4 files changed, 15 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
> index 9015c7b76d60..55d2e870fdda 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
> @@ -564,7 +564,7 @@ static int init_user_pages(struct kgd_mem *mem, uint64_t user_addr)
>  
>  	mutex_lock(&process_info->lock);
>  
> -	ret = amdgpu_ttm_tt_set_userptr(bo->tbo.ttm, user_addr, 0);
> +	ret = amdgpu_ttm_tt_set_userptr(&bo->tbo, user_addr, 0);
>  	if (ret) {
>  		pr_err("%s: Failed to set userptr: %d\n", __func__, ret);
>  		goto out;

I suspect more needs to be done for KFD, e.g.
amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu can dereference
bo->tbo.ttm before calling init_user_pages, and there are more usages of
bo->tbo.ttm that need to be audited.


-- 
Earthling Michel Dänzer               |               https://redhat.com
Libre software enthusiast             |             Mesa and X developer


More information about the amd-gfx mailing list