drm/amdgpu: make sure userptr ttm is allocated
Subsystems (3)
PATCH 1/1 drm/amdgpu: make sure userptr ttm is allocated
We need to allocate that manually now.
Signed-off-by Christian König <[email protected]>
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(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +1 -1
@@ -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;
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +1 -1
@@ -332,7 +332,7 @@ int amdgpu_gem_userptr_ioctl(struct drm_device *dev, void *data, bo =gem_to_amdgpu_bo (gobj); bo->preferred_domains =AMDGPU_GEM_DOMAIN_GTT ; bo->allowed_domains =AMDGPU_GEM_DOMAIN_GTT ; - r =amdgpu_ttm_tt_set_userptr (bo->tbo.ttm, args->addr, args->flags); + r =amdgpu_ttm_tt_set_userptr (&bo->tbo, args->addr, args->flags);if (r) goto release_object;
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +11 -6
@@ -1407,21 +1407,26 @@ static void amdgpu_ttm_tt_unpopulate(struct ttm_tt *ttm)* amdgpu_ttm_tt_set_userptr - Initialize userptr GTT ttm_tt for the current * task * -* @ttm: The ttm_tt object to bind this userptr object to +* @bo: The ttm_buffer_object to bind this userptr to * @addr: The address in the current tasks VM space to use * @flags: Requirements of userptr object. * * Called by amdgpu_gem_userptr_ioctl() to bind userptr pages * to current task */ -int amdgpu_ttm_tt_set_userptr (struct ttm_tt *ttm,uint64_t addr, -uint32_t flags) +int amdgpu_ttm_tt_set_userptr (struct ttm_buffer_object *bo, +uint64_t addr,uint32_t flags) { -struct amdgpu_ttm_tt *gtt = (void *)ttm; +struct amdgpu_ttm_tt *gtt; -if (gtt ==NULL ) -return -EINVAL ; +if (!bo->ttm) { +/* TODO: We want a separate TTM object type for userptrs */ + bo->ttm =amdgpu_ttm_tt_create (bo,0 ); +if (bo->ttm ==NULL ) +return -ENOMEM ; + } + gtt = (void *)bo->ttm; gtt->userptr = addr; gtt->userflags = flags;
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +2 -2
@@ -132,8 +132,8 @@ static inline bool amdgpu_ttm_tt_get_user_pages_done(struct ttm_tt *ttm)#endif void amdgpu_ttm_tt_set_user_pages (struct ttm_tt *ttm,struct page **pages); -int amdgpu_ttm_tt_set_userptr (struct ttm_tt *ttm,uint64_t addr, -uint32_t flags); +int amdgpu_ttm_tt_set_userptr (struct ttm_buffer_object *bo, +uint64_t addr,uint32_t flags);bool amdgpu_ttm_tt_has_userptr (struct ttm_tt *ttm);struct mm_struct *amdgpu_ttm_tt_get_usermm (struct ttm_tt *ttm); bool amdgpu_ttm_tt_affect_userptr(struct ttm_tt *ttm, unsigned long start,
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 4 lines · Christian König
We need to allocate that manually now.
Signed-off-by Christian König <[email protected]>Fixes 2ddef17678bc (HEAD) drm/ttm: make TT creation purely optional v3
Reviewed-by Michel Dänzer <[email protected]>
Tested-by Michel Dänzer <[email protected]>
Thanks!
Signature · 6 lines
Earthling Michel Dänzer | https://redhat.com Libre software enthusiast | Mesa and X developer _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 16 lines · Christian König
We need to allocate that manually now.
Signed-off-by Christian König <[email protected]>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(-)drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c static int init_user_pages(struct kgd_mem *mem, uint64_t user_addr) · line 570
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +1
-1@@ -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.
Signature · 6 lines
Earthling Michel Dänzer | https://redhat.com Libre software enthusiast | Mesa and X developer _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx