drm/amd/powerplay: add od condition for power limit
authorLikun Gao <Likun.Gao@amd.com>
Fri, 1 Feb 2019 05:22:33 +0000 (13:22 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 19 Mar 2019 20:04:02 +0000 (15:04 -0500)
Add condition to judge whether overdrive is enabled and correct power
limit value for overdrive used by power limit interface.

Signed-off-by: Likun Gao <Likun.Gao@amd.com>
Reviewed-by: Kevin Wang <kevin1.wang@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Huang Rui <ray.huang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h
drivers/gpu/drm/amd/powerplay/smu_v11_0.c
drivers/gpu/drm/amd/powerplay/vega20_ppt.c

index 3e79fd9c9cbd8bf8ed67b19fb97b4c46e361e819..6a4e9f242aaf7c4f54e35da84b4ba7cdb23aafb4 100644 (file)
@@ -307,6 +307,7 @@ struct smu_table_context
        struct smu_table                memory_pool;
        uint16_t                        software_shutdown_temp;
        uint8_t                         thermal_controller_type;
+       uint16_t                        TDPODLimit;
 
        uint8_t                         *od_feature_capabilities;
        uint32_t                        *od_settings_max;
index a3c7d1d5176fdeb8e6f7fbe76639a6500fba7a55..f90410435e4cc57212302745f103ddf7ac1b78c6 100644 (file)
@@ -925,6 +925,10 @@ static int smu_v11_0_get_power_limit(struct smu_context *smu,
        if (get_default) {
                mutex_lock(&smu->mutex);
                *limit = smu->default_power_limit;
+               if (smu->od_enabled) {
+                       *limit *= (100 + smu->smu_table.TDPODLimit);
+                       *limit /= 100;
+               }
                mutex_unlock(&smu->mutex);
        } else {
                ret = smu_send_smc_msg_with_param(smu, SMU_MSG_GetPptLimit,
@@ -942,8 +946,19 @@ static int smu_v11_0_get_power_limit(struct smu_context *smu,
 
 static int smu_v11_0_set_power_limit(struct smu_context *smu, uint32_t n)
 {
+       uint32_t max_power_limit;
        int ret = 0;
 
+       if (n == 0)
+               n = smu->default_power_limit;
+
+       max_power_limit = smu->default_power_limit;
+
+       if (smu->od_enabled) {
+               max_power_limit *= (100 + smu->smu_table.TDPODLimit);
+               max_power_limit /= 100;
+       }
+
        if (smu_feature_is_enabled(smu, FEATURE_PPT_BIT))
                ret = smu_send_smc_msg_with_param(smu, SMU_MSG_SetPptLimit, n);
        if (ret) {
index 6763dcd21cf19813a5e4468c2edec4cf26265033..f7188a7fb194a85d734703d98d650d63fc14d7f1 100644 (file)
@@ -274,6 +274,7 @@ static int vega20_store_powerplay_table(struct smu_context *smu)
 
        table_context->software_shutdown_temp = powerplay_table->usSoftwareShutdownTemp;
        table_context->thermal_controller_type = powerplay_table->ucThermalControllerType;
+       table_context->TDPODLimit = le32_to_cpu(powerplay_table->OverDrive8Table.ODSettingsMax[ATOM_VEGA20_ODSETTING_POWERPERCENTAGE]);
 
        ret = vega20_setup_od8_information(smu);