drm/amd/pm: Add interface for request WGPs
authorJinzhou Su <Jinzhou.Su@amd.com>
Thu, 17 Dec 2020 09:37:38 +0000 (17:37 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 23 Dec 2020 20:06:42 +0000 (15:06 -0500)
When user specifies a reduced WGP(CU) config via disalbe_cu module
parameter, this does not disable the clocks which uses additional
power. This interface send active WGP number to SMU and SMU will
cooperate with RLC to power off relative WGPs.

v2: Add request active WGPs in Vangogh smu post init.

Signed-off-by: Jinzhou.Su <Jinzhou.Su@amd.com>
Reviewed-by: Jiansong Chen <Jiansong.Chen@amd.com>
Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/pm/inc/smu_types.h
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c

index 720d15612fe1ac45c1965d169be8069b198a8412..b2d0d8fcf429fea9a3b5eef41945e4fd0fdace0c 100644 (file)
        __SMU_DUMMY_MAP(SetGpoFeaturePMask),             \
        __SMU_DUMMY_MAP(DisallowGpo),                    \
        __SMU_DUMMY_MAP(Enable2ndUSB20Port),             \
+       __SMU_DUMMY_MAP(RequestActiveWgp),               \
 
 #undef __SMU_DUMMY_MAP
 #define __SMU_DUMMY_MAP(type)  SMU_MSG_##type
index 8b867a6d52b57f0f6e3b9aa1f136494f82ac81d5..d921986448c547b5ad0f5283370fe07f17fdd7a9 100644 (file)
@@ -478,9 +478,6 @@ static int smu_late_init(void *handle)
 
        smu_set_fine_grain_gfx_freq_parameters(smu);
 
-       if (adev->asic_type == CHIP_VANGOGH)
-               return 0;
-
        if (!smu->pm_enabled)
                return 0;
 
@@ -490,6 +487,9 @@ static int smu_late_init(void *handle)
                return ret;
        }
 
+       if (adev->asic_type == CHIP_VANGOGH)
+               return 0;
+
        ret = smu_set_default_od_settings(smu);
        if (ret) {
                dev_err(adev->dev, "Failed to setup default OD settings!\n");
index 8cb4fcee9a2c3750143775c940435fb4ba947a65..48d4d4d4d26af91e0e77e9b49c127f5ef6af19e2 100644 (file)
@@ -31,6 +31,9 @@
 #include "smu_v11_5_ppsmc.h"
 #include "smu_v11_5_pmfw.h"
 #include "smu_cmn.h"
+#include "soc15_common.h"
+#include "asic_reg/gc/gc_10_3_0_offset.h"
+#include "asic_reg/gc/gc_10_3_0_sh_mask.h"
 
 /*
  * DO NOT use these for err/warn/info/debug messages.
@@ -118,6 +121,7 @@ static struct cmn2asic_msg_mapping vangogh_message_map[SMU_MSG_MAX_COUNT] = {
        MSG_MAP(StopDramLogging,                    PPSMC_MSG_StopDramLogging,                                          0),
        MSG_MAP(SetSoftMinCclk,                     PPSMC_MSG_SetSoftMinCclk,                                           0),
        MSG_MAP(SetSoftMaxCclk,                     PPSMC_MSG_SetSoftMaxCclk,                                           0),
+       MSG_MAP(RequestActiveWgp,                   PPSMC_MSG_RequestActiveWgp,                     0),
 };
 
 static struct cmn2asic_mapping vangogh_feature_mask_map[SMU_FEATURE_COUNT] = {
@@ -733,6 +737,38 @@ static int vangogh_system_features_control(struct smu_context *smu, bool en)
                return 0;
 }
 
+static int vangogh_post_smu_init(struct smu_context *smu)
+{
+       struct amdgpu_device *adev = smu->adev;
+       uint32_t tmp;
+       uint8_t aon_bits = 0;
+       /* Two CUs in one WGP */
+       uint32_t req_active_wgps = adev->gfx.cu_info.number/2;
+       uint32_t total_cu = adev->gfx.config.max_cu_per_sh *
+               adev->gfx.config.max_sh_per_se * adev->gfx.config.max_shader_engines;
+
+       /* if all CUs are active, no need to power off any WGPs */
+       if (total_cu == adev->gfx.cu_info.number)
+               return 0;
+
+       /*
+        * Calculate the total bits number of always on WGPs for all SA/SEs in
+        * RLC_PG_ALWAYS_ON_WGP_MASK.
+        */
+       tmp = RREG32_KIQ(SOC15_REG_OFFSET(GC, 0, mmRLC_PG_ALWAYS_ON_WGP_MASK));
+       tmp &= RLC_PG_ALWAYS_ON_WGP_MASK__AON_WGP_MASK_MASK;
+
+       aon_bits = hweight32(tmp) * adev->gfx.config.max_sh_per_se * adev->gfx.config.max_shader_engines;
+
+       /* Do not request any WGPs less than set in the AON_WGP_MASK */
+       if (aon_bits > req_active_wgps) {
+               dev_info(adev->dev, "Number of always on WGPs greater than active WGPs: WGP power save not requested.\n");
+               return 0;
+       } else {
+               return smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_RequestActiveWgp, req_active_wgps, NULL);
+       }
+}
+
 static const struct pptable_funcs vangogh_ppt_funcs = {
 
        .check_fw_status = smu_v11_0_check_fw_status,
@@ -761,6 +797,7 @@ static const struct pptable_funcs vangogh_ppt_funcs = {
        .set_default_dpm_table = vangogh_set_default_dpm_tables,
        .set_fine_grain_gfx_freq_parameters = vangogh_set_fine_grain_gfx_freq_parameters,
        .system_features_control = vangogh_system_features_control,
+       .post_init = vangogh_post_smu_init,
 };
 
 void vangogh_set_ppt_funcs(struct smu_context *smu)