Skip to contentSkip to conversation

drm/amdgpu: adjust gtt memory size

PATCH In review Ken Wang 4 participants 13 messages Jul 21, 2016 – Aug 2, 2016 12 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

Ken Wang

author
#0 lore raw

PATCH 1/1 drm/amdgpu: adjust gtt memory size

Change-Id If00d5b97ba9e30f9b7f68fdfc134a0f8b3ad2add
---
 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(-)
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +6 -1
index a3b6048..0b095d5 100644
@@ -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;
 
 	/* 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;
 
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +6 -1
index 02b6872..790bf7a 100644
@@ -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;
 
Signature · 6 lines
2.7.4

_______________________________________________
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): 1469087199-20802-1-git-send-email-Qingqing.Wang-5C7GfCeVMHo@public.gmane.org

#2 lore raw

Am 21.07.2016 um 09:46 schrieb Ken Wang:

Quoted 12 lines
Change-Id If00d5b97ba9e30f9b7f68fdfc134a0f8b3ad2add
---
  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(-)
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +0 -0
index a3b6048..0b095d5 100644

drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c static int gmc_v7_0_mc_init(struct amdgpu_device *adev) · line 343

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +5 -0
@@ -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.

Quoted 29 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +1 -1
  	/* 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;
 
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +5 -0
index 02b6872..790bf7a 100644
@@ -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);

drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c static int gmc_v8_0_mc_init(struct amdgpu_device *adev) · line 480

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +1 -1
@@ -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
[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): fe341676-48d3-a847-89b4-224f2ba4620e-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org

#4 lore raw

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 <[email protected]> 代表 Christian König <[email protected]> 发送时间: 2016年7月21日 16:53:05
收件人: Wang, Qingqing; [email protected]
主题: Re: [PATCH] drm/amdgpu: adjust gtt memory size

Am 21.07.2016 um 09:46 schrieb Ken Wang:

Quoted 12 lines
Change-Id If00d5b97ba9e30f9b7f68fdfc134a0f8b3ad2add
---
  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(-)
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +0 -0
index a3b6048..0b095d5 100644

drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c static int gmc_v7_0_mc_init(struct amdgpu_device *adev) · line 343

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +5 -0
@@ -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.

Quoted 29 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +1 -1
       /* 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;
 
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +5 -0
index 02b6872..790bf7a 100644
@@ -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);

drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c static int gmc_v8_0_mc_init(struct amdgpu_device *adev) · line 480

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +1 -1
@@ -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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
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): SN1PR12MB0511612A271156A2EFC7B449EC090-z7L1TMIYDg7GFhS5Ttmc/[email protected]

#6 lore raw

Am 21.07.2016 um 11:16 schrieb Wang, Qingqing:

Quoted 6 lines

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?

Both values are 32bit on a 32bit system, so as soon as you have more than 4GB installed this will overflow.

You need to cast the long to a 64bit value to avoid that.

Quoted 7 lines

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.

Actually that discussion was held long ago internally but we never got a conclusion on this IIRC. So we should probably continue the discussion on this thread now.

Regards,
Christian.

Quoted 85 lines

------------------------------------------------------------------------
*发件人:* amd-gfx <amd-gfx-bounces-PD4FTy7X32nrcLQh/[email protected]> 代表 Christian König <[email protected]> *发送时间:* 2016年7月21日 16:53:05
*收件人:* Wang, Qingqing; [email protected]
*主题:* Re: [PATCH] drm/amdgpu: adjust gtt memory size
Am 21.07.2016 um 09:46 schrieb Ken Wang:

Review

Quoted 8 lines
Change-Id If00d5b97ba9e30f9b7f68fdfc134a0f8b3ad2add
---
  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(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c

drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c static int gmc_v7_0_mc_init(struct

Quoted 4 lines

index a3b6048..0b095d5 100644

drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +0 -0
@@ -336,6 +336,11 @@ static int gmc_v7_0_mc_init(struct 

amdgpu_device *adev)

drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c static int gmc_v7_0_mc_init(struct amdgpu_device *adev) · line 343

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +5 -0
  {
       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.

drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c static int gmc_v7_0_mc_init(struct amdgpu_device

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +0 -0
       /* Get VRAM informations */
       tmp = RREG32(mmMC_ARB_RAMCFG);
@@ -392,7 +397,7 @@ static int gmc_v7_0_mc_init(struct amdgpu_device 

*adev)

drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c static int gmc_v7_0_mc_init(struct amdgpu_device *adev)

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +0 -1
        * 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);

drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c static int gmc_v7_0_mc_init(struct amdgpu_device · line 400

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +1 -0
+             adev->mc.gtt_size = max((1024ULL << 20), 

min(adev->mc.mc_vram_size, sysmem_size/2));

Review

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +0 -0
       else
               adev->mc.gtt_size = (uint64_t)amdgpu_gart_size << 20;
 
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c

drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c static int gmc_v8_0_mc_init(struct

Quoted 4 lines

index 02b6872..790bf7a 100644

drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +0 -0
@@ -413,6 +413,11 @@ static int gmc_v8_0_mc_init(struct 

amdgpu_device *adev)

drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c static int gmc_v8_0_mc_init(struct amdgpu_device

Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +5 -0
  {
       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)

drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c static int gmc_v8_0_mc_init(struct amdgpu_device · line 472

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +0 -1
        * 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);

drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c static int gmc_v8_0_mc_init(struct amdgpu_device · line 477

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +1 -0
+             adev->mc.gtt_size = max((1024ULL << 20), 

min(adev->mc.mc_vram_size, sysmem_size/2));

drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c static int gmc_v8_0_mc_init(struct amdgpu_device · line 480

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +0 -0
       else
               adev->mc.gtt_size = (uint64_t)amdgpu_gart_size << 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

A message that is not in the archive (sent off-list or not yet received): cb3c1f87-f14f-dd6b-df69-26c12672c51f-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org

#8 lore raw

Actually that discussion was held long ago internally but we never got a conclusion on this IIRC. So we should probably continue the discussion on this thread now.

-there is a thread for this topic yesterday, some people are not in amd-gfx mail list, we'd better discuss in the internal thread.

________________________________
发件人: Christian König <[email protected]> 发送时间: 2016年7月21日 17:48:41
收件人: Wang, Qingqing; [email protected] 主题: Re: 答复: [PATCH] drm/amdgpu: adjust gtt memory size

Am 21.07.2016 um 11:16 schrieb Wang, Qingqing:

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?

Both values are 32bit on a 32bit system, so as soon as you have more than 4GB installed this will overflow.

You need to cast the long to a 64bit value to avoid that.

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.

Actually that discussion was held long ago internally but we never got a conclusion on this IIRC. So we should probably continue the discussion on this thread now.

Regards,
Christian.

________________________________
发件人: amd-gfx <[email protected]><mailto:[email protected]> 代表 Christian König <[email protected]><mailto:[email protected]> 发送时间: 2016年7月21日 16:53:05
收件人: Wang, Qingqing; [email protected]<mailto:[email protected]>
主题: Re: [PATCH] drm/amdgpu: adjust gtt memory size

Am 21.07.2016 um 09:46 schrieb Ken Wang:

Quoted 12 lines
Change-Id If00d5b97ba9e30f9b7f68fdfc134a0f8b3ad2add
---
  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(-)
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +0 -0
index a3b6048..0b095d5 100644

drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c static int gmc_v7_0_mc_init(struct amdgpu_device *adev) · line 343

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +5 -0
@@ -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.

Quoted 29 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +1 -1
       /* 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;
 
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +5 -0
index 02b6872..790bf7a 100644
@@ -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);

drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c static int gmc_v8_0_mc_init(struct amdgpu_device *adev) · line 480

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +1 -1
@@ -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 [email protected]<mailto:[email protected]>
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
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): SN1PR12MB051120166EEFC6A65C7BB795EC090-z7L1TMIYDg7GFhS5Ttmc/[email protected]

#10 lore raw

Am 21.07.2016 um 13:15 schrieb Wang, Qingqing:

Quoted 6 lines

Actually that discussion was held long ago internally but we never got a conclusion on this IIRC. So we should probably continue the discussion on this thread now.

-there is a thread for this topic yesterday, some people are not in amd-gfx mail list, we'd better discuss in the internal thread.

No, exactly for this reason we have the public mailing list. I for example wasn't part of the internal thread either.

Christian.

Quoted 21 lines

------------------------------------------------------------------------
*发件人:* Christian König <[email protected]>
*发送时间:* 2016年7月21日 17:48:41
*收件人:* Wang, Qingqing; [email protected] *主题:* Re: 答复: [PATCH] drm/amdgpu: adjust gtt memory size
Am 21.07.2016 um 11:16 schrieb Wang, Qingqing:

Quoted 6 lines

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?

Both values are 32bit on a 32bit system, so as soon as you have more than 4GB installed this will overflow.

You need to cast the long to a 64bit value to avoid that.

Quoted 4 lines

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

Quoted 100 lines
Quoted 3 lines

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

Actually that discussion was held long ago internally but we never got a conclusion on this IIRC. So we should probably continue the discussion on this thread now.

Regards,
Christian.

Quoted 89 lines

------------------------------------------------------------------------
*发件人:* amd-gfx <amd-gfx-bounces-PD4FTy7X32lzq7FAFJ/[email protected]> 代表 Christian König <[email protected]> *发送时间:* 2016年7月21日 16:53:05
*收件人:* Wang, Qingqing; amd-gfx-PD4FTy7X32nrcLQh/[email protected]
*主题:* Re: [PATCH] drm/amdgpu: adjust gtt memory size
Am 21.07.2016 um 09:46 schrieb Ken Wang:

Review

Quoted 8 lines
Change-Id If00d5b97ba9e30f9b7f68fdfc134a0f8b3ad2add
---
  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(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c

drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c static int gmc_v7_0_mc_init(struct

Quoted 4 lines

index a3b6048..0b095d5 100644

drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +0 -0
@@ -336,6 +336,11 @@ static int gmc_v7_0_mc_init(struct 

amdgpu_device *adev)

drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c static int gmc_v7_0_mc_init(struct · line 343

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +5 -0
  {
       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.

drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c static int gmc_v7_0_mc_init(struct

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +0 -0
       /* Get VRAM informations */
       tmp = RREG32(mmMC_ARB_RAMCFG);
@@ -392,7 +397,7 @@ static int gmc_v7_0_mc_init(struct 

amdgpu_device *adev)

drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c static int gmc_v7_0_mc_init(struct · line 395

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +0 -1
        * 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);

drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c static int gmc_v7_0_mc_init(struct · line 400

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +1 -0
+             adev->mc.gtt_size = max((1024ULL << 20), 

min(adev->mc.mc_vram_size, sysmem_size/2));

Review

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +0 -0
       else
               adev->mc.gtt_size = (uint64_t)amdgpu_gart_size << 20;
 
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c

drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c static int gmc_v8_0_mc_init(struct

Quoted 4 lines

index 02b6872..790bf7a 100644

drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +0 -0
@@ -413,6 +413,11 @@ static int gmc_v8_0_mc_init(struct 

amdgpu_device *adev)

drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c static int gmc_v8_0_mc_init(struct

Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +5 -0
  {
       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)

drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c static int gmc_v8_0_mc_init(struct · line 472

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +0 -1
        * 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);

drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c static int gmc_v8_0_mc_init(struct · line 477

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +1 -0
+             adev->mc.gtt_size = max((1024ULL << 20), 

min(adev->mc.mc_vram_size, sysmem_size/2));

drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c static int gmc_v8_0_mc_init(struct · line 480

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +0 -0
       else
               adev->mc.gtt_size = (uint64_t)amdgpu_gart_size << 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

A message that is not in the archive (sent off-list or not yet received): 324ba8e3-c296-2d74-0cb5-5d212a6f2d54-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org

#12 lore raw

alright, I didn't realize you're not in that thread.

we can add people in if necessary here. so the initial though of this change is with latest big memory GPU released, the remote memory goes very large, like Polaris10.

According to the windows WDDM, remote memory size is half of the system memory, I don't know what was discussed before, Please let me know if there're use case indeed need that big of remote memory.

________________________________
发件人: Christian König <[email protected]> 发送时间: 2016年7月21日 19:48:17
收件人: Wang, Qingqing; [email protected] 主题: Re: 答复: 答复: [PATCH] drm/amdgpu: adjust gtt memory size

Am 21.07.2016 um 13:15 schrieb Wang, Qingqing:

Actually that discussion was held long ago internally but we never got a conclusion on this IIRC. So we should probably continue the discussion on this thread now.

-there is a thread for this topic yesterday, some people are not in amd-gfx mail list, we'd better discuss in the internal thread.

No, exactly for this reason we have the public mailing list. I for example wasn't part of the internal thread either.

Christian.

________________________________
发件人: Christian König <[email protected]><mailto:[email protected]> 发送时间: 2016年7月21日 17:48:41
收件人: Wang, Qingqing; [email protected]<mailto:[email protected]> 主题: Re: 答复: [PATCH] drm/amdgpu: adjust gtt memory size

Am 21.07.2016 um 11:16 schrieb Wang, Qingqing:

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?

Both values are 32bit on a 32bit system, so as soon as you have more than 4GB installed this will overflow.

You need to cast the long to a 64bit value to avoid that.

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.

Actually that discussion was held long ago internally but we never got a conclusion on this IIRC. So we should probably continue the discussion on this thread now.

Regards,
Christian.

________________________________
发件人: amd-gfx <[email protected]><mailto:[email protected]> 代表 Christian König <[email protected]><mailto:[email protected]> 发送时间: 2016年7月21日 16:53:05
收件人: Wang, Qingqing; [email protected]<mailto:[email protected]>
主题: Re: [PATCH] drm/amdgpu: adjust gtt memory size

Am 21.07.2016 um 09:46 schrieb Ken Wang:

Quoted 12 lines
Change-Id If00d5b97ba9e30f9b7f68fdfc134a0f8b3ad2add
---
  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(-)
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +0 -0
index a3b6048..0b095d5 100644

drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c static int gmc_v7_0_mc_init(struct amdgpu_device *adev) · line 343

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +5 -0
@@ -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.

Quoted 29 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +1 -1
       /* 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;
 
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +5 -0
index 02b6872..790bf7a 100644
@@ -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);

drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c static int gmc_v8_0_mc_init(struct amdgpu_device *adev) · line 480

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +1 -1
@@ -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 [email protected]<mailto:[email protected]>
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
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): SN1PR12MB0511DD6F60EAFDB326320B46EC090-z7L1TMIYDg7GFhS5Ttmc/[email protected]

#14 lore raw
Quoted 4 lines

we can add people in if necessary here. so the initial though of this change is with latest big memory GPU released, the remote memory goes very large, like Polaris10.

According to the windows WDDM, remote memory size is half of the system memory, I don't know what was discussed before, Please let me know if there're use case indeed need that big of remote memory.

Well that is at least something that makes sense.

Previous discussions where always settled around making GART bigger than VRAM and not the other way around.

Anyway I think a prerequisite to this is actually allowing half of system memory to be allocated for GART and I'm not sure if that is currently the case. TTM has a limitation for that as well, but I off hand don't remember how high much it was.

I think we should use the same value which TTM uses for the upper limit here.

Regards,
Christian.

Am 21.07.2016 um 13:56 schrieb Wang, Qingqing:

Quoted 14 lines

alright, I didn't realize you're not in that thread.

we can add people in if necessary here. so the initial though of this change is with latest big memory GPU released, the remote memory goes very large, like Polaris10.

According to the windows WDDM, remote memory size is half of the system memory, I don't know what was discussed before, Please let me know if there're use case indeed need that big of remote memory.

------------------------------------------------------------------------
*发件人:* Christian König <[email protected]>
*发送时间:* 2016年7月21日 19:48:17
*收件人:* Wang, Qingqing; [email protected] *主题:* Re: 答复: 答复: [PATCH] drm/amdgpu: adjust gtt memory size
Am 21.07.2016 um 13:15 schrieb Wang, Qingqing:

Quoted 1 line
Quoted 131 lines
Quoted 5 lines

Actually that discussion was held long ago internally but we never got a conclusion on this IIRC. So we should probably continue the discussion on this thread now.

-there is a thread for this topic yesterday, some people are not in amd-gfx mail list, we'd better discuss in the internal thread.

No, exactly for this reason we have the public mailing list. I for example wasn't part of the internal thread either.

Christian.

Quoted 121 lines

------------------------------------------------------------------------
*发件人:* Christian König <[email protected]>
*发送时间:* 2016年7月21日 17:48:41
*收件人:* Wang, Qingqing; amd-gfx-PD4FTy7X32nrcLQh/[email protected] *主题:* Re: 答复: [PATCH] drm/amdgpu: adjust gtt memory size
Am 21.07.2016 um 11:16 schrieb Wang, Qingqing:

Quoted 6 lines

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?

Both values are 32bit on a 32bit system, so as soon as you have more than 4GB installed this will overflow.

You need to cast the long to a 64bit value to avoid that.

Quoted 7 lines

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.

Actually that discussion was held long ago internally but we never got a conclusion on this IIRC. So we should probably continue the discussion on this thread now.

Regards,
Christian.

Quoted 89 lines

------------------------------------------------------------------------
*发件人:* amd-gfx <[email protected]> 代表 Christian König <[email protected]> *发送时间:* 2016年7月21日 16:53:05
*收件人:* Wang, Qingqing; amd-gfx-PD4FTy7X32lzq7FAFJ/[email protected]
*主题:* Re: [PATCH] drm/amdgpu: adjust gtt memory size
Am 21.07.2016 um 09:46 schrieb Ken Wang:

Review

Quoted 8 lines
Change-Id If00d5b97ba9e30f9b7f68fdfc134a0f8b3ad2add
---
  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(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c

drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c static int gmc_v7_0_mc_init(struct

Quoted 4 lines

index a3b6048..0b095d5 100644

drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +0 -0
@@ -336,6 +336,11 @@ static int gmc_v7_0_mc_init(struct 

amdgpu_device *adev)

drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c static int gmc_v7_0_mc_init(struct · line 343

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +5 -0
  {
       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.

drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c static int gmc_v7_0_mc_init(struct

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +0 -0
       /* Get VRAM informations */
       tmp = RREG32(mmMC_ARB_RAMCFG);
@@ -392,7 +397,7 @@ static int gmc_v7_0_mc_init(struct 

amdgpu_device *adev)

drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c static int gmc_v7_0_mc_init(struct · line 395

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +0 -1
        * 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);

drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c static int gmc_v7_0_mc_init(struct · line 400

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +1 -0
+             adev->mc.gtt_size = max((1024ULL << 20), 

min(adev->mc.mc_vram_size, sysmem_size/2));

Review

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +0 -0
       else
               adev->mc.gtt_size = (uint64_t)amdgpu_gart_size << 20;
 
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c

drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c static int gmc_v8_0_mc_init(struct

Quoted 4 lines

index 02b6872..790bf7a 100644

drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +0 -0
@@ -413,6 +413,11 @@ static int gmc_v8_0_mc_init(struct 

amdgpu_device *adev)

drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c static int gmc_v8_0_mc_init(struct

Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +5 -0
  {
       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)

drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c static int gmc_v8_0_mc_init(struct · line 472

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +0 -1
        * 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);

drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c static int gmc_v8_0_mc_init(struct · line 477

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +1 -0
+             adev->mc.gtt_size = max((1024ULL << 20), 

min(adev->mc.mc_vram_size, sysmem_size/2));

drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c static int gmc_v8_0_mc_init(struct · line 480

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +0 -0
       else
               adev->mc.gtt_size = (uint64_t)amdgpu_gart_size << 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

A message that is not in the archive (sent off-list or not yet received): 3839ef42-6275-99d8-9aee-54143a971f0b-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org

#16 lore raw

TTM limits system memory allocations to 1/2 system memory for regular processes, or 3/4 for privileged processes.

For compute we opted to make the GART bigger than system memory to allow for fragmentation. However, we argued that you don't really need GART for most buffers anyways, since they are never accessed in VMID 0. They need to be mapped in some VM page table, but never in the GART table. So I think the long-term goal should be to remove the need to allocate GART addresses for system memory BOs. Then you could get away with a quite small GART size.

Regards,

Felix

Quoted 188 lines · Christian König
Quoted 9 lines

we can add people in if necessary here. so the initial though of this change is with latest big memory GPU released, the remote memory goes very large, like Polaris10.

According to the windows WDDM, remote memory size is half of the system memory, I don't know what was discussed before, Please let me know if there're use case indeed need that big of remote memory.

Well that is at least something that makes sense.

Previous discussions where always settled around making GART bigger than VRAM and not the other way around.

Anyway I think a prerequisite to this is actually allowing half of system memory to be allocated for GART and I'm not sure if that is currently the case. TTM has a limitation for that as well, but I off hand don't remember how high much it was.

I think we should use the same value which TTM uses for the upper limit here.

Regards,
Christian.

Am 21.07.2016 um 13:56 schrieb Wang, Qingqing:

Quoted 23 lines

alright, I didn't realize you're not in that thread.

we can add people in if necessary here. so the initial though of this change is with latest big memory GPU released, the remote memory goes very large, like Polaris10.

According to the windows WDDM, remote memory size is half of the system memory, I don't know what was discussed before, Please let me know if there're use case indeed need that big of remote memory.

------------------------------------------------------------------------
*发件人:* Christian König <[email protected]>
*发送时间:* 2016年7月21日 19:48:17
*收件人:* Wang, Qingqing; amd-gfx-PD4FTy7X32nrcLQh/[email protected] *主题:* Re: 答复: 答复: [PATCH] drm/amdgpu: adjust gtt memory size

Am 21.07.2016 um 13:15 schrieb Wang, Qingqing:

Quoted 5 lines

Actually that discussion was held long ago internally but we never got a conclusion on this IIRC. So we should probably continue the discussion on this thread now.

Quoted 136 lines
Quoted 3 lines

-there is a thread for this topic yesterday, some people are not in amd-gfx mail list, we'd better discuss in the internal thread.

No, exactly for this reason we have the public mailing list. I for example wasn't part of the internal thread either.

Christian.

Quoted 127 lines

------------------------------------------------------------------------
*发件人:* Christian König <[email protected]>
*发送时间:* 2016年7月21日 17:48:41
*收件人:* Wang, Qingqing; amd-gfx-PD4FTy7X32lzq7FAFJ/[email protected] *主题:* Re: 答复: [PATCH] drm/amdgpu: adjust gtt memory size

Am 21.07.2016 um 11:16 schrieb Wang, Qingqing:

Quoted 6 lines

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?

Both values are 32bit on a 32bit system, so as soon as you have more than 4GB installed this will overflow.

You need to cast the long to a 64bit value to avoid that.

Quoted 7 lines

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.

Actually that discussion was held long ago internally but we never got a conclusion on this IIRC. So we should probably continue the discussion on this thread now.

Regards,
Christian.

Quoted 91 lines

------------------------------------------------------------------------
*发件人:* amd-gfx <[email protected]> 代表 Christian König <[email protected]> *发送时间:* 2016年7月21日 16:53:05
*收件人:* Wang, Qingqing; [email protected] *主题:* Re: [PATCH] drm/amdgpu: adjust gtt memory size

Am 21.07.2016 um 09:46 schrieb Ken Wang:

Review

Quoted 8 lines
Change-Id If00d5b97ba9e30f9b7f68fdfc134a0f8b3ad2add
---
  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(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c

drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c static int gmc_v7_0_mc_init(struct

Quoted 4 lines

index a3b6048..0b095d5 100644

drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +0 -0
@@ -336,6 +336,11 @@ static int gmc_v7_0_mc_init(struct

amdgpu_device *adev)

drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c static int gmc_v7_0_mc_init(struct · line 343

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +5 -0
  {
       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.

drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c static int gmc_v7_0_mc_init(struct

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +0 -0
       /* Get VRAM informations */
       tmp = RREG32(mmMC_ARB_RAMCFG);
@@ -392,7 +397,7 @@ static int gmc_v7_0_mc_init(struct

amdgpu_device *adev)

drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c static int gmc_v7_0_mc_init(struct · line 395

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +0 -1
        * 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);

drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c static int gmc_v7_0_mc_init(struct · line 400

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +1 -0
+             adev->mc.gtt_size = max((1024ULL << 20),

min(adev->mc.mc_vram_size, sysmem_size/2));

Review

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +0 -0
       else
               adev->mc.gtt_size = (uint64_t)amdgpu_gart_size << 20;
 
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c

drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c static int gmc_v8_0_mc_init(struct

Quoted 4 lines

index 02b6872..790bf7a 100644

drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +0 -0
@@ -413,6 +413,11 @@ static int gmc_v8_0_mc_init(struct

amdgpu_device *adev)

drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c static int gmc_v8_0_mc_init(struct

Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +5 -0
  {
       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)

drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c static int gmc_v8_0_mc_init(struct · line 472

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +0 -1
        * 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);

drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c static int gmc_v8_0_mc_init(struct · line 477

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +1 -0
+             adev->mc.gtt_size = max((1024ULL << 20),

min(adev->mc.mc_vram_size, sysmem_size/2));

drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c static int gmc_v8_0_mc_init(struct · line 480

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +0 -0
       else
               adev->mc.gtt_size = (uint64_t)amdgpu_gart_size << 20;
 

_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

A message that is not in the archive (sent off-list or not yet received): 458f751a-6f4a-1dd9-45d0-ad1ad5f7154f-5C7GfCeVMHo@public.gmane.org

author
#18 lore raw

thanks Felix,

I see that logci in TTM as well, so choose 1/2 of system memory as up limit seems good enough here? if no object I will fix the overflow issue and send the review again.

________________________________
发件人: amd-gfx <[email protected]> 代表 Felix Kuehling <[email protected]> 发送时间: 2016年7月22日 3:19:38
收件人: [email protected]
主题: Re: 答复: 答复: 答复: [PATCH] drm/amdgpu: adjust gtt memory size

TTM limits system memory allocations to 1/2 system memory for regular processes, or 3/4 for privileged processes.

For compute we opted to make the GART bigger than system memory to allow for fragmentation. However, we argued that you don't really need GART for most buffers anyways, since they are never accessed in VMID 0. They need to be mapped in some VM page table, but never in the GART table. So I think the long-term goal should be to remove the need to allocate GART addresses for system memory BOs. Then you could get away with a quite small GART size.

Regards,

Felix

On 16-07-21 08:04 AM, Christian König wrote:

we can add people in if necessary here. so the initial though of this change is with latest big memory GPU released, the remote memory goes very large, like Polaris10.

According to the windows WDDM, remote memory size is half of the system memory, I don't know what was discussed before, Please let me know if there're use case indeed need that big of remote memory.

Well that is at least something that makes sense.

Previous discussions where always settled around making GART bigger than VRAM and not the other way around.

Anyway I think a prerequisite to this is actually allowing half of system memory to be allocated for GART and I'm not sure if that is currently the case. TTM has a limitation for that as well, but I off hand don't remember how high much it was.

I think we should use the same value which TTM uses for the upper limit here.

Regards,
Christian.

Am 21.07.2016 um 13:56 schrieb Wang, Qingqing:

alright, I didn't realize you're not in that thread.

we can add people in if necessary here. so the initial though of this change is with latest big memory GPU released, the remote memory goes very large, like Polaris10.

According to the windows WDDM, remote memory size is half of the system memory, I don't know what was discussed before, Please let me know if there're use case indeed need that big of remote memory.

________________________________
发件人: Christian König <[email protected]><mailto:[email protected]> 发送时间: 2016年7月21日 19:48:17
收件人: Wang, Qingqing; [email protected]<mailto:[email protected]> 主题: Re: 答复: 答复: [PATCH] drm/amdgpu: adjust gtt memory size

Am 21.07.2016 um 13:15 schrieb Wang, Qingqing:

Actually that discussion was held long ago internally but we never got a conclusion on this IIRC. So we should probably continue the discussion on this thread now.

-there is a thread for this topic yesterday, some people are not in amd-gfx mail list, we'd better discuss in the internal thread.

No, exactly for this reason we have the public mailing list. I for example wasn't part of the internal thread either.

Christian.

________________________________
发件人: Christian König <[email protected]><mailto:[email protected]> 发送时间: 2016年7月21日 17:48:41
收件人: Wang, Qingqing; [email protected]<mailto:[email protected]> 主题: Re: 答复: [PATCH] drm/amdgpu: adjust gtt memory size

Am 21.07.2016 um 11:16 schrieb Wang, Qingqing:

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?

Both values are 32bit on a 32bit system, so as soon as you have more than 4GB installed this will overflow.

You need to cast the long to a 64bit value to avoid that.

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.

Actually that discussion was held long ago internally but we never got a conclusion on this IIRC. So we should probably continue the discussion on this thread now.

Regards,
Christian.

________________________________
发件人: amd-gfx <[email protected]><mailto:[email protected]> 代表 Christian König <[email protected]><mailto:[email protected]> 发送时间: 2016年7月21日 16:53:05
收件人: Wang, Qingqing; [email protected]<mailto:[email protected]>
主题: Re: [PATCH] drm/amdgpu: adjust gtt memory size

Am 21.07.2016 um 09:46 schrieb Ken Wang:

Quoted 12 lines
Change-Id If00d5b97ba9e30f9b7f68fdfc134a0f8b3ad2add
---
  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(-)
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +0 -0
index a3b6048..0b095d5 100644

drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c static int gmc_v7_0_mc_init(struct amdgpu_device *adev) · line 343

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +5 -0
@@ -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.

Quoted 29 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +1 -1
       /* 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;
 
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +5 -0
index 02b6872..790bf7a 100644
@@ -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);

drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c static int gmc_v8_0_mc_init(struct amdgpu_device *adev) · line 480

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +1 -1
@@ -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 [email protected]<mailto:[email protected]>
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list [email protected]<mailto:[email protected]>
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
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): CY1PR12MB0508280B4E4E1408F5ECAD24EC0A0-1s8aH8ViOEfJai4n+QWBiQdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

#20 lore raw

Yeah sounds good to me.

Could we make a global ttm function returning how much system memory can be used at the same time?

This way we could make those values depend on each other, e.g. when somebody modifies the TTM value we automatically change the GART size as well.

Regards,
Christian.

Am 22.07.2016 um 08:06 schrieb Wang, Ken:

Quoted 196 lines

thanks Felix,

I see that logci in TTM as well, so choose 1/2 of system memory as
up limit seems good enough here? if no object I will fix the overflow issue and send the review again.

------------------------------------------------------------------------
*发件人:* amd-gfx <amd-gfx-bounces-PD4FTy7X32nrcLQh/[email protected]> 代表 Felix Kuehling <[email protected]> *发送时间:* 2016年7月22日 3:19:38
*收件人:* [email protected]
*主题:* Re: 答复: 答复: 答复: [PATCH] drm/amdgpu: adjust gtt memory size

TTM limits system memory allocations to 1/2 system memory for regular processes, or 3/4 for privileged processes.

For compute we opted to make the GART bigger than system memory to allow for fragmentation. However, we argued that you don't really need GART for most buffers anyways, since they are never accessed in VMID 0. They need to be mapped in some VM page table, but never in the GART table. So I think the long-term goal should be to remove the need to allocate GART addresses for system memory BOs. Then you could get away with a quite small GART size.

Regards,

Felix

Quoted 165 lines · Christian König
Quoted 5 lines

we can add people in if necessary here. so the initial though of this change is with latest big memory GPU released, the remote memory goes very large, like Polaris10.

According to the windows WDDM, remote memory size is half of the system memory, I don't know what was discussed before, Please let me know if there're use case indeed need that big of remote memory.

Well that is at least something that makes sense.

Previous discussions where always settled around making GART bigger than VRAM and not the other way around.

Anyway I think a prerequisite to this is actually allowing half of system memory to be allocated for GART and I'm not sure if that is currently the case. TTM has a limitation for that as well, but I off hand don't remember how high much it was.

I think we should use the same value which TTM uses for the upper limit here.

Regards,
Christian.

Am 21.07.2016 um 13:56 schrieb Wang, Qingqing:

Quoted 14 lines

alright, I didn't realize you're not in that thread.

we can add people in if necessary here. so the initial though of this change is with latest big memory GPU released, the remote memory goes very large, like Polaris10.

According to the windows WDDM, remote memory size is half of the system memory, I don't know what was discussed before, Please let me know if there're use case indeed need that big of remote memory.

------------------------------------------------------------------------
*发件人:* Christian König <[email protected]>
*发送时间:* 2016年7月21日 19:48:17
*收件人:* Wang, Qingqing; amd-gfx-PD4FTy7X32lzq7FAFJ/[email protected] *主题:* Re: 答复: 答复: [PATCH] drm/amdgpu: adjust gtt memory size
Am 21.07.2016 um 13:15 schrieb Wang, Qingqing:

Quoted 1 line
Quoted 131 lines
Quoted 5 lines

Actually that discussion was held long ago internally but we never got a conclusion on this IIRC. So we should probably continue the discussion on this thread now.

-there is a thread for this topic yesterday, some people are not in amd-gfx mail list, we'd better discuss in the internal thread.

No, exactly for this reason we have the public mailing list. I for example wasn't part of the internal thread either.

Christian.

Quoted 121 lines

------------------------------------------------------------------------
*发件人:* Christian König <[email protected]>
*发送时间:* 2016年7月21日 17:48:41
*收件人:* Wang, Qingqing; [email protected] *主题:* Re: 答复: [PATCH] drm/amdgpu: adjust gtt memory size
Am 21.07.2016 um 11:16 schrieb Wang, Qingqing:

Quoted 6 lines

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?

Both values are 32bit on a 32bit system, so as soon as you have more than 4GB installed this will overflow.

You need to cast the long to a 64bit value to avoid that.

Quoted 7 lines

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.

Actually that discussion was held long ago internally but we never got a conclusion on this IIRC. So we should probably continue the discussion on this thread now.

Regards,
Christian.

Quoted 89 lines

------------------------------------------------------------------------
*发件人:* amd-gfx <amd-gfx-bounces-PD4FTy7X32mMSPqsTGOZug@public.gmane.orgesktop.org> 代表 Christian König <[email protected]> *发送时间:* 2016年7月21日 16:53:05
*收件人:* Wang, Qingqing; [email protected]
*主题:* Re: [PATCH] drm/amdgpu: adjust gtt memory size
Am 21.07.2016 um 09:46 schrieb Ken Wang:

Review

Quoted 8 lines
Change-Id If00d5b97ba9e30f9b7f68fdfc134a0f8b3ad2add
---
  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(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c

drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c static int gmc_v7_0_mc_init(struct

Quoted 4 lines

index a3b6048..0b095d5 100644

drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +0 -0
@@ -336,6 +336,11 @@ static int gmc_v7_0_mc_init(struct 

amdgpu_device *adev)

drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c static int gmc_v7_0_mc_init(struct · line 343

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +5 -0
  {
       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.

drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c static int gmc_v7_0_mc_init(struct

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +0 -0
       /* Get VRAM informations */
       tmp = RREG32(mmMC_ARB_RAMCFG);
@@ -392,7 +397,7 @@ static int gmc_v7_0_mc_init(struct 

amdgpu_device *adev)

drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c static int gmc_v7_0_mc_init(struct · line 395

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +0 -1
        * 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);

drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c static int gmc_v7_0_mc_init(struct · line 400

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +1 -0
+             adev->mc.gtt_size = max((1024ULL << 20), 

min(adev->mc.mc_vram_size, sysmem_size/2));

Review

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +0 -0
       else
               adev->mc.gtt_size = (uint64_t)amdgpu_gart_size << 20;
 
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c

drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c static int gmc_v8_0_mc_init(struct

Quoted 4 lines

index 02b6872..790bf7a 100644

drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +0 -0
@@ -413,6 +413,11 @@ static int gmc_v8_0_mc_init(struct 

amdgpu_device *adev)

drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c static int gmc_v8_0_mc_init(struct

Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +5 -0
  {
       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)

drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c static int gmc_v8_0_mc_init(struct · line 472

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +0 -1
        * 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);

drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c static int gmc_v8_0_mc_init(struct · line 477

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +1 -0
+             adev->mc.gtt_size = max((1024ULL << 20), 

min(adev->mc.mc_vram_size, sysmem_size/2));

drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c static int gmc_v8_0_mc_init(struct · line 480

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +0 -0
       else
               adev->mc.gtt_size = (uint64_t)amdgpu_gart_size << 20;
 

_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Quoted 4 lines

_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

A message that is not in the archive (sent off-list or not yet received): eda1830b-45a8-084c-2db6-a0ab4a23f499-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org

#22 lore raw

Hi Christian,

Patches has been updated and sent for reviewing in another thread, please take a look.

________________________________
发件人: Christian König <[email protected]>
发送时间: 2016年7月22日 21:02:56
收件人: Wang, Ken; Kuehling, Felix; [email protected] 主题: Re: 答复: 答复: 答复: 答复: [PATCH] drm/amdgpu: adjust gtt memory size

Yeah sounds good to me.

Could we make a global ttm function returning how much system memory can be used at the same time?

This way we could make those values depend on each other, e.g. when somebody modifies the TTM value we automatically change the GART size as well.

Regards,
Christian.

Am 22.07.2016 um 08:06 schrieb Wang, Ken:

thanks Felix,

I see that logci in TTM as well, so choose 1/2 of system memory as up limit seems good enough here? if no object I will fix the overflow issue and send the review again.

________________________________
发件人: amd-gfx <[email protected]><mailto:[email protected]> 代表 Felix Kuehling <[email protected]><mailto:[email protected]> 发送时间: 2016年7月22日 3:19:38
收件人: [email protected]<mailto:[email protected]>
主题: Re: 答复: 答复: 答复: [PATCH] drm/amdgpu: adjust gtt memory size

TTM limits system memory allocations to 1/2 system memory for regular processes, or 3/4 for privileged processes.

For compute we opted to make the GART bigger than system memory to allow for fragmentation. However, we argued that you don't really need GART for most buffers anyways, since they are never accessed in VMID 0. They need to be mapped in some VM page table, but never in the GART table. So I think the long-term goal should be to remove the need to allocate GART addresses for system memory BOs. Then you could get away with a quite small GART size.

Regards,

Felix

On 16-07-21 08:04 AM, Christian König wrote:

we can add people in if necessary here. so the initial though of this change is with latest big memory GPU released, the remote memory goes very large, like Polaris10.

According to the windows WDDM, remote memory size is half of the system memory, I don't know what was discussed before, Please let me know if there're use case indeed need that big of remote memory.

Well that is at least something that makes sense.

Previous discussions where always settled around making GART bigger than VRAM and not the other way around.

Anyway I think a prerequisite to this is actually allowing half of system memory to be allocated for GART and I'm not sure if that is currently the case. TTM has a limitation for that as well, but I off hand don't remember how high much it was.

I think we should use the same value which TTM uses for the upper limit here.

Regards,
Christian.

Am 21.07.2016 um 13:56 schrieb Wang, Qingqing:

alright, I didn't realize you're not in that thread.

we can add people in if necessary here. so the initial though of this change is with latest big memory GPU released, the remote memory goes very large, like Polaris10.

According to the windows WDDM, remote memory size is half of the system memory, I don't know what was discussed before, Please let me know if there're use case indeed need that big of remote memory.

________________________________
发件人: Christian König <[email protected]><mailto:[email protected]> 发送时间: 2016年7月21日 19:48:17
收件人: Wang, Qingqing; [email protected]<mailto:[email protected]> 主题: Re: 答复: 答复: [PATCH] drm/amdgpu: adjust gtt memory size

Am 21.07.2016 um 13:15 schrieb Wang, Qingqing:

Actually that discussion was held long ago internally but we never got a conclusion on this IIRC. So we should probably continue the discussion on this thread now.

-there is a thread for this topic yesterday, some people are not in amd-gfx mail list, we'd better discuss in the internal thread.

No, exactly for this reason we have the public mailing list. I for example wasn't part of the internal thread either.

Christian.

________________________________
发件人: Christian König <[email protected]><mailto:[email protected]> 发送时间: 2016年7月21日 17:48:41
收件人: Wang, Qingqing; [email protected]<mailto:[email protected]> 主题: Re: 答复: [PATCH] drm/amdgpu: adjust gtt memory size

Am 21.07.2016 um 11:16 schrieb Wang, Qingqing:

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?

Both values are 32bit on a 32bit system, so as soon as you have more than 4GB installed this will overflow.

You need to cast the long to a 64bit value to avoid that.

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.

Actually that discussion was held long ago internally but we never got a conclusion on this IIRC. So we should probably continue the discussion on this thread now.

Regards,
Christian.

________________________________
发件人: amd-gfx <[email protected]><mailto:[email protected]> 代表 Christian König <[email protected]><mailto:[email protected]> 发送时间: 2016年7月21日 16:53:05
收件人: Wang, Qingqing; [email protected]<mailto:[email protected]>
主题: Re: [PATCH] drm/amdgpu: adjust gtt memory size

Am 21.07.2016 um 09:46 schrieb Ken Wang:

Quoted 12 lines
Change-Id If00d5b97ba9e30f9b7f68fdfc134a0f8b3ad2add
---
  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(-)
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +0 -0
index a3b6048..0b095d5 100644

drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c static int gmc_v7_0_mc_init(struct amdgpu_device *adev) · line 343

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +5 -0
@@ -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.

Quoted 29 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +1 -1
       /* 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;
 
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +5 -0
index 02b6872..790bf7a 100644
@@ -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);

drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c static int gmc_v8_0_mc_init(struct amdgpu_device *adev) · line 480

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +1 -1
@@ -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 [email protected]<mailto:[email protected]>
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list [email protected]<mailto:[email protected]>
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list [email protected]<mailto:[email protected]>
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
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): CY1PR12MB05088E560E902995F2E7C41B8C000-1s8aH8ViOEfJai4n+QWBiQdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

#24 lore raw

Hi Alex,

Can you take a look at the change?

________________________________
发件人: amd-gfx <[email protected]> 代表 Wang, Ken <[email protected]> 发送时间: 2016年7月28日 18:56:47
收件人: Christian König; Kuehling, Felix; [email protected] 主题: 答复: 答复: 答复: 答复: 答复: [PATCH] drm/amdgpu: adjust gtt memory size

Hi Christian,

Patches has been updated and sent for reviewing in another thread, please take a look.

________________________________
发件人: Christian König <[email protected]>
发送时间: 2016年7月22日 21:02:56
收件人: Wang, Ken; Kuehling, Felix; [email protected] 主题: Re: 答复: 答复: 答复: 答复: [PATCH] drm/amdgpu: adjust gtt memory size

Yeah sounds good to me.

Could we make a global ttm function returning how much system memory can be used at the same time?

This way we could make those values depend on each other, e.g. when somebody modifies the TTM value we automatically change the GART size as well.

Regards,
Christian.

Am 22.07.2016 um 08:06 schrieb Wang, Ken:

thanks Felix,

I see that logci in TTM as well, so choose 1/2 of system memory as up limit seems good enough here? if no object I will fix the overflow issue and send the review again.

________________________________
发件人: amd-gfx <[email protected]><mailto:[email protected]> 代表 Felix Kuehling <[email protected]><mailto:[email protected]> 发送时间: 2016年7月22日 3:19:38
收件人: [email protected]<mailto:[email protected]>
主题: Re: 答复: 答复: 答复: [PATCH] drm/amdgpu: adjust gtt memory size

TTM limits system memory allocations to 1/2 system memory for regular processes, or 3/4 for privileged processes.

For compute we opted to make the GART bigger than system memory to allow for fragmentation. However, we argued that you don't really need GART for most buffers anyways, since they are never accessed in VMID 0. They need to be mapped in some VM page table, but never in the GART table. So I think the long-term goal should be to remove the need to allocate GART addresses for system memory BOs. Then you could get away with a quite small GART size.

Regards,

Felix

On 16-07-21 08:04 AM, Christian König wrote:

we can add people in if necessary here. so the initial though of this change is with latest big memory GPU released, the remote memory goes very large, like Polaris10.

According to the windows WDDM, remote memory size is half of the system memory, I don't know what was discussed before, Please let me know if there're use case indeed need that big of remote memory.

Well that is at least something that makes sense.

Previous discussions where always settled around making GART bigger than VRAM and not the other way around.

Anyway I think a prerequisite to this is actually allowing half of system memory to be allocated for GART and I'm not sure if that is currently the case. TTM has a limitation for that as well, but I off hand don't remember how high much it was.

I think we should use the same value which TTM uses for the upper limit here.

Regards,
Christian.

Am 21.07.2016 um 13:56 schrieb Wang, Qingqing:

alright, I didn't realize you're not in that thread.

we can add people in if necessary here. so the initial though of this change is with latest big memory GPU released, the remote memory goes very large, like Polaris10.

According to the windows WDDM, remote memory size is half of the system memory, I don't know what was discussed before, Please let me know if there're use case indeed need that big of remote memory.

________________________________
发件人: Christian König <[email protected]><mailto:[email protected]> 发送时间: 2016年7月21日 19:48:17
收件人: Wang, Qingqing; [email protected]<mailto:[email protected]> 主题: Re: 答复: 答复: [PATCH] drm/amdgpu: adjust gtt memory size

Am 21.07.2016 um 13:15 schrieb Wang, Qingqing:

Actually that discussion was held long ago internally but we never got a conclusion on this IIRC. So we should probably continue the discussion on this thread now.

-there is a thread for this topic yesterday, some people are not in amd-gfx mail list, we'd better discuss in the internal thread.

No, exactly for this reason we have the public mailing list. I for example wasn't part of the internal thread either.

Christian.

________________________________
发件人: Christian König <[email protected]><mailto:[email protected]> 发送时间: 2016年7月21日 17:48:41
收件人: Wang, Qingqing; [email protected]<mailto:[email protected]> 主题: Re: 答复: [PATCH] drm/amdgpu: adjust gtt memory size

Am 21.07.2016 um 11:16 schrieb Wang, Qingqing:

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?

Both values are 32bit on a 32bit system, so as soon as you have more than 4GB installed this will overflow.

You need to cast the long to a 64bit value to avoid that.

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.

Actually that discussion was held long ago internally but we never got a conclusion on this IIRC. So we should probably continue the discussion on this thread now.

Regards,
Christian.

________________________________
发件人: amd-gfx <[email protected]><mailto:[email protected]> 代表 Christian König <[email protected]><mailto:[email protected]> 发送时间: 2016年7月21日 16:53:05
收件人: Wang, Qingqing; [email protected]<mailto:[email protected]>
主题: Re: [PATCH] drm/amdgpu: adjust gtt memory size

Am 21.07.2016 um 09:46 schrieb Ken Wang:

Quoted 12 lines
Change-Id If00d5b97ba9e30f9b7f68fdfc134a0f8b3ad2add
---
  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(-)
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +0 -0
index a3b6048..0b095d5 100644

drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c static int gmc_v7_0_mc_init(struct amdgpu_device *adev) · line 343

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +5 -0
@@ -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.

Quoted 29 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +1 -1
       /* 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;
 
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +5 -0
index 02b6872..790bf7a 100644
@@ -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);

drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c static int gmc_v8_0_mc_init(struct amdgpu_device *adev) · line 480

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +1 -1
@@ -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 [email protected]<mailto:[email protected]>
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list [email protected]<mailto:[email protected]>
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list [email protected]<mailto:[email protected]>
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx