[PATCH] drm/amdgpu/sriov: skip programing some regs with new L1 policy

Deucher, Alexander Alexander.Deucher at amd.com
Tue Mar 3 21:42:07 UTC 2020


[AMD Public Use]

Acked-by: Alex Deucher <alexander.deucher at amd.com>

________________________________
From: amd-gfx <amd-gfx-bounces at lists.freedesktop.org> on behalf of Zhou, Tiecheng <Tiecheng.Zhou at amd.com>
Sent: Tuesday, March 3, 2020 6:04 AM
To: Zhou, Tiecheng <Tiecheng.Zhou at amd.com>; amd-gfx at lists.freedesktop.org <amd-gfx at lists.freedesktop.org>
Subject: RE: [PATCH] drm/amdgpu/sriov: skip programing some regs with new L1 policy

[AMD Official Use Only - Internal Distribution Only]

Ping

-----Original Message-----
From: Tiecheng Zhou <Tiecheng.Zhou at amd.com>
Sent: Monday, March 2, 2020 3:08 PM
To: amd-gfx at lists.freedesktop.org
Cc: Zhou, Tiecheng <Tiecheng.Zhou at amd.com>
Subject: [PATCH] drm/amdgpu/sriov: skip programing some regs with new L1 policy

With new L1 policy, some regs are blocked at guest and they are programed at host side. So skip programing the regs under sriov.

the regs are:
GCMC_VM_FB_LOCATION_TOP
GCMC_VM_FB_LOCATION_BASE
MMMC_VM_FB_LOCATION_TOP
MMMC_VM_FB_LOCATION_BASE
GCMC_VM_SYSTEM_APERTURE_HIGH_ADDR
GCMC_VM_SYSTEM_APERTURE_LOW_ADDR
MMMC_VM_SYSTEM_APERTURE_HIGH_ADDR
MMMC_VM_SYSTEM_APERTURE_LOW_ADDR
HDP_NONSURFACE_BASE
HDP_NONSURFACE_BASE_HI
GCMC_VM_AGP_TOP
GCMC_VM_AGP_BOT
GCMC_VM_AGP_BASE

Signed-off-by: Tiecheng Zhou <Tiecheng.Zhou at amd.com>
---
 drivers/gpu/drm/amd/amdgpu/gfxhub_v2_0.c | 55 +++++++++++-------------  drivers/gpu/drm/amd/amdgpu/mmhub_v2_0.c  | 29 ++++++-------
 2 files changed, 37 insertions(+), 47 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfxhub_v2_0.c b/drivers/gpu/drm/amd/amdgpu/gfxhub_v2_0.c
