Skip to contentSkip to conversation

drm/amdgpu/gmc6: fix in case the PCI BAR is larger than the actual amount of vram

PATCH Applied hongao 3 participants 3 messages Aug 15, 2023 – Aug 16, 2023

Subsystems (2)
lore
Share & tools
lore

hongao

author
#0 lore raw

PATCH 1/1 drm/amdgpu/gmc6: fix in case the PCI BAR is larger than the actual amount of vram

[why]
limit visible_vram_size to real_vram_size in case the PCI BAR is larger than the actual amount of vram.

---
 drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +2 -0
index b7dad4e67813..c0de7496bfd1 100644
@@ -320,6 +320,8 @@ static int gmc_v6_0_mc_init(struct amdgpu_device *adev)
 	adev->gmc.aper_base = pci_resource_start(adev->pdev, 0);
 	adev->gmc.aper_size = pci_resource_len(adev->pdev, 0);
 	adev->gmc.visible_vram_size = adev->gmc.aper_size;
+	if (adev->gmc.visible_vram_size > adev->gmc.real_vram_size)
+		adev->gmc.visible_vram_size = adev->gmc.real_vram_size;
 
 	/* set the gart size */
 	if (amdgpu_gart_size == -1) {
Signature · 1 line
2.20.1
Applied
#1 lore raw

Applied. Thanks!

Quoted 26 lines · hongao

[why]
limit visible_vram_size to real_vram_size in case the PCI BAR is larger than the actual amount of vram.

---
 drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +2 -1
index b7dad4e67813..c0de7496bfd1 100644
@@ -320,6 +320,8 @@ static int gmc_v6_0_mc_init(struct amdgpu_device *adev)
        adev->gmc.aper_base = pci_resource_start(adev->pdev, 0);
        adev->gmc.aper_size = pci_resource_len(adev->pdev, 0);
        adev->gmc.visible_vram_size = adev->gmc.aper_size;
+       if (adev->gmc.visible_vram_size > adev->gmc.real_vram_size)
+               adev->gmc.visible_vram_size = adev->gmc.real_vram_size;
 
        /* set the gart size */
        if (amdgpu_gart_size == -1) {
--

2.20.1

#2 lore raw

Wait a second.

This is unnecessary because we have this check in amdgpu_gmc_vram_location():

        if (mc->real_vram_size < mc->visible_vram_size) mc->visible_vram_size = mc->real_vram_size;

Which makes sure that the visible VRAM size is never larger than the actual size for all HW generations.

Regards,
Christian.

Am 15.08.23 um 17:50 schrieb Alex Deucher:

Quoted 28 lines

Applied. Thanks!

Quoted 25 lines · hongao

[why]
limit visible_vram_size to real_vram_size in case the PCI BAR is larger than the actual amount of vram.

---
  drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c | 2 ++
  1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +2 -1
index b7dad4e67813..c0de7496bfd1 100644
@@ -320,6 +320,8 @@ static int gmc_v6_0_mc_init(struct amdgpu_device *adev)
         adev->gmc.aper_base = pci_resource_start(adev->pdev, 0);
         adev->gmc.aper_size = pci_resource_len(adev->pdev, 0);
         adev->gmc.visible_vram_size = adev->gmc.aper_size;
+       if (adev->gmc.visible_vram_size > adev->gmc.real_vram_size)
+               adev->gmc.visible_vram_size = adev->gmc.real_vram_size;
 
         /* set the gart size */
         if (amdgpu_gart_size == -1) {
--

2.20.1