drm/amdgpu: Don't change preferred domian when fallback GTT
Subsystems (2)
PATCH 1/2 drm/amdgpu: Don't change preferred domian when fallback GTT
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 5 ----- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 12 ++++++++++-- 2 files changed, 10 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0 -5
@@ -85,11 +85,6 @@ int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size, flags &= ~AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED ; goto retry; } - -if (initial_domain ==AMDGPU_GEM_DOMAIN_VRAM ) { - initial_domain |=AMDGPU_GEM_DOMAIN_GTT ; - goto retry; - }DRM_DEBUG ("Failed to allocate GEM object (%ld, %d, %u, %d)\n" , size, initial_domain, alignment, r); }
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +10 -2
@@ -371,6 +371,7 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev,enum ttm_bo_type type;unsigned long page_align;size_t acc_size; +u32 setting_domain;int r; page_align =roundup (byte_align,PAGE_SIZE ) >>PAGE_SHIFT ;
@@ -440,13 +441,20 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev,#endif bo->tbo.bdev = &adev->mman.bdev; -amdgpu_ttm_placement_from_domain (bo, domain); + setting_domain = bo->preferred_domains; +retry: +amdgpu_ttm_placement_from_domain (bo, setting_domain); r =ttm_bo_init_reserved (&adev->mman.bdev, &bo->tbo, size, type, &bo->placement, page_align, &ctx, acc_size, sg, resv, &amdgpu_ttm_bo_destroy); -if (unlikely (r !=0 )) +if (unlikely (r !=0 )) { +if (r != -ERESTARTSYS ) { + setting_domain = bo->allowed_domains; + goto retry; + }return r; + } if (adev->gmc.visible_vram_size < adev->gmc.real_vram_size && bo->tbo.mem.mem_type == TTM_PL_VRAM &&
Signature · 6 lines
2.14.1 _______________________________________________ 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]
PATCH 2/2 drm/amdgpu: validate fallback BOs
issue:
Game F1 performance drops 13% when per vm bo is enabled.
root cause:
if some BOs are fallback to allowed domain, they will never be validated if no eviction happens, that means they always exist in allowed domain.
Fix:
maintain a per vm allowed domain BOs list, then try to validated them with perferred domain.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 15 +++++++---- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 49 ++++++++++++++++++++++++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 7 ++++- 3 files changed, 63 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +10 -5
@@ -359,7 +359,7 @@ void amdgpu_cs_report_moved_bytes(struct amdgpu_device *adev, u64 num_bytes, }static int amdgpu_cs_bo_validate (struct amdgpu_cs_parser *p, -struct amdgpu_bo *bo) +struct amdgpu_bo *bo,bool *allowed) {struct amdgpu_device *adev =amdgpu_ttm_adev (bo->tbo.bdev);struct ttm_operation_ctx ctx = {
@@ -374,6 +374,8 @@ static int amdgpu_cs_bo_validate(struct amdgpu_cs_parser *p,if (bo->pin_count)return 0 ; +if (allowed) + *allowed = false;/* Don't move this buffer if we have depleted our allowance * to move it. Don't move anything if the threshold is zero. */
@@ -396,6 +398,9 @@ static int amdgpu_cs_bo_validate(struct amdgpu_cs_parser *p, } retry: +if (domain != bo->preferred_domains && domain == bo->allowed_domains && + allowed) + *allowed = true;amdgpu_ttm_placement_from_domain (bo, domain); r =ttm_bo_validate (&bo->tbo, &bo->placement, &ctx);
@@ -479,19 +484,19 @@ static bool amdgpu_cs_try_evict(struct amdgpu_cs_parser *p,return false; } -static int amdgpu_cs_validate (void *param,struct amdgpu_bo *bo) +static int amdgpu_cs_validate (void *param,struct amdgpu_bo *bo,bool *allowed) {struct amdgpu_cs_parser *p = param;int r;do { - r =amdgpu_cs_bo_validate (p, bo); + r =amdgpu_cs_bo_validate (p, bo, allowed); }while (r == -ENOMEM &&amdgpu_cs_try_evict (p, bo));if (r)return r;if (bo->shadow) - r =amdgpu_cs_bo_validate (p, bo->shadow); + r =amdgpu_cs_bo_validate (p, bo->shadow,NULL );return r; }
@@ -528,7 +533,7 @@ static int amdgpu_cs_list_validate(struct amdgpu_cs_parser *p,if (p->evictable == lobj) p->evictable =NULL ; - r =amdgpu_cs_validate (p, bo); + r =amdgpu_cs_validate (p, bo,NULL );if (r)return r;
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +47 -2
106 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +6 -1
@@ -149,6 +149,7 @@ struct amdgpu_vm_bo_base {/* protected by spinlock */ struct list_head vm_status; +struct list_head allowed_domain_list;/* protected by the BO being reserved */ bool moved;
@@ -177,6 +178,9 @@ struct amdgpu_vm {/* protecting invalidated */ spinlock_t status_lock; +/* per vm bo is validated to allowed domain */ +struct list_head allowed_domain; +/* BOs who needs a validation */ struct list_head evicted;
@@ -266,7 +270,8 @@ void amdgpu_vm_get_pd_bo(struct amdgpu_vm *vm, struct amdgpu_bo_list_entry *entry);bool amdgpu_vm_ready (struct amdgpu_vm *vm);int amdgpu_vm_validate_pt_bos (struct amdgpu_device *adev,struct amdgpu_vm *vm, -int (*callback)(void *p,struct amdgpu_bo *bo), +int (*callback)(void *p,struct amdgpu_bo *bo, +bool *allowed),void *param); int amdgpu_vm_alloc_pts(struct amdgpu_device *adev, struct amdgpu_vm *vm,
Signature · 6 lines
2.14.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Am 16.03.2018 um 10:56 schrieb Chunming Zhou:
Quoted 41 lines
Change-Id I2cf672ad36b8b4cc1a6b2e704f786bf6a155d9ceSigned-off-by Chunming Zhou <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 5 ----- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 12 ++++++++++-- 2 files changed, 10 insertions(+), 7 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0
-5@@ -85,11 +85,6 @@ int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size, flags &= ~AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED ; goto retry; } - -if (initial_domain ==AMDGPU_GEM_DOMAIN_VRAM ) { - initial_domain |=AMDGPU_GEM_DOMAIN_GTT ; - goto retry; - }DRM_DEBUG ("Failed to allocate GEM object (%ld, %d, %u, %d)\n" , size, initial_domain, alignment, r); }drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +2
-1@@ -371,6 +371,7 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev,enum ttm_bo_type type;unsigned long page_align;size_t acc_size; +u32 setting_domain;int r; page_align =roundup (byte_align,PAGE_SIZE ) >>PAGE_SHIFT ;@@ -440,13 +441,20 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev,#endif bo->tbo.bdev = &adev->mman.bdev; -amdgpu_ttm_placement_from_domain (bo, domain); + setting_domain = bo->preferred_domains;
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c static int amdgpu_bo_do_create(struct amdgpu_device *adev, · line 453
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +5
-1+retry: +amdgpu_ttm_placement_from_domain (bo, setting_domain); r =ttm_bo_init_reserved (&adev->mman.bdev, &bo->tbo, size, type, &bo->placement, page_align, &ctx, acc_size, sg, resv, &amdgpu_ttm_bo_destroy); -if (unlikely (r !=0 )) +if (unlikely (r !=0 )) { +if (r != -ERESTARTSYS ) { + setting_domain = bo->allowed_domains;
If the allocation fails with setting domain as well that will result in an endless loop. Rather open code that, e.g.
amdgpu_ttm_placement_from_domain(bo, bo->prefered_domains); r = ttm_bo_init_reserved(&adev->mman.bdev, &bo->tbo, size, type, &bo->placement, page_align, &ctx, acc_size, sg, resv, &amdgpu_ttm_bo_destroy);
if (unlikely(r && r != -ERESTARTSYS) && bo->allowed_domains != bo->prefered_domains) { amdgpu_ttm_placement_from_domain(bo, bo->allowed_domains);
r = ttm_bo_init_reserved(&adev->mman.bdev, &bo->tbo, size, type,
....
Regards,
Christian.
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c static int amdgpu_bo_do_create(struct amdgpu_device *adev, · line 460
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +3
-0+ goto retry; + }return r; + } if (adev->gmc.visible_vram_size < adev->gmc.real_vram_size && bo->tbo.mem.mem_type == TTM_PL_VRAM &&
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx