[PATCH] drm/amdgpu: add function to program pbb mode for sienna cichlid

Wang, Kevin(Yang) Kevin1.Wang at amd.com
Thu Oct 15 05:04:29 UTC 2020


[AMD Official Use Only - Internal Distribution Only]



________________________________
From: amd-gfx <amd-gfx-bounces at lists.freedesktop.org> on behalf of Likun Gao <likun.gao at amd.com>
Sent: Thursday, October 15, 2020 12:03 PM
To: amd-gfx at lists.freedesktop.org <amd-gfx at lists.freedesktop.org>
Cc: Gao, Likun <Likun.Gao at amd.com>
Subject: [PATCH] drm/amdgpu: add function to program pbb mode for sienna cichlid

From: Likun Gao <Likun.Gao at amd.com>

Add function for sienna_cichlid to force PBB workload mode to zero by
checking whether there have SE been harvested.

Signed-off-by: Likun Gao <Likun.Gao at amd.com>
Change-Id: I3bf2fe0b976affe26c829ac67bee176018f13fe9
---
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 62 ++++++++++++++++++++++++++
 1 file changed, 62 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
index 65804137b7f8..aa48eab85c7a 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
@@ -112,6 +112,22 @@
 #define mmCP_HYP_ME_UCODE_DATA                  0x5817
 #define mmCP_HYP_ME_UCODE_DATA_BASE_IDX         1

+//CC_GC_SA_UNIT_DISABLE
+#define mmCC_GC_SA_UNIT_DISABLE                 0x0fe9
+#define mmCC_GC_SA_UNIT_DISABLE_BASE_IDX        0
+#define CC_GC_SA_UNIT_DISABLE__SA_DISABLE__SHIFT       0x8
+#define CC_GC_SA_UNIT_DISABLE__SA_DISABLE_MASK         0x0000FF00L
+//GC_USER_SA_UNIT_DISABLE
+#define mmGC_USER_SA_UNIT_DISABLE               0x0fea
+#define mmGC_USER_SA_UNIT_DISABLE_BASE_IDX      0
+#define GC_USER_SA_UNIT_DISABLE__SA_DISABLE__SHIFT     0x8
+#define GC_USER_SA_UNIT_DISABLE__SA_DISABLE_MASK       0x0000FF00L
+//PA_SC_ENHANCE_3
+#define mmPA_SC_ENHANCE_3                       0x1085
+#define mmPA_SC_ENHANCE_3_BASE_IDX              0
+#define PA_SC_ENHANCE_3__FORCE_PBB_WORKLOAD_MODE_TO_ZERO__SHIFT 0x3
+#define PA_SC_ENHANCE_3__FORCE_PBB_WORKLOAD_MODE_TO_ZERO_MASK   0x00000008L
+
 MODULE_FIRMWARE("amdgpu/navi10_ce.bin");
 MODULE_FIRMWARE("amdgpu/navi10_pfp.bin");
 MODULE_FIRMWARE("amdgpu/navi10_me.bin");
@@ -3188,6 +3204,8 @@ static int gfx_v10_0_wait_for_rlc_autoload_complete(struct amdgpu_device *adev);
 static void gfx_v10_0_ring_emit_ce_meta(struct amdgpu_ring *ring, bool resume);
 static void gfx_v10_0_ring_emit_de_meta(struct amdgpu_ring *ring, bool resume);
 static void gfx_v10_0_ring_emit_frame_cntl(struct amdgpu_ring *ring, bool start, bool secure);
+static u32 gfx_v10_3_get_disabled_sa(struct amdgpu_device *adev);
+static void gfx_v10_3_program_pbb_mode(struct amdgpu_device *adev);

 static void gfx10_kiq_set_resources(struct amdgpu_ring *kiq_ring, uint64_t queue_mask)
 {
@@ -6990,6 +7008,9 @@ static int gfx_v10_0_hw_init(void *handle)
         if (r)
                 return r;

+       if (adev->asic_type == CHIP_SIENNA_CICHLID)
+               gfx_v10_3_program_pbb_mode(adev);
+
         return r;
 }

@@ -8841,6 +8862,47 @@ static int gfx_v10_0_get_cu_info(struct amdgpu_device *adev,
         return 0;
 }

+static u32 gfx_v10_3_get_disabled_sa(struct amdgpu_device *adev)
+{
+       uint32_t efuse_setting, vbios_setting, disabled_sa, max_sa_mask;
+
+       efuse_setting = RREG32_SOC15(GC, 0, mmCC_GC_SA_UNIT_DISABLE);
+       efuse_setting &= CC_GC_SA_UNIT_DISABLE__SA_DISABLE_MASK;
+       efuse_setting >>= CC_GC_SA_UNIT_DISABLE__SA_DISABLE__SHIFT;
+
+       vbios_setting = RREG32_SOC15(GC, 0, mmGC_USER_SA_UNIT_DISABLE);
+       vbios_setting &= GC_USER_SA_UNIT_DISABLE__SA_DISABLE_MASK;
+       vbios_setting >>= GC_USER_SA_UNIT_DISABLE__SA_DISABLE__SHIFT;

[kevin]:
the above codes can be replaced with helper macro of "REG_GET_FIELD".
#define REG_GET_FIELD(value, reg, field)                                \
        (((value) & REG_FIELD_MASK(reg, field)) >> REG_FIELD_SHIFT(reg, field))
+
+       max_sa_mask = amdgpu_gfx_create_bitmask(adev->gfx.config.max_sh_per_se *
+                                               adev->gfx.config.max_shader_engines);
+       disabled_sa = efuse_setting | vbios_setting;
+       disabled_sa &= max_sa_mask;
+
+       return disabled_sa;
+}
+
+static void gfx_v10_3_program_pbb_mode(struct amdgpu_device *adev)
+{
+       uint32_t max_sa_per_se, max_sa_per_se_mask, max_shader_engines;
+       uint32_t disabled_sa_mask, se_index, disabled_sa_per_se;
+
+       disabled_sa_mask = gfx_v10_3_get_disabled_sa(adev);
+
+       max_sa_per_se = adev->gfx.config.max_sh_per_se;
+       max_sa_per_se_mask = (1 << max_sa_per_se) - 1;
+       max_shader_engines = adev->gfx.config.max_shader_engines;
+
+       for (se_index = 0; max_shader_engines > se_index; se_index++) {
+               disabled_sa_per_se = disabled_sa_mask >> (se_index * max_sa_per_se);
+               disabled_sa_per_se &= max_sa_per_se_mask;
+               if (disabled_sa_per_se == max_sa_per_se_mask) {
+                       WREG32_FIELD15(GC, 0, PA_SC_ENHANCE_3, FORCE_PBB_WORKLOAD_MODE_TO_ZERO, 1);
+                       break;
+               }
+       }
+}
+
 const struct amdgpu_ip_block_version gfx_v10_0_ip_block =
 {
         .type = AMD_IP_BLOCK_TYPE_GFX,
--
2.25.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%7CKevin1.Wang%40amd.com%7Caa2f838b492e41b2b35c08d870bf6a6b%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637383314725026504&sdata=63CLPN9Dw6NsIk2qXyRepfGpLXbCznLVu%2BegsnJq%2BPg%3D&reserved=0
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/amd-gfx/attachments/20201015/f86e57c0/attachment-0001.htm>


More information about the amd-gfx mailing list