drm/amdgpu: fix size validation failure in large buffer creation
Subsystems (2)
PATCH 1/1 drm/amdgpu: fix size validation failure in large buffer creation
From: "Tianci.Yin" <[email protected]>
[why]
When GTT domain size is smaller than VRAM, if APP apply a very large buffer whose size is larger than GTT but smaller than VRAM, the size validation will fail.
[how]
Validate VRAM domain size at first place, then GTT domain.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +9 -9
@@ -464,21 +464,21 @@ static bool amdgpu_bo_validate_size(struct amdgpu_device *adev, {struct ttm_mem_type_manager *man =NULL ; -/* -* If GTT is part of requested domains the check must succeed to -* allow fall back to GTT -*/ -if (domain &AMDGPU_GEM_DOMAIN_GTT ) { - man = &adev->mman.bdev.man[TTM_PL_TT ]; +if (domain &AMDGPU_GEM_DOMAIN_VRAM ) { + man = &adev->mman.bdev.man[TTM_PL_VRAM ];if (size < (man->size <<PAGE_SHIFT ))return true; -else +else if (!(domain &AMDGPU_GEM_DOMAIN_GTT )) goto fail; } -if (domain &AMDGPU_GEM_DOMAIN_VRAM ) { - man = &adev->mman.bdev.man[TTM_PL_VRAM ]; +/* +* If GTT is part of requested domains the check must succeed to +* allow fall back to GTT +*/ +if (domain &AMDGPU_GEM_DOMAIN_GTT ) { + man = &adev->mman.bdev.man[TTM_PL_TT ];if (size < (man->size <<PAGE_SHIFT ))return true;
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Christian König
NAKAm 20.03.20 um 10:46 schrieb Tianci Yin:
Quoted 9 lines
From: "Tianci.Yin" <[email protected]>
[why]
When GTT domain size is smaller than VRAM, if APP apply a very large buffer whose size is larger than GTT but smaller than VRAM, the size validation will fail.[how]
Validate VRAM domain size at first place, then GTT domain.
NAK, this is intended behavior. VRAM allocations larger than GTT allocations are illegal and can crash the memory management.
Regards,
Christian.
Quoted 32 lines
Change-Id Ic1d31b9b0a4939e6bba0241ff79ae9aa2225ee05Signed-off-by Tianci.Yin <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +3
-8@@ -464,21 +464,21 @@ static bool amdgpu_bo_validate_size(struct amdgpu_device *adev, {struct ttm_mem_type_manager *man =NULL ; -/* -* If GTT is part of requested domains the check must succeed to -* allow fall back to GTT -*/ -if (domain &AMDGPU_GEM_DOMAIN_GTT ) { - man = &adev->mman.bdev.man[TTM_PL_TT ]; +if (domain &AMDGPU_GEM_DOMAIN_VRAM ) { + man = &adev->mman.bdev.man[TTM_PL_VRAM ];if (size < (man->size <<PAGE_SHIFT ))return true; -else +else if (!(domain &AMDGPU_GEM_DOMAIN_GTT )) goto fail; } -if (domain &AMDGPU_GEM_DOMAIN_VRAM ) {
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c static bool amdgpu_bo_validate_size(struct amdgpu_device *adev, · line 484
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +6
-1- man = &adev->mman.bdev.man[TTM_PL_VRAM ]; +/* +* If GTT is part of requested domains the check must succeed to +* allow fall back to GTT +*/ +if (domain &AMDGPU_GEM_DOMAIN_GTT ) { + man = &adev->mman.bdev.man[TTM_PL_TT ];if (size < (man->size <<PAGE_SHIFT ))return true;
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
[AMD Official Use Only - Internal Distribution Only]
Hi Christian,
You mean amdgpu_bo_validate_size() return false is the expectation when GTT < request < VRAM, even if VRAM size can meet the requirement, right?
Thanks!
Rico
________________________________
From: Christian K?nig <[email protected]>
Sent: Saturday, March 21, 2020 2:27
To: Yin, Tianci (Rico) <[email protected]>; [email protected] <[email protected]>
Cc: Xu, Feifei <[email protected]>; Li, Pauline <[email protected]>; Long, Gang <[email protected]>; Zhang, Hawking <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: fix size validation failure in large buffer creation
Am 20.03.20 um 10:46 schrieb Tianci Yin:
Quoted 9 lines
From: "Tianci.Yin" <[email protected]>
[why]
When GTT domain size is smaller than VRAM, if APP apply a very large buffer whose size is larger than GTT but smaller than VRAM, the size validation will fail.[how]
Validate VRAM domain size at first place, then GTT domain.
NAK, this is intended behavior. VRAM allocations larger than GTT allocations are illegal and can crash the memory management.
Regards,
Christian.
Quoted 32 lines
Change-Id Ic1d31b9b0a4939e6bba0241ff79ae9aa2225ee05Signed-off-by Tianci.Yin <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +3
-8@@ -464,21 +464,21 @@ static bool amdgpu_bo_validate_size(struct amdgpu_device *adev, {struct ttm_mem_type_manager *man =NULL ; -/* -* If GTT is part of requested domains the check must succeed to -* allow fall back to GTT -*/ -if (domain &AMDGPU_GEM_DOMAIN_GTT ) { - man = &adev->mman.bdev.man[TTM_PL_TT ]; +if (domain &AMDGPU_GEM_DOMAIN_VRAM ) { + man = &adev->mman.bdev.man[TTM_PL_VRAM ];if (size < (man->size <<PAGE_SHIFT ))return true; -else +else if (!(domain &AMDGPU_GEM_DOMAIN_GTT )) goto fail; } -if (domain &AMDGPU_GEM_DOMAIN_VRAM ) {
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c static bool amdgpu_bo_validate_size(struct amdgpu_device *adev, · line 484
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +6
-1- man = &adev->mman.bdev.man[TTM_PL_VRAM ]; +/* +* If GTT is part of requested domains the check must succeed to +* allow fall back to GTT +*/ +if (domain &AMDGPU_GEM_DOMAIN_GTT ) { + man = &adev->mman.bdev.man[TTM_PL_TT ];if (size < (man->size <<PAGE_SHIFT ))return true;
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Correct, yes.
For example if you have a 16GB VRAM Vega10 in a system with just 4GB RAM you can only allocate < 4GB VRAM (actually more like ~3GB) in a single BO.
Otherwise we wouldn't be able to evacuate VRAM to system memory and disk during suspend/resume or during memory pressure.
Regards,
Christian.
Am 21.03.2020 09:32 schrieb "Yin, Tianci (Rico)" <[email protected]>:
[AMD Official Use Only - Internal Distribution Only]
Hi Christian,
You mean amdgpu_bo_validate_size() return false is the expectation when GTT < request < VRAM, even if VRAM size can meet the requirement, right?
Thanks!
Rico
________________________________
From: Christian König <[email protected]>
Sent: Saturday, March 21, 2020 2:27
To: Yin, Tianci (Rico) <[email protected]>; [email protected] <[email protected]>
Cc: Xu, Feifei <[email protected]>; Li, Pauline <[email protected]>; Long, Gang <[email protected]>; Zhang, Hawking <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: fix size validation failure in large buffer creation
Am 20.03.20 um 10:46 schrieb Tianci Yin:
Quoted 9 lines
From: "Tianci.Yin" <[email protected]>
[why]
When GTT domain size is smaller than VRAM, if APP apply a very large buffer whose size is larger than GTT but smaller than VRAM, the size validation will fail.[how]
Validate VRAM domain size at first place, then GTT domain.
NAK, this is intended behavior. VRAM allocations larger than GTT allocations are illegal and can crash the memory management.
Regards,
Christian.
Quoted 32 lines
Change-Id Ic1d31b9b0a4939e6bba0241ff79ae9aa2225ee05Signed-off-by Tianci.Yin <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +3
-8@@ -464,21 +464,21 @@ static bool amdgpu_bo_validate_size(struct amdgpu_device *adev, {struct ttm_mem_type_manager *man =NULL ; -/* -* If GTT is part of requested domains the check must succeed to -* allow fall back to GTT -*/ -if (domain &AMDGPU_GEM_DOMAIN_GTT ) { - man = &adev->mman.bdev.man[TTM_PL_TT ]; +if (domain &AMDGPU_GEM_DOMAIN_VRAM ) { + man = &adev->mman.bdev.man[TTM_PL_VRAM ];if (size < (man->size <<PAGE_SHIFT ))return true; -else +else if (!(domain &AMDGPU_GEM_DOMAIN_GTT )) goto fail; } -if (domain &AMDGPU_GEM_DOMAIN_VRAM ) {
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c static bool amdgpu_bo_validate_size(struct amdgpu_device *adev, · line 484
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +6
-1- man = &adev->mman.bdev.man[TTM_PL_VRAM ]; +/* +* If GTT is part of requested domains the check must succeed to +* allow fall back to GTT +*/ +if (domain &AMDGPU_GEM_DOMAIN_GTT ) { + man = &adev->mman.bdev.man[TTM_PL_TT ];if (size < (man->size <<PAGE_SHIFT ))return true;
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
[AMD Official Use Only - Internal Distribution Only]
I see, thanks your explanation.
Regards,
Rico
________________________________
From: Koenig, Christian <[email protected]>
Sent: Saturday, March 21, 2020 16:44
To: Yin, Tianci (Rico) <[email protected]>
Cc: [email protected] <[email protected]>; Xu, Feifei <[email protected]>; Li, Pauline <[email protected]>; Long, Gang <[email protected]>; Zhang, Hawking <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: fix size validation failure in large buffer creation
Correct, yes.
For example if you have a 16GB VRAM Vega10 in a system with just 4GB RAM you can only allocate < 4GB VRAM (actually more like ~3GB) in a single BO.
Otherwise we wouldn't be able to evacuate VRAM to system memory and disk during suspend/resume or during memory pressure.
Regards,
Christian.
Am 21.03.2020 09:32 schrieb "Yin, Tianci (Rico)" <[email protected]>:
[AMD Official Use Only - Internal Distribution Only]
Hi Christian,
You mean amdgpu_bo_validate_size() return false is the expectation when GTT < request < VRAM, even if VRAM size can meet the requirement, right?
Thanks!
Rico
________________________________
From: Christian König <[email protected]>
Sent: Saturday, March 21, 2020 2:27
To: Yin, Tianci (Rico) <[email protected]>; [email protected] <[email protected]>
Cc: Xu, Feifei <[email protected]>; Li, Pauline <[email protected]>; Long, Gang <[email protected]>; Zhang, Hawking <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: fix size validation failure in large buffer creation
Am 20.03.20 um 10:46 schrieb Tianci Yin:
Quoted 9 lines
From: "Tianci.Yin" <[email protected]>
[why]
When GTT domain size is smaller than VRAM, if APP apply a very large buffer whose size is larger than GTT but smaller than VRAM, the size validation will fail.[how]
Validate VRAM domain size at first place, then GTT domain.
NAK, this is intended behavior. VRAM allocations larger than GTT allocations are illegal and can crash the memory management.
Regards,
Christian.
Quoted 32 lines
Change-Id Ic1d31b9b0a4939e6bba0241ff79ae9aa2225ee05Signed-off-by Tianci.Yin <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +3
-8@@ -464,21 +464,21 @@ static bool amdgpu_bo_validate_size(struct amdgpu_device *adev, {struct ttm_mem_type_manager *man =NULL ; -/* -* If GTT is part of requested domains the check must succeed to -* allow fall back to GTT -*/ -if (domain &AMDGPU_GEM_DOMAIN_GTT ) { - man = &adev->mman.bdev.man[TTM_PL_TT ]; +if (domain &AMDGPU_GEM_DOMAIN_VRAM ) { + man = &adev->mman.bdev.man[TTM_PL_VRAM ];if (size < (man->size <<PAGE_SHIFT ))return true; -else +else if (!(domain &AMDGPU_GEM_DOMAIN_GTT )) goto fail; } -if (domain &AMDGPU_GEM_DOMAIN_VRAM ) {
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c static bool amdgpu_bo_validate_size(struct amdgpu_device *adev, · line 484
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +6
-1- man = &adev->mman.bdev.man[TTM_PL_VRAM ]; +/* +* If GTT is part of requested domains the check must succeed to +* allow fall back to GTT +*/ +if (domain &AMDGPU_GEM_DOMAIN_GTT ) { + man = &adev->mman.bdev.man[TTM_PL_TT ];if (size < (man->size <<PAGE_SHIFT ))return true;
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx