drm/amd/pm: modify the power limit level parameter from bool to enum type
authorXiaomeng Hou <Xiaomeng.Hou@amd.com>
Fri, 5 Feb 2021 10:51:13 +0000 (18:51 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 9 Feb 2021 20:29:22 +0000 (15:29 -0500)
The original smu_get_power_limit callback accepts the power limit level
parameter as bool which limits to max and current. For possible needs to
retrieve other level like min, extend the parameter type using enum.

Signed-off-by: Xiaomeng Hou <Xiaomeng.Hou@amd.com>
Reviewed-by: Lijo Lazar <lijo.lazar@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

index cf475ac01b2754c5d88e66972c4438eda314893f..39899e7989a25d4a57b2a5134b381b7d31bb393b 100644 (file)
@@ -3073,7 +3073,7 @@ static ssize_t amdgpu_hwmon_show_power_cap_max(struct device *dev,
        }
 
        if (is_support_sw_smu(adev)) {
-               smu_get_power_limit(&adev->smu, &limit, true);
+               smu_get_power_limit(&adev->smu, &limit, SMU_PPT_LIMIT_MAX);
                size = snprintf(buf, PAGE_SIZE, "%u\n", limit * 1000000);
        } else if (adev->powerplay.pp_funcs && adev->powerplay.pp_funcs->get_power_limit) {
                adev->powerplay.pp_funcs->get_power_limit(adev->powerplay.pp_handle, &limit, true);
@@ -3107,7 +3107,7 @@ static ssize_t amdgpu_hwmon_show_power_cap(struct device *dev,
        }
 
        if (is_support_sw_smu(adev)) {
-               smu_get_power_limit(&adev->smu, &limit, false);
+               smu_get_power_limit(&adev->smu, &limit, SMU_PPT_LIMIT_CURRENT);
                size = snprintf(buf, PAGE_SIZE, "%u\n", limit * 1000000);
        } else if (adev->powerplay.pp_funcs && adev->powerplay.pp_funcs->get_power_limit) {
                adev->powerplay.pp_funcs->get_power_limit(adev->powerplay.pp_handle, &limit, false);
index 44279c2afccbad6910f08cb0daa5133b292efd8d..82a5f4a4faf5af972abc170bb9d8d89552487844 100644 (file)
@@ -161,6 +161,13 @@ enum smu_power_src_type
        SMU_POWER_SOURCE_COUNT,
 };
 
+enum smu_ppt_limit_level
+{
+       SMU_PPT_LIMIT_MIN = -1,
+       SMU_PPT_LIMIT_CURRENT,
+       SMU_PPT_LIMIT_MAX,
+};
+
 enum smu_memory_pool_size
 {
     SMU_MEMORY_POOL_SIZE_ZERO   = 0,
@@ -1218,7 +1225,7 @@ int smu_set_fan_speed_rpm(struct smu_context *smu, uint32_t speed);
 
 int smu_get_power_limit(struct smu_context *smu,
                        uint32_t *limit,
-                       bool max_setting);
+                       enum smu_ppt_limit_level limit_level);
 
 int smu_set_power_limit(struct smu_context *smu, uint32_t limit);
 int smu_print_clk_levels(struct smu_context *smu, enum smu_clk_type clk_type, char *buf);
index c00f3f531965957e7c62788035706eb72f740d9a..9017024642bb38826e8080725d70f8aacf5172d6 100644 (file)
@@ -2044,14 +2044,23 @@ int smu_set_fan_speed_rpm(struct smu_context *smu, uint32_t speed)
 
 int smu_get_power_limit(struct smu_context *smu,
                        uint32_t *limit,
-                       bool max_setting)
+                       enum smu_ppt_limit_level limit_level)
 {
        if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
                return -EOPNOTSUPP;
 
        mutex_lock(&smu->mutex);
 
-       *limit = (max_setting ? smu->max_power_limit : smu->current_power_limit);
+       switch (limit_level) {
+       case SMU_PPT_LIMIT_CURRENT:
+               *limit = smu->current_power_limit;
+               break;
+       case SMU_PPT_LIMIT_MAX:
+               *limit = smu->max_power_limit;
+               break;
+       default:
+               break;
+       }
 
        mutex_unlock(&smu->mutex);