drm/amd/powerplay: correct smu_update_table usage
authorEvan Quan <evan.quan@amd.com>
Thu, 11 Jul 2019 07:13:17 +0000 (15:13 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 17 Jul 2019 18:34:30 +0000 (13:34 -0500)
The interface was used in a confusing way. In profile mode scenario,
the 2nd parameter of the interface was used in a different way from
other scenarios.

Signed-off-by: Evan Quan <evan.quan@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h
drivers/gpu/drm/amd/powerplay/navi10_ppt.c
drivers/gpu/drm/amd/powerplay/smu_v11_0.c
drivers/gpu/drm/amd/powerplay/vega20_ppt.c

index 20257c036a65600944c605a4656c8f7937b2b166..f1565c448de5169812d4aa5e289ae10b7b2b7508 100644 (file)
@@ -323,7 +323,7 @@ int smu_common_read_sensor(struct smu_context *smu, enum amd_pp_sensors sensor,
        return ret;
 }
 
-int smu_update_table(struct smu_context *smu, enum smu_table_id table_index,
+int smu_update_table(struct smu_context *smu, enum smu_table_id table_index, int argument,
                     void *table_data, bool drv2smu)
 {
        struct smu_table_context *smu_table = &smu->smu_table;
@@ -350,7 +350,7 @@ int smu_update_table(struct smu_context *smu, enum smu_table_id table_index,
        ret = smu_send_smc_msg_with_param(smu, drv2smu ?
                                          SMU_MSG_TransferTableDram2Smu :
                                          SMU_MSG_TransferTableSmu2Dram,
-                                         table_id);
+                                         table_id | ((argument & 0xFFFF) << 16));
        if (ret)
                return ret;
 
index 135a3236f7ed58e07985ee759beebd9ec42b89fc..1af992fb0bdedce0f4d89d0059a334a510d92a00 100644 (file)
@@ -937,7 +937,7 @@ extern int smu_feature_is_supported(struct smu_context *smu,
 extern int smu_feature_set_supported(struct smu_context *smu,
                                     enum smu_feature_mask mask, bool enable);
 
-int smu_update_table(struct smu_context *smu, uint32_t table_index,
+int smu_update_table(struct smu_context *smu, enum smu_table_id table_index, int argument,
                     void *table_data, bool drv2smu);
 
 bool is_support_sw_smu(struct amdgpu_device *adev);
index 7f11c641b7b8ed8c50fa93e66d9023801093adfe..2dae0ae0829ef0de9df11e83f2e692eb54ad0868 100644 (file)
@@ -613,7 +613,7 @@ static int navi10_get_current_clk_freq_by_table(struct smu_context *smu,
 
        memset(&metrics, 0, sizeof(metrics));
 
-       ret = smu_update_table(smu, SMU_TABLE_SMU_METRICS, (void *)&metrics, false);
+       ret = smu_update_table(smu, SMU_TABLE_SMU_METRICS, 0, (void *)&metrics, false);
        if (ret)
                return ret;
 
@@ -866,7 +866,7 @@ static int navi10_get_gpu_power(struct smu_context *smu, uint32_t *value)
        if (!value)
                return -EINVAL;
 
-       ret = smu_update_table(smu, SMU_TABLE_SMU_METRICS, (void *)&metrics,
+       ret = smu_update_table(smu, SMU_TABLE_SMU_METRICS, 0, (void *)&metrics,
                               false);
        if (ret)
                return ret;
@@ -888,7 +888,7 @@ static int navi10_get_current_activity_percent(struct smu_context *smu,
 
        msleep(1);
 
-       ret = smu_update_table(smu, SMU_TABLE_SMU_METRICS,
+       ret = smu_update_table(smu, SMU_TABLE_SMU_METRICS, 0,
                               (void *)&metrics, false);
        if (ret)
                return ret;
@@ -929,7 +929,7 @@ static int navi10_get_fan_speed(struct smu_context *smu, uint16_t *value)
 
        memset(&metrics, 0, sizeof(metrics));
 
-       ret = smu_update_table(smu, SMU_TABLE_SMU_METRICS,
+       ret = smu_update_table(smu, SMU_TABLE_SMU_METRICS, 0,
                               (void *)&metrics, false);
        if (ret)
                return ret;
@@ -995,7 +995,7 @@ static int navi10_get_power_profile_mode(struct smu_context *smu, char *buf)
                /* conv PP_SMC_POWER_PROFILE* to WORKLOAD_PPLIB_*_BIT */
                workload_type = smu_workload_get_type(smu, i);
                result = smu_update_table(smu,
-                                         SMU_TABLE_ACTIVITY_MONITOR_COEFF | workload_type << 16,
+                                         SMU_TABLE_ACTIVITY_MONITOR_COEFF, workload_type,
                                          (void *)(&activity_monitor), false);
                if (result) {
                        pr_err("[%s] Failed to get activity monitor!", __func__);
@@ -1068,7 +1068,7 @@ static int navi10_set_power_profile_mode(struct smu_context *smu, long *input, u
                        return -EINVAL;
 
                ret = smu_update_table(smu,
-                                      SMU_TABLE_ACTIVITY_MONITOR_COEFF | WORKLOAD_PPLIB_CUSTOM_BIT << 16,
+                                      SMU_TABLE_ACTIVITY_MONITOR_COEFF, WORKLOAD_PPLIB_CUSTOM_BIT,
                                       (void *)(&activity_monitor), false);
                if (ret) {
                        pr_err("[%s] Failed to get activity monitor!", __func__);
@@ -1112,7 +1112,7 @@ static int navi10_set_power_profile_mode(struct smu_context *smu, long *input, u
                }
 
                ret = smu_update_table(smu,
-                                      SMU_TABLE_ACTIVITY_MONITOR_COEFF | WORKLOAD_PPLIB_CUSTOM_BIT << 16,
+                                      SMU_TABLE_ACTIVITY_MONITOR_COEFF, WORKLOAD_PPLIB_CUSTOM_BIT,
                                       (void *)(&activity_monitor), true);
                if (ret) {
                        pr_err("[%s] Failed to set activity monitor!", __func__);
@@ -1278,7 +1278,7 @@ static int navi10_thermal_get_temperature(struct smu_context *smu,
        if (!value)
                return -EINVAL;
 
-       ret = smu_update_table(smu, SMU_TABLE_SMU_METRICS, (void *)&metrics, false);
+       ret = smu_update_table(smu, SMU_TABLE_SMU_METRICS, 0, (void *)&metrics, false);
        if (ret)
                return ret;
 
index a87b86ae2cc5605ece331ffbb1776019eae87f8b..f182d75e127def96e75cdf66c2f33cd89a39699c 100644 (file)
@@ -703,7 +703,7 @@ static int smu_v11_0_write_pptable(struct smu_context *smu)
        struct smu_table_context *table_context = &smu->smu_table;
        int ret = 0;
 
-       ret = smu_update_table(smu, SMU_TABLE_PPTABLE,
+       ret = smu_update_table(smu, SMU_TABLE_PPTABLE, 0,
                               table_context->driver_pptable, true);
 
        return ret;
@@ -722,7 +722,7 @@ static int smu_v11_0_write_watermarks_table(struct smu_context *smu)
        if (!table->cpu_addr)
                return -EINVAL;
 
-       ret = smu_update_table(smu, SMU_TABLE_WATERMARKS, table->cpu_addr,
+       ret = smu_update_table(smu, SMU_TABLE_WATERMARKS, 0, table->cpu_addr,
                                true);
 
        return ret;
index 6d267aeacda37072a201a45006a3db41fc66ea70..bb9bb09cfc7a2fc779e261aae0d8366d19c4557a 100644 (file)
@@ -1680,7 +1680,7 @@ static int vega20_get_metrics_table(struct smu_context *smu,
        int ret = 0;
 
        if (!smu_table->metrics_time || time_after(jiffies, smu_table->metrics_time + HZ / 1000)) {
-               ret = smu_update_table(smu, SMU_TABLE_SMU_METRICS,
+               ret = smu_update_table(smu, SMU_TABLE_SMU_METRICS, 0,
                                (void *)smu_table->metrics_table, false);
                if (ret) {
                        pr_info("Failed to export SMU metrics table!\n");
@@ -1709,7 +1709,7 @@ static int vega20_set_default_od_settings(struct smu_context *smu,
                if (!table_context->overdrive_table)
                        return -ENOMEM;
 
-               ret = smu_update_table(smu, SMU_TABLE_OVERDRIVE,
+               ret = smu_update_table(smu, SMU_TABLE_OVERDRIVE, 0,
                                       table_context->overdrive_table, false);
                if (ret) {
                        pr_err("Failed to export over drive table!\n");
@@ -1721,7 +1721,7 @@ static int vega20_set_default_od_settings(struct smu_context *smu,
                        return ret;
        }
 
-       ret = smu_update_table(smu, SMU_TABLE_OVERDRIVE,
+       ret = smu_update_table(smu, SMU_TABLE_OVERDRIVE, 0,
                               table_context->overdrive_table, true);
        if (ret) {
                pr_err("Failed to import over drive table!\n");
@@ -1805,7 +1805,7 @@ static int vega20_get_power_profile_mode(struct smu_context *smu, char *buf)
                /* conv PP_SMC_POWER_PROFILE* to WORKLOAD_PPLIB_*_BIT */
                workload_type = smu_workload_get_type(smu, i);
                result = smu_update_table(smu,
-                                         SMU_TABLE_ACTIVITY_MONITOR_COEFF | workload_type << 16,
+                                         SMU_TABLE_ACTIVITY_MONITOR_COEFF, workload_type,
                                          (void *)(&activity_monitor), false);
                if (result) {
                        pr_err("[%s] Failed to get activity monitor!", __func__);
@@ -1891,7 +1891,7 @@ static int vega20_set_power_profile_mode(struct smu_context *smu, long *input, u
 
        if (smu->power_profile_mode == PP_SMC_POWER_PROFILE_CUSTOM) {
                ret = smu_update_table(smu,
-                                      SMU_TABLE_ACTIVITY_MONITOR_COEFF | WORKLOAD_PPLIB_CUSTOM_BIT << 16,
+                                      SMU_TABLE_ACTIVITY_MONITOR_COEFF, WORKLOAD_PPLIB_CUSTOM_BIT,
                                       (void *)(&activity_monitor), false);
                if (ret) {
                        pr_err("[%s] Failed to get activity monitor!", __func__);
@@ -1946,7 +1946,7 @@ static int vega20_set_power_profile_mode(struct smu_context *smu, long *input, u
                }
 
                ret = smu_update_table(smu,
-                                      SMU_TABLE_ACTIVITY_MONITOR_COEFF | WORKLOAD_PPLIB_CUSTOM_BIT << 16,
+                                      SMU_TABLE_ACTIVITY_MONITOR_COEFF, WORKLOAD_PPLIB_CUSTOM_BIT,
                                       (void *)(&activity_monitor), true);
                if (ret) {
                        pr_err("[%s] Failed to set activity monitor!", __func__);
@@ -2495,7 +2495,7 @@ static int vega20_update_od8_settings(struct smu_context *smu,
        struct smu_table_context *table_context = &smu->smu_table;
        int ret;
 
-       ret = smu_update_table(smu, SMU_TABLE_OVERDRIVE,
+       ret = smu_update_table(smu, SMU_TABLE_OVERDRIVE, 0,
                               table_context->overdrive_table, false);
        if (ret) {
                pr_err("Failed to export over drive table!\n");
@@ -2506,7 +2506,7 @@ static int vega20_update_od8_settings(struct smu_context *smu,
        if (ret)
                return ret;
 
-       ret = smu_update_table(smu, SMU_TABLE_OVERDRIVE,
+       ret = smu_update_table(smu, SMU_TABLE_OVERDRIVE, 0,
                               table_context->overdrive_table, true);
        if (ret) {
                pr_err("Failed to import over drive table!\n");
@@ -2770,7 +2770,7 @@ static int vega20_odn_edit_dpm_table(struct smu_context *smu,
                break;
 
        case PP_OD_RESTORE_DEFAULT_TABLE:
-               ret = smu_update_table(smu, SMU_TABLE_OVERDRIVE, table_context->overdrive_table, false);
+               ret = smu_update_table(smu, SMU_TABLE_OVERDRIVE, 0, table_context->overdrive_table, false);
                if (ret) {
                        pr_err("Failed to export over drive table!\n");
                        return ret;
@@ -2779,7 +2779,7 @@ static int vega20_odn_edit_dpm_table(struct smu_context *smu,
                break;
 
        case PP_OD_COMMIT_DPM_TABLE:
-               ret = smu_update_table(smu, SMU_TABLE_OVERDRIVE, table_context->overdrive_table, true);
+               ret = smu_update_table(smu, SMU_TABLE_OVERDRIVE, 0, table_context->overdrive_table, true);
                if (ret) {
                        pr_err("Failed to import over drive table!\n");
                        return ret;