Skip to contentSkip to conversation

drm/amdgpu: fix aper_base for APU

PATCH In review Alex Deucher 3 participants 4 messages May 26, 2022 – Jun 1, 2022

Subsystems (2)
lore
Share & tools
lore

Alex Deucher

author maintainer
#0 lore raw

PATCH 1/2 drm/amdgpu: fix aper_base for APU

From: Roman Li <[email protected]>

[Why]
Wrong fb offset results in dmub f/w errors and white screen. [drm:dc_dmub_srv_wait_idle [amdgpu]] *ERROR* Error waiting for DMUB idle: status=3

[How]
Read aper_base from mmhub because GC is off by default

v2: use BAR for passthrough (Alex)

---
 drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c +6 -0
index 11b61da419e7..b6daa4146dd3 100644
@@ -685,6 +685,12 @@ static int gmc_v11_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);
 
+#ifdef CONFIG_X86_64
+	if ((adev->flags & AMD_IS_APU) && !amdgpu_passthrough(adev)) {
+		adev->gmc.aper_base = adev->mmhub.funcs->get_mc_fb_offset(adev);
+		adev->gmc.aper_size = adev->gmc.real_vram_size;
+	}
+#endif
 	/* In case the PCI BAR is larger than the actual amount of vram */
 	adev->gmc.visible_vram_size = adev->gmc.aper_size;
 	if (adev->gmc.visible_vram_size > adev->gmc.real_vram_size)
Signature · 1 line
2.35.3
author maintainer
#1 lore raw

PATCH 2/2 drm/amdgpu/gmc11: enable AGP aperture

Enable the AGP aperture on chips with GMC v11.

---
 drivers/gpu/drm/amd/amdgpu/gfxhub_v3_0.c  | 7 ++++---
 drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c    | 1 +
 drivers/gpu/drm/amd/amdgpu/mmhub_v3_0.c   | 6 +++---
 drivers/gpu/drm/amd/amdgpu/mmhub_v3_0_2.c | 6 +++---
 4 files changed, 11 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfxhub_v3_0.c +4 -3
index 5eccaa2c7ca0..f99d7641bb21 100644
@@ -154,10 +154,11 @@ static void gfxhub_v3_0_init_system_aperture_regs(struct amdgpu_device *adev)
 {
 	uint64_t value;
 
-	/* Disable AGP. */
+	/* Program the AGP BAR */
 	WREG32_SOC15(GC, 0, regGCMC_VM_AGP_BASE, 0);
-	WREG32_SOC15(GC, 0, regGCMC_VM_AGP_TOP, 0);
-	WREG32_SOC15(GC, 0, regGCMC_VM_AGP_BOT, 0x00FFFFFF);
+	WREG32_SOC15(GC, 0, regGCMC_VM_AGP_BOT, adev->gmc.agp_start >> 24);
+	WREG32_SOC15(GC, 0, regGCMC_VM_AGP_TOP, adev->gmc.agp_end >> 24);
+
 
 	/* Program the system aperture low logical page number. */
 	WREG32_SOC15(GC, 0, regGCMC_VM_SYSTEM_APERTURE_LOW_ADDR,
drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c +1 -0
index b6daa4146dd3..635103c7e2a0 100644
@@ -654,6 +654,7 @@ static void gmc_v11_0_vram_gtt_location(struct amdgpu_device *adev,
 
 	amdgpu_gmc_vram_location(adev, &adev->gmc, base);
 	amdgpu_gmc_gart_location(adev, mc);
+	amdgpu_gmc_agp_location(adev, mc);
 
 	/* base offset of vram pages */
 	adev->vm_manager.vram_base_offset = adev->mmhub.funcs->get_mc_fb_offset(adev);
drivers/gpu/drm/amd/amdgpu/mmhub_v3_0.c +3 -3
index bc11b2de37ae..4926fa82c1c4 100644
@@ -169,10 +169,10 @@ static void mmhub_v3_0_init_system_aperture_regs(struct amdgpu_device *adev)
 	uint64_t value;
 	uint32_t tmp;
 
-	/* Disable AGP. */
+	/* Program the AGP BAR */
 	WREG32_SOC15(MMHUB, 0, regMMMC_VM_AGP_BASE, 0);
-	WREG32_SOC15(MMHUB, 0, regMMMC_VM_AGP_TOP, 0);
-	WREG32_SOC15(MMHUB, 0, regMMMC_VM_AGP_BOT, 0x00FFFFFF);
+	WREG32_SOC15(MMHUB, 0, regMMMC_VM_AGP_BOT, adev->gmc.agp_start >> 24);
+	WREG32_SOC15(MMHUB, 0, regMMMC_VM_AGP_TOP, adev->gmc.agp_end >> 24);
 
 	if (!amdgpu_sriov_vf(adev)) {
 		/*
drivers/gpu/drm/amd/amdgpu/mmhub_v3_0_2.c +3 -3
index 770be0a8f7ce..5e5b884d8357 100644
@@ -162,10 +162,10 @@ static void mmhub_v3_0_2_init_system_aperture_regs(struct amdgpu_device *adev)
 	uint64_t value;
 	uint32_t tmp;
 
-	/* Disable AGP. */
+	/* Program the AGP BAR */
 	WREG32_SOC15(MMHUB, 0, regMMMC_VM_AGP_BASE, 0);
-	WREG32_SOC15(MMHUB, 0, regMMMC_VM_AGP_TOP, 0);
-	WREG32_SOC15(MMHUB, 0, regMMMC_VM_AGP_BOT, 0x00FFFFFF);
+	WREG32_SOC15(MMHUB, 0, regMMMC_VM_AGP_BOT, adev->gmc.agp_start >> 24);
+	WREG32_SOC15(MMHUB, 0, regMMMC_VM_AGP_TOP, adev->gmc.agp_end >> 24);
 
 	if (!amdgpu_sriov_vf(adev)) {
 		/*
Signature · 1 line
2.35.3
#2 lore raw

Re: [PATCH 2/2] drm/amdgpu/gmc11: enable AGP aperture

Ping?

Quoted 81 lines · Alex Deucher

Enable the AGP aperture on chips with GMC v11.

---
 drivers/gpu/drm/amd/amdgpu/gfxhub_v3_0.c  | 7 ++++---
 drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c    | 1 +
 drivers/gpu/drm/amd/amdgpu/mmhub_v3_0.c   | 6 +++---
 drivers/gpu/drm/amd/amdgpu/mmhub_v3_0_2.c | 6 +++---
 4 files changed, 11 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfxhub_v3_0.c +4 -3
index 5eccaa2c7ca0..f99d7641bb21 100644
@@ -154,10 +154,11 @@ static void gfxhub_v3_0_init_system_aperture_regs(struct amdgpu_device *adev)
 {
        uint64_t value;
 
-       /* Disable AGP. */
+       /* Program the AGP BAR */
        WREG32_SOC15(GC, 0, regGCMC_VM_AGP_BASE, 0);
-       WREG32_SOC15(GC, 0, regGCMC_VM_AGP_TOP, 0);
-       WREG32_SOC15(GC, 0, regGCMC_VM_AGP_BOT, 0x00FFFFFF);
+       WREG32_SOC15(GC, 0, regGCMC_VM_AGP_BOT, adev->gmc.agp_start >> 24);
+       WREG32_SOC15(GC, 0, regGCMC_VM_AGP_TOP, adev->gmc.agp_end >> 24);
+
 
        /* Program the system aperture low logical page number. */
        WREG32_SOC15(GC, 0, regGCMC_VM_SYSTEM_APERTURE_LOW_ADDR,
drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c +1 -0
index b6daa4146dd3..635103c7e2a0 100644
@@ -654,6 +654,7 @@ static void gmc_v11_0_vram_gtt_location(struct amdgpu_device *adev,
 
        amdgpu_gmc_vram_location(adev, &adev->gmc, base);
        amdgpu_gmc_gart_location(adev, mc);
+       amdgpu_gmc_agp_location(adev, mc);
 
        /* base offset of vram pages */
        adev->vm_manager.vram_base_offset = adev->mmhub.funcs->get_mc_fb_offset(adev);
drivers/gpu/drm/amd/amdgpu/mmhub_v3_0.c +3 -3
index bc11b2de37ae..4926fa82c1c4 100644
@@ -169,10 +169,10 @@ static void mmhub_v3_0_init_system_aperture_regs(struct amdgpu_device *adev)
        uint64_t value;
        uint32_t tmp;
 
-       /* Disable AGP. */
+       /* Program the AGP BAR */
        WREG32_SOC15(MMHUB, 0, regMMMC_VM_AGP_BASE, 0);
-       WREG32_SOC15(MMHUB, 0, regMMMC_VM_AGP_TOP, 0);
-       WREG32_SOC15(MMHUB, 0, regMMMC_VM_AGP_BOT, 0x00FFFFFF);
+       WREG32_SOC15(MMHUB, 0, regMMMC_VM_AGP_BOT, adev->gmc.agp_start >> 24);
+       WREG32_SOC15(MMHUB, 0, regMMMC_VM_AGP_TOP, adev->gmc.agp_end >> 24);
 
        if (!amdgpu_sriov_vf(adev)) {
                /*
drivers/gpu/drm/amd/amdgpu/mmhub_v3_0_2.c +3 -4
index 770be0a8f7ce..5e5b884d8357 100644
@@ -162,10 +162,10 @@ static void mmhub_v3_0_2_init_system_aperture_regs(struct amdgpu_device *adev)
        uint64_t value;
        uint32_t tmp;
 
-       /* Disable AGP. */
+       /* Program the AGP BAR */
        WREG32_SOC15(MMHUB, 0, regMMMC_VM_AGP_BASE, 0);
-       WREG32_SOC15(MMHUB, 0, regMMMC_VM_AGP_TOP, 0);
-       WREG32_SOC15(MMHUB, 0, regMMMC_VM_AGP_BOT, 0x00FFFFFF);
+       WREG32_SOC15(MMHUB, 0, regMMMC_VM_AGP_BOT, adev->gmc.agp_start >> 24);
+       WREG32_SOC15(MMHUB, 0, regMMMC_VM_AGP_TOP, adev->gmc.agp_end >> 24);
 
        if (!amdgpu_sriov_vf(adev)) {
                /*
--

2.35.3

Reviewed-by on v1 2/2
#3 lore raw

Re: [PATCH 2/2] drm/amdgpu/gmc11: enable AGP aperture

In reply to Alex Deucher

Am 26.05.22 um 19:58 schrieb Alex Deucher:

Quoted 3 lines

Enable the AGP aperture on chips with GMC v11.

Quoted 74 lines
---
  drivers/gpu/drm/amd/amdgpu/gfxhub_v3_0.c  | 7 ++++---
  drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c    | 1 +
  drivers/gpu/drm/amd/amdgpu/mmhub_v3_0.c   | 6 +++---
  drivers/gpu/drm/amd/amdgpu/mmhub_v3_0_2.c | 6 +++---
  4 files changed, 11 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfxhub_v3_0.c +4 -3
index 5eccaa2c7ca0..f99d7641bb21 100644
@@ -154,10 +154,11 @@ static void gfxhub_v3_0_init_system_aperture_regs(struct amdgpu_device *adev)
  {
  	uint64_t value;
 
-	/* Disable AGP. */
+	/* Program the AGP BAR */
  	WREG32_SOC15(GC, 0, regGCMC_VM_AGP_BASE, 0);
-	WREG32_SOC15(GC, 0, regGCMC_VM_AGP_TOP, 0);
-	WREG32_SOC15(GC, 0, regGCMC_VM_AGP_BOT, 0x00FFFFFF);
+	WREG32_SOC15(GC, 0, regGCMC_VM_AGP_BOT, adev->gmc.agp_start >> 24);
+	WREG32_SOC15(GC, 0, regGCMC_VM_AGP_TOP, adev->gmc.agp_end >> 24);
+
 
  	/* Program the system aperture low logical page number. */
  	WREG32_SOC15(GC, 0, regGCMC_VM_SYSTEM_APERTURE_LOW_ADDR,
drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c +1 -0
index b6daa4146dd3..635103c7e2a0 100644
@@ -654,6 +654,7 @@ static void gmc_v11_0_vram_gtt_location(struct amdgpu_device *adev,
 
  	amdgpu_gmc_vram_location(adev, &adev->gmc, base);
  	amdgpu_gmc_gart_location(adev, mc);
+	amdgpu_gmc_agp_location(adev, mc);
 
  	/* base offset of vram pages */
  	adev->vm_manager.vram_base_offset = adev->mmhub.funcs->get_mc_fb_offset(adev);
drivers/gpu/drm/amd/amdgpu/mmhub_v3_0.c +3 -3
index bc11b2de37ae..4926fa82c1c4 100644
@@ -169,10 +169,10 @@ static void mmhub_v3_0_init_system_aperture_regs(struct amdgpu_device *adev)
  	uint64_t value;
  	uint32_t tmp;
 
-	/* Disable AGP. */
+	/* Program the AGP BAR */
  	WREG32_SOC15(MMHUB, 0, regMMMC_VM_AGP_BASE, 0);
-	WREG32_SOC15(MMHUB, 0, regMMMC_VM_AGP_TOP, 0);
-	WREG32_SOC15(MMHUB, 0, regMMMC_VM_AGP_BOT, 0x00FFFFFF);
+	WREG32_SOC15(MMHUB, 0, regMMMC_VM_AGP_BOT, adev->gmc.agp_start >> 24);
+	WREG32_SOC15(MMHUB, 0, regMMMC_VM_AGP_TOP, adev->gmc.agp_end >> 24);
 
  	if (!amdgpu_sriov_vf(adev)) {
  		/*
drivers/gpu/drm/amd/amdgpu/mmhub_v3_0_2.c +3 -3
index 770be0a8f7ce..5e5b884d8357 100644
@@ -162,10 +162,10 @@ static void mmhub_v3_0_2_init_system_aperture_regs(struct amdgpu_device *adev)
  	uint64_t value;
  	uint32_t tmp;
 
-	/* Disable AGP. */
+	/* Program the AGP BAR */
  	WREG32_SOC15(MMHUB, 0, regMMMC_VM_AGP_BASE, 0);
-	WREG32_SOC15(MMHUB, 0, regMMMC_VM_AGP_TOP, 0);
-	WREG32_SOC15(MMHUB, 0, regMMMC_VM_AGP_BOT, 0x00FFFFFF);
+	WREG32_SOC15(MMHUB, 0, regMMMC_VM_AGP_BOT, adev->gmc.agp_start >> 24);
+	WREG32_SOC15(MMHUB, 0, regMMMC_VM_AGP_TOP, adev->gmc.agp_end >> 24);
 
  	if (!amdgpu_sriov_vf(adev)) {
  		/*