答复: [PATCH] drm/amdgpu: adjust gtt memory size

Wang, Qingqing Qingqing.Wang at amd.com
Thu Jul 21 09:16:34 UTC 2016


This doesn't work on 32bit systems since totalram is a long (IIRC) and
so this will certainly overflow.

-- can you be more specific, how could the overflow happen?


Additional if I remember correctly we didn't ended the discussion on
what to do here with a conclusion.

-- ok, since it happens in anther mail list, we should stop talking about it here, you can send out your ideas there.

________________________________
发件人: amd-gfx <amd-gfx-bounces at lists.freedesktop.org> 代表 Christian König <deathsimple at vodafone.de>
发送时间: 2016年7月21日 16:53:05
收件人: Wang, Qingqing; amd-gfx at lists.freedesktop.org
主题: Re: [PATCH] drm/amdgpu: adjust gtt memory size

Am 21.07.2016 um 09:46 schrieb Ken Wang:
> Change-Id: If00d5b97ba9e30f9b7f68fdfc134a0f8b3ad2add
> Signed-off-by: Ken Wang <Qingqing.Wang at amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c | 7 ++++++-
>   drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 7 ++++++-
>   2 files changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
> index a3b6048..0b095d5 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
> @@ -336,6 +336,11 @@ static int gmc_v7_0_mc_init(struct amdgpu_device *adev)
>   {
>        u32 tmp;
>        int chansize, numchan;
> +     u64 sysmem_size;
> +     struct sysinfo si;
> +
> +     si_meminfo(&si);
> +     sysmem_size = si.totalram * si.mem_unit;

This doesn't work on 32bit systems since totalram is a long (IIRC) and
so this will certainly overflow.

Additional if I remember correctly we didn't ended the discussion on
what to do here with a conclusion.

Regards,
Christian.

>
>        /* Get VRAM informations */
>        tmp = RREG32(mmMC_ARB_RAMCFG);
> @@ -392,7 +397,7 @@ static int gmc_v7_0_mc_init(struct amdgpu_device *adev)
>         * size equal to the 1024 or vram, whichever is larger.
>         */
>        if (amdgpu_gart_size == -1)
> -             adev->mc.gtt_size = max((1024ULL << 20), adev->mc.mc_vram_size);
> +             adev->mc.gtt_size = max((1024ULL << 20), min(adev->mc.mc_vram_size, sysmem_size/2));
>        else
>                adev->mc.gtt_size = (uint64_t)amdgpu_gart_size << 20;
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
> index 02b6872..790bf7a 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
> @@ -413,6 +413,11 @@ static int gmc_v8_0_mc_init(struct amdgpu_device *adev)
>   {
>        u32 tmp;
>        int chansize, numchan;
> +     u64 sysmem_size;
> +     struct sysinfo si;
> +
> +     si_meminfo(&si);
> +     sysmem_size = si.totalram * si.mem_unit;
>
>        /* Get VRAM informations */
>        tmp = RREG32(mmMC_ARB_RAMCFG);
> @@ -469,7 +474,7 @@ static int gmc_v8_0_mc_init(struct amdgpu_device *adev)
>         * size equal to the 1024 or vram, whichever is larger.
>         */
>        if (amdgpu_gart_size == -1)
> -             adev->mc.gtt_size = max((1024ULL << 20), adev->mc.mc_vram_size);
> +             adev->mc.gtt_size = max((1024ULL << 20), min(adev->mc.mc_vram_size, sysmem_size/2));
>        else
>                adev->mc.gtt_size = (uint64_t)amdgpu_gart_size << 20;
>


_______________________________________________
amd-gfx mailing list
amd-gfx at lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/amd-gfx/attachments/20160721/e2b87861/attachment-0001.html>


More information about the amd-gfx mailing list