]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/amd/pm: add set{get}_power_limit support for smu 15.0.8
authorYang Wang <kevinyang.wang@amd.com>
Wed, 22 Oct 2025 13:32:55 +0000 (21:32 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 23 Mar 2026 18:18:07 +0000 (14:18 -0400)
export .set_power_limit & .get_power_limit interface for smu 15.0.8

Signed-off-by: Yang Wang <kevinyang.wang@amd.com>
Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
drivers/gpu/drm/amd/pm/swsmu/smu15/smu_v15_0_8_ppt.c

index 013d34e2f8426698c2e90faf5937fbbcd0b02d7e..eee2fe0743b23ed19e199e6dccad5c59b995d113 100644 (file)
@@ -2966,6 +2966,7 @@ int smu_get_power_limit(void *handle,
                        case IP_VERSION(11, 0, 11):
                        case IP_VERSION(11, 0, 12):
                        case IP_VERSION(11, 0, 13):
+                       case IP_VERSION(15, 0, 8):
                                ret = smu_get_asic_power_limits(smu,
                                                                &smu->current_power_limit,
                                                                NULL, NULL, NULL);
index f3aa25c59f9ce75d15ef806ee04f80d9921a5a9c..0c06b650012195f82240317c2c3616fcd726ced0 100644 (file)
@@ -1147,6 +1147,38 @@ static void smu_v15_0_8_get_unique_id(struct smu_context *smu)
        adev->unique_id = pptable->PublicSerialNumberMID;
 }
 
+static int smu_v15_0_8_get_power_limit(struct smu_context *smu,
+                                      uint32_t *current_power_limit,
+                                      uint32_t *default_power_limit,
+                                      uint32_t *max_power_limit,
+                                      uint32_t *min_power_limit)
+{
+       struct smu_table_context *smu_table = &smu->smu_table;
+       PPTable_t *pptable = (PPTable_t *)smu_table->driver_pptable;
+       uint32_t power_limit = 0;
+       int ret;
+
+       ret = smu_cmn_send_smc_msg(smu, SMU_MSG_GetPptLimit, &power_limit);
+       if (ret) {
+               dev_err(smu->adev->dev, "Couldn't get PPT limit");
+               return -EINVAL;
+       }
+
+       if (current_power_limit)
+               *current_power_limit = power_limit;
+
+       if (default_power_limit)
+               *max_power_limit = pptable->MaxSocketPowerLimit;
+
+       if (max_power_limit)
+               *max_power_limit = pptable->MaxSocketPowerLimit;
+
+       if (min_power_limit)
+               *min_power_limit = 0;
+
+       return 0;
+}
+
 static const struct pptable_funcs smu_v15_0_8_ppt_funcs = {
        .init_allowed_features = smu_v15_0_8_init_allowed_features,
        .set_default_dpm_table = smu_v15_0_8_set_default_dpm_table,
@@ -1172,6 +1204,8 @@ static const struct pptable_funcs smu_v15_0_8_ppt_funcs = {
        .get_dpm_ultimate_freq = smu_v15_0_8_get_dpm_ultimate_freq,
        .get_gpu_metrics = smu_v15_0_8_get_gpu_metrics,
        .get_unique_id = smu_v15_0_8_get_unique_id,
+       .get_power_limit = smu_v15_0_8_get_power_limit,
+       .set_power_limit = smu_v15_0_set_power_limit,
 };
 
 static void smu_v15_0_8_init_msg_ctl(struct smu_context *smu,