]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/amd/pm: modify the fine grain tuning function for Renoir
authorXiaojian Du <Xiaojian.Du@amd.com>
Wed, 13 Jan 2021 10:05:15 +0000 (18:05 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 14 Jan 2021 18:13:31 +0000 (13:13 -0500)
This patch is to modify the fine grain tuning function for Renoir.
The fine grain tuning function uses the sysfs node -- pp_od_clk_voltage
to config gfxclk. Meanwhile, another sysfs
node -- power_dpm_force_perfomance_level also affects the gfx clk.
It will cause confusion when these two sysfs nodes works
together.
It is risky to add two new flags to common smu struct, so
this patch uses the existing flag to make these two sysfs nodes works
separately. Only when power_dpm_force_perfomance_level is changed
to "manual" mode, the fine grain function will be started.
In other profile modes, including "auto", "high", "low", "profile_peak",
"profile_standard", "profile_min_sclk", "profile_min_mclk",
the fine grain tuning function will be shut down and the frequency range
of gfx will be restored the default value.

Signed-off-by: Xiaojian Du <Xiaojian.Du@amd.com>
Reviewed-by: Huang Rui <ray.huang@amd.com>
Reviewed-by: Kevin Wang <kevin1.wang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/pm/amdgpu_pm.c
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
drivers/gpu/drm/amd/pm/swsmu/smu12/renoir_ppt.c

index ecd72d896b4922fd2363944e2c838cccd1d6e66d..80d6298912aa3385181dba17e3d17e7250d6cf41 100644 (file)
@@ -2221,7 +2221,7 @@ static int default_attr_update(struct amdgpu_device *adev, struct amdgpu_device_
        } else if (DEVICE_ATTR_IS(pp_od_clk_voltage)) {
                *states = ATTR_STATE_UNSUPPORTED;
                if ((is_support_sw_smu(adev) && adev->smu.od_enabled) ||
-                   (is_support_sw_smu(adev) && adev->smu.fine_grain_enabled) ||
+                   (is_support_sw_smu(adev) && adev->smu.is_apu) ||
                        (!is_support_sw_smu(adev) && hwmgr->od_enabled))
                        *states = ATTR_STATE_SUPPORTED;
        } else if (DEVICE_ATTR_IS(mem_busy_percent)) {
index 277559e80961a912a33d4268fa576e17ad051600..25ee9f51813b197af989ff9fac4efcfc8d46b0bc 100644 (file)
@@ -466,9 +466,6 @@ struct smu_context
        uint32_t gfx_actual_hard_min_freq;
        uint32_t gfx_actual_soft_max_freq;
 
-       bool fine_grain_enabled;
-       bool fine_grain_started;
-
        uint32_t cpu_default_soft_min_freq;
        uint32_t cpu_default_soft_max_freq;
        uint32_t cpu_actual_soft_min_freq;
index e94d1b4551b4c5f46d4e5efff85ec9112586c354..976a9105aeccf0bc80389134f5d92f7331fe394f 100644 (file)
@@ -416,10 +416,6 @@ static int smu_set_funcs(struct amdgpu_device *adev)
                break;
        case CHIP_RENOIR:
                renoir_set_ppt_funcs(smu);
-               /* enable the fine grain tuning function by default */
-               smu->fine_grain_enabled = true;
-               /* close the fine grain tuning function by default */
-               smu->fine_grain_started = false;
                break;
        case CHIP_VANGOGH:
                vangogh_set_ppt_funcs(smu);
index f33f5141cbe1ccb1e58d41bfd17872e0f99016cb..6c8a8ccd2f843dec04900e99241adb5288231fa3 100644 (file)
@@ -349,17 +349,13 @@ static int renoir_od_edit_dpm_table(struct smu_context *smu,
                                                        long input[], uint32_t size)
 {
        int ret = 0;
+       struct smu_dpm_context *smu_dpm_ctx = &(smu->smu_dpm);
 
-       if (!smu->fine_grain_enabled) {
+       if (!(smu_dpm_ctx->dpm_level == AMD_DPM_FORCED_LEVEL_MANUAL)) {
                dev_warn(smu->adev->dev, "Fine grain is not enabled!\n");
                return -EINVAL;
        }
 
-       if (!smu->fine_grain_started) {
-               dev_warn(smu->adev->dev, "Fine grain is enabled but not started!\n");
-               return -EINVAL;
-       }
-
        switch (type) {
        case PP_OD_EDIT_SCLK_VDDC_TABLE:
                if (size != 2) {
@@ -482,6 +478,7 @@ static int renoir_print_clk_levels(struct smu_context *smu,
        int i, size = 0, ret = 0;
        uint32_t cur_value = 0, value = 0, count = 0, min = 0, max = 0;
        SmuMetrics_t metrics;
+       struct smu_dpm_context *smu_dpm_ctx = &(smu->smu_dpm);
        bool cur_value_match_level = false;
 
        memset(&metrics, 0, sizeof(metrics));
@@ -492,7 +489,7 @@ static int renoir_print_clk_levels(struct smu_context *smu,
 
        switch (clk_type) {
        case SMU_OD_RANGE:
-               if (smu->fine_grain_enabled) {
+               if (smu_dpm_ctx->dpm_level == AMD_DPM_FORCED_LEVEL_MANUAL) {
                        ret = smu_cmn_send_smc_msg_with_param(smu,
                                                SMU_MSG_GetMinGfxclkFrequency,
                                                0, &min);
@@ -507,7 +504,7 @@ static int renoir_print_clk_levels(struct smu_context *smu,
                }
                break;
        case SMU_OD_SCLK:
-               if (smu->fine_grain_enabled) {
+               if (smu_dpm_ctx->dpm_level == AMD_DPM_FORCED_LEVEL_MANUAL) {
                        min = (smu->gfx_actual_hard_min_freq > 0) ? smu->gfx_actual_hard_min_freq : smu->gfx_default_hard_min_freq;
                        max = (smu->gfx_actual_soft_max_freq > 0) ? smu->gfx_actual_soft_max_freq : smu->gfx_default_soft_max_freq;
                        size += sprintf(buf + size, "OD_SCLK\n");
@@ -897,28 +894,24 @@ static int renoir_set_performance_level(struct smu_context *smu,
 
        switch (level) {
        case AMD_DPM_FORCED_LEVEL_HIGH:
-               smu->fine_grain_started = 0;
                smu->gfx_actual_hard_min_freq = smu->gfx_default_hard_min_freq;
                smu->gfx_actual_soft_max_freq = smu->gfx_default_soft_max_freq;
 
                ret = renoir_force_dpm_limit_value(smu, true);
                break;
        case AMD_DPM_FORCED_LEVEL_LOW:
-               smu->fine_grain_started = 0;
                smu->gfx_actual_hard_min_freq = smu->gfx_default_hard_min_freq;
                smu->gfx_actual_soft_max_freq = smu->gfx_default_soft_max_freq;
 
                ret = renoir_force_dpm_limit_value(smu, false);
                break;
        case AMD_DPM_FORCED_LEVEL_AUTO:
-               smu->fine_grain_started = 0;
                smu->gfx_actual_hard_min_freq = smu->gfx_default_hard_min_freq;
                smu->gfx_actual_soft_max_freq = smu->gfx_default_soft_max_freq;
 
                ret = renoir_unforce_dpm_levels(smu);
                break;
        case AMD_DPM_FORCED_LEVEL_PROFILE_STANDARD:
-               smu->fine_grain_started = 0;
                smu->gfx_actual_hard_min_freq = smu->gfx_default_hard_min_freq;
                smu->gfx_actual_soft_max_freq = smu->gfx_default_soft_max_freq;
 
@@ -974,7 +967,6 @@ static int renoir_set_performance_level(struct smu_context *smu,
                break;
        case AMD_DPM_FORCED_LEVEL_PROFILE_MIN_SCLK:
        case AMD_DPM_FORCED_LEVEL_PROFILE_MIN_MCLK:
-               smu->fine_grain_started = 0;
                smu->gfx_actual_hard_min_freq = smu->gfx_default_hard_min_freq;
                smu->gfx_actual_soft_max_freq = smu->gfx_default_soft_max_freq;
 
@@ -989,14 +981,12 @@ static int renoir_set_performance_level(struct smu_context *smu,
                renoir_force_clk_levels(smu, SMU_SOCCLK, 1 << soc_mask);
                break;
        case AMD_DPM_FORCED_LEVEL_PROFILE_PEAK:
-               smu->fine_grain_started = 0;
                smu->gfx_actual_hard_min_freq = smu->gfx_default_hard_min_freq;
                smu->gfx_actual_soft_max_freq = smu->gfx_default_soft_max_freq;
 
                ret = renoir_set_peak_clock_by_device(smu);
                break;
        case AMD_DPM_FORCED_LEVEL_MANUAL:
-               smu->fine_grain_started = 1;
        case AMD_DPM_FORCED_LEVEL_PROFILE_EXIT:
        default:
                break;