index e0654a216ab5..cc866c367939 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfxhub_v2_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfxhub_v2_0.c
@@ -81,24 +81,31 @@ static void gfxhub_v2_0_init_system_aperture_regs(struct amdgpu_device *adev)  {
         uint64_t value;

-       /* Disable AGP. */
-       WREG32_SOC15(GC, 0, mmGCMC_VM_AGP_BASE, 0);
-       WREG32_SOC15(GC, 0, mmGCMC_VM_AGP_TOP, 0);
-       WREG32_SOC15(GC, 0, mmGCMC_VM_AGP_BOT, 0x00FFFFFF);
-
-       /* Program the system aperture low logical page number. */
-       WREG32_SOC15(GC, 0, mmGCMC_VM_SYSTEM_APERTURE_LOW_ADDR,
-                    adev->gmc.vram_start >> 18);
-       WREG32_SOC15(GC, 0, mmGCMC_VM_SYSTEM_APERTURE_HIGH_ADDR,
-                    adev->gmc.vram_end >> 18);
-
-       /* Set default page address. */
-       value = adev->vram_scratch.gpu_addr - adev->gmc.vram_start
-               + adev->vm_manager.vram_base_offset;
-       WREG32_SOC15(GC, 0, mmGCMC_VM_SYSTEM_APERTURE_DEFAULT_ADDR_LSB,
-                    (u32)(value >> 12));
-       WREG32_SOC15(GC, 0, mmGCMC_VM_SYSTEM_APERTURE_DEFAULT_ADDR_MSB,
-                    (u32)(value >> 44));
+       if (!amdgpu_sriov_vf(adev)) {
+               /*
+                * the new L1 policy will block SRIOV guest from writing
+                * these regs, and they will be programed at host.
+                * so skip programing these regs.
+                */
+               /* Disable AGP. */
+               WREG32_SOC15(GC, 0, mmGCMC_VM_AGP_BASE, 0);
+               WREG32_SOC15(GC, 0, mmGCMC_VM_AGP_TOP, 0);
+               WREG32_SOC15(GC, 0, mmGCMC_VM_AGP_BOT, 0x00FFFFFF);
+
+               /* Program the system aperture low logical page number. */
+               WREG32_SOC15(GC, 0, mmGCMC_VM_SYSTEM_APERTURE_LOW_ADDR,
+                            adev->gmc.vram_start >> 18);
+               WREG32_SOC15(GC, 0, mmGCMC_VM_SYSTEM_APERTURE_HIGH_ADDR,
+                            adev->gmc.vram_end >> 18);
+
+               /* Set default page address. */
+               value = adev->vram_scratch.gpu_addr - adev->gmc.vram_start
+                       + adev->vm_manager.vram_base_offset;
+               WREG32_SOC15(GC, 0, mmGCMC_VM_SYSTEM_APERTURE_DEFAULT_ADDR_LSB,
+                            (u32)(value >> 12));
+               WREG32_SOC15(GC, 0, mmGCMC_VM_SYSTEM_APERTURE_DEFAULT_ADDR_MSB,
+                            (u32)(value >> 44));
+       }

         /* Program "protection fault". */
         WREG32_SOC15(GC, 0, mmGCVM_L2_PROTECTION_FAULT_DEFAULT_ADDR_LO32,
@@ -260,18 +267,6 @@ static void gfxhub_v2_0_program_invalidation(struct amdgpu_device *adev)

 int gfxhub_v2_0_gart_enable(struct amdgpu_device *adev)  {
-       if (amdgpu_sriov_vf(adev)) {
-               /*
-                * GCMC_VM_FB_LOCATION_BASE/TOP is NULL for VF, becuase they are
-                * VF copy registers so vbios post doesn't program them, for
-                * SRIOV driver need to program them
-                */
-               WREG32_SOC15(GC, 0, mmGCMC_VM_FB_LOCATION_BASE,
-                            adev->gmc.vram_start >> 24);
-               WREG32_SOC15(GC, 0, mmGCMC_VM_FB_LOCATION_TOP,
-                            adev->gmc.vram_end >> 24);
-       }
-
         /* GART Enable. */
         gfxhub_v2_0_init_gart_aperture_regs(adev);
         gfxhub_v2_0_init_system_aperture_regs(adev);
diff --git a/drivers/gpu/drm/amd/amdgpu/mmhub_v2_0.c b/drivers/gpu/drm/amd/amdgpu/mmhub_v2_0.c
index bde189680521..fb3f228458e5 100644
--- a/drivers/gpu/drm/amd/amdgpu/mmhub_v2_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/mmhub_v2_0.c
@@ -72,11 +72,18 @@ static void mmhub_v2_0_init_system_aperture_regs(struct amdgpu_device *adev)
         WREG32_SOC15(MMHUB, 0, mmMMMC_VM_AGP_TOP, 0);
         WREG32_SOC15(MMHUB, 0, mmMMMC_VM_AGP_BOT, 0x00FFFFFF);

-       /* Program the system aperture low logical page number. */
-       WREG32_SOC15(MMHUB, 0, mmMMMC_VM_SYSTEM_APERTURE_LOW_ADDR,
-                    adev->gmc.vram_start >> 18);
-       WREG32_SOC15(MMHUB, 0, mmMMMC_VM_SYSTEM_APERTURE_HIGH_ADDR,
-                    adev->gmc.vram_end >> 18);
+       if (!amdgpu_sriov_vf(adev)) {
+               /*
+                * the new L1 policy will block SRIOV guest from writing
+                * these regs, and they will be programed at host.
+                * so skip programing these regs.
+                */
+               /* Program the system aperture low logical page number. */
+               WREG32_SOC15(MMHUB, 0, mmMMMC_VM_SYSTEM_APERTURE_LOW_ADDR,
+                            adev->gmc.vram_start >> 18);
+               WREG32_SOC15(MMHUB, 0, mmMMMC_VM_SYSTEM_APERTURE_HIGH_ADDR,
+                            adev->gmc.vram_end >> 18);
+       }

         /* Set default page address. */
         value = adev->vram_scratch.gpu_addr - adev->gmc.vram_start + @@ -247,18 +254,6 @@ static void mmhub_v2_0_program_invalidation(struct amdgpu_device *adev)

 int mmhub_v2_0_gart_enable(struct amdgpu_device *adev)  {
-       if (amdgpu_sriov_vf(adev)) {
-               /*
-                * MMMC_VM_FB_LOCATION_BASE/TOP is NULL for VF, becuase they are
-                * VF copy registers so vbios post doesn't program them, for
-                * SRIOV driver need to program them
-                */
-               WREG32_SOC15(MMHUB, 0, mmMMMC_VM_FB_LOCATION_BASE,
-                            adev->gmc.vram_start >> 24);
-               WREG32_SOC15(MMHUB, 0, mmMMMC_VM_FB_LOCATION_TOP,
-                            adev->gmc.vram_end >> 24);
-       }
-
         /* GART Enable. */
         mmhub_v2_0_init_gart_aperture_regs(adev);
         mmhub_v2_0_init_system_aperture_regs(adev);
--
2.17.1
_______________________________________________
amd-gfx mailing list
amd-gfx at lists.freedesktop.org
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=02%7C01%7Calexander.deucher%40amd.com%7C5c67ab87ec474567746608d7bf62b5ce%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637188303458046365&sdata=xQ%2Fx7i5LhvDFFZ%2BOJzhJYPr0TbHLpUW4NrbBxvcvyaE%3D&reserved=0
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/amd-gfx/attachments/20200303/bb348de6/attachment-0001.htm>


More information about the amd-gfx mailing list