tools/power/x86/intel-speed-select: Abstract set_tdp_level
authorZhang Rui <rui.zhang@intel.com>
Mon, 8 Aug 2022 17:49:48 +0000 (01:49 +0800)
committerSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Wed, 22 Mar 2023 20:36:51 +0000 (13:36 -0700)
Allow platform specific implementation to set a SST-PP level.

No functional changes are expected.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
[srinivas.pandruvada@linux.intel.com: changelog edits]
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
tools/power/x86/intel-speed-select/isst-core-mbox.c
tools/power/x86/intel-speed-select/isst-core.c
tools/power/x86/intel-speed-select/isst.h

index 0cc08db..f6f1632 100644 (file)
@@ -250,6 +250,28 @@ static int mbox_get_trl_bucket_info(struct isst_id *id, int level, unsigned long
        return 0;
 }
 
+static int mbox_set_tdp_level(struct isst_id *id, int tdp_level)
+{
+       unsigned int resp;
+       int ret;
+
+
+       if (isst_get_config_tdp_lock_status(id)) {
+               isst_display_error_info_message(1, "TDP is locked", 0, 0);
+               return -1;
+
+       }
+
+       ret = isst_send_mbox_command(id->cpu, CONFIG_TDP, CONFIG_TDP_SET_LEVEL, 0,
+                                    tdp_level, &resp);
+       if (ret) {
+               isst_display_error_info_message(1, "Set TDP level failed for level", 1, tdp_level);
+               return ret;
+       }
+
+       return 0;
+}
+
 static struct isst_platform_ops mbox_ops = {
        .get_disp_freq_multiplier = mbox_get_disp_freq_multiplier,
        .get_trl_max_levels = mbox_get_trl_max_levels,
@@ -262,6 +284,7 @@ static struct isst_platform_ops mbox_ops = {
        .get_coremask_info = mbox_get_coremask_info,
        .get_get_trl = mbox_get_get_trl,
        .get_trl_bucket_info = mbox_get_trl_bucket_info,
+       .set_tdp_level = mbox_set_tdp_level,
 };
 
 struct isst_platform_ops *mbox_get_platform_ops(void)
index bd4facd..53bfc5d 100644 (file)
@@ -354,24 +354,8 @@ int isst_get_trl_bucket_info(struct isst_id *id, int level, unsigned long long *
 
 int isst_set_tdp_level(struct isst_id *id, int tdp_level)
 {
-       unsigned int resp;
-       int ret;
-
-
-       if (isst_get_config_tdp_lock_status(id)) {
-               isst_display_error_info_message(1, "TDP is locked", 0, 0);
-               return -1;
-
-       }
-
-       ret = isst_send_mbox_command(id->cpu, CONFIG_TDP, CONFIG_TDP_SET_LEVEL, 0,
-                                    tdp_level, &resp);
-       if (ret) {
-               isst_display_error_info_message(1, "Set TDP level failed for level", 1, tdp_level);
-               return ret;
-       }
-
-       return 0;
+       CHECK_CB(set_tdp_level);
+       return isst_ops->set_tdp_level(id, tdp_level);
 }
 
 int isst_get_pbf_info(struct isst_id *id, int level, struct isst_pbf_info *pbf_info)
index 465e079..cc1487c 100644 (file)
@@ -193,6 +193,7 @@ struct isst_platform_ops {
        int (*get_coremask_info)(struct isst_id *id, int config_index, struct isst_pkg_ctdp_level_info *ctdp_level);
        int (*get_get_trl)(struct isst_id *id, int level, int avx_level, int *trl);
        int (*get_trl_bucket_info)(struct isst_id *id, int level, unsigned long long *buckets_info);
+       int (*set_tdp_level)(struct isst_id *id, int tdp_level);
 };
 
 extern int is_cpu_in_power_domain(int cpu, struct isst_id *id);