drm/amdgpu: linear validate first then bind to GART
Subsystems (2)
PATCH 1/2 drm/amdgpu: linear validate first then bind to GART
From: Christian König <[email protected]>
For VM emulation for old UVD/VCE we need to validate the BO with linear VRAM flag set first and then eventually bind it to GART.
Validating with linear VRAM flag set can move the BO to GART making UVD/VCE read/write from an unbound GART BO.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +9 -9
@@ -1583,14 +1583,14 @@ int amdgpu_cs_find_mapping(struct amdgpu_cs_parser *parser,if (READ_ONCE ((*bo)->tbo.resv->lock.ctx) != &parser->ticket)return -EINVAL ; - r =amdgpu_ttm_bind (&(*bo)->tbo, &(*bo)->tbo.mem); -if (unlikely (r)) -return r; - -if ((*bo)->flags &AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS ) -return 0 ; +if (!((*bo)->flags &AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS )) { + (*bo)->flags |=AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS ; +amdgpu_ttm_placement_from_domain (*bo, (*bo)->allowed_domains); + r =ttm_bo_validate (&(*bo)->tbo, &(*bo)->placement, false, + false); +if (r) +return r; + } - (*bo)->flags |=AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS ; -amdgpu_ttm_placement_from_domain (*bo, (*bo)->allowed_domains); -return ttm_bo_validate (&(*bo)->tbo, &(*bo)->placement, false, false); +return amdgpu_ttm_bind (&(*bo)->tbo, &(*bo)->tbo.mem); }
Signature · 6 lines
2.11.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): 20171016092646.1625-1-deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org
PATCH 2/2 drm/amdgpu: allow GTT overcommit during bind
From: Christian König <[email protected]>
While binding BOs to GART we need to allow a bit overcommit in the GTT domain. Otherwise we can never use the full GART space when GART size=GTT size.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +5 -3
@@ -169,7 +169,8 @@ static int amdgpu_gtt_mgr_new(struct ttm_mem_type_manager *man,int r;spin_lock (&mgr->lock); -if (atomic64_read (&mgr->available) < mem->num_pages) { +if ((&tbo->mem == mem || tbo->mem.mem_type !=TTM_PL_TT ) && +atomic64_read (&mgr->available) < mem->num_pages) {spin_unlock (&mgr->lock);return 0 ; }
@@ -244,8 +245,9 @@ static void amdgpu_gtt_mgr_del(struct ttm_mem_type_manager *man,uint64_t amdgpu_gtt_mgr_usage (struct ttm_mem_type_manager *man) {struct amdgpu_gtt_mgr *mgr = man->priv; +s64 result = man->size -atomic64_read (&mgr->available); -return (u64)(man->size -atomic64_read (&mgr->available)) *PAGE_SIZE ; +return (result >0 ? result :0 ) *PAGE_SIZE ; }/**
@@ -265,7 +267,7 @@ static void amdgpu_gtt_mgr_debug(struct ttm_mem_type_manager *man,drm_mm_print (&mgr->mm, printer);spin_unlock (&mgr->lock); -drm_printf (printer,"man size:%llu pages, gtt available:%llu pages, usage:%lluMB\n" , +drm_printf (printer,"man size:%llu pages, gtt available:%lld pages, usage:%lluMB\n" , man->size, (u64 )atomic64_read (&mgr->available),amdgpu_gtt_mgr_usage (man) >>20 ); }
Signature · 6 lines
2.11.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): 20171016092646.1625-2-deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org
Re: [PATCH 2/2] drm/amdgpu: allow GTT overcommit during bind
Quoted 4 lines · Christian König
From: Christian König <[email protected]>
While binding BOs to GART we need to allow a bit overcommit in the GTT domain.
If allowing overcommit, will the new node not over the GART mc range? Which is also allowed?
Regards,
David Zhou
Quoted 33 lines
Otherwise we can never use the full GART space when GART size=GTT size.
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +4
-2@@ -169,7 +169,8 @@ static int amdgpu_gtt_mgr_new(struct ttm_mem_type_manager *man,int r;spin_lock (&mgr->lock); -if (atomic64_read (&mgr->available) < mem->num_pages) { +if ((&tbo->mem == mem || tbo->mem.mem_type !=TTM_PL_TT ) && +atomic64_read (&mgr->available) < mem->num_pages) {spin_unlock (&mgr->lock);return 0 ; }@@ -244,8 +245,9 @@ static void amdgpu_gtt_mgr_del(struct ttm_mem_type_manager *man,uint64_t amdgpu_gtt_mgr_usage (struct ttm_mem_type_manager *man) {struct amdgpu_gtt_mgr *mgr = man->priv; +s64 result = man->size -atomic64_read (&mgr->available); -return (u64)(man->size -atomic64_read (&mgr->available)) *PAGE_SIZE ; +return (result >0 ? result :0 ) *PAGE_SIZE ; }/**
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c static void amdgpu_gtt_mgr_debug(struct ttm_mem_type_manager *man, · line 273
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +1
-1@@ -265,7 +267,7 @@ static void amdgpu_gtt_mgr_debug(struct ttm_mem_type_manager *man,drm_mm_print (&mgr->mm, printer);spin_unlock (&mgr->lock); -drm_printf (printer,"man size:%llu pages, gtt available:%llu pages, usage:%lluMB\n" , +drm_printf (printer,"man size:%llu pages, gtt available:%lld pages, usage:%lluMB\n" , man->size, (u64 )atomic64_read (&mgr->available),amdgpu_gtt_mgr_usage (man) >>20 ); }
_______________________________________________
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): eb30bfdf-e5ce-dc2d-1cdf-19f424894b74-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 2/2] drm/amdgpu: allow GTT overcommit during bind
Am 16.10.2017 um 11:42 schrieb Chunming Zhou:
Quoted 8 lines · Christian König
Quoted 4 lines
From: Christian König <[email protected]>
While binding BOs to GART we need to allow a bit overcommit in the GTT domain.
If allowing overcommit, will the new node not over the GART mc range? Which is also allowed?
No that is checked separately by drm_mm_insert_node_in_range().
This is just to cover the case when we have a BO in GTT space which needs to be bound into the GART table.
Regards,
Christian.
Quoted 39 lines
Regards,
David ZhouQuoted 36 lines
Otherwise we can never use the full GART space when GART size=GTT
size.Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +4
-1@@ -169,7 +169,8 @@ static int amdgpu_gtt_mgr_new(structttm_mem_type_manager *man, int r;spin_lock (&mgr->lock); -if (atomic64_read (&mgr->available) < mem->num_pages) { +if ((&tbo->mem == mem || tbo->mem.mem_type !=TTM_PL_TT ) && +atomic64_read (&mgr->available) < mem->num_pages) {spin_unlock (&mgr->lock);return 0 ; }@@ -244,8 +245,9 @@ static void amdgpu_gtt_mgr_del(structttm_mem_type_manager *man, uint64_t amdgpu_gtt_mgr_usage(struct ttm_mem_type_manager *man) { struct amdgpu_gtt_mgr *mgr = man->priv; +s64 result = man->size -atomic64_read (&mgr->available); - return (u64)(man->size - atomic64_read(&mgr->available)) *PAGE_SIZE ; +return (result >0 ? result :0 ) *PAGE_SIZE ; }/** @@ -265,7 +267,7 @@ static void amdgpu_gtt_mgr_debug(struct ttm_mem_type_manager *man,drm_mm_print (&mgr->mm, printer);
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c static void amdgpu_gtt_mgr_debug(struct ttm_mem_type_manager *man, · line 273
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +1
-0spin_unlock (&mgr->lock); - drm_printf(printer, "man size:%llu pages, gtt available:%llu pages, usage:%lluMB\n", + drm_printf(printer, "man size:%llu pages, gtt available:%lld pages, usage:%lluMB\n", man->size, (u64)atomic64_read(&mgr->available), amdgpu_gtt_mgr_usage(man) >> 20); }
_______________________________________________
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): 8a8ade87-e51c-3aab-b5c0-207dbee60ef9-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Re: [PATCH 2/2] drm/amdgpu: allow GTT overcommit during bind
Quoted 4 lines · Christian König
Am 16.10.2017 um 11:42 schrieb Chunming Zhou:
Quoted 3 lines · Christian König
Quoted 8 lines
Quoted 5 lines
Quoted 4 lines
From: Christian König <[email protected]>
While binding BOs to GART we need to allow a bit overcommit in the GTT domain.
If allowing overcommit, will the new node not over the GART mc range? Which is also allowed?
No that is checked separately by
drm_mm_insert_node_in_range().This is just to cover the case when we have a BO in GTT space which needs to be bound into the GART table.
Sorry, I missed that even gart BO is also without node during creating.
One nitpick, atomic64_sub(mem->num_pages, &mgr->available) will be calculated twice for one gart bo create and pin, which results in available isn't correct.
Regards,
David Zhou
Quoted 50 lines
Regards,
Christian.Quoted 45 lines
Regards,
David ZhouQuoted 41 lines
Otherwise we can never use the full GART space when GART size=GTT size.
Signed-off-by Christian König <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c| 8 +++++---1 file changed, 5 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +5
-1@@ -169,7 +169,8 @@ static int amdgpu_gtt_mgr_new(structttm_mem_type_manager *man, int r; spin_lock(&mgr->lock); - if (atomic64_read(&mgr->available) < mem->num_pages) { + if ((&tbo->mem == mem || tbo->mem.mem_type != TTM_PL_TT) && + atomic64_read(&mgr->available) < mem->num_pages) { spin_unlock(&mgr->lock); return 0; }@@ -244,8 +245,9 @@ static void amdgpu_gtt_mgr_del(structttm_mem_type_manager *man, uint64_t amdgpu_gtt_mgr_usage(struct ttm_mem_type_manager *man) { struct amdgpu_gtt_mgr *mgr = man->priv; + s64 result = man->size - atomic64_read(&mgr->available); - return (u64)(man->size - atomic64_read(&mgr->available)) * PAGE_SIZE; + return (result > 0 ? result : 0) * PAGE_SIZE; } /**@@ -265,7 +267,7 @@ static void amdgpu_gtt_mgr_debug(structttm_mem_type_manager *man, drm_mm_print(&mgr->mm, printer); spin_unlock(&mgr->lock); - drm_printf(printer, "man size:%llu pages, gtt available:%llu pages, usage:%lluMB\n", + drm_printf(printer, "man size:%llu pages, gtt available:%lld pages, usage:%lluMB\n", man->size, (u64)atomic64_read(&mgr->available),
amdgpu_gtt_mgr_usage(man)>> 20);
}
_______________________________________________
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): 88d7a8da-821d-396a-1fb9-84454478b7c4-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 2/2] drm/amdgpu: allow GTT overcommit during bind
Am 17.10.2017 um 06:11 schrieb Chunming Zhou:
Quoted 9 lines · Christian König
Quoted 6 lines
Am 16.10.2017 um 11:42 schrieb Chunming Zhou:
Quoted 5 lines · Christian König
Quoted 2 lines
From: Christian König <[email protected]>
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 2 lines
While binding BOs to GART we need to allow a bit overcommit in the GTT domain.
If allowing overcommit, will the new node not over the GART mc range? Which is also allowed?
No that is checked separately by
drm_mm_insert_node_in_range().This is just to cover the case when we have a BO in GTT space which needs to be bound into the GART table.
Sorry, I missed that even gart BO is also without node during creating.
One nitpick,atomic64_sub(mem->num_pages, &mgr->available)will be calculated twice for one gart bo create and pin, which results in available isn't correct.
Yeah, that is true but not as problematic as you think.
The BO is transfered from the old mem object (without GART mapping) to the new mem object (with GART mapping). While doing this the old mem object is released, so we actually don't leak the memory.
It's just that for a moment the BO is accounted twice, once for the old location and once for the new one.
But we had that behavior previously as well, so that is not something introduced with this patch.
Regards,
Christian.
Quoted 57 lines
Regards,
David ZhouQuoted 53 lines
Regards,
Christian.Quoted 48 lines
Regards,
David ZhouQuoted 44 lines
Otherwise we can never use the full GART space when GART size=GTT
size.Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +5
-1@@ -169,7 +169,8 @@ static int amdgpu_gtt_mgr_new(structttm_mem_type_manager *man, int r;spin_lock (&mgr->lock); -if (atomic64_read (&mgr->available) < mem->num_pages) { +if ((&tbo->mem == mem || tbo->mem.mem_type !=TTM_PL_TT ) && +atomic64_read (&mgr->available) < mem->num_pages) {spin_unlock (&mgr->lock);return 0 ; }@@ -244,8 +245,9 @@ static void amdgpu_gtt_mgr_del(structttm_mem_type_manager *man, uint64_t amdgpu_gtt_mgr_usage(struct ttm_mem_type_manager *man) { struct amdgpu_gtt_mgr *mgr = man->priv; +s64 result = man->size -atomic64_read (&mgr->available); - return (u64)(man->size - atomic64_read(&mgr->available)) *PAGE_SIZE ; +return (result >0 ? result :0 ) *PAGE_SIZE ; }/** @@ -265,7 +267,7 @@ static void amdgpu_gtt_mgr_debug(struct ttm_mem_type_manager *man,drm_mm_print (&mgr->mm, printer);spin_unlock (&mgr->lock); - drm_printf(printer, "man size:%llu pages, gtt available:%llu pages, usage:%lluMB\n", + drm_printf(printer, "man size:%llu pages, gtt available:%lld pages, usage:%lluMB\n", man->size, (u64)atomic64_read(&mgr->available), amdgpu_gtt_mgr_usage(man) >> 20); }
_______________________________________________
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): d23f395f-df2e-8cba-c973-253111e92f61-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 2/2] drm/amdgpu: allow GTT overcommit during bind
Quoted 16 lines · Christian König
Am 17.10.2017 um 06:11 schrieb Chunming Zhou:
Quoted 15 lines · Christian König
Quoted 12 lines
Am 16.10.2017 um 11:42 schrieb Chunming Zhou:
Quoted 8 lines · Christian König
Quoted 4 lines
From: Christian König <[email protected]>
While binding BOs to GART we need to allow a bit overcommit in the GTT domain.
If allowing overcommit, will the new node not over the GART mc range? Which is also allowed?
No that is checked separately by
drm_mm_insert_node_in_range().This is just to cover the case when we have a BO in GTT space which needs to be bound into the GART table.
Quoted 8 lines
Quoted 2 lines
Sorry, I missed that even gart BO is also without node during creating.
One nitpick,atomic64_sub(mem->num_pages, &mgr->available)will be calculated twice for one gart bo create and pin, which results in available isn't correct.Yeah, that is true but not as problematic as you think.
The BO is transfered from the old mem object (without GART mapping) to the new mem object (with GART mapping). While doing this the old mem object is released, so we actually don't leak the memory.
It's just that for a moment the BO is accounted twice, once for the old location and once for the new one.
If in memory pressure, I think we could allocate memory over the mgr limitation.
For example, the limitation is 1024M, the BO allocation is 800M, when the second counting, the available will be -576M, since available is unsigned, if another process allocation(800M) is coming at this moment, the bo_create is still successful, the binding will be fail. But the total allocation will be over the mgr limitation.
Regards,
David Zhou
Quoted 61 lines
But we had that behavior previously as well, so that is not something introduced with this patch.
Regards,
Christian.Quoted 54 lines
Regards,
David ZhouQuoted 50 lines
Regards,
Christian.Quoted 45 lines
Regards,
David ZhouQuoted 41 lines
Otherwise we can never use the full GART space when GART size=GTT size.
Signed-off-by Christian König <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c| 8 +++++---1 file changed, 5 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +5
-1@@ -169,7 +169,8 @@ static int amdgpu_gtt_mgr_new(structttm_mem_type_manager *man, int r; spin_lock(&mgr->lock); - if (atomic64_read(&mgr->available) < mem->num_pages) { + if ((&tbo->mem == mem || tbo->mem.mem_type != TTM_PL_TT) && + atomic64_read(&mgr->available) < mem->num_pages) { spin_unlock(&mgr->lock); return 0; }@@ -244,8 +245,9 @@ static void amdgpu_gtt_mgr_del(structttm_mem_type_manager *man, uint64_t amdgpu_gtt_mgr_usage(struct ttm_mem_type_manager *man) { struct amdgpu_gtt_mgr *mgr = man->priv; + s64 result = man->size - atomic64_read(&mgr->available); - return (u64)(man->size - atomic64_read(&mgr->available)) * PAGE_SIZE; + return (result > 0 ? result : 0) * PAGE_SIZE; } /**@@ -265,7 +267,7 @@ static void amdgpu_gtt_mgr_debug(structttm_mem_type_manager *man, drm_mm_print(&mgr->mm, printer); spin_unlock(&mgr->lock); - drm_printf(printer, "man size:%llu pages, gtt available:%llu pages, usage:%lluMB\n", + drm_printf(printer, "man size:%llu pages, gtt available:%lld pages, usage:%lluMB\n", man->size, (u64)atomic64_read(&mgr->available),
amdgpu_gtt_mgr_usage(man)>> 20);
}
_______________________________________________
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): 621ab89b-83a7-1947-ecec-e371433bcaa6-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 2/2] drm/amdgpu: allow GTT overcommit during bind
Am 17.10.2017 um 10:15 schrieb Chunming Zhou:
Quoted 22 lines · Christian König
Quoted 19 lines
Am 17.10.2017 um 06:11 schrieb Chunming Zhou:
Quoted 17 lines · Christian König
Quoted 4 lines
Am 16.10.2017 um 11:42 schrieb Chunming Zhou:
Quoted 3 lines · Christian König
Quoted 8 lines
Quoted 5 lines
Quoted 4 lines
From: Christian König <[email protected]>
While binding BOs to GART we need to allow a bit overcommit in the GTT domain.
If allowing overcommit, will the new node not over the GART mc range? Which is also allowed?
No that is checked separately by
drm_mm_insert_node_in_range().This is just to cover the case when we have a BO in GTT space which needs to be bound into the GART table.
Sorry, I missed that even gart BO is also without node during creating.
One nitpick,atomic64_sub(mem->num_pages, &mgr->available)will be calculated twice for one gart bo create and pin, which results in available isn't correct.
Quoted 8 lines
Quoted 5 lines
Yeah, that is true but not as problematic as you think.
The BO is transfered from the old mem object (without GART mapping) to the new mem object (with GART mapping). While doing this the old mem object is released, so we actually don't leak the memory.
It's just that for a moment the BO is accounted twice, once for the old location and once for the new one.
If in memory pressure, I think we could allocate memory over the mgr limitation.
For example, the limitation is 1024M, the BO allocation is 800M, when the second counting, the available will be -576M,
Yes, correct so far. That's why I've added the extra check in amdgpu_gtt_mgr_usage().
Quoted 1 line
since available is unsigned
available is an atomic64_t and that is signed IIRC.
We could cast mem->num_pages to signed as well to be double sure, but as far as I can see that should work.
Regards,
Christian.
Quoted 68 lines
Regards,
David ZhouQuoted 64 lines
But we had that behavior previously as well, so that is not something introduced with this patch.
Regards,
Christian.Quoted 57 lines
Regards,
David ZhouQuoted 53 lines
Regards,
Christian.Quoted 48 lines
Regards,
David ZhouQuoted 44 lines
Otherwise we can never use the full GART space when GART
size=GTT size.Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +5
-1@@ -169,7 +169,8 @@ static int amdgpu_gtt_mgr_new(structttm_mem_type_manager *man, int r;spin_lock (&mgr->lock); -if (atomic64_read (&mgr->available) < mem->num_pages) { +if ((&tbo->mem == mem || tbo->mem.mem_type !=TTM_PL_TT ) && +atomic64_read (&mgr->available) < mem->num_pages) {spin_unlock (&mgr->lock);return 0 ; }@@ -244,8 +245,9 @@ static void amdgpu_gtt_mgr_del(structttm_mem_type_manager *man, uint64_t amdgpu_gtt_mgr_usage(struct ttm_mem_type_manager *man) { struct amdgpu_gtt_mgr *mgr = man->priv; +s64 result = man->size -atomic64_read (&mgr->available); - return (u64)(man->size - atomic64_read(&mgr->available)) *PAGE_SIZE ; +return (result >0 ? result :0 ) *PAGE_SIZE ; }/** @@ -265,7 +267,7 @@ static void amdgpu_gtt_mgr_debug(struct ttm_mem_type_manager *man,drm_mm_print (&mgr->mm, printer);spin_unlock (&mgr->lock); - drm_printf(printer, "man size:%llu pages, gtt available:%llu pages, usage:%lluMB\n", + drm_printf(printer, "man size:%llu pages, gtt available:%lld pages, usage:%lluMB\n", man->size, (u64)atomic64_read(&mgr->available), amdgpu_gtt_mgr_usage(man) >> 20); }
_______________________________________________
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): d5ea66a0-134c-ac18-5056-ecf62d7b6dab-5C7GfCeVMHo@public.gmane.org
Zhu, Rex
Tested-by Rex ZhuRE: [PATCH 2/2] drm/amdgpu: allow GTT overcommit during bind
Patch is
Best Regards
Rex
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Christian König
Sent: Tuesday, October 17, 2017 4:28 PM
To: Zhou, David(ChunMing); [email protected]
Subject: Re: [PATCH 2/2] drm/amdgpu: allow GTT overcommit during bind
Am 17.10.2017 um 10:15 schrieb Chunming Zhou:
Quoted 32 lines · Christian König
Quoted 29 lines
Am 17.10.2017 um 06:11 schrieb Chunming Zhou:
Quoted 13 lines · Christian König
Quoted 10 lines
Am 16.10.2017 um 11:42 schrieb Chunming Zhou:
Quoted 9 lines · Christian König
Quoted 4 lines
From: Christian König <[email protected]>
While binding BOs to GART we need to allow a bit overcommit in the GTT domain.
If allowing overcommit, will the new node not over the GART mc range? Which is also allowed?
Quoted 8 lines
Quoted 4 lines
No that is checked separately by
drm_mm_insert_node_in_range().This is just to cover the case when we have a BO in GTT space which needs to be bound into the GART table.
Sorry, I missed that even gart BO is also without node during creating. One nitpick,
atomic64_sub(mem->num_pages, &mgr->available)will be calculated twice for one gart bo create and pin, which results in available isn't correct.Yeah, that is true but not as problematic as you think.
The BO is transfered from the old mem object (without GART mapping) to the new mem object (with GART mapping). While doing this the old mem object is released, so we actually don't leak the memory.
Quoted 7 lines
Quoted 2 lines
It's just that for a moment the BO is accounted twice, once for the old location and once for the new one.
If in memory pressure, I think we could allocate memory over the mgr limitation.
For example, the limitation is 1024M, the BO allocation is 800M, when the second counting, the available will be -576M,
Yes, correct so far. That's why I've added the extra check in amdgpu_gtt_mgr_usage().
Quoted 1 line
since available is unsigned
available is an atomic64_t and that is signed IIRC.
We could cast mem->num_pages to signed as well to be double sure, but as far as I can see that should work.
Regards,
Christian.
Quoted 70 lines
Regards,
David ZhouQuoted 66 lines
But we had that behavior previously as well, so that is not something introduced with this patch.
Regards,
Christian.Quoted 58 lines
Regards,
David ZhouQuoted 54 lines
Regards,
Christian.Quoted 49 lines
Regards,
David ZhouQuoted 45 lines
Otherwise we can never use the full GART space when GART
size=GTT size.Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +5
-1@@ -169,7 +169,8 @@ static int amdgpu_gtt_mgr_new(structttm_mem_type_manager *man, int r;spin_lock (&mgr->lock); -if (atomic64_read (&mgr->available) < mem->num_pages) { +if ((&tbo->mem == mem || tbo->mem.mem_type !=TTM_PL_TT ) && +atomic64_read (&mgr->available) < mem->num_pages) {spin_unlock (&mgr->lock);return 0 ; }@@ -244,8 +245,9 @@ static void amdgpu_gtt_mgr_del(structttm_mem_type_manager *man, uint64_t amdgpu_gtt_mgr_usage(struct ttm_mem_type_manager *man) { struct amdgpu_gtt_mgr *mgr = man->priv; +s64 result = man->size -atomic64_read (&mgr->available); - return (u64)(man->size - atomic64_read(&mgr->available)) *PAGE_SIZE ; +return (result >0 ? result :0 ) *PAGE_SIZE ; }/** @@ -265,7 +267,7 @@ static void amdgpu_gtt_mgr_debug(struct ttm_mem_type_manager *man,drm_mm_print (&mgr->mm, printer);spin_unlock (&mgr->lock); - drm_printf(printer, "man size:%llu pages, gtt available:%llu pages, usage:%lluMB\n", + drm_printf(printer, "man size:%llu pages, gtt available:%lld pages, usage:%lluMB\n", man->size, (u64)atomic64_read(&mgr->available), amdgpu_gtt_mgr_usage(man) >> 20); }
_______________________________________________
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: allow GTT overcommit during bind
In reply to a message not in the archiveQuoted 32 lines · Christian König
Am 17.10.2017 um 10:15 schrieb Chunming Zhou:
Quoted 22 lines · Christian König
Quoted 19 lines
Am 17.10.2017 um 06:11 schrieb Chunming Zhou:
Quoted 17 lines · Christian König
Quoted 4 lines
Am 16.10.2017 um 11:42 schrieb Chunming Zhou:
Quoted 3 lines · Christian König
Quoted 8 lines
Quoted 5 lines
Quoted 4 lines
From: Christian König <[email protected]>
While binding BOs to GART we need to allow a bit overcommit in the GTT domain.
If allowing overcommit, will the new node not over the GART mc range? Which is also allowed?
No that is checked separately by
drm_mm_insert_node_in_range().This is just to cover the case when we have a BO in GTT space which needs to be bound into the GART table.
Sorry, I missed that even gart BO is also without node during creating.
One nitpick,atomic64_sub(mem->num_pages, &mgr->available)will be calculated twice for one gart bo create and pin, which results in available isn't correct.Quoted 8 lines
Quoted 5 lines
Yeah, that is true but not as problematic as you think.
The BO is transfered from the old mem object (without GART mapping) to the new mem object (with GART mapping). While doing this the old mem object is released, so we actually don't leak the memory.
It's just that for a moment the BO is accounted twice, once for the old location and once for the new one.
If in memory pressure, I think we could allocate memory over the mgr limitation.
For example, the limitation is 1024M, the BO allocation is 800M, when the second counting, the available will be -576M,
Quoted 7 lines
Yes, correct so far. That's why I've added the extra check in
amdgpu_gtt_mgr_usage().Quoted 1 line
since available is unsigned
available is an
atomic64_tand that is signed IIRC.We could cast
mem->num_pagesto signed as well to be double sure, but as far as I can see that should work.
I agree above, but why you cut some part of mine:" if another process allocation(800M) is coming at this moment, the bo_create is still successful, the binding will be fail. But the total allocation will be over the mgr limitation." What do you think of you cut?
Regards,
David Zhou
Quoted 70 lines
Regards,
Christian.Quoted 65 lines
Regards,
David ZhouQuoted 61 lines
But we had that behavior previously as well, so that is not something introduced with this patch.
Regards,
Christian.Quoted 54 lines
Regards,
David ZhouQuoted 50 lines
Regards,
Christian.Quoted 45 lines
Regards,
David ZhouQuoted 41 lines
Otherwise we can never use the full GART space when GART size=GTT size.
Signed-off-by Christian König <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c| 8 +++++---1 file changed, 5 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +5
-1@@ -169,7 +169,8 @@ static int amdgpu_gtt_mgr_new(structttm_mem_type_manager *man, int r; spin_lock(&mgr->lock); - if (atomic64_read(&mgr->available) < mem->num_pages) { + if ((&tbo->mem == mem || tbo->mem.mem_type != TTM_PL_TT) && + atomic64_read(&mgr->available) < mem->num_pages) { spin_unlock(&mgr->lock); return 0; }@@ -244,8 +245,9 @@ static void amdgpu_gtt_mgr_del(structttm_mem_type_manager *man, uint64_t amdgpu_gtt_mgr_usage(struct ttm_mem_type_manager *man) { struct amdgpu_gtt_mgr *mgr = man->priv; + s64 result = man->size - atomic64_read(&mgr->available); - return (u64)(man->size - atomic64_read(&mgr->available)) * PAGE_SIZE; + return (result > 0 ? result : 0) * PAGE_SIZE; } /**@@ -265,7 +267,7 @@ static void amdgpu_gtt_mgr_debug(structttm_mem_type_manager *man, drm_mm_print(&mgr->mm, printer); spin_unlock(&mgr->lock); - drm_printf(printer, "man size:%llu pages, gtt available:%llu pages, usage:%lluMB\n", + drm_printf(printer, "man size:%llu pages, gtt available:%lld pages, usage:%lluMB\n", man->size, (u64)atomic64_read(&mgr->available),
amdgpu_gtt_mgr_usage(man)>> 20);
}
_______________________________________________
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): ce043b07-a962-c62e-451c-74b02c577fce-5C7GfCeVMHo@public.gmane.org
Chunming Zhou
Reviewed-byRe: [PATCH 2/2] drm/amdgpu: allow GTT overcommit during bind
Quoted 37 lines · Chunming Zhou
Quoted 34 lines · Christian König
Am 17.10.2017 um 10:15 schrieb Chunming Zhou:
Quoted 22 lines · Christian König
Quoted 19 lines
Am 17.10.2017 um 06:11 schrieb Chunming Zhou:
Quoted 17 lines · Christian König
Quoted 4 lines
Am 16.10.2017 um 11:42 schrieb Chunming Zhou:
Quoted 3 lines · Christian König
Quoted 8 lines
Quoted 5 lines
Quoted 4 lines
From: Christian König <[email protected]>
While binding BOs to GART we need to allow a bit overcommit in the GTT domain.
If allowing overcommit, will the new node not over the GART mc range? Which is also allowed?
No that is checked separately by
drm_mm_insert_node_in_range().This is just to cover the case when we have a BO in GTT space which needs to be bound into the GART table.
Sorry, I missed that even gart BO is also without node during creating.
One nitpick,atomic64_sub(mem->num_pages, &mgr->available)will be calculated twice for one gart bo create and pin, which results in available isn't correct.Quoted 8 lines
Quoted 5 lines
Yeah, that is true but not as problematic as you think.
The BO is transfered from the old mem object (without GART mapping) to the new mem object (with GART mapping). While doing this the old mem object is released, so we actually don't leak the memory.
It's just that for a moment the BO is accounted twice, once for the old location and once for the new one.
If in memory pressure, I think we could allocate memory over the mgr limitation.
For example, the limitation is 1024M, the BO allocation is 800M, when the second counting, the available will be -576M,
Yes, correct so far. That's why I've added the extra check in
amdgpu_gtt_mgr_usage().
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
since available is unsigned
available is an
atomic64_tand that is signed IIRC.We could cast
mem->num_pagesto signed as well to be double sure, but as far as I can see that should work.I agree above, but why you cut some part of mine:" if another process allocation(800M) is coming at this moment, the
bo_createis still successful, the binding will be fail. But the total allocation will be over the mgr limitation." What do you think of you cut?
Ah, sorry, atomic64_t is singed, so the checking will fail, this case will not happen.
Quoted 75 lines
Regards,
David ZhouQuoted 70 lines
Regards,
Christian.Quoted 65 lines
Regards,
David ZhouQuoted 61 lines
But we had that behavior previously as well, so that is not something introduced with this patch.
Regards,
Christian.Quoted 54 lines
Regards,
David ZhouQuoted 50 lines
Regards,
Christian.Quoted 45 lines
Regards,
David ZhouQuoted 41 lines
Otherwise we can never use the full GART space when GART size=GTT size.
Signed-off-by Christian König <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c| 8 +++++---1 file changed, 5 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +5
-1@@ -169,7 +169,8 @@ static int amdgpu_gtt_mgr_new(structttm_mem_type_manager *man, int r; spin_lock(&mgr->lock); - if (atomic64_read(&mgr->available) < mem->num_pages) { + if ((&tbo->mem == mem || tbo->mem.mem_type != TTM_PL_TT) && + atomic64_read(&mgr->available) < mem->num_pages) { spin_unlock(&mgr->lock); return 0; }@@ -244,8 +245,9 @@ static void amdgpu_gtt_mgr_del(structttm_mem_type_manager *man, uint64_t amdgpu_gtt_mgr_usage(struct ttm_mem_type_manager *man) { struct amdgpu_gtt_mgr *mgr = man->priv; + s64 result = man->size - atomic64_read(&mgr->available); - return (u64)(man->size - atomic64_read(&mgr->available)) * PAGE_SIZE; + return (result > 0 ? result : 0) * PAGE_SIZE; } /**@@ -265,7 +267,7 @@ static void amdgpu_gtt_mgr_debug(structttm_mem_type_manager *man, drm_mm_print(&mgr->mm, printer); spin_unlock(&mgr->lock); - drm_printf(printer, "man size:%llu pages, gtt available:%llu pages, usage:%lluMB\n", + drm_printf(printer, "man size:%llu pages, gtt available:%lld pages, usage:%lluMB\n", man->size, (u64)atomic64_read(&mgr->available),
amdgpu_gtt_mgr_usage(man)>> 20);
}
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
Deucher, Alexander
Reviewed-by Alex DeucherQuoted 9 lines
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Christian König
Sent: Monday, October 16, 2017 5:27 AM
To: [email protected]
Subject: [PATCH 1/2] drm/amdgpu: linear validate first then bind to GARTFrom: Christian König <[email protected]>
Quoted 7 lines
For VM emulation for old UVD/VCE we need to validate the BO with linear VRAM flag set first and then eventually bind it to GART.
Validating with linear VRAM flag set can move the BO to GART making UVD/VCE read/write from an unbound GART BO.
Signed-off-by Christian König <[email protected]>
Alex
Quoted 42 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +8
-8@@ -1583,14 +1583,14 @@ int amdgpu_cs_find_mapping(struct amdgpu_cs_parser *parser, if (READ_ONCE((*bo)->tbo.resv->lock.ctx) != &parser->ticket) return -EINVAL; - r =amdgpu_ttm_bind (&(*bo)->tbo, &(*bo)->tbo.mem); -if (unlikely (r)) -return r; - -if ((*bo)->flags &AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS ) -return 0 ; +if (!((*bo)->flags &AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS )) { + (*bo)->flags |=AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS ; +amdgpu_ttm_placement_from_domain (*bo, (*bo)- >allowed_domains); + r =ttm_bo_validate (&(*bo)->tbo, &(*bo)->placement, false, + false); +if (r) +return r; + } - (*bo)->flags |=AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS ; - amdgpu_ttm_placement_from_domain(*bo, (*bo)-Quoted 1 line
allowed_domains);drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0
-1- return ttm_bo_validate(&(*bo)->tbo, &(*bo)->placement, false,false);
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +1
-1+return amdgpu_ttm_bind (&(*bo)->tbo, &(*bo)->tbo.mem); } --2.11.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