[PATCH] drm/amd/amdgpu: set gtt size according to system memory size only
Christian König
christian.koenig at amd.com
Tue Nov 28 10:00:55 UTC 2017
Am 28.11.2017 um 10:40 schrieb Roger He:
> Change-Id: Ib634375b90d875fe04a890fc82fb1e3b7112676a
> Signed-off-by: Roger He <Hongbo.He at amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 16 +++++++++++-----
> 1 file changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> index 17bf0ce..d773c5e 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> @@ -1328,13 +1328,19 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
>
> if (amdgpu_gtt_size == -1) {
> struct sysinfo si;
> + uint64_t sys_mem_size;
>
> si_meminfo(&si);
> - gtt_size = min(max((AMDGPU_DEFAULT_GTT_SIZE_MB << 20),
> - adev->mc.mc_vram_size),
> - ((uint64_t)si.totalram * si.mem_unit * 3/4));
> - }
> - else
> + sys_mem_size = (uint64_t)si.totalram * si.mem_unit;
> + gtt_size = AMDGPU_DEFAULT_GTT_SIZE_MB << 20;
> +
> + /* leave 2GB for OS to work with */
> + if (sys_mem_size > (2ULL << 30)) {
> + gtt_size = max(gtt_size, sys_mem_size - (2ULL << 30));
> + } else
No need for the "{}" here.
> + DRM_INFO("amdgpu: Too small system memory %llu MB\n",
> + sys_mem_size >> 20);
> + } else
I have a preference to stick with the 75% rule similar to how TTM does
things, but that isn't a hard opinion if you have a good argument.
Regards,
Christian.
> gtt_size = (uint64_t)amdgpu_gtt_size << 20;
> r = ttm_bo_init_mm(&adev->mman.bdev, TTM_PL_TT, gtt_size >> PAGE_SHIFT);
> if (r) {
More information about the amd-gfx
mailing list