drm/amdgpu: use ctx bytes_moved
Subsystems (2)
PATCH 1/3 drm/amdgpu: use ctx bytes_moved
Instead of the global (inaccurate) counter.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +3 -7
@@ -412,7 +412,6 @@ static bool amdgpu_cs_try_evict(struct amdgpu_cs_parser *p,struct amdgpu_bo_list_entry *candidate = p->evictable;struct amdgpu_bo *bo = candidate->robj;struct amdgpu_device *adev =amdgpu_ttm_adev (bo->tbo.bdev); -u64 initial_bytes_moved, bytes_moved;bool update_bytes_moved_vis;uint32_t other;
@@ -436,18 +435,15 @@ static bool amdgpu_cs_try_evict(struct amdgpu_cs_parser *p,continue ;/* Good we can try to move this BO somewhere else */ -amdgpu_ttm_placement_from_domain (bo, other); update_bytes_moved_vis = adev->gmc.visible_vram_size < adev->gmc.real_vram_size && bo->tbo.mem.mem_type ==TTM_PL_VRAM && bo->tbo.mem.start < adev->gmc.visible_vram_size >>PAGE_SHIFT ; - initial_bytes_moved =atomic64_read (&adev->num_bytes_moved); +amdgpu_ttm_placement_from_domain (bo, other); r =ttm_bo_validate (&bo->tbo, &bo->placement, &ctx); - bytes_moved =atomic64_read (&adev->num_bytes_moved) - - initial_bytes_moved; - p->bytes_moved += bytes_moved; + p->bytes_moved += ctx.bytes_moved;if (update_bytes_moved_vis) - p->bytes_moved_vis += bytes_moved; + p->bytes_moved_vis += ctx.bytes_moved;if (unlikely (r))break ;
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): 20180409101900.2790-1-christian.koenig-5C7GfCeVMHo@public.gmane.org
PATCH 2/3 drm/amdgpu: fix and cleanup cpu visible VRAM handling
The detection if a BO was placed in CPU visible VRAM was incorrect.
Fix it and merge it with the correct detection in amdgpu_ttm.c
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 6 ++---- drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 21 +++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 19 +++---------------- 3 files changed, 26 insertions(+), 20 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +2 -4
@@ -382,8 +382,7 @@ static int amdgpu_cs_bo_validate(struct amdgpu_cs_parser *p, p->bytes_moved += ctx.bytes_moved;if (adev->gmc.visible_vram_size < adev->gmc.real_vram_size && - bo->tbo.mem.mem_type ==TTM_PL_VRAM && - bo->tbo.mem.start < adev->gmc.visible_vram_size >>PAGE_SHIFT ) +amdgpu_bo_in_cpu_visible_vram (bo)) p->bytes_moved_vis += ctx.bytes_moved; if (unlikely(r == -ENOMEM) && domain != bo->allowed_domains &&
@@ -437,8 +436,7 @@ static bool amdgpu_cs_try_evict(struct amdgpu_cs_parser *p,/* Good we can try to move this BO somewhere else */ update_bytes_moved_vis = adev->gmc.visible_vram_size < adev->gmc.real_vram_size && - bo->tbo.mem.mem_type ==TTM_PL_VRAM && - bo->tbo.mem.start < adev->gmc.visible_vram_size >>PAGE_SHIFT ; +amdgpu_bo_in_cpu_visible_vram (bo);amdgpu_ttm_placement_from_domain (bo, other); r =ttm_bo_validate (&bo->tbo, &bo->placement, &ctx); p->bytes_moved += ctx.bytes_moved;
drivers/gpu/drm/amd/amdgpu/amdgpu_object.h +21 -0
@@ -193,6 +193,27 @@ static inline bool amdgpu_bo_gpu_accessible(struct amdgpu_bo *bo) } } +/** +* amdgpu_bo_in_cpu_visible_vram - check if BO is (partly) in visible VRAM +*/ +static inline bool amdgpu_bo_in_cpu_visible_vram (struct amdgpu_bo *bo) +{ +struct amdgpu_device *adev =amdgpu_ttm_adev (bo->tbo.bdev); +unsigned fpfn = adev->gmc.visible_vram_size >>PAGE_SHIFT ; +struct drm_mm_node *node = bo->tbo.mem.mm_node; +unsigned long pages_left; + +if (bo->tbo.mem.mem_type !=TTM_PL_VRAM ) +return false; + +for (pages_left = bo->tbo.mem.num_pages; pages_left; + pages_left -= node->size, node++) +if (node->start < fpfn) +return true; + +return false; +} +/** * amdgpu_bo_explicit_sync - return whether the bo is explicitly synced */
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +3 -16
@@ -222,20 +222,8 @@ static void amdgpu_evict_flags(struct ttm_buffer_object *bo,if (!adev->mman.buffer_funcs_enabled) {amdgpu_ttm_placement_from_domain (abo,AMDGPU_GEM_DOMAIN_CPU ); }else if (adev->gmc.visible_vram_size < adev->gmc.real_vram_size && - !(abo->flags &AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED )) { -unsigned fpfn = adev->gmc.visible_vram_size >>PAGE_SHIFT ; -struct drm_mm_node *node = bo->mem.mm_node; -unsigned long pages_left; - -for (pages_left = bo->mem.num_pages; - pages_left; - pages_left -= node->size, node++) { -if (node->start < fpfn) -break ; - } - -if (!pages_left) - goto gtt; + !(abo->flags &AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED ) && +amdgpu_bo_in_cpu_visible_vram (abo)) {/* Try evicting to the CPU inaccessible part of VRAM * first, but only set GTT as busy placement, so this
@@ -244,12 +232,11 @@ static void amdgpu_evict_flags(struct ttm_buffer_object *bo,*/ amdgpu_ttm_placement_from_domain (abo,AMDGPU_GEM_DOMAIN_VRAM |AMDGPU_GEM_DOMAIN_GTT ); - abo->placements[0 ].fpfn = fpfn; + abo->placements[0 ].fpfn = adev->gmc.visible_vram_size >>PAGE_SHIFT ; abo->placements[0 ].lpfn =0 ; abo->placement.busy_placement = &abo->placements[1 ]; abo->placement.num_busy_placement =1 ; }else { -gtt:amdgpu_ttm_placement_from_domain (abo,AMDGPU_GEM_DOMAIN_GTT ); }break ;
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): 20180409101900.2790-2-christian.koenig-5C7GfCeVMHo@public.gmane.org
Michel Dänzer
Reviewed-byRe: [PATCH 2/3] drm/amdgpu: fix and cleanup cpu visible VRAM handling
Quoted 5 lines · Christian König
The detection if a BO was placed in CPU visible VRAM was incorrect.
Fix it and merge it with the correct detection in
amdgpu_ttm.cSigned-off-by Christian König <[email protected]>
Good catch! All three patches are
Signature · 6 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
zhoucm1
Reviewed-by Chunming ZhouRe: [PATCH 2/3] drm/amdgpu: fix and cleanup cpu visible VRAM handling
In reply to a message not in the archiveQuoted 5 lines · Christian König
The detection if a BO was placed in CPU visible VRAM was incorrect.
Fix it and merge it with the correct detection in
amdgpu_ttm.cSigned-off-by Christian König <[email protected]>
Quoted 93 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 6 ++---- drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 21 +++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 19 +++---------------- 3 files changed, 26 insertions(+), 20 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +2
-4@@ -382,8 +382,7 @@ static int amdgpu_cs_bo_validate(struct amdgpu_cs_parser *p, p->bytes_moved += ctx.bytes_moved;if (adev->gmc.visible_vram_size < adev->gmc.real_vram_size && - bo->tbo.mem.mem_type ==TTM_PL_VRAM && - bo->tbo.mem.start < adev->gmc.visible_vram_size >>PAGE_SHIFT ) +amdgpu_bo_in_cpu_visible_vram (bo)) p->bytes_moved_vis += ctx.bytes_moved; if (unlikely(r == -ENOMEM) && domain != bo->allowed_domains &&@@ -437,8 +436,7 @@ static bool amdgpu_cs_try_evict(struct amdgpu_cs_parser *p,/* Good we can try to move this BO somewhere else */ update_bytes_moved_vis = adev->gmc.visible_vram_size < adev->gmc.real_vram_size && - bo->tbo.mem.mem_type ==TTM_PL_VRAM && - bo->tbo.mem.start < adev->gmc.visible_vram_size >>PAGE_SHIFT ; +amdgpu_bo_in_cpu_visible_vram (bo);amdgpu_ttm_placement_from_domain (bo, other); r =ttm_bo_validate (&bo->tbo, &bo->placement, &ctx); p->bytes_moved += ctx.bytes_moved;drivers/gpu/drm/amd/amdgpu/amdgpu_object.h +21
-0@@ -193,6 +193,27 @@ static inline bool amdgpu_bo_gpu_accessible(struct amdgpu_bo *bo) } } +/** +* amdgpu_bo_in_cpu_visible_vram - check if BO is (partly) in visible VRAM +*/ +static inline bool amdgpu_bo_in_cpu_visible_vram (struct amdgpu_bo *bo) +{ +struct amdgpu_device *adev =amdgpu_ttm_adev (bo->tbo.bdev); +unsigned fpfn = adev->gmc.visible_vram_size >>PAGE_SHIFT ; +struct drm_mm_node *node = bo->tbo.mem.mm_node; +unsigned long pages_left; + +if (bo->tbo.mem.mem_type !=TTM_PL_VRAM ) +return false; + +for (pages_left = bo->tbo.mem.num_pages; pages_left; + pages_left -= node->size, node++) +if (node->start < fpfn) +return true; + +return false; +} +/** * amdgpu_bo_explicit_sync - return whether the bo is explicitly synced */ drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +2
-14@@ -222,20 +222,8 @@ static void amdgpu_evict_flags(struct ttm_buffer_object *bo,if (!adev->mman.buffer_funcs_enabled) {amdgpu_ttm_placement_from_domain (abo,AMDGPU_GEM_DOMAIN_CPU ); }else if (adev->gmc.visible_vram_size < adev->gmc.real_vram_size && - !(abo->flags &AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED )) { -unsigned fpfn = adev->gmc.visible_vram_size >>PAGE_SHIFT ; -struct drm_mm_node *node = bo->mem.mm_node; -unsigned long pages_left; - -for (pages_left = bo->mem.num_pages; - pages_left; - pages_left -= node->size, node++) { -if (node->start < fpfn) -break ; - } - -if (!pages_left) - goto gtt; + !(abo->flags &AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED ) && +amdgpu_bo_in_cpu_visible_vram (abo)) {/* Try evicting to the CPU inaccessible part of VRAM * first, but only set GTT as busy placement, so this @@ -244,12 +232,11 @@ static void amdgpu_evict_flags(struct ttm_buffer_object *bo,*/ amdgpu_ttm_placement_from_domain (abo,AMDGPU_GEM_DOMAIN_VRAM |AMDGPU_GEM_DOMAIN_GTT );
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static void amdgpu_evict_flags(struct ttm_buffer_object *bo, · line 242
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1
-2- abo->placements[0 ].fpfn = fpfn; + abo->placements[0 ].fpfn = adev->gmc.visible_vram_size >>PAGE_SHIFT ; abo->placements[0 ].lpfn =0 ; abo->placement.busy_placement = &abo->placements[1 ]; abo->placement.num_busy_placement =1 ; }else { -gtt:amdgpu_ttm_placement_from_domain (abo,AMDGPU_GEM_DOMAIN_GTT ); }break ;
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/3 drm/amdgpu: remove AMDGPU_GEM_CREATE_NO_FALLBACK handling from CS again
In reply to a message not in the archiveThat should purely be handled by preferred/allowed domains.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +1 -2
@@ -385,8 +385,7 @@ static int amdgpu_cs_bo_validate(struct amdgpu_cs_parser *p, amdgpu_bo_in_cpu_visible_vram(bo)) p->bytes_moved_vis += ctx.bytes_moved; -if (unlikely (r == -ENOMEM ) && domain != bo->allowed_domains && - !(bo->flags &AMDGPU_GEM_CREATE_NO_FALLBACK )) { +if (unlikely (r == -ENOMEM ) && domain != bo->allowed_domains) { domain = bo->allowed_domains; goto retry; }
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): 20180409101900.2790-3-christian.koenig-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 3/3] drm/amdgpu: remove AMDGPU_GEM_CREATE_NO_FALLBACK handling from CS again
Quoted 1 line · Christian König
That should purely be handled by preferred/allowed domains.
Although this flag isn't exported to user space yet, I'm curious that how preferred/allowed domains handle no_fallback? IIRC, currently, our driver will always add GTT fallback for VRAM bo.
Regards,
David Zhou
Quoted 11 lines
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c static int amdgpu_cs_bo_validate(struct amdgpu_cs_parser *p, · line 391
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +1
-2@@ -385,8 +385,7 @@ static int amdgpu_cs_bo_validate(struct amdgpu_cs_parser *p, amdgpu_bo_in_cpu_visible_vram(bo)) p->bytes_moved_vis += ctx.bytes_moved; -if (unlikely (r == -ENOMEM ) && domain != bo->allowed_domains && - !(bo->flags &AMDGPU_GEM_CREATE_NO_FALLBACK )) { +if (unlikely (r == -ENOMEM ) && domain != bo->allowed_domains) { domain = bo->allowed_domains; goto retry; }
_______________________________________________
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): 11e2b937-9e84-428a-1a90-8752f0dadda4-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 3/3] drm/amdgpu: remove AMDGPU_GEM_CREATE_NO_FALLBACK handling from CS again
Am 10.04.2018 um 04:43 schrieb zhoucm1:
Quoted 6 lines · Christian König
Quoted 1 line
That should purely be handled by preferred/allowed domains.
Although this flag isn't exported to user space yet, I'm curious that how preferred/allowed domains handle
no_fallback? IIRC, currently, our driver will always add GTT fallback for VRAM bo.
And that is intentional. Going a step further back I think moving the fallback handling into amdgpu_bo_do_create() and adding the flag was a mistake to begin with.
Going to send patches to revert all this and further clean the stuff up.
Regards,
Christian.
Quoted 9 lines
Regards,
David ZhouQuoted 6 lines
Signed-off-by Christian König <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c| 3 +--1 file changed, 1 insertion(+), 2 deletions(-)
Quoted 15 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0
-0@@ -385,8 +385,7 @@ static int amdgpu_cs_bo_validate(struct amdgpu_cs_parser *p, amdgpu_bo_in_cpu_visible_vram(bo)) p->bytes_moved_vis += ctx.bytes_moved;Quoted 6 lines
- if (unlikely(r ==
-ENOMEM) && domain !=bo->allowed_domains&& - !(bo->flags &AMDGPU_GEM_CREATE_NO_FALLBACK)) {
+ if (unlikely(r ==-ENOMEM) && domain !=bo->allowed_domains) { domain =bo->allowed_domains;
goto retry;
}
_______________________________________________
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): 94eedefc-bd56-652f-39cf-7331bc5892ea-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Re: [PATCH 3/3] drm/amdgpu: remove AMDGPU_GEM_CREATE_NO_FALLBACK handling from CS again
Quoted 11 lines · Christian König
Am 10.04.2018 um 04:43 schrieb zhoucm1:
Quoted 6 lines · Christian König
Quoted 1 line
That should purely be handled by preferred/allowed domains.
Although this flag isn't exported to user space yet, I'm curious that how preferred/allowed domains handle
no_fallback? IIRC, currently, our driver will always add GTT fallback for VRAM bo.And that is intentional. Going a step further back I think moving the fallback handling into
amdgpu_bo_do_create()and adding the flag was a mistake to begin with.Going to send patches to revert all this and further clean the stuff up.
if you are able to not change the preferred domain when fallback, it's no problem to me.
David Zhou
Quoted 29 lines
Regards,
Christian.Quoted 24 lines
Regards,
David ZhouQuoted 20 lines
Signed-off-by Christian König <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c| 3 +--1 file changed, 1 insertion(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0
-0@@ -385,8 +385,7 @@ static int amdgpu_cs_bo_validate(struct amdgpu_cs_parser *p, amdgpu_bo_in_cpu_visible_vram(bo)) p->bytes_moved_vis += ctx.bytes_moved;- if (unlikely(r ==
-ENOMEM) && domain !=bo->allowed_domains&& - !(bo->flags &AMDGPU_GEM_CREATE_NO_FALLBACK)) {
+ if (unlikely(r ==-ENOMEM) && domain !=bo->allowed_domains) { domain =bo->allowed_domains;
goto retry;
}
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
zhoucm1
Reviewed-by Chunming ZhouQuoted 3 lines · Christian König
Instead of the global (inaccurate) counter.
Signed-off-by Christian König <[email protected]>
Quoted 28 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +1
-3@@ -412,7 +412,6 @@ static bool amdgpu_cs_try_evict(struct amdgpu_cs_parser *p,struct amdgpu_bo_list_entry *candidate = p->evictable;struct amdgpu_bo *bo = candidate->robj;struct amdgpu_device *adev =amdgpu_ttm_adev (bo->tbo.bdev); -u64 initial_bytes_moved, bytes_moved;bool update_bytes_moved_vis;uint32_t other;@@ -436,18 +435,15 @@ static bool amdgpu_cs_try_evict(struct amdgpu_cs_parser *p,continue ;/* Good we can try to move this BO somewhere else */ -amdgpu_ttm_placement_from_domain (bo, other); update_bytes_moved_vis = adev->gmc.visible_vram_size < adev->gmc.real_vram_size && bo->tbo.mem.mem_type ==TTM_PL_VRAM && bo->tbo.mem.start < adev->gmc.visible_vram_size >>PAGE_SHIFT ; - initial_bytes_moved =atomic64_read (&adev->num_bytes_moved); +amdgpu_ttm_placement_from_domain (bo, other); r =ttm_bo_validate (&bo->tbo, &bo->placement, &ctx);
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c static bool amdgpu_cs_try_evict(struct amdgpu_cs_parser *p, · line 449
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +2
-4- bytes_moved =atomic64_read (&adev->num_bytes_moved) - - initial_bytes_moved; - p->bytes_moved += bytes_moved; + p->bytes_moved += ctx.bytes_moved;if (update_bytes_moved_vis) - p->bytes_moved_vis += bytes_moved; + p->bytes_moved_vis += ctx.bytes_moved;if (unlikely (r))break ;
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx