<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:DengXian;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"\@DengXian";
        panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        font-size:10.0pt;
        font-family:"Calibri",sans-serif;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body lang="en-CN" link="#0563C1" vlink="#954F72" style="word-wrap:break-word">
<p style="font-family:Arial;font-size:10pt;color:#0000FF;margin:5pt;" align="Left">
[AMD Official Use Only - General]<br>
</p>
<br>
<div>
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt">Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt">Regards,<br>
Hawking<o:p></o:p></span></p>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal" style="margin-bottom:12.0pt"><b><span style="font-size:12.0pt;color:black">From:
</span></b><span style="font-size:12.0pt;color:black">amd-gfx <amd-gfx-bounces@lists.freedesktop.org> on behalf of Alex Deucher <alexander.deucher@amd.com><br>
<b>Date: </b>Thursday, February 9, 2023 at 21:43<br>
<b>To: </b>amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc: </b>Deucher, Alexander <Alexander.Deucher@amd.com><br>
<b>Subject: </b>[PATCH 1/2] drm/amdgpu/gmc11: fix system aperture set when AGP is enabled<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:11.0pt">Need to cover both FB and AGP apertures.<br>
<br>
v2: fix missed gfxhub_v3_0_3.c<br>
<br>
Fixes: c6eafee038ed ("Revert "Revert "drm/amdgpu/gmc11: enable AGP aperture""")<br>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com><br>
---<br>
 drivers/gpu/drm/amd/amdgpu/gfxhub_v3_0.c   | 4 ++--<br>
 drivers/gpu/drm/amd/amdgpu/gfxhub_v3_0_3.c | 8 ++++----<br>
 drivers/gpu/drm/amd/amdgpu/mmhub_v3_0.c    | 4 ++--<br>
 drivers/gpu/drm/amd/amdgpu/mmhub_v3_0_1.c  | 4 ++--<br>
 drivers/gpu/drm/amd/amdgpu/mmhub_v3_0_2.c  | 4 ++--<br>
 5 files changed, 12 insertions(+), 12 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/gfxhub_v3_0.c b/drivers/gpu/drm/amd/amdgpu/gfxhub_v3_0.c<br>
index 7c069010ca9a..be0d0f47415e 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/gfxhub_v3_0.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/gfxhub_v3_0.c<br>
@@ -159,9 +159,9 @@ static void gfxhub_v3_0_init_system_aperture_regs(struct amdgpu_device *adev)<br>
 <br>
         /* Program the system aperture low logical page number. */<br>
         WREG32_SOC15(GC, 0, regGCMC_VM_SYSTEM_APERTURE_LOW_ADDR,<br>
-                    adev->gmc.vram_start >> 18);<br>
+                    min(adev->gmc.fb_start, adev->gmc.agp_start) >> 18);<br>
         WREG32_SOC15(GC, 0, regGCMC_VM_SYSTEM_APERTURE_HIGH_ADDR,<br>
-                    adev->gmc.vram_end >> 18);<br>
+                    max(adev->gmc.fb_end, adev->gmc.agp_end) >> 18);<br>
 <br>
         /* Set default page address. */<br>
         value = adev->mem_scratch.gpu_addr - adev->gmc.vram_start<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/gfxhub_v3_0_3.c b/drivers/gpu/drm/amd/amdgpu/gfxhub_v3_0_3.c<br>
index 3dc17a3deedb..6e0bd628c889 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/gfxhub_v3_0_3.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/gfxhub_v3_0_3.c<br>
@@ -159,14 +159,14 @@ static void gfxhub_v3_0_3_init_system_aperture_regs(struct amdgpu_device *adev)<br>
 <br>
         /* Disable AGP. */<br>
         WREG32_SOC15(GC, 0, regGCMC_VM_AGP_BASE, 0);<br>
-       WREG32_SOC15(GC, 0, regGCMC_VM_AGP_TOP, 0);<br>
-       WREG32_SOC15(GC, 0, regGCMC_VM_AGP_BOT, 0x00FFFFFF);<br>
+       WREG32_SOC15(GC, 0, regGCMC_VM_AGP_BOT, adev->gmc.agp_start >> 24);<br>
+       WREG32_SOC15(GC, 0, regGCMC_VM_AGP_TOP, adev->gmc.agp_end >> 24);<br>
 <br>
         /* Program the system aperture low logical page number. */<br>
         WREG32_SOC15(GC, 0, regGCMC_VM_SYSTEM_APERTURE_LOW_ADDR,<br>
-                    adev->gmc.vram_start >> 18);<br>
+                    min(adev->gmc.fb_start, adev->gmc.agp_start) >> 18);<br>
         WREG32_SOC15(GC, 0, regGCMC_VM_SYSTEM_APERTURE_HIGH_ADDR,<br>
-                    adev->gmc.vram_end >> 18);<br>
+                    max(adev->gmc.fb_end, adev->gmc.agp_end) >> 18);<br>
 <br>
         /* Set default page address. */<br>
         value = adev->mem_scratch.gpu_addr - adev->gmc.vram_start<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/mmhub_v3_0.c b/drivers/gpu/drm/amd/amdgpu/mmhub_v3_0.c<br>
index 923fc09bc8fc..164948c50ac3 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/mmhub_v3_0.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/mmhub_v3_0.c<br>
@@ -184,9 +184,9 @@ static void mmhub_v3_0_init_system_aperture_regs(struct amdgpu_device *adev)<br>
 <br>
         /* Program the system aperture low logical page number. */<br>
         WREG32_SOC15(MMHUB, 0, regMMMC_VM_SYSTEM_APERTURE_LOW_ADDR,<br>
-                    adev->gmc.vram_start >> 18);<br>
+                    min(adev->gmc.fb_start, adev->gmc.agp_start) >> 18);<br>
         WREG32_SOC15(MMHUB, 0, regMMMC_VM_SYSTEM_APERTURE_HIGH_ADDR,<br>
-                    adev->gmc.vram_end >> 18);<br>
+                    max(adev->gmc.fb_end, adev->gmc.agp_end) >> 18);<br>
 <br>
         /* Set default page address. */<br>
         value = adev->mem_scratch.gpu_addr - adev->gmc.vram_start +<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/mmhub_v3_0_1.c b/drivers/gpu/drm/amd/amdgpu/mmhub_v3_0_1.c<br>
index c8d478f2afdc..26509b6b8c24 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/mmhub_v3_0_1.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/mmhub_v3_0_1.c<br>
@@ -183,9 +183,9 @@ static void mmhub_v3_0_1_init_system_aperture_regs(struct amdgpu_device *adev)<br>
          */<br>
         /* Program the system aperture low logical page number. */<br>
         WREG32_SOC15(MMHUB, 0, regMMMC_VM_SYSTEM_APERTURE_LOW_ADDR,<br>
-                    adev->gmc.vram_start >> 18);<br>
+                    min(adev->gmc.fb_start, adev->gmc.agp_start) >> 18);<br>
         WREG32_SOC15(MMHUB, 0, regMMMC_VM_SYSTEM_APERTURE_HIGH_ADDR,<br>
-                    adev->gmc.vram_end >> 18);<br>
+                    max(adev->gmc.fb_end, adev->gmc.agp_end) >> 18);<br>
 <br>
         /* Set default page address. */<br>
         value = adev->mem_scratch.gpu_addr - adev->gmc.vram_start +<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/mmhub_v3_0_2.c b/drivers/gpu/drm/amd/amdgpu/mmhub_v3_0_2.c<br>
index 51580302ec42..26abbc6a47ab 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/mmhub_v3_0_2.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/mmhub_v3_0_2.c<br>
@@ -175,9 +175,9 @@ static void mmhub_v3_0_2_init_system_aperture_regs(struct amdgpu_device *adev)<br>
                  */<br>
                 /* Program the system aperture low logical page number. */<br>
                 WREG32_SOC15(MMHUB, 0, regMMMC_VM_SYSTEM_APERTURE_LOW_ADDR,<br>
-                            adev->gmc.vram_start >> 18);<br>
+                            min(adev->gmc.fb_start, adev->gmc.agp_start) >> 18);<br>
                 WREG32_SOC15(MMHUB, 0, regMMMC_VM_SYSTEM_APERTURE_HIGH_ADDR,<br>
-                            adev->gmc.vram_end >> 18);<br>
+                            max(adev->gmc.fb_end, adev->gmc.agp_end) >> 18);<br>
         }<br>
 <br>
         /* Set default page address. */<br>
-- <br>
2.39.1<o:p></o:p></span></p>
</div>
</div>
</div>
</body>
</html>