[PATCH] drm/amdgpu: adjust get preferred domain policy

Christian König christian.koenig at amd.com
Fri Aug 27 08:51:19 UTC 2021


Am 27.08.21 um 10:45 schrieb Yifan Zhang:
> current preferred domain policy is static, which makes vram > 256M
> APU never get a chance to allocate system S/G framebuffer. Change
> this policy to take vram memory pressure into accout. If system
> support both vram/system memory, return the preferred domain based
> on vram usage.
>
> Signed-off-by: Yifan Zhang <yifan1.zhang at amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> index 65a9b23f0a46..ea3b084e3c3f 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> @@ -1530,7 +1530,9 @@ uint32_t amdgpu_bo_get_preferred_domain(struct amdgpu_device *adev,
>   {
>   	if (domain == (AMDGPU_GEM_DOMAIN_VRAM | AMDGPU_GEM_DOMAIN_GTT)) {
>   		domain = AMDGPU_GEM_DOMAIN_VRAM;
> -		if (adev->gmc.real_vram_size <= AMDGPU_SG_THRESHOLD)
> +		if (adev->gmc.real_vram_size -
> +				atomic64_read(&adev->mman.vram_mgr.vis_usage) <=
> +				AMDGPU_SG_THRESHOLD)

Well apart from that you are accessing a private member of the vram 
manager and have messed up the coding style I don't think that this is a 
good idea at all from the design point of view.

Scanning out from SG has some huge disadvantages (unstable on some HW 
generations, more walker overhead etc) that we certainly don't want to 
enable it unless we don't absolutely need it.

Christian.

>   			domain = AMDGPU_GEM_DOMAIN_GTT;
>   	}
>   	return domain;



More information about the amd-gfx mailing list