drm/amdgpu: fix GTT offset handling
Subsystems (2)
PATCH 1/2 drm/amdgpu: fix GTT offset handling
From: Christian König <[email protected]>
Otherwise we run into problems on 32bit systems with more than 4GB GART.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +5 -5
@@ -649,7 +649,7 @@ static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm,return r; } } - gtt->offset = (unsigned long )(bo_mem->start <<PAGE_SHIFT ); + gtt->offset = (u64 )bo_mem->start <<PAGE_SHIFT ;if (!ttm->num_pages) {WARN (1 ,"nothing to bind %lu pages for mreg %p back %p!\n" , ttm->num_pages, bo_mem, ttm);
@@ -664,8 +664,8 @@ static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm, ttm->pages, gtt->ttm.dma_address, flags);if (r) { -DRM_ERROR ("failed to bind %lu pages at 0x%08X\n" , - ttm->num_pages, (unsigned )gtt->offset); +DRM_ERROR ("failed to bind %lu pages at 0x%08llX\n" , + ttm->num_pages, gtt->offset);return r; }spin_lock (>t->adev->gtt_list_lock);
@@ -690,8 +690,8 @@ int amdgpu_ttm_recover_gart(struct amdgpu_device *adev) flags);if (r) {spin_unlock (&adev->gtt_list_lock); -DRM_ERROR ("failed to bind %lu pages at 0x%08X\n" , - gtt->ttm.ttm.num_pages, (unsigned )gtt->offset); +DRM_ERROR ("failed to bind %lu pages at 0x%08llX\n" , + gtt->ttm.ttm.num_pages, gtt->offset);return r; } }
Signature · 6 lines
2.5.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1473154866-2448-1-git-send-email-deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org
PATCH 2/2 drm/amdgpu: bind GTT on demand
From: Christian König <[email protected]>
We don't really need the GTT table any more most of the time. So bind it only on demand.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 34 ++++++++++++++++++++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 7 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 33 ++++++++++++++++++++++++++--- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | 3 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 6 +++++- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 3 ++- 8 files changed, 84 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
@@ -2521,6 +2521,7 @@ static inline void amdgpu_acpi_fini(struct amdgpu_device *adev) { }struct amdgpu_bo_va_mapping *amdgpu_cs_find_mapping (struct amdgpu_cs_parser *parser,uint64_t addr,struct amdgpu_bo **bo); +int amdgpu_cs_sysvm_access_required (struct amdgpu_cs_parser *parser);#if defined(CONFIG_DRM_AMD_DAL )int amdgpu_dm_display_resume (struct amdgpu_device *adev );
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +32 -2
@@ -640,8 +640,12 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p, } } -if (p->uf_entry.robj) - p->job->uf_addr +=amdgpu_bo_gpu_offset (p->uf_entry.robj); +if (!r && p->uf_entry.robj) { +struct amdgpu_bo *uf = p->uf_entry.robj; + + r =amdgpu_ttm_bind (uf->tbo.ttm, &uf->tbo.mem); + p->job->uf_addr +=amdgpu_bo_gpu_offset (uf); + } error_validate:if (r) {
@@ -1156,3 +1160,29 @@ amdgpu_cs_find_mapping(struct amdgpu_cs_parser *parser,return NULL ; } + +/** +* amdgpu_cs_sysvm_access_required - make BOs accessible by the system VM +* +* @parser: command submission parser context +* +* Helper for UVD/VCE VM emulation, make sure BOs are accessible by the system VM. +*/ +int amdgpu_cs_sysvm_access_required (struct amdgpu_cs_parser *parser) +{ +unsigned i; +int r; + +if (!parser->bo_list) +return 0 ; + +for (i =0 ; i < parser->bo_list->num_entries; i++) { +struct amdgpu_bo *bo = parser->bo_list->array[i].robj; + + r =amdgpu_ttm_bind (bo->tbo.ttm, &bo->tbo.mem); +if (unlikely (r)) +return r; + } + +return 0 ; +}
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +7 -0
@@ -646,6 +646,11 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,dev_err (bo->adev->dev,"%p pin failed\n" , bo); goto error; } + r =amdgpu_ttm_bind (bo->tbo.ttm, &bo->tbo.mem); +if (unlikely (r)) { +dev_err (bo->adev->dev,"%p bind failed\n" , bo); + goto error; + } bo->pin_count =1 ;if (gpu_addr !=NULL )
@@ -918,6 +923,8 @@ void amdgpu_bo_fence(struct amdgpu_bo *bo, struct fence *fence,u64 amdgpu_bo_gpu_offset (struct amdgpu_bo *bo) {WARN_ON_ONCE (bo->tbo.mem.mem_type ==TTM_PL_SYSTEM ); +WARN_ON_ONCE (bo->tbo.mem.mem_type ==TTM_PL_TT && + !amdgpu_ttm_is_bound (bo->tbo.ttm));WARN_ON_ONCE (!ww_mutex_is_locked (&bo->tbo.resv->lock) && !bo->pin_count);
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +30 -3
@@ -256,8 +256,12 @@ static int amdgpu_move_blit(struct ttm_buffer_object *bo, new_start = (u64 )new_mem->start <<PAGE_SHIFT ;switch (old_mem->mem_type) { -case TTM_PL_VRAM :case TTM_PL_TT : + r =amdgpu_ttm_bind (bo->ttm, old_mem); +if (r) +return r; + +case TTM_PL_VRAM : old_start += bo->bdev->man[old_mem->mem_type].gpu_offset;break ;default :
@@ -265,8 +269,12 @@ static int amdgpu_move_blit(struct ttm_buffer_object *bo,return -EINVAL ; }switch (new_mem->mem_type) { -case TTM_PL_VRAM :case TTM_PL_TT : + r =amdgpu_ttm_bind (bo->ttm, new_mem); +if (r) +return r; + +case TTM_PL_VRAM : new_start += bo->bdev->man[new_mem->mem_type].gpu_offset;break ;default :
@@ -639,7 +647,6 @@ static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm, struct ttm_mem_reg *bo_mem) {struct amdgpu_ttm_tt *gtt = (void *)ttm; -uint32_t flags =amdgpu_ttm_tt_pte_flags (gtt->adev, ttm, bo_mem);int r;if (gtt->userptr) {
@@ -660,6 +667,26 @@ static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm, bo_mem->mem_type == AMDGPU_PL_OA)return -EINVAL ; +return 0 ; +} + +bool amdgpu_ttm_is_bound (struct ttm_tt *ttm) +{ +struct amdgpu_ttm_tt *gtt = (void *)ttm; + +return gtt && !list_empty (>t->list); +} + +int amdgpu_ttm_bind (struct ttm_tt *ttm,struct ttm_mem_reg *bo_mem) +{ +struct amdgpu_ttm_tt *gtt = (void *)ttm; +uint32_t flags; +int r; + +if (!ttm ||amdgpu_ttm_is_bound (ttm)) +return 0 ; + + flags =amdgpu_ttm_tt_pte_flags (gtt->adev, ttm, bo_mem); r =amdgpu_gart_bind (gtt->adev, gtt->offset, ttm->num_pages, ttm->pages, gtt->ttm.dma_address, flags);
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +3 -0
@@ -77,4 +77,7 @@ int amdgpu_fill_buffer(struct amdgpu_bo *bo, struct fence **fence);int amdgpu_mmap (struct file *filp,struct vm_area_struct *vma); +bool amdgpu_ttm_is_bound (struct ttm_tt *ttm); +int amdgpu_ttm_bind (struct ttm_tt *ttm,struct ttm_mem_reg *bo_mem); +#endif
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +4 -0
@@ -891,6 +891,10 @@ int amdgpu_uvd_ring_parse_cs(struct amdgpu_cs_parser *parser, uint32_t ib_idx)return -EINVAL ; } + r =amdgpu_cs_sysvm_access_required (parser); +if (r) +return r; + ctx.parser = parser; ctx.buf_sizes = buf_sizes; ctx.ib_idx = ib_idx;
drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c +5 -1
@@ -634,7 +634,11 @@ int amdgpu_vce_ring_parse_cs(struct amdgpu_cs_parser *p, uint32_t ib_idx)uint32_t allocated =0 ;uint32_t tmp, handle =0 ;uint32_t *size = &tmp; -int i, r =0 , idx =0 ; +int i, r, idx =0 ; + + r =amdgpu_cs_sysvm_access_required (p); +if (r) +return r;while (idx < ib->length_dw) {uint32_t len =amdgpu_get_ib_value (p, ib_idx, idx);
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2 -1
@@ -1162,7 +1162,8 @@ int amdgpu_vm_bo_update(struct amdgpu_device *adev, } flags =amdgpu_ttm_tt_pte_flags (adev, bo_va->bo->tbo.ttm, mem); - gtt_flags = (adev == bo_va->bo->adev) ? flags :0 ; + gtt_flags = (amdgpu_ttm_is_bound (bo_va->bo->tbo.ttm) && + adev == bo_va->bo->adev) ? flags :0 ;spin_lock (&vm->status_lock);if (!list_empty (&bo_va->vm_status))
Signature · 6 lines
2.5.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1473154866-2448-2-git-send-email-deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org
Re: [PATCH 2/2] drm/amdgpu: bind GTT on demand
Quoted 3 lines · Christian König
From: Christian König <[email protected]>
We don't really need the GTT table any more most of the time.
Why? I thought GTT bo is always needed to be bound when GPU is trying to access it, doesn't it?
Regards,
David Zhou
Quoted 217 lines
So bind it
only on demand.Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 34 ++++++++++++++++++++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 7 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 33 ++++++++++++++++++++++++++--- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | 3 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 6 +++++- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 3 ++- 8 files changed, 84 insertions(+), 7 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +1
-0@@ -2521,6 +2521,7 @@ static inline void amdgpu_acpi_fini(struct amdgpu_device *adev) { }struct amdgpu_bo_va_mapping *amdgpu_cs_find_mapping (struct amdgpu_cs_parser *parser,uint64_t addr,struct amdgpu_bo **bo); +int amdgpu_cs_sysvm_access_required (struct amdgpu_cs_parser *parser);#if defined(CONFIG_DRM_AMD_DAL )int amdgpu_dm_display_resume (struct amdgpu_device *adev );drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +32
-2@@ -640,8 +640,12 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p, } } -if (p->uf_entry.robj) - p->job->uf_addr +=amdgpu_bo_gpu_offset (p->uf_entry.robj); +if (!r && p->uf_entry.robj) { +struct amdgpu_bo *uf = p->uf_entry.robj; + + r =amdgpu_ttm_bind (uf->tbo.ttm, &uf->tbo.mem); + p->job->uf_addr +=amdgpu_bo_gpu_offset (uf); + } error_validate:if (r) {@@ -1156,3 +1160,29 @@ amdgpu_cs_find_mapping(struct amdgpu_cs_parser *parser,return NULL ; } + +/** +* amdgpu_cs_sysvm_access_required - make BOs accessible by the system VM +* +* @parser: command submission parser context +* +* Helper for UVD/VCE VM emulation, make sure BOs are accessible by the system VM. +*/ +int amdgpu_cs_sysvm_access_required (struct amdgpu_cs_parser *parser) +{ +unsigned i; +int r; + +if (!parser->bo_list) +return 0 ; + +for (i =0 ; i < parser->bo_list->num_entries; i++) { +struct amdgpu_bo *bo = parser->bo_list->array[i].robj; + + r =amdgpu_ttm_bind (bo->tbo.ttm, &bo->tbo.mem); +if (unlikely (r)) +return r; + } + +return 0 ; +}drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +7
-0@@ -646,6 +646,11 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,dev_err (bo->adev->dev,"%p pin failed\n" , bo); goto error; } + r =amdgpu_ttm_bind (bo->tbo.ttm, &bo->tbo.mem); +if (unlikely (r)) { +dev_err (bo->adev->dev,"%p bind failed\n" , bo); + goto error; + } bo->pin_count =1 ;if (gpu_addr !=NULL )@@ -918,6 +923,8 @@ void amdgpu_bo_fence(struct amdgpu_bo *bo, struct fence *fence,u64 amdgpu_bo_gpu_offset (struct amdgpu_bo *bo) {WARN_ON_ONCE (bo->tbo.mem.mem_type ==TTM_PL_SYSTEM ); +WARN_ON_ONCE (bo->tbo.mem.mem_type ==TTM_PL_TT && + !amdgpu_ttm_is_bound (bo->tbo.ttm));WARN_ON_ONCE (!ww_mutex_is_locked (&bo->tbo.resv->lock) && !bo->pin_count);drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +30
-3@@ -256,8 +256,12 @@ static int amdgpu_move_blit(struct ttm_buffer_object *bo, new_start = (u64 )new_mem->start <<PAGE_SHIFT ;switch (old_mem->mem_type) { -case TTM_PL_VRAM :case TTM_PL_TT : + r =amdgpu_ttm_bind (bo->ttm, old_mem); +if (r) +return r; + +case TTM_PL_VRAM : old_start += bo->bdev->man[old_mem->mem_type].gpu_offset;break ;default :@@ -265,8 +269,12 @@ static int amdgpu_move_blit(struct ttm_buffer_object *bo,return -EINVAL ; }switch (new_mem->mem_type) { -case TTM_PL_VRAM :case TTM_PL_TT : + r =amdgpu_ttm_bind (bo->ttm, new_mem); +if (r) +return r; + +case TTM_PL_VRAM : new_start += bo->bdev->man[new_mem->mem_type].gpu_offset;break ;default :@@ -639,7 +647,6 @@ static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm, struct ttm_mem_reg *bo_mem) {struct amdgpu_ttm_tt *gtt = (void *)ttm; -uint32_t flags =amdgpu_ttm_tt_pte_flags (gtt->adev, ttm, bo_mem);int r;if (gtt->userptr) {@@ -660,6 +667,26 @@ static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm, bo_mem->mem_type == AMDGPU_PL_OA)return -EINVAL ; +return 0 ; +} + +bool amdgpu_ttm_is_bound (struct ttm_tt *ttm) +{ +struct amdgpu_ttm_tt *gtt = (void *)ttm; + +return gtt && !list_empty (>t->list); +} + +int amdgpu_ttm_bind (struct ttm_tt *ttm,struct ttm_mem_reg *bo_mem) +{ +struct amdgpu_ttm_tt *gtt = (void *)ttm; +uint32_t flags; +int r; + +if (!ttm ||amdgpu_ttm_is_bound (ttm)) +return 0 ; + + flags =amdgpu_ttm_tt_pte_flags (gtt->adev, ttm, bo_mem); r =amdgpu_gart_bind (gtt->adev, gtt->offset, ttm->num_pages, ttm->pages, gtt->ttm.dma_address, flags);drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +3
-0@@ -77,4 +77,7 @@ int amdgpu_fill_buffer(struct amdgpu_bo *bo, struct fence **fence);int amdgpu_mmap (struct file *filp,struct vm_area_struct *vma); +bool amdgpu_ttm_is_bound (struct ttm_tt *ttm); +int amdgpu_ttm_bind (struct ttm_tt *ttm,struct ttm_mem_reg *bo_mem); +#endif drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +4
-0@@ -891,6 +891,10 @@ int amdgpu_uvd_ring_parse_cs(struct amdgpu_cs_parser *parser, uint32_t ib_idx)return -EINVAL ; } + r =amdgpu_cs_sysvm_access_required (parser); +if (r) +return r; + ctx.parser = parser; ctx.buf_sizes = buf_sizes; ctx.ib_idx = ib_idx;drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c +5
-1@@ -634,7 +634,11 @@ int amdgpu_vce_ring_parse_cs(struct amdgpu_cs_parser *p, uint32_t ib_idx)uint32_t allocated =0 ;uint32_t tmp, handle =0 ;uint32_t *size = &tmp; -int i, r =0 , idx =0 ; +int i, r, idx =0 ; + + r =amdgpu_cs_sysvm_access_required (p); +if (r) +return r;while (idx < ib->length_dw) {uint32_t len =amdgpu_get_ib_value (p, ib_idx, idx);drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_bo_update(struct amdgpu_device *adev, · line 1169
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2
-1@@ -1162,7 +1162,8 @@ int amdgpu_vm_bo_update(struct amdgpu_device *adev, } flags =amdgpu_ttm_tt_pte_flags (adev, bo_va->bo->tbo.ttm, mem); - gtt_flags = (adev == bo_va->bo->adev) ? flags :0 ; + gtt_flags = (amdgpu_ttm_is_bound (bo_va->bo->tbo.ttm) && + adev == bo_va->bo->adev) ? flags :0 ;spin_lock (&vm->status_lock);if (!list_empty (&bo_va->vm_status))
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH 2/2] drm/amdgpu: bind GTT on demand
Am 06.09.2016 um 11:53 schrieb zhoucm1:
Quoted 7 lines · Christian König
Quoted 3 lines
From: Christian König <[email protected]>
We don't really need the GTT table any more most of the time.
Why? I thought GTT bo is always needed to be bound when GPU is trying to access it, doesn't it?
We only need it to be bound when we try to access it from the system VM (UVD/VCE, ring buffers, fences etc...).
The VMs for each process can work without it and it is just overhead to bind it all the time.
Regards,
Christian.
Quoted 224 lines
Regards,
David ZhouQuoted 221 lines
So bind it
only on demand.Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 34 ++++++++++++++++++++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 7 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 33 ++++++++++++++++++++++++++--- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | 3 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 6 +++++- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 3 ++- 8 files changed, 84 insertions(+), 7 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +1
-0@@ -2521,6 +2521,7 @@ static inline void amdgpu_acpi_fini(struct amdgpu_device *adev) { }struct amdgpu_bo_va_mapping *amdgpu_cs_find_mapping (struct amdgpu_cs_parser *parser,uint64_t addr,struct amdgpu_bo **bo); +int amdgpu_cs_sysvm_access_required (struct amdgpu_cs_parser *parser);#if defined(CONFIG_DRM_AMD_DAL )int amdgpu_dm_display_resume (struct amdgpu_device *adev );drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +9
-1@@ -640,8 +640,12 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p, } } - if (p->uf_entry.robj) - p->job->uf_addr += amdgpu_bo_gpu_offset(p->uf_entry.robj); +if (!r && p->uf_entry.robj) { +struct amdgpu_bo *uf = p->uf_entry.robj; + + r =amdgpu_ttm_bind (uf->tbo.ttm, &uf->tbo.mem); + p->job->uf_addr +=amdgpu_bo_gpu_offset (uf); + } error_validate:if (r) {@@ -1156,3 +1160,29 @@ amdgpu_cs_find_mapping(struct amdgpu_cs_parser *parser, return NULL; } + +/** +* amdgpu_cs_sysvm_access_required - make BOs accessible by the system VM
+ *
+ * @parser: command submission parser context
+ *
+ * Helper for UVD/VCE VM emulation, make sure BOs are accessible by the system VM.
+ */drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +18
-0+int amdgpu_cs_sysvm_access_required (struct amdgpu_cs_parser *parser) +{ +unsigned i; +int r; + +if (!parser->bo_list) +return 0 ; + +for (i =0 ; i < parser->bo_list->num_entries; i++) { +struct amdgpu_bo *bo = parser->bo_list->array[i].robj; + + r =amdgpu_ttm_bind (bo->tbo.ttm, &bo->tbo.mem); +if (unlikely (r)) +return r; + } + +return 0 ; +}drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +7
-0@@ -646,6 +646,11 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,dev_err (bo->adev->dev,"%p pin failed\n" , bo); goto error; } + r =amdgpu_ttm_bind (bo->tbo.ttm, &bo->tbo.mem); +if (unlikely (r)) { +dev_err (bo->adev->dev,"%p bind failed\n" , bo); + goto error; + } bo->pin_count =1 ;if (gpu_addr !=NULL )@@ -918,6 +923,8 @@ void amdgpu_bo_fence(struct amdgpu_bo *bo, structfence *fence, u64 amdgpu_bo_gpu_offset(struct amdgpu_bo *bo) { WARN_ON_ONCE(bo->tbo.mem.mem_type == TTM_PL_SYSTEM); +WARN_ON_ONCE (bo->tbo.mem.mem_type ==TTM_PL_TT && + !amdgpu_ttm_is_bound (bo->tbo.ttm));WARN_ON_ONCE(!ww_mutex_is_locked(&bo->tbo.resv->lock) &&
!bo->pin_count);diff --git
a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.cindex 4337b3a..c294aa9 100644drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +10
-2@@ -256,8 +256,12 @@ static int amdgpu_move_blit(structttm_buffer_object *bo, new_start = (u64 )new_mem->start <<PAGE_SHIFT ;switch (old_mem->mem_type) { -case TTM_PL_VRAM :case TTM_PL_TT : + r =amdgpu_ttm_bind (bo->ttm, old_mem); +if (r) +return r; + +case TTM_PL_VRAM : old_start += bo->bdev->man[old_mem->mem_type].gpu_offset;break ;default :@@ -265,8 +269,12 @@ static int amdgpu_move_blit(struct ttm_buffer_object *bo, return -EINVAL ; }switch (new_mem->mem_type) { -case TTM_PL_VRAM :case TTM_PL_TT : + r =amdgpu_ttm_bind (bo->ttm, new_mem); +if (r) +return r; + +case TTM_PL_VRAM : new_start += bo->bdev->man[new_mem->mem_type].gpu_offset;break ;default:
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +19
-1@@ -639,7 +647,6 @@ static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm, struct ttm_mem_reg *bo_mem) {struct amdgpu_ttm_tt *gtt = (void *)ttm; -uint32_t flags =amdgpu_ttm_tt_pte_flags (gtt->adev, ttm, bo_mem);int r;if (gtt->userptr) {@@ -660,6 +667,26 @@ static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm, bo_mem->mem_type == AMDGPU_PL_OA)return -EINVAL ; + return 0; +} + +bool amdgpu_ttm_is_bound (struct ttm_tt *ttm) +{ +struct amdgpu_ttm_tt *gtt = (void *)ttm; + +return gtt && !list_empty (>t->list); +} + +int amdgpu_ttm_bind (struct ttm_tt *ttm,struct ttm_mem_reg *bo_mem) +{ +struct amdgpu_ttm_tt *gtt = (void *)ttm; +uint32_t flags; +int r; + +if (!ttm ||amdgpu_ttm_is_bound (ttm)) +return 0 ; + + flags =amdgpu_ttm_tt_pte_flags (gtt->adev, ttm, bo_mem); r =amdgpu_gart_bind (gtt->adev, gtt->offset, ttm->num_pages, ttm->pages, gtt->ttm.dma_address, flags); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
index 72f6bfc..214bae9 100644drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +3
-0@@ -77,4 +77,7 @@ int amdgpu_fill_buffer(struct amdgpu_bo *bo, struct fence **fence);int amdgpu_mmap (struct file *filp,struct vm_area_struct *vma); +bool amdgpu_ttm_is_bound (struct ttm_tt *ttm); +int amdgpu_ttm_bind (struct ttm_tt *ttm,struct ttm_mem_reg *bo_mem); +#endif drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +3
-0@@ -891,6 +891,10 @@ int amdgpu_uvd_ring_parse_cs(struct amdgpu_cs_parser *parser, uint32_t ib_idx) return -EINVAL; } + r =amdgpu_cs_sysvm_access_required (parser); +if (r) +return r; + ctx.parser = parser; ctx.buf_sizes = buf_sizes; ctx.ib_idx = ib_idx;drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c +5
-1@@ -634,7 +634,11 @@ int amdgpu_vce_ring_parse_cs(struct amdgpu_cs_parser *p, uint32_t ib_idx) uint32_t allocated = 0;uint32_t tmp, handle =0 ;uint32_t *size = &tmp; -int i, r =0 , idx =0 ; +int i, r, idx =0 ; + + r =amdgpu_cs_sysvm_access_required (p); +if (r) +return r;while (idx < ib->length_dw) {uint32_t len =amdgpu_get_ib_value (p, ib_idx, idx);drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0
-0@@ -1162,7 +1162,8 @@ int amdgpu_vm_bo_update(struct amdgpu_device
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_bo_update(struct amdgpu_device *adev, · line 1169
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2
-1*adev, } flags =amdgpu_ttm_tt_pte_flags (adev, bo_va->bo->tbo.ttm, mem); - gtt_flags = (adev == bo_va->bo->adev) ? flags :0 ; + gtt_flags = (amdgpu_ttm_is_bound (bo_va->bo->tbo.ttm) && + adev == bo_va->bo->adev) ? flags :0 ;spin_lock (&vm->status_lock);if (!list_empty (&bo_va->vm_status))
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): e3ec968a-32b0-cfdd-36d3-6f07b0f5e14b-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org
Re: [PATCH 2/2] drm/amdgpu: bind GTT on demand
Quoted 4 lines · Christian König
Am 06.09.2016 um 11:53 schrieb zhoucm1:
Quoted 3 lines · Christian König
Quoted 8 lines
Quoted 4 lines
Quoted 3 lines
From: Christian König <[email protected]>
We don't really need the GTT table any more most of the time.
Why? I thought GTT bo is always needed to be bound when GPU is trying to access it, doesn't it?
We only need it to be bound when we try to access it from the system VM (UVD/VCE, ring buffers, fences etc...).
The VMs for each process can work without it and it is just overhead to bind it all the time.
Yes, I got your mean, copying pte from GART to VM confused me, I thought binding GTT table is a must, that's wrong.
Go though vm code again, pte can be created by amdgpu_vm_map_gart if no GTT pte source when we don't bind it at all under VM process, am I right now?
Regards,
David Zhou
Quoted 239 lines
Regards,
Christian.Quoted 224 lines
Regards,
David ZhouQuoted 221 lines
So bind it
only on demand.Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 34 ++++++++++++++++++++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 7 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 33 ++++++++++++++++++++++++++--- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | 3 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 6 +++++- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 3 ++- 8 files changed, 84 insertions(+), 7 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +1
-0@@ -2521,6 +2521,7 @@ static inline void amdgpu_acpi_fini(struct amdgpu_device *adev) { }struct amdgpu_bo_va_mapping *amdgpu_cs_find_mapping (struct amdgpu_cs_parser *parser,uint64_t addr,struct amdgpu_bo **bo); +int amdgpu_cs_sysvm_access_required (struct amdgpu_cs_parser *parser);#if defined(CONFIG_DRM_AMD_DAL )int amdgpu_dm_display_resume (struct amdgpu_device *adev );drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +9
-1@@ -640,8 +640,12 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p, } } - if (p->uf_entry.robj) - p->job->uf_addr += amdgpu_bo_gpu_offset(p->uf_entry.robj); +if (!r && p->uf_entry.robj) { +struct amdgpu_bo *uf = p->uf_entry.robj; + + r =amdgpu_ttm_bind (uf->tbo.ttm, &uf->tbo.mem); + p->job->uf_addr +=amdgpu_bo_gpu_offset (uf); + } error_validate:if (r) {@@ -1156,3 +1160,29 @@ amdgpu_cs_find_mapping(structamdgpu_cs_parser *parser, return NULL; } + +/** +* amdgpu_cs_sysvm_access_required - make BOs accessible by the system VM
+ *
+ * @parser: command submission parser context
+ *
+ * Helper for UVD/VCE VM emulation, make sure BOs are accessible by the system VM.
+ */drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +18
-0+int amdgpu_cs_sysvm_access_required (struct amdgpu_cs_parser *parser) +{ +unsigned i; +int r; + +if (!parser->bo_list) +return 0 ; + +for (i =0 ; i < parser->bo_list->num_entries; i++) { +struct amdgpu_bo *bo = parser->bo_list->array[i].robj; + + r =amdgpu_ttm_bind (bo->tbo.ttm, &bo->tbo.mem); +if (unlikely (r)) +return r; + } + +return 0 ; +}drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +7
-0@@ -646,6 +646,11 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,dev_err (bo->adev->dev,"%p pin failed\n" , bo); goto error; } + r =amdgpu_ttm_bind (bo->tbo.ttm, &bo->tbo.mem); +if (unlikely (r)) { +dev_err (bo->adev->dev,"%p bind failed\n" , bo); + goto error; + } bo->pin_count =1 ;if (gpu_addr !=NULL )@@ -918,6 +923,8 @@ void amdgpu_bo_fence(struct amdgpu_bo *bo,struct fence *fence, u64 amdgpu_bo_gpu_offset(struct amdgpu_bo *bo) { WARN_ON_ONCE(bo->tbo.mem.mem_type == TTM_PL_SYSTEM); +WARN_ON_ONCE (bo->tbo.mem.mem_type ==TTM_PL_TT && + !amdgpu_ttm_is_bound (bo->tbo.ttm));WARN_ON_ONCE(!ww_mutex_is_locked(&bo->tbo.resv->lock) &&
!bo->pin_count);diff --git
a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.cindex 4337b3a..c294aa9 100644drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +10
-2@@ -256,8 +256,12 @@ static int amdgpu_move_blit(structttm_buffer_object *bo, new_start = (u64 )new_mem->start <<PAGE_SHIFT ;switch (old_mem->mem_type) { -case TTM_PL_VRAM :case TTM_PL_TT : + r =amdgpu_ttm_bind (bo->ttm, old_mem); +if (r) +return r; + +case TTM_PL_VRAM : old_start += bo->bdev->man[old_mem->mem_type].gpu_offset;break ;default :@@ -265,8 +269,12 @@ static int amdgpu_move_blit(struct ttm_buffer_object *bo, return -EINVAL ; }switch (new_mem->mem_type) { -case TTM_PL_VRAM :case TTM_PL_TT : + r =amdgpu_ttm_bind (bo->ttm, new_mem); +if (r) +return r; + +case TTM_PL_VRAM : new_start += bo->bdev->man[new_mem->mem_type].gpu_offset;break ;default:
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +19
-1@@ -639,7 +647,6 @@ static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm, struct ttm_mem_reg *bo_mem) {struct amdgpu_ttm_tt *gtt = (void *)ttm; -uint32_t flags =amdgpu_ttm_tt_pte_flags (gtt->adev, ttm, bo_mem);int r;if (gtt->userptr) {@@ -660,6 +667,26 @@ static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm, bo_mem->mem_type == AMDGPU_PL_OA)return -EINVAL ; + return 0; +} + +bool amdgpu_ttm_is_bound (struct ttm_tt *ttm) +{ +struct amdgpu_ttm_tt *gtt = (void *)ttm; + +return gtt && !list_empty (>t->list); +} + +int amdgpu_ttm_bind (struct ttm_tt *ttm,struct ttm_mem_reg *bo_mem) +{ +struct amdgpu_ttm_tt *gtt = (void *)ttm; +uint32_t flags; +int r; + +if (!ttm ||amdgpu_ttm_is_bound (ttm)) +return 0 ; + + flags =amdgpu_ttm_tt_pte_flags (gtt->adev, ttm, bo_mem); r =amdgpu_gart_bind (gtt->adev, gtt->offset, ttm->num_pages, ttm->pages, gtt->ttm.dma_address, flags); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
index 72f6bfc..214bae9 100644drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +3
-0@@ -77,4 +77,7 @@ int amdgpu_fill_buffer(struct amdgpu_bo *bo, struct fence **fence);int amdgpu_mmap (struct file *filp,struct vm_area_struct *vma); +bool amdgpu_ttm_is_bound (struct ttm_tt *ttm); +int amdgpu_ttm_bind (struct ttm_tt *ttm,struct ttm_mem_reg *bo_mem); +#endif drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +3
-0@@ -891,6 +891,10 @@ int amdgpu_uvd_ring_parse_cs(struct amdgpu_cs_parser *parser, uint32_t ib_idx) return -EINVAL; } + r =amdgpu_cs_sysvm_access_required (parser); +if (r) +return r; + ctx.parser = parser; ctx.buf_sizes = buf_sizes; ctx.ib_idx = ib_idx;drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c +5
-1@@ -634,7 +634,11 @@ int amdgpu_vce_ring_parse_cs(struct amdgpu_cs_parser *p, uint32_t ib_idx) uint32_t allocated = 0;uint32_t tmp, handle =0 ;uint32_t *size = &tmp; -int i, r =0 , idx =0 ; +int i, r, idx =0 ; + + r =amdgpu_cs_sysvm_access_required (p); +if (r) +return r;while (idx < ib->length_dw) {uint32_t len =amdgpu_get_ib_value (p, ib_idx, idx);drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0
-0@@ -1162,7 +1162,8 @@ int amdgpu_vm_bo_update(struct amdgpu_deviceQuoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_bo_update(struct amdgpu_device *adev, · line 1169
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2
-1*adev, } flags =amdgpu_ttm_tt_pte_flags (adev, bo_va->bo->tbo.ttm, mem); - gtt_flags = (adev == bo_va->bo->adev) ? flags :0 ; + gtt_flags = (amdgpu_ttm_is_bound (bo_va->bo->tbo.ttm) && + adev == bo_va->bo->adev) ? flags :0 ;spin_lock (&vm->status_lock);if (!list_empty (&bo_va->vm_status))
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH 2/2] drm/amdgpu: bind GTT on demand
Am 07.09.2016 um 09:18 schrieb zhoucm1:
Quoted 9 lines · Christian König
Quoted 6 lines
Am 06.09.2016 um 11:53 schrieb zhoucm1:
Quoted 5 lines · Christian König
Quoted 2 lines
From: Christian König <[email protected]>
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Quoted 1 line
We don't really need the GTT table any more most of the time.
Why? I thought GTT bo is always needed to be bound when GPU is trying to access it, doesn't it?
We only need it to be bound when we try to access it from the system VM (UVD/VCE, ring buffers, fences etc...).
The VMs for each process can work without it and it is just overhead to bind it all the time.
Yes, I got your mean, copying pte from GART to VM confused me, I thought binding GTT table is a must, that's wrong.
Go though vm code again, pte can be created byamdgpu_vm_map_gartif no GTT pte source when we don't bind it at all under VM process, am I right now?
Yes exactly. I still need to measure the performance impact of that, adding the copy from the GTT made quite a difference when I introduced that.
I hope that doing the write when the update the VM is still faster than doing the GTT write.
Regards,
Christian.
Quoted 249 lines
Regards,
David ZhouQuoted 244 lines
Regards,
Christian.Quoted 225 lines
Regards,
David ZhouQuoted 222 lines
So bind it
only on demand.Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 34 ++++++++++++++++++++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 7 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 33 ++++++++++++++++++++++++++--- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | 3 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 6 +++++- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 3 ++- 8 files changed, 84 insertions(+), 7 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +1
-0@@ -2521,6 +2521,7 @@ static inline void amdgpu_acpi_fini(struct amdgpu_device *adev) { }struct amdgpu_bo_va_mapping *amdgpu_cs_find_mapping (struct amdgpu_cs_parser *parser,uint64_t addr,struct amdgpu_bo **bo); +int amdgpu_cs_sysvm_access_required (struct amdgpu_cs_parser *parser);#if defined(CONFIG_DRM_AMD_DAL )int amdgpu_dm_display_resume (struct amdgpu_device *adev );drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +9
-1@@ -640,8 +640,12 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p, } } - if (p->uf_entry.robj) - p->job->uf_addr += amdgpu_bo_gpu_offset(p->uf_entry.robj); +if (!r && p->uf_entry.robj) { +struct amdgpu_bo *uf = p->uf_entry.robj; + + r =amdgpu_ttm_bind (uf->tbo.ttm, &uf->tbo.mem); + p->job->uf_addr +=amdgpu_bo_gpu_offset (uf); + } error_validate:if (r) {@@ -1156,3 +1160,29 @@ amdgpu_cs_find_mapping(structamdgpu_cs_parser *parser, return NULL; } + +/** +* amdgpu_cs_sysvm_access_required - make BOs accessible by the system VM
+ *
+ * @parser: command submission parser context
+ *
+ * Helper for UVD/VCE VM emulation, make sure BOs are accessible by the system VM.
+ */drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +18
-0+int amdgpu_cs_sysvm_access_required (struct amdgpu_cs_parser *parser) +{ +unsigned i; +int r; + +if (!parser->bo_list) +return 0 ; + +for (i =0 ; i < parser->bo_list->num_entries; i++) { +struct amdgpu_bo *bo = parser->bo_list->array[i].robj; + + r =amdgpu_ttm_bind (bo->tbo.ttm, &bo->tbo.mem); +if (unlikely (r)) +return r; + } + +return 0 ; +}drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +7
-0@@ -646,6 +646,11 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,dev_err (bo->adev->dev,"%p pin failed\n" , bo); goto error; } + r =amdgpu_ttm_bind (bo->tbo.ttm, &bo->tbo.mem); +if (unlikely (r)) { +dev_err (bo->adev->dev,"%p bind failed\n" , bo); + goto error; + } bo->pin_count =1 ;if (gpu_addr !=NULL )@@ -918,6 +923,8 @@ void amdgpu_bo_fence(struct amdgpu_bo *bo,struct fence *fence, u64 amdgpu_bo_gpu_offset(struct amdgpu_bo *bo) { WARN_ON_ONCE(bo->tbo.mem.mem_type == TTM_PL_SYSTEM); +WARN_ON_ONCE (bo->tbo.mem.mem_type ==TTM_PL_TT && + !amdgpu_ttm_is_bound (bo->tbo.ttm));WARN_ON_ONCE(!ww_mutex_is_locked(&bo->tbo.resv->lock) &&
!bo->pin_count);diff --git
a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.cindex 4337b3a..c294aa9 100644drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +10
-2@@ -256,8 +256,12 @@ static int amdgpu_move_blit(structttm_buffer_object *bo, new_start = (u64 )new_mem->start <<PAGE_SHIFT ;switch (old_mem->mem_type) { -case TTM_PL_VRAM :case TTM_PL_TT : + r =amdgpu_ttm_bind (bo->ttm, old_mem); +if (r) +return r; + +case TTM_PL_VRAM : old_start += bo->bdev->man[old_mem->mem_type].gpu_offset;break ;default :@@ -265,8 +269,12 @@ static int amdgpu_move_blit(struct ttm_buffer_object *bo, return -EINVAL ; }switch (new_mem->mem_type) { -case TTM_PL_VRAM :case TTM_PL_TT : + r =amdgpu_ttm_bind (bo->ttm, new_mem); +if (r) +return r; + +case TTM_PL_VRAM : new_start += bo->bdev->man[new_mem->mem_type].gpu_offset;break ;default:
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +19
-1@@ -639,7 +647,6 @@ static int amdgpu_ttm_backend_bind(structttm_tt *ttm, struct ttm_mem_reg *bo_mem) { struct amdgpu_ttm_tt *gtt = (void*)ttm; -uint32_t flags =amdgpu_ttm_tt_pte_flags (gtt->adev, ttm, bo_mem);int r;if (gtt->userptr) {@@ -660,6 +667,26 @@ static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm, bo_mem->mem_type == AMDGPU_PL_OA)return -EINVAL ; + return 0; +} + +bool amdgpu_ttm_is_bound (struct ttm_tt *ttm) +{ +struct amdgpu_ttm_tt *gtt = (void *)ttm; + +return gtt && !list_empty (>t->list); +} + +int amdgpu_ttm_bind (struct ttm_tt *ttm,struct ttm_mem_reg *bo_mem) +{ +struct amdgpu_ttm_tt *gtt = (void *)ttm; +uint32_t flags; +int r; + +if (!ttm ||amdgpu_ttm_is_bound (ttm)) +return 0 ; + + flags =amdgpu_ttm_tt_pte_flags (gtt->adev, ttm, bo_mem); r =amdgpu_gart_bind (gtt->adev, gtt->offset, ttm->num_pages, ttm->pages, gtt->ttm.dma_address, flags); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
index 72f6bfc..214bae9 100644drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +3
-0@@ -77,4 +77,7 @@ int amdgpu_fill_buffer(struct amdgpu_bo *bo, struct fence **fence);int amdgpu_mmap (struct file *filp,struct vm_area_struct *vma); +bool amdgpu_ttm_is_bound (struct ttm_tt *ttm); +int amdgpu_ttm_bind (struct ttm_tt *ttm,struct ttm_mem_reg *bo_mem); +#endif drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +3
-0@@ -891,6 +891,10 @@ int amdgpu_uvd_ring_parse_cs(struct amdgpu_cs_parser *parser, uint32_t ib_idx) return -EINVAL; } + r =amdgpu_cs_sysvm_access_required (parser); +if (r) +return r; + ctx.parser = parser; ctx.buf_sizes = buf_sizes; ctx.ib_idx = ib_idx;drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c +5
-1@@ -634,7 +634,11 @@ int amdgpu_vce_ring_parse_cs(struct amdgpu_cs_parser *p, uint32_t ib_idx) uint32_t allocated = 0;uint32_t tmp, handle =0 ;uint32_t *size = &tmp; -int i, r =0 , idx =0 ; +int i, r, idx =0 ; + + r =amdgpu_cs_sysvm_access_required (p); +if (r) +return r;while (idx < ib->length_dw) {uint32_t len =amdgpu_get_ib_value (p, ib_idx, idx);drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0
-0@@ -1162,7 +1162,8 @@ int amdgpu_vm_bo_update(struct amdgpu_device *adev,Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_bo_update(struct amdgpu_device · line 1169
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2
-1} flags =amdgpu_ttm_tt_pte_flags (adev, bo_va->bo->tbo.ttm, mem); - gtt_flags = (adev == bo_va->bo->adev) ? flags :0 ; + gtt_flags = (amdgpu_ttm_is_bound (bo_va->bo->tbo.ttm) && + adev == bo_va->bo->adev) ? flags :0 ;spin_lock (&vm->status_lock);if (!list_empty (&bo_va->vm_status))_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 24352e53-0c1c-8b55-0b39-35b3e5d350ff-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org
Felix Kuehling
Acked-byRe: [PATCH 2/2] drm/amdgpu: bind GTT on demand
Yeah, you save yourself the GTT update, which always uses the CPU. Instead you write the page table entries to IBs using the CPU. Will be interesting to see if that's a net speed-up or slow-down, if the difference is significant at all.
The patch looks good to me. Thanks for tackling this. I didn't review it too thoroughly, and if you forgot to map to GART somewhere important, I would probably have missed it.
Once we pull this change into the KFD branch, we can probably revert our ridiculous GART size without losing the ability to map lots of system memory to GPUVM. :)
Regards,
Felix
Quoted 293 lines · Christian König
Am 07.09.2016 um 09:18 schrieb zhoucm1:
Quoted 16 lines · Christian König
Quoted 13 lines
Am 06.09.2016 um 11:53 schrieb zhoucm1:
Quoted 8 lines · Christian König
Quoted 3 lines
From: Christian König <[email protected]>
We don't really need the GTT table any more most of the time.
Why? I thought GTT bo is always needed to be bound when GPU is trying to access it, doesn't it?
We only need it to be bound when we try to access it from the system VM (UVD/VCE, ring buffers, fences etc...).
Quoted 7 lines
Quoted 2 lines
The VMs for each process can work without it and it is just overhead to bind it all the time.
Yes, I got your mean, copying pte from GART to VM confused me, I thought binding GTT table is a must, that's wrong.
Go though vm code again, pte can be created byamdgpu_vm_map_gartif no GTT pte source when we don't bind it at all under VM process, am I right now?Yes exactly. I still need to measure the performance impact of that, adding the copy from the GTT made quite a difference when I introduced that.
I hope that doing the write when the update the VM is still faster than doing the GTT write.
Regards,
Christian.Quoted 257 lines
Regards,
David ZhouQuoted 252 lines
Regards,
Christian.Quoted 233 lines
Regards,
David ZhouQuoted 230 lines
So bind it
only on demand.Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 34 ++++++++++++++++++++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 7 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 33 ++++++++++++++++++++++++++--- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | 3 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 6 +++++- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 3 ++- 8 files changed, 84 insertions(+), 7 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +1
-0@@ -2521,6 +2521,7 @@ static inline void amdgpu_acpi_fini(struct amdgpu_device *adev) { }struct amdgpu_bo_va_mapping *amdgpu_cs_find_mapping (struct amdgpu_cs_parser *parser,uint64_t addr,struct amdgpu_bo **bo); +int amdgpu_cs_sysvm_access_required (struct amdgpu_cs_parser *parser);#if defined(CONFIG_DRM_AMD_DAL )int amdgpu_dm_display_resume(struct amdgpu_device *adev );drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +9
-1@@ -640,8 +640,12 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p, } } - if (p->uf_entry.robj) - p->job->uf_addr += amdgpu_bo_gpu_offset(p->uf_entry.robj); +if (!r && p->uf_entry.robj) { +struct amdgpu_bo *uf = p->uf_entry.robj; + + r =amdgpu_ttm_bind (uf->tbo.ttm, &uf->tbo.mem); + p->job->uf_addr +=amdgpu_bo_gpu_offset (uf); + } error_validate:if (r) {@@ -1156,3 +1160,29 @@ amdgpu_cs_find_mapping(structamdgpu_cs_parser *parser, return NULL; } + +/** +* amdgpu_cs_sysvm_access_required - make BOs accessible by the system VM
+ *
+ * @parser: command submission parser context
+ *
+ * Helper for UVD/VCE VM emulation, make sure BOs are accessible by the system VM.
+ */drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +18
-0+int amdgpu_cs_sysvm_access_required (struct amdgpu_cs_parser *parser) +{ +unsigned i; +int r; + +if (!parser->bo_list) +return 0 ; + +for (i =0 ; i < parser->bo_list->num_entries; i++) { +struct amdgpu_bo *bo = parser->bo_list->array[i].robj; + + r =amdgpu_ttm_bind (bo->tbo.ttm, &bo->tbo.mem); +if (unlikely (r)) +return r; + } + +return 0 ; +}drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +7
-0@@ -646,6 +646,11 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,dev_err (bo->adev->dev,"%p pin failed\n" , bo); goto error; } + r =amdgpu_ttm_bind (bo->tbo.ttm, &bo->tbo.mem); +if (unlikely (r)) { +dev_err (bo->adev->dev,"%p bind failed\n" , bo); + goto error; + } bo->pin_count =1 ;if (gpu_addr !=NULL )@@ -918,6 +923,8 @@ void amdgpu_bo_fence(struct amdgpu_bo *bo,struct fence *fence, u64 amdgpu_bo_gpu_offset(struct amdgpu_bo *bo) { WARN_ON_ONCE(bo->tbo.mem.mem_type == TTM_PL_SYSTEM); +WARN_ON_ONCE (bo->tbo.mem.mem_type ==TTM_PL_TT && + !amdgpu_ttm_is_bound (bo->tbo.ttm));WARN_ON_ONCE(!ww_mutex_is_locked(&bo->tbo.resv->lock) &&
!bo->pin_count);diff --git
a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.cindex 4337b3a..c294aa9 100644drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +10
-2@@ -256,8 +256,12 @@ static int amdgpu_move_blit(structttm_buffer_object *bo, new_start = (u64 )new_mem->start <<PAGE_SHIFT ;switch (old_mem->mem_type) { -case TTM_PL_VRAM :case TTM_PL_TT : + r =amdgpu_ttm_bind (bo->ttm, old_mem); +if (r) +return r; + +case TTM_PL_VRAM : old_start += bo->bdev->man[old_mem->mem_type].gpu_offset;break ;default :@@ -265,8 +269,12 @@ static int amdgpu_move_blit(struct ttm_buffer_object *bo, return -EINVAL ; }switch (new_mem->mem_type) { -case TTM_PL_VRAM :case TTM_PL_TT : + r =amdgpu_ttm_bind (bo->ttm, new_mem); +if (r) +return r; + +case TTM_PL_VRAM : new_start += bo->bdev->man[new_mem->mem_type].gpu_offset;break ;default:
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0
-1@@ -639,7 +647,6 @@ static int amdgpu_ttm_backend_bind(structttm_tt *ttm, struct ttm_mem_reg *bo_mem) { struct amdgpu_ttm_tt *gtt = (void*)ttm; -uint32_t flags =amdgpu_ttm_tt_pte_flags (gtt->adev, ttm, bo_mem);int r;if (gtt->userptr) {drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +19
-0@@ -660,6 +667,26 @@ static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm, bo_mem->mem_type == AMDGPU_PL_OA)return -EINVAL ; + return 0; +} + +bool amdgpu_ttm_is_bound (struct ttm_tt *ttm) +{ +struct amdgpu_ttm_tt *gtt = (void *)ttm; + +return gtt && !list_empty (>t->list); +} + +int amdgpu_ttm_bind (struct ttm_tt *ttm,struct ttm_mem_reg *bo_mem) +{ +struct amdgpu_ttm_tt *gtt = (void *)ttm; +uint32_t flags; +int r; + +if (!ttm ||amdgpu_ttm_is_bound (ttm)) +return 0 ; + + flags =amdgpu_ttm_tt_pte_flags (gtt->adev, ttm, bo_mem); r =amdgpu_gart_bind (gtt->adev, gtt->offset, ttm->num_pages, ttm->pages, gtt->ttm.dma_address, flags); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
index 72f6bfc..214bae9 100644drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +3
-0@@ -77,4 +77,7 @@ int amdgpu_fill_buffer(struct amdgpu_bo *bo, struct fence **fence);int amdgpu_mmap (struct file *filp,struct vm_area_struct *vma); +bool amdgpu_ttm_is_bound (struct ttm_tt *ttm); +int amdgpu_ttm_bind (struct ttm_tt *ttm,struct ttm_mem_reg *bo_mem); +#endif drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +3
-0@@ -891,6 +891,10 @@ int amdgpu_uvd_ring_parse_cs(struct amdgpu_cs_parser *parser, uint32_t ib_idx) return -EINVAL; } + r =amdgpu_cs_sysvm_access_required (parser); +if (r) +return r; + ctx.parser = parser; ctx.buf_sizes = buf_sizes; ctx.ib_idx = ib_idx;drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c +5
-1@@ -634,7 +634,11 @@ int amdgpu_vce_ring_parse_cs(struct amdgpu_cs_parser *p, uint32_t ib_idx) uint32_t allocated = 0;uint32_t tmp, handle =0 ;uint32_t *size = &tmp; -int i, r =0 , idx =0 ; +int i, r, idx =0 ; + + r =amdgpu_cs_sysvm_access_required (p); +if (r) +return r;while (idx < ib->length_dw) {uint32_t len =amdgpu_get_ib_value (p, ib_idx, idx);drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0
-0@@ -1162,7 +1162,8 @@ int amdgpu_vm_bo_update(struct amdgpu_device *adev,Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_bo_update(struct amdgpu_device · line 1169
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2
-1} flags =amdgpu_ttm_tt_pte_flags (adev, bo_va->bo->tbo.ttm, mem); - gtt_flags = (adev == bo_va->bo->adev) ? flags :0 ; + gtt_flags = (amdgpu_ttm_is_bound (bo_va->bo->tbo.ttm) && + adev == bo_va->bo->adev) ? flags :0 ;spin_lock (&vm->status_lock);if (!list_empty (&bo_va->vm_status))_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 2a4f24fa-6873-7c7f-486f-ef4f29efa63a-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 2/2] drm/amdgpu: bind GTT on demand
Quoted 3 lines
The patch looks good to me. Thanks for tackling this. I didn't review it too thoroughly, and if you forgot to map to GART somewhere important, I would probably have missed it.
Yeah that's also my biggest concern, but that should at least raise a WARN_ON().
Quoted 1 line
Acked-by Felix Kuehling <[email protected]>
Thanks.
Quoted 3 lines
Once we pull this change into the KFD branch, we can probably revert our ridiculous GART size without losing the ability to map lots of system memory to GPUVM. :)
Wait a second with that. You also need my second part of that work where I also stop assigning address space to all those buffers which aren't mapped.
But I'm still working on that.
Regards,
Christian.
Am 07.09.2016 um 18:07 schrieb Felix Kuehling:
Quoted 301 lines
Yeah, you save yourself the GTT update, which always uses the CPU. Instead you write the page table entries to IBs using the CPU. Will be interesting to see if that's a net speed-up or slow-down, if the difference is significant at all.
The patch looks good to me. Thanks for tackling this. I didn't review it too thoroughly, and if you forgot to map to GART somewhere important, I would probably have missed it.
Acked-by Felix Kuehling <[email protected]>Once we pull this change into the KFD branch, we can probably revert our ridiculous GART size without losing the ability to map lots of system memory to GPUVM. :)
Regards,
FelixQuoted 282 lines · Christian König
Am 07.09.2016 um 09:18 schrieb zhoucm1:
Quoted 13 lines · Christian König
Quoted 11 lines
Am 06.09.2016 um 11:53 schrieb zhoucm1:
Quoted 7 lines · Christian König
Quoted 3 lines
From: Christian König <[email protected]>
We don't really need the GTT table any more most of the time.
Why? I thought GTT bo is always needed to be bound when GPU is trying to access it, doesn't it?
We only need it to be bound when we try to access it from the system VM (UVD/VCE, ring buffers, fences etc...).
Quoted 7 lines
Quoted 2 lines
The VMs for each process can work without it and it is just overhead to bind it all the time.
Yes, I got your mean, copying pte from GART to VM confused me, I thought binding GTT table is a must, that's wrong.
Go though vm code again, pte can be created byamdgpu_vm_map_gartif no GTT pte source when we don't bind it at all under VM process, am I right now?Yes exactly. I still need to measure the performance impact of that, adding the copy from the GTT made quite a difference when I introduced that.
I hope that doing the write when the update the VM is still faster than doing the GTT write.
Regards,
Christian.Quoted 251 lines
Regards,
David ZhouQuoted 248 lines
Regards,
Christian.Quoted 232 lines
Regards,
David ZhouQuoted 230 lines
So bind it
only on demand.Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 34 ++++++++++++++++++++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 7 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 33 ++++++++++++++++++++++++++--- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | 3 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 6 +++++- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 3 ++- 8 files changed, 84 insertions(+), 7 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +1
-0@@ -2521,6 +2521,7 @@ static inline void amdgpu_acpi_fini(struct amdgpu_device *adev) { }struct amdgpu_bo_va_mapping *amdgpu_cs_find_mapping (struct amdgpu_cs_parser *parser,uint64_t addr,struct amdgpu_bo **bo); +int amdgpu_cs_sysvm_access_required (struct amdgpu_cs_parser *parser);#if defined(CONFIG_DRM_AMD_DAL )int amdgpu_dm_display_resume(struct amdgpu_device *adev );drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +9
-1@@ -640,8 +640,12 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p, } } - if (p->uf_entry.robj) - p->job->uf_addr += amdgpu_bo_gpu_offset(p->uf_entry.robj); +if (!r && p->uf_entry.robj) { +struct amdgpu_bo *uf = p->uf_entry.robj; + + r =amdgpu_ttm_bind (uf->tbo.ttm, &uf->tbo.mem); + p->job->uf_addr +=amdgpu_bo_gpu_offset (uf); + } error_validate:if (r) {@@ -1156,3 +1160,29 @@ amdgpu_cs_find_mapping(structamdgpu_cs_parser *parser, return NULL; } + +/** +* amdgpu_cs_sysvm_access_required - make BOs accessible by the system VM
+ *
+ * @parser: command submission parser context
+ *
+ * Helper for UVD/VCE VM emulation, make sure BOs are accessible by the system VM.
+ */drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +18
-0+int amdgpu_cs_sysvm_access_required (struct amdgpu_cs_parser *parser) +{ +unsigned i; +int r; + +if (!parser->bo_list) +return 0 ; + +for (i =0 ; i < parser->bo_list->num_entries; i++) { +struct amdgpu_bo *bo = parser->bo_list->array[i].robj; + + r =amdgpu_ttm_bind (bo->tbo.ttm, &bo->tbo.mem); +if (unlikely (r)) +return r; + } + +return 0 ; +}drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +7
-0@@ -646,6 +646,11 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,dev_err (bo->adev->dev,"%p pin failed\n" , bo); goto error; } + r =amdgpu_ttm_bind (bo->tbo.ttm, &bo->tbo.mem); +if (unlikely (r)) { +dev_err (bo->adev->dev,"%p bind failed\n" , bo); + goto error; + } bo->pin_count =1 ;if (gpu_addr !=NULL )@@ -918,6 +923,8 @@ void amdgpu_bo_fence(struct amdgpu_bo *bo,struct fence *fence, u64 amdgpu_bo_gpu_offset(struct amdgpu_bo *bo) { WARN_ON_ONCE(bo->tbo.mem.mem_type == TTM_PL_SYSTEM); +WARN_ON_ONCE (bo->tbo.mem.mem_type ==TTM_PL_TT && + !amdgpu_ttm_is_bound (bo->tbo.ttm));WARN_ON_ONCE(!ww_mutex_is_locked(&bo->tbo.resv->lock) &&
!bo->pin_count);diff --git
a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.cindex 4337b3a..c294aa9 100644drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +10
-2@@ -256,8 +256,12 @@ static int amdgpu_move_blit(structttm_buffer_object *bo, new_start = (u64 )new_mem->start <<PAGE_SHIFT ;switch (old_mem->mem_type) { -case TTM_PL_VRAM :case TTM_PL_TT : + r =amdgpu_ttm_bind (bo->ttm, old_mem); +if (r) +return r; + +case TTM_PL_VRAM : old_start += bo->bdev->man[old_mem->mem_type].gpu_offset;break ;default :@@ -265,8 +269,12 @@ static int amdgpu_move_blit(struct ttm_buffer_object *bo, return -EINVAL ; }switch (new_mem->mem_type) { -case TTM_PL_VRAM :case TTM_PL_TT : + r =amdgpu_ttm_bind (bo->ttm, new_mem); +if (r) +return r; + +case TTM_PL_VRAM : new_start += bo->bdev->man[new_mem->mem_type].gpu_offset;break ;default:
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0
-1@@ -639,7 +647,6 @@ static int amdgpu_ttm_backend_bind(structttm_tt *ttm, struct ttm_mem_reg *bo_mem) { struct amdgpu_ttm_tt *gtt = (void*)ttm; -uint32_t flags =amdgpu_ttm_tt_pte_flags (gtt->adev, ttm, bo_mem);int r;if (gtt->userptr) {drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +19
-0@@ -660,6 +667,26 @@ static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm, bo_mem->mem_type == AMDGPU_PL_OA)return -EINVAL ; + return 0; +} + +bool amdgpu_ttm_is_bound (struct ttm_tt *ttm) +{ +struct amdgpu_ttm_tt *gtt = (void *)ttm; + +return gtt && !list_empty (>t->list); +} + +int amdgpu_ttm_bind (struct ttm_tt *ttm,struct ttm_mem_reg *bo_mem) +{ +struct amdgpu_ttm_tt *gtt = (void *)ttm; +uint32_t flags; +int r; + +if (!ttm ||amdgpu_ttm_is_bound (ttm)) +return 0 ; + + flags =amdgpu_ttm_tt_pte_flags (gtt->adev, ttm, bo_mem); r =amdgpu_gart_bind (gtt->adev, gtt->offset, ttm->num_pages, ttm->pages, gtt->ttm.dma_address, flags); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
index 72f6bfc..214bae9 100644drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +3
-0@@ -77,4 +77,7 @@ int amdgpu_fill_buffer(struct amdgpu_bo *bo, struct fence **fence);int amdgpu_mmap (struct file *filp,struct vm_area_struct *vma); +bool amdgpu_ttm_is_bound (struct ttm_tt *ttm); +int amdgpu_ttm_bind (struct ttm_tt *ttm,struct ttm_mem_reg *bo_mem); +#endif drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +3
-0@@ -891,6 +891,10 @@ int amdgpu_uvd_ring_parse_cs(struct amdgpu_cs_parser *parser, uint32_t ib_idx) return -EINVAL; } + r =amdgpu_cs_sysvm_access_required (parser); +if (r) +return r; + ctx.parser = parser; ctx.buf_sizes = buf_sizes; ctx.ib_idx = ib_idx;drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c +5
-1@@ -634,7 +634,11 @@ int amdgpu_vce_ring_parse_cs(struct amdgpu_cs_parser *p, uint32_t ib_idx) uint32_t allocated = 0;uint32_t tmp, handle =0 ;uint32_t *size = &tmp; -int i, r =0 , idx =0 ; +int i, r, idx =0 ; + + r =amdgpu_cs_sysvm_access_required (p); +if (r) +return r;while (idx < ib->length_dw) {uint32_t len =amdgpu_get_ib_value (p, ib_idx, idx);drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0
-0@@ -1162,7 +1162,8 @@ int amdgpu_vm_bo_update(struct amdgpu_device *adev,Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_bo_update(struct amdgpu_device · line 1169
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2
-1} flags =amdgpu_ttm_tt_pte_flags (adev, bo_va->bo->tbo.ttm, mem); - gtt_flags = (adev == bo_va->bo->adev) ? flags :0 ; + gtt_flags = (amdgpu_ttm_is_bound (bo_va->bo->tbo.ttm) && + adev == bo_va->bo->adev) ? flags :0 ;spin_lock (&vm->status_lock);if (!list_empty (&bo_va->vm_status))_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 8 lines
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Deucher, Alexander
Reviewed-by Alex DeucherRE: [PATCH 2/2] drm/amdgpu: bind GTT on demand
In reply to a message not in the archiveQuoted 7 lines
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Christian König
Sent: Tuesday, September 06, 2016 5:41 AM
To: [email protected]
Subject: [PATCH 2/2] drm/amdgpu: bind GTT on demand
Quoted 6 lines
From: Christian König <[email protected]>
We don't really need the GTT table any more most of the time. So bind it only on demand.
Signed-off-by Christian König <[email protected]>
For the series:
Quoted 253 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 34 ++++++++++++++++++++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 7 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 33 ++++++++++++++++++++++++++--- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | 3 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 6 +++++- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 3 ++- 8 files changed, 84 insertions(+), 7 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +1
-0@@ -2521,6 +2521,7 @@ static inline void amdgpu_acpi_fini(struct amdgpu_device *adev) { }struct amdgpu_bo_va_mapping *amdgpu_cs_find_mapping (struct amdgpu_cs_parser *parser,uint64_t addr,struct amdgpu_bo **bo); +int amdgpu_cs_sysvm_access_required (struct amdgpu_cs_parser *parser);#if defined(CONFIG_DRM_AMD_DAL )int
amdgpu_dm_display_resume(struct amdgpu_device *adev );drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +6
-2@@ -640,8 +640,12 @@ static int amdgpu_cs_parser_bos(structamdgpu_cs_parser *p, } } -if (p->uf_entry.robj) - p->job->uf_addr +=amdgpu_bo_gpu_offset (p- >uf_entry.robj); +if (!r && p->uf_entry.robj) { +struct amdgpu_bo *uf = p->uf_entry.robj; + + r =amdgpu_ttm_bind (uf->tbo.ttm, &uf->tbo.mem); + p->job->uf_addr +=amdgpu_bo_gpu_offset (uf); + }
error_validate:drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +3
-0if (r) {@@ -1156,3 +1160,29 @@ amdgpu_cs_find_mapping(structamdgpu_cs_parser *parser, return NULL; } + +/** +* amdgpu_cs_sysvm_access_required - make BOs accessible by the system VM
+ *
+ * @parser: command submission parser context
+ *
+ * Helper for UVD/VCE VM emulation, make sure BOs are accessible by the system VM.
+ */drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +18
-0+int amdgpu_cs_sysvm_access_required (struct amdgpu_cs_parser *parser) +{ +unsigned i; +int r; + +if (!parser->bo_list) +return 0 ; + +for (i =0 ; i < parser->bo_list->num_entries; i++) { +struct amdgpu_bo *bo = parser->bo_list->array[i].robj; + + r =amdgpu_ttm_bind (bo->tbo.ttm, &bo->tbo.mem); +if (unlikely (r)) +return r; + } + +return 0 ; +}drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +5
-0@@ -646,6 +646,11 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,dev_err (bo->adev->dev,"%p pin failed\n" , bo); goto error; } + r =amdgpu_ttm_bind (bo->tbo.ttm, &bo->tbo.mem); +if (unlikely (r)) { +dev_err (bo->adev->dev,"%p bind failed\n" , bo); + goto error; + } bo->pin_count =1 ;drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +2
-0if (gpu_addr !=NULL )@@ -918,6 +923,8 @@ void amdgpu_bo_fence(struct amdgpu_bo *bo,struct fence *fence, u64 amdgpu_bo_gpu_offset(struct amdgpu_bo *bo) { WARN_ON_ONCE(bo->tbo.mem.mem_type == TTM_PL_SYSTEM); +WARN_ON_ONCE (bo->tbo.mem.mem_type ==TTM_PL_TT && + !amdgpu_ttm_is_bound (bo->tbo.ttm));WARN_ON_ONCE (!ww_mutex_is_locked (&bo->tbo.resv->lock) && !bo->pin_count);drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +5
-1@@ -256,8 +256,12 @@ static int amdgpu_move_blit(structttm_buffer_object *bo, new_start = (u64 )new_mem->start <<PAGE_SHIFT ;switch (old_mem->mem_type) { -case TTM_PL_VRAM :case TTM_PL_TT : + r =amdgpu_ttm_bind (bo->ttm, old_mem); +if (r) +return r; + +case TTM_PL_VRAM : old_start += bo->bdev->man[old_mem- >mem_type].gpu_offset;drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +5
-1break ;default :@@ -265,8 +269,12 @@ static int amdgpu_move_blit(struct ttm_buffer_object *bo, return -EINVAL ; }switch (new_mem->mem_type) { -case TTM_PL_VRAM :case TTM_PL_TT : + r =amdgpu_ttm_bind (bo->ttm, new_mem); +if (r) +return r; + +case TTM_PL_VRAM : new_start += bo->bdev->man[new_mem- >mem_type].gpu_offset;drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0
-1break ;default :@@ -639,7 +647,6 @@ static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm, struct ttm_mem_reg *bo_mem) {struct amdgpu_ttm_tt *gtt = (void *)ttm; -uint32_t flags =amdgpu_ttm_tt_pte_flags (gtt->adev, ttm, bo_mem);int r;drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +20
-0if (gtt->userptr) {@@ -660,6 +667,26 @@ static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm, bo_mem->mem_type == AMDGPU_PL_OA)return -EINVAL ; +return 0 ; +} + +bool amdgpu_ttm_is_bound (struct ttm_tt *ttm) +{ +struct amdgpu_ttm_tt *gtt = (void *)ttm; + +return gtt && !list_empty (>t->list); +} + +int amdgpu_ttm_bind (struct ttm_tt *ttm,struct ttm_mem_reg *bo_mem) +{ +struct amdgpu_ttm_tt *gtt = (void *)ttm; +uint32_t flags; +int r; + +if (!ttm ||amdgpu_ttm_is_bound (ttm)) +return 0 ; + + flags =amdgpu_ttm_tt_pte_flags (gtt->adev, ttm, bo_mem); r =amdgpu_gart_bind (gtt->adev, gtt->offset, ttm->num_pages, ttm->pages, gtt->ttm.dma_address, flags);drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +3
-0@@ -77,4 +77,7 @@ int amdgpu_fill_buffer(struct amdgpu_bo *bo, struct fence **fence);int amdgpu_mmap (struct file *filp,struct vm_area_struct *vma); +bool amdgpu_ttm_is_bound (struct ttm_tt *ttm); +int amdgpu_ttm_bind (struct ttm_tt *ttm,struct ttm_mem_reg *bo_mem); +#endif drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +4
-0@@ -891,6 +891,10 @@ int amdgpu_uvd_ring_parse_cs(struct amdgpu_cs_parser *parser, uint32_t ib_idx) return -EINVAL; } + r =amdgpu_cs_sysvm_access_required (parser); +if (r) +return r; + ctx.parser = parser; ctx.buf_sizes = buf_sizes;drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +0
-0ctx.ib_idx = ib_idx;drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c +5
-1@@ -634,7 +634,11 @@ int amdgpu_vce_ring_parse_cs(struct amdgpu_cs_parser *p, uint32_t ib_idx) uint32_t allocated = 0;uint32_t tmp, handle =0 ;uint32_t *size = &tmp; -int i, r =0 , idx =0 ; +int i, r, idx =0 ; + + r =amdgpu_cs_sysvm_access_required (p); +if (r) +return r;while (idx < ib->length_dw) {drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c +0
-0uint32_t len =amdgpu_get_ib_value (p, ib_idx, idx);drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2
-1@@ -1162,7 +1162,8 @@ int amdgpu_vm_bo_update(struct amdgpu_device *adev, } flags =amdgpu_ttm_tt_pte_flags (adev, bo_va->bo->tbo.ttm, mem); - gtt_flags = (adev == bo_va->bo->adev) ? flags :0 ; + gtt_flags = (amdgpu_ttm_is_bound (bo_va->bo->tbo.ttm) && + adev == bo_va->bo->adev) ? flags :0 ;spin_lock (&vm->status_lock);if (!list_empty(&bo_va->vm_status))
--
2.5.0
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 2/2] drm/amdgpu: bind GTT on demand
In reply to a message not in the archiveThis breaks Tonga such that it hangs. Reproducible quickly with:
R600_DEBUG=testdma glxgears
It's a randomized test that runs forever. It should hang within 2 seconds.
Marek
Quoted 231 lines · Christian König
From: Christian König <[email protected]>
We don't really need the GTT table any more most of the time. So bind it only on demand.
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 34 ++++++++++++++++++++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 7 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 33 ++++++++++++++++++++++++++--- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | 3 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 6 +++++- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 3 ++- 8 files changed, 84 insertions(+), 7 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +1
-0@@ -2521,6 +2521,7 @@ static inline void amdgpu_acpi_fini(struct amdgpu_device *adev) { }struct amdgpu_bo_va_mapping *amdgpu_cs_find_mapping (struct amdgpu_cs_parser *parser,uint64_t addr,struct amdgpu_bo **bo); +int amdgpu_cs_sysvm_access_required (struct amdgpu_cs_parser *parser);#if defined(CONFIG_DRM_AMD_DAL )int amdgpu_dm_display_resume (struct amdgpu_device *adev );drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +32
-2@@ -640,8 +640,12 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p, } } -if (p->uf_entry.robj) - p->job->uf_addr +=amdgpu_bo_gpu_offset (p->uf_entry.robj); +if (!r && p->uf_entry.robj) { +struct amdgpu_bo *uf = p->uf_entry.robj; + + r =amdgpu_ttm_bind (uf->tbo.ttm, &uf->tbo.mem); + p->job->uf_addr +=amdgpu_bo_gpu_offset (uf); + } error_validate:if (r) {@@ -1156,3 +1160,29 @@ amdgpu_cs_find_mapping(struct amdgpu_cs_parser *parser,return NULL ; } + +/** +* amdgpu_cs_sysvm_access_required - make BOs accessible by the system VM +* +* @parser: command submission parser context +* +* Helper for UVD/VCE VM emulation, make sure BOs are accessible by the system VM. +*/ +int amdgpu_cs_sysvm_access_required (struct amdgpu_cs_parser *parser) +{ +unsigned i; +int r; + +if (!parser->bo_list) +return 0 ; + +for (i =0 ; i < parser->bo_list->num_entries; i++) { +struct amdgpu_bo *bo = parser->bo_list->array[i].robj; + + r =amdgpu_ttm_bind (bo->tbo.ttm, &bo->tbo.mem); +if (unlikely (r)) +return r; + } + +return 0 ; +}drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +7
-0@@ -646,6 +646,11 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,dev_err (bo->adev->dev,"%p pin failed\n" , bo); goto error; } + r =amdgpu_ttm_bind (bo->tbo.ttm, &bo->tbo.mem); +if (unlikely (r)) { +dev_err (bo->adev->dev,"%p bind failed\n" , bo); + goto error; + } bo->pin_count =1 ;if (gpu_addr !=NULL )@@ -918,6 +923,8 @@ void amdgpu_bo_fence(struct amdgpu_bo *bo, struct fence *fence,u64 amdgpu_bo_gpu_offset (struct amdgpu_bo *bo) {WARN_ON_ONCE (bo->tbo.mem.mem_type ==TTM_PL_SYSTEM ); +WARN_ON_ONCE (bo->tbo.mem.mem_type ==TTM_PL_TT && + !amdgpu_ttm_is_bound (bo->tbo.ttm));WARN_ON_ONCE (!ww_mutex_is_locked (&bo->tbo.resv->lock) && !bo->pin_count);drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +30
-3@@ -256,8 +256,12 @@ static int amdgpu_move_blit(struct ttm_buffer_object *bo, new_start = (u64 )new_mem->start <<PAGE_SHIFT ;switch (old_mem->mem_type) { -case TTM_PL_VRAM :case TTM_PL_TT : + r =amdgpu_ttm_bind (bo->ttm, old_mem); +if (r) +return r; + +case TTM_PL_VRAM : old_start += bo->bdev->man[old_mem->mem_type].gpu_offset;break ;default :@@ -265,8 +269,12 @@ static int amdgpu_move_blit(struct ttm_buffer_object *bo,return -EINVAL ; }switch (new_mem->mem_type) { -case TTM_PL_VRAM :case TTM_PL_TT : + r =amdgpu_ttm_bind (bo->ttm, new_mem); +if (r) +return r; + +case TTM_PL_VRAM : new_start += bo->bdev->man[new_mem->mem_type].gpu_offset;break ;default :@@ -639,7 +647,6 @@ static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm, struct ttm_mem_reg *bo_mem) {struct amdgpu_ttm_tt *gtt = (void *)ttm; -uint32_t flags =amdgpu_ttm_tt_pte_flags (gtt->adev, ttm, bo_mem);int r;if (gtt->userptr) {@@ -660,6 +667,26 @@ static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm, bo_mem->mem_type == AMDGPU_PL_OA)return -EINVAL ; +return 0 ; +} + +bool amdgpu_ttm_is_bound (struct ttm_tt *ttm) +{ +struct amdgpu_ttm_tt *gtt = (void *)ttm; + +return gtt && !list_empty (>t->list); +} + +int amdgpu_ttm_bind (struct ttm_tt *ttm,struct ttm_mem_reg *bo_mem) +{ +struct amdgpu_ttm_tt *gtt = (void *)ttm; +uint32_t flags; +int r; + +if (!ttm ||amdgpu_ttm_is_bound (ttm)) +return 0 ; + + flags =amdgpu_ttm_tt_pte_flags (gtt->adev, ttm, bo_mem); r =amdgpu_gart_bind (gtt->adev, gtt->offset, ttm->num_pages, ttm->pages, gtt->ttm.dma_address, flags);drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +3
-0@@ -77,4 +77,7 @@ int amdgpu_fill_buffer(struct amdgpu_bo *bo, struct fence **fence);int amdgpu_mmap (struct file *filp,struct vm_area_struct *vma); +bool amdgpu_ttm_is_bound (struct ttm_tt *ttm); +int amdgpu_ttm_bind (struct ttm_tt *ttm,struct ttm_mem_reg *bo_mem); +#endif drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +4
-0@@ -891,6 +891,10 @@ int amdgpu_uvd_ring_parse_cs(struct amdgpu_cs_parser *parser, uint32_t ib_idx)return -EINVAL ; } + r =amdgpu_cs_sysvm_access_required (parser); +if (r) +return r; + ctx.parser = parser; ctx.buf_sizes = buf_sizes; ctx.ib_idx = ib_idx;drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c +5
-1@@ -634,7 +634,11 @@ int amdgpu_vce_ring_parse_cs(struct amdgpu_cs_parser *p, uint32_t ib_idx)uint32_t allocated =0 ;uint32_t tmp, handle =0 ;uint32_t *size = &tmp; -int i, r =0 , idx =0 ; +int i, r, idx =0 ; + + r =amdgpu_cs_sysvm_access_required (p); +if (r) +return r;while (idx < ib->length_dw) {uint32_t len =amdgpu_get_ib_value (p, ib_idx, idx);drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2
-2@@ -1162,7 +1162,8 @@ int amdgpu_vm_bo_update(struct amdgpu_device *adev, } flags =amdgpu_ttm_tt_pte_flags (adev, bo_va->bo->tbo.ttm, mem); - gtt_flags = (adev == bo_va->bo->adev) ? flags :0 ; + gtt_flags = (amdgpu_ttm_is_bound (bo_va->bo->tbo.ttm) && + adev == bo_va->bo->adev) ? flags :0 ;spin_lock (&vm->status_lock);if (!list_empty (&bo_va->vm_status)) --2.5.0
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): CAAxE2A4p=fnpwRsXDPhNW518uQqFoDzTxxhYg4_+yzJvhWOoBQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [PATCH 2/2] drm/amdgpu: bind GTT on demand
Thanks for the note, going to take a look tomorrow.
Probably just another case I've missed.
Christian.
Am 17.09.2016 um 23:14 schrieb Marek Olšák:
Quoted 241 lines
This breaks Tonga such that it hangs. Reproducible quickly with:
R600_DEBUG=testdma glxgears
It's a randomized test that runs forever. It should hang within 2 seconds.
Marek
Quoted 231 lines · Christian König
From: Christian König <[email protected]>
We don't really need the GTT table any more most of the time. So bind it only on demand.
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 34 ++++++++++++++++++++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 7 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 33 ++++++++++++++++++++++++++--- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | 3 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 4 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 6 +++++- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 3 ++- 8 files changed, 84 insertions(+), 7 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +1
-0@@ -2521,6 +2521,7 @@ static inline void amdgpu_acpi_fini(struct amdgpu_device *adev) { }struct amdgpu_bo_va_mapping *amdgpu_cs_find_mapping (struct amdgpu_cs_parser *parser,uint64_t addr,struct amdgpu_bo **bo); +int amdgpu_cs_sysvm_access_required (struct amdgpu_cs_parser *parser);#if defined(CONFIG_DRM_AMD_DAL )int amdgpu_dm_display_resume (struct amdgpu_device *adev );drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +32
-2@@ -640,8 +640,12 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p, } } -if (p->uf_entry.robj) - p->job->uf_addr +=amdgpu_bo_gpu_offset (p->uf_entry.robj); +if (!r && p->uf_entry.robj) { +struct amdgpu_bo *uf = p->uf_entry.robj; + + r =amdgpu_ttm_bind (uf->tbo.ttm, &uf->tbo.mem); + p->job->uf_addr +=amdgpu_bo_gpu_offset (uf); + } error_validate:if (r) {@@ -1156,3 +1160,29 @@ amdgpu_cs_find_mapping(struct amdgpu_cs_parser *parser,return NULL ; } + +/** +* amdgpu_cs_sysvm_access_required - make BOs accessible by the system VM +* +* @parser: command submission parser context +* +* Helper for UVD/VCE VM emulation, make sure BOs are accessible by the system VM. +*/ +int amdgpu_cs_sysvm_access_required (struct amdgpu_cs_parser *parser) +{ +unsigned i; +int r; + +if (!parser->bo_list) +return 0 ; + +for (i =0 ; i < parser->bo_list->num_entries; i++) { +struct amdgpu_bo *bo = parser->bo_list->array[i].robj; + + r =amdgpu_ttm_bind (bo->tbo.ttm, &bo->tbo.mem); +if (unlikely (r)) +return r; + } + +return 0 ; +}drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +7
-0@@ -646,6 +646,11 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,dev_err (bo->adev->dev,"%p pin failed\n" , bo); goto error; } + r =amdgpu_ttm_bind (bo->tbo.ttm, &bo->tbo.mem); +if (unlikely (r)) { +dev_err (bo->adev->dev,"%p bind failed\n" , bo); + goto error; + } bo->pin_count =1 ;if (gpu_addr !=NULL )@@ -918,6 +923,8 @@ void amdgpu_bo_fence(struct amdgpu_bo *bo, struct fence *fence,u64 amdgpu_bo_gpu_offset (struct amdgpu_bo *bo) {WARN_ON_ONCE (bo->tbo.mem.mem_type ==TTM_PL_SYSTEM ); +WARN_ON_ONCE (bo->tbo.mem.mem_type ==TTM_PL_TT && + !amdgpu_ttm_is_bound (bo->tbo.ttm));WARN_ON_ONCE (!ww_mutex_is_locked (&bo->tbo.resv->lock) && !bo->pin_count);drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +30
-3@@ -256,8 +256,12 @@ static int amdgpu_move_blit(struct ttm_buffer_object *bo, new_start = (u64 )new_mem->start <<PAGE_SHIFT ;switch (old_mem->mem_type) { -case TTM_PL_VRAM :case TTM_PL_TT : + r =amdgpu_ttm_bind (bo->ttm, old_mem); +if (r) +return r; + +case TTM_PL_VRAM : old_start += bo->bdev->man[old_mem->mem_type].gpu_offset;break ;default :@@ -265,8 +269,12 @@ static int amdgpu_move_blit(struct ttm_buffer_object *bo,return -EINVAL ; }switch (new_mem->mem_type) { -case TTM_PL_VRAM :case TTM_PL_TT : + r =amdgpu_ttm_bind (bo->ttm, new_mem); +if (r) +return r; + +case TTM_PL_VRAM : new_start += bo->bdev->man[new_mem->mem_type].gpu_offset;break ;default :@@ -639,7 +647,6 @@ static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm, struct ttm_mem_reg *bo_mem) {struct amdgpu_ttm_tt *gtt = (void *)ttm; -uint32_t flags =amdgpu_ttm_tt_pte_flags (gtt->adev, ttm, bo_mem);int r;if (gtt->userptr) {@@ -660,6 +667,26 @@ static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm, bo_mem->mem_type == AMDGPU_PL_OA)return -EINVAL ; +return 0 ; +} + +bool amdgpu_ttm_is_bound (struct ttm_tt *ttm) +{ +struct amdgpu_ttm_tt *gtt = (void *)ttm; + +return gtt && !list_empty (>t->list); +} + +int amdgpu_ttm_bind (struct ttm_tt *ttm,struct ttm_mem_reg *bo_mem) +{ +struct amdgpu_ttm_tt *gtt = (void *)ttm; +uint32_t flags; +int r; + +if (!ttm ||amdgpu_ttm_is_bound (ttm)) +return 0 ; + + flags =amdgpu_ttm_tt_pte_flags (gtt->adev, ttm, bo_mem); r =amdgpu_gart_bind (gtt->adev, gtt->offset, ttm->num_pages, ttm->pages, gtt->ttm.dma_address, flags);drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +3
-0@@ -77,4 +77,7 @@ int amdgpu_fill_buffer(struct amdgpu_bo *bo, struct fence **fence);int amdgpu_mmap (struct file *filp,struct vm_area_struct *vma); +bool amdgpu_ttm_is_bound (struct ttm_tt *ttm); +int amdgpu_ttm_bind (struct ttm_tt *ttm,struct ttm_mem_reg *bo_mem); +#endif drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +4
-0@@ -891,6 +891,10 @@ int amdgpu_uvd_ring_parse_cs(struct amdgpu_cs_parser *parser, uint32_t ib_idx)return -EINVAL ; } + r =amdgpu_cs_sysvm_access_required (parser); +if (r) +return r; + ctx.parser = parser; ctx.buf_sizes = buf_sizes; ctx.ib_idx = ib_idx;drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c +5
-1@@ -634,7 +634,11 @@ int amdgpu_vce_ring_parse_cs(struct amdgpu_cs_parser *p, uint32_t ib_idx)uint32_t allocated =0 ;uint32_t tmp, handle =0 ;uint32_t *size = &tmp; -int i, r =0 , idx =0 ; +int i, r, idx =0 ; + + r =amdgpu_cs_sysvm_access_required (p); +if (r) +return r;while (idx < ib->length_dw) {uint32_t len =amdgpu_get_ib_value (p, ib_idx, idx);drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2
-2@@ -1162,7 +1162,8 @@ int amdgpu_vm_bo_update(struct amdgpu_device *adev, } flags =amdgpu_ttm_tt_pte_flags (adev, bo_va->bo->tbo.ttm, mem); - gtt_flags = (adev == bo_va->bo->adev) ? flags :0 ; + gtt_flags = (amdgpu_ttm_is_bound (bo_va->bo->tbo.ttm) && + adev == bo_va->bo->adev) ? flags :0 ;spin_lock (&vm->status_lock);if (!list_empty (&bo_va->vm_status)) --2.5.0
Quoted 4 lines
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 2/2] drm/amdgpu: bind GTT on demand
In reply to a message not in the archiveQuoted 5 lines · Marek Olšák
This breaks Tonga such that it hangs. Reproducible quickly with:
R600_DEBUG=testdma glxgears
It's a randomized test that runs forever. It should hang within 2 seconds.
So what is the status of this now?
R600_DEBUG=testdma glxgears isn't a test I've run on my r9285 tonga until I, by luck, saw this.
On agddf 4.9-wip at post time it did hang/reboot after 2 seconds.
On every update since it's still hung though now it takes longer.
Todays update tested both on head and reset on to the drm-next tag still hang.
Going back over older 4.9-wips it's one built on 26th August that is the first not to hang.
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH 2/2] drm/amdgpu: bind GTT on demand
Am 22.09.2016 um 23:54 schrieb Andy Furniss:
Quoted 8 lines
Quoted 5 lines · Marek Olšák
This breaks Tonga such that it hangs. Reproducible quickly with:
R600_DEBUG=testdma glxgears
It's a randomized test that runs forever. It should hang within 2 seconds.
So what is the status of this now?
The status is that I'm hammering my head on the desk for two weeks now what the heck is going wrong here.
What I've found so far is that a VM update command doesn't have the result it should have, but I absolutely don't understand what happens here.
The good news is that it's 100% reproducible and I already found and fixed two bugs.
If you have any idea or more testing results what is going wrong here please let me know.
If we can't fix this before the 4.9 release we are just going to revert the patch causing this.
Regards,
Christian.
Quoted 16 lines
R600_DEBUG=testdma glxgears isn't a test I've run on my r9285 tonga until I, by luck, saw this.
On agddf 4.9-wip at post time it did hang/reboot after 2 seconds.
On every update since it's still hung though now it takes longer.
Todays update tested both on head and reset on to the drm-next tag still hang.
Going back over older 4.9-wips it's one built on 26th August that is the first not to hang.
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 99035862-cf25-c2e1-4460-78622a539f32-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org
Re: [PATCH 2/2] drm/amdgpu: bind GTT on demand
Quoted 6 lines · Christian König
Am 22.09.2016 um 23:54 schrieb Andy Furniss:
Quoted 5 lines
Quoted 4 lines · Marek Olšák
This breaks Tonga such that it hangs. Reproducible quickly with:
R600_DEBUG=testdma glxgears
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
It's a randomized test that runs forever. It should hang within 2 seconds.
So what is the status of this now?
The status is that I'm hammering my head on the desk for two weeks now what the heck is going wrong here.
Oh, OK, I was just checking no one thought it was fixed really.
Quoted 9 lines
What I've found so far is that a VM update command doesn't have the result it should have, but I absolutely don't understand what happens here.
The good news is that it's 100% reproducible and I already found and fixed two bugs.
If you have any idea or more testing results what is going wrong here please let me know.
I guess, you already did it anyway or it doesn't help, but
R600_DEBUG=testdma,check_vm glxgears
Does catch a vmfault and output to ddebug_dumps.
It initially saves me from locking, though I will lock on repeated runs.
Quoted 30 lines
If we can't fix this before the 4.9 release we are just going to revert the patch causing this.
Regards,
Christian.Quoted 20 lines
R600_DEBUG=testdma glxgears isn't a test I've run on my r9285 tonga until I, by luck, saw this.
On agddf 4.9-wip at post time it did hang/reboot after 2 seconds.
On every update since it's still hung though now it takes longer.
Todays update tested both on head and reset on to the drm-next tag still hang.
Going back over older 4.9-wips it's one built on 26th August that is the first not to hang.
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH 2/2] drm/amdgpu: bind GTT on demand
Quoted 27 lines · EDT Andy Furniss
Quoted 6 lines · Christian König
Am 22.09.2016 um 23:54 schrieb Andy Furniss:
Quoted 5 lines
Quoted 4 lines · Marek Olšák
This breaks Tonga such that it hangs. Reproducible quickly with:
R600_DEBUG=testdma glxgears
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
It's a randomized test that runs forever. It should hang within 2 seconds.
So what is the status of this now?
The status is that I'm hammering my head on the desk for two weeks now what the heck is going wrong here.
Oh, OK, I was just checking no one thought it was fixed really.
Quoted 9 lines
What I've found so far is that a VM update command doesn't have the result it should have, but I absolutely don't understand what happens here.
The good news is that it's 100% reproducible and I already found and fixed two bugs.
If you have any idea or more testing results what is going wrong here please let me know.
Quoted 13 lines
I guess, you already did it anyway or it doesn't help, but
R600_DEBUG=testdma,check_vm glxgears
Does catch a vmfault and output to
ddebug_dumps.
It initially saves me from locking, though I will lock on repeated runs.Quoted 6 lines
If we can't fix this before the 4.9 release we are just going to revert the patch causing this.
Regards,
Christian.
This is directly related to my thread on [amdgpu][CIK] drm-next-4.9-wip - piglit test - max-texture-size - GPU deadlock
Using Linus master kernel w/o drm-next-4.9-wip:
I cannot wedge GPU, the amdgpu kernel driver correctly throws errors if I've run out of memory vs crashing GPU.
as CIK doesn't have SDMA enabled in Mesa, I cannot reproduce Andy's test case, using max-texture-size can however.
Thanks,
Shawn
Quoted 20 lines
Quoted 15 lines
Quoted 15 lines
R600_DEBUG=testdma glxgears isn't a test I've run on my r9285 tonga until I, by luck, saw this.
On agddf 4.9-wip at post time it did hang/reboot after 2 seconds.
On every update since it's still hung though now it takes longer.
Todays update tested both on head and reset on to the drm-next tag still hang.
Going back over older 4.9-wips it's one built on 26th August that is the first not to hang.
Quoted 4 lines
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 2/2] drm/amdgpu: bind GTT on demand
In reply to a message not in the archiveWith current drm-next-4.9-wip plus drm/amdgpu: fix addr handling in amdgpu_vm_bo_update_mapping
testdma is now working OK for my R9285 - just did 35k tests while simultaneously running valley/heaven, plus messing with powerplay/cpufreq and all is good, no lock, no vm faults.
Quoted 28 lines · Andy Furniss
Quoted 6 lines · Christian König
Am 22.09.2016 um 23:54 schrieb Andy Furniss:
Quoted 5 lines
Quoted 4 lines · Marek Olšák
This breaks Tonga such that it hangs. Reproducible quickly with:
R600_DEBUG=testdma glxgears
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
It's a randomized test that runs forever. It should hang within 2 seconds.
So what is the status of this now?
The status is that I'm hammering my head on the desk for two weeks now what the heck is going wrong here.
Oh, OK, I was just checking no one thought it was fixed really.
Quoted 10 lines
What I've found so far is that a VM update command doesn't have the result it should have, but I absolutely don't understand what happens here.
The good news is that it's 100% reproducible and I already found and fixed two bugs.
If you have any idea or more testing results what is going wrong here please let me know.
Quoted 38 lines
I guess, you already did it anyway or it doesn't help, but
R600_DEBUG=testdma,check_vm glxgears
Does catch a vmfault and output to
ddebug_dumps.
It initially saves me from locking, though I will lock on repeated runs.Quoted 30 lines
If we can't fix this before the 4.9 release we are just going to revert the patch causing this.
Regards,
Christian.Quoted 20 lines
R600_DEBUG=testdma glxgears isn't a test I've run on my r9285 tonga until I, by luck, saw this.
On agddf 4.9-wip at post time it did hang/reboot after 2 seconds.
On every update since it's still hung though now it takes longer.
Todays update tested both on head and reset on to the drm-next tag still hang.
Going back over older 4.9-wips it's one built on 26th August that is the first not to hang.
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx