summaryrefslogtreecommitdiff
path: root/tools/power
diff options
context:
space:
mode:
authorZhang Rui <rui.zhang@intel.com>2022-08-08 16:52:17 +0300
committerSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>2023-03-22 23:36:51 +0300
commit7b5f586dcfdf94dad72a7f3569c100087b80a9ac (patch)
tree203e3c41aa243ebc80432ce7f4aa922b475fbfa1 /tools/power
parent5843f2177058dab4d656fee692a0e8a2370e2d3d (diff)
downloadlinux-7b5f586dcfdf94dad72a7f3569c100087b80a9ac.tar.xz
tools/power/x86/intel-speed-select: Abstract get_fact_info
Allow platform specific implementation to get SST-TF info. 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>
Diffstat (limited to 'tools/power')
-rw-r--r--tools/power/x86/intel-speed-select/isst-core-mbox.c92
-rw-r--r--tools/power/x86/intel-speed-select/isst-core.c88
-rw-r--r--tools/power/x86/intel-speed-select/isst.h3
3 files changed, 96 insertions, 87 deletions
diff --git a/tools/power/x86/intel-speed-select/isst-core-mbox.c b/tools/power/x86/intel-speed-select/isst-core-mbox.c
index e6d32786a6ad..bf873dfe72e6 100644
--- a/tools/power/x86/intel-speed-select/isst-core-mbox.c
+++ b/tools/power/x86/intel-speed-select/isst-core-mbox.c
@@ -390,6 +390,97 @@ static int mbox_set_pbf_fact_status(struct isst_id *id, int pbf, int enable)
return 0;
}
+static int _get_fact_bucket_info(struct isst_id *id, int level,
+ struct isst_fact_bucket_info *bucket_info)
+{
+ unsigned int resp;
+ int i, k, ret;
+
+ for (i = 0; i < 2; ++i) {
+ int j;
+
+ ret = isst_send_mbox_command(
+ id->cpu, CONFIG_TDP,
+ CONFIG_TDP_GET_FACT_HP_TURBO_LIMIT_NUMCORES, 0,
+ (i << 8) | level, &resp);
+ if (ret)
+ return ret;
+
+ debug_printf(
+ "cpu:%d CONFIG_TDP_GET_FACT_HP_TURBO_LIMIT_NUMCORES index:%d level:%d resp:%x\n",
+ id->cpu, i, level, resp);
+
+ for (j = 0; j < 4; ++j) {
+ bucket_info[j + (i * 4)].hp_cores =
+ (resp >> (j * 8)) & 0xff;
+ }
+ }
+
+ for (k = 0; k < 3; ++k) {
+ for (i = 0; i < 2; ++i) {
+ int j;
+
+ ret = isst_send_mbox_command(
+ id->cpu, CONFIG_TDP,
+ CONFIG_TDP_GET_FACT_HP_TURBO_LIMIT_RATIOS, 0,
+ (k << 16) | (i << 8) | level, &resp);
+ if (ret)
+ return ret;
+
+ debug_printf(
+ "cpu:%d CONFIG_TDP_GET_FACT_HP_TURBO_LIMIT_RATIOS index:%d level:%d avx:%d resp:%x\n",
+ id->cpu, i, level, k, resp);
+
+ for (j = 0; j < 4; ++j) {
+ bucket_info[j + (i * 4)].hp_ratios[k] =
+ (resp >> (j * 8)) & 0xff;
+ }
+ }
+ }
+
+ return 0;
+}
+
+static int mbox_get_fact_info(struct isst_id *id, int level, int fact_bucket, struct isst_fact_info *fact_info)
+{
+ unsigned int resp;
+ int j, ret, print;
+
+ ret = isst_send_mbox_command(id->cpu, CONFIG_TDP,
+ CONFIG_TDP_GET_FACT_LP_CLIPPING_RATIO, 0,
+ level, &resp);
+ if (ret)
+ return ret;
+
+ debug_printf("cpu:%d CONFIG_TDP_GET_FACT_LP_CLIPPING_RATIO resp:%x\n",
+ id->cpu, resp);
+
+ fact_info->lp_ratios[0] = resp & 0xff;
+ fact_info->lp_ratios[1] = (resp >> 8) & 0xff;
+ fact_info->lp_ratios[2] = (resp >> 16) & 0xff;
+
+ ret = _get_fact_bucket_info(id, level, fact_info->bucket_info);
+ if (ret)
+ return ret;
+
+ print = 0;
+ for (j = 0; j < ISST_FACT_MAX_BUCKETS; ++j) {
+ if (fact_bucket != 0xff && fact_bucket != j)
+ continue;
+
+ if (!fact_info->bucket_info[j].hp_cores)
+ break;
+
+ print = 1;
+ }
+ if (!print) {
+ isst_display_error_info_message(1, "Invalid bucket", 0, 0);
+ return -1;
+ }
+
+ 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,
@@ -405,6 +496,7 @@ static struct isst_platform_ops mbox_ops = {
.set_tdp_level = mbox_set_tdp_level,
.get_pbf_info = mbox_get_pbf_info,
.set_pbf_fact_status = mbox_set_pbf_fact_status,
+ .get_fact_info = mbox_get_fact_info,
};
struct isst_platform_ops *mbox_get_platform_ops(void)
diff --git a/tools/power/x86/intel-speed-select/isst-core.c b/tools/power/x86/intel-speed-select/isst-core.c
index 3765a1eefcc5..e42469363803 100644
--- a/tools/power/x86/intel-speed-select/isst-core.c
+++ b/tools/power/x86/intel-speed-select/isst-core.c
@@ -396,63 +396,13 @@ int isst_set_pbf_fact_status(struct isst_id *id, int pbf, int enable)
return isst_ops->set_pbf_fact_status(id, pbf, enable);
}
-int isst_get_fact_bucket_info(struct isst_id *id, int level,
- struct isst_fact_bucket_info *bucket_info)
-{
- unsigned int resp;
- int i, k, ret;
-
- for (i = 0; i < 2; ++i) {
- int j;
-
- ret = isst_send_mbox_command(
- id->cpu, CONFIG_TDP,
- CONFIG_TDP_GET_FACT_HP_TURBO_LIMIT_NUMCORES, 0,
- (i << 8) | level, &resp);
- if (ret)
- return ret;
-
- debug_printf(
- "cpu:%d CONFIG_TDP_GET_FACT_HP_TURBO_LIMIT_NUMCORES index:%d level:%d resp:%x\n",
- id->cpu, i, level, resp);
-
- for (j = 0; j < 4; ++j) {
- bucket_info[j + (i * 4)].hp_cores =
- (resp >> (j * 8)) & 0xff;
- }
- }
- for (k = 0; k < 3; ++k) {
- for (i = 0; i < 2; ++i) {
- int j;
-
- ret = isst_send_mbox_command(
- id->cpu, CONFIG_TDP,
- CONFIG_TDP_GET_FACT_HP_TURBO_LIMIT_RATIOS, 0,
- (k << 16) | (i << 8) | level, &resp);
- if (ret)
- return ret;
-
- debug_printf(
- "cpu:%d CONFIG_TDP_GET_FACT_HP_TURBO_LIMIT_RATIOS index:%d level:%d avx:%d resp:%x\n",
- id->cpu, i, level, k, resp);
-
- for (j = 0; j < 4; ++j) {
- bucket_info[j + (i * 4)].hp_ratios[k] =
- (resp >> (j * 8)) & 0xff;
- }
- }
- }
-
- return 0;
-}
int isst_get_fact_info(struct isst_id *id, int level, int fact_bucket, struct isst_fact_info *fact_info)
{
struct isst_pkg_ctdp_level_info ctdp_level;
struct isst_pkg_ctdp pkg_dev;
- unsigned int resp;
- int j, ret, print;
+ int ret;
ret = isst_get_ctdp_levels(id, &pkg_dev);
if (ret) {
@@ -473,40 +423,8 @@ int isst_get_fact_info(struct isst_id *id, int level, int fact_bucket, struct is
isst_display_error_info_message(1, "turbo-freq feature is not present at this level", 1, level);
return -1;
}
-
- ret = isst_send_mbox_command(id->cpu, CONFIG_TDP,
- CONFIG_TDP_GET_FACT_LP_CLIPPING_RATIO, 0,
- level, &resp);
- if (ret)
- return ret;
-
- debug_printf("cpu:%d CONFIG_TDP_GET_FACT_LP_CLIPPING_RATIO resp:%x\n",
- id->cpu, resp);
-
- fact_info->lp_ratios[0] = resp & 0xff;
- fact_info->lp_ratios[1] = (resp >> 8) & 0xff;
- fact_info->lp_ratios[2] = (resp >> 16) & 0xff;
-
- ret = isst_get_fact_bucket_info(id, level, fact_info->bucket_info);
- if (ret)
- return ret;
-
- print = 0;
- for (j = 0; j < ISST_FACT_MAX_BUCKETS; ++j) {
- if (fact_bucket != 0xff && fact_bucket != j)
- continue;
-
- if (!fact_info->bucket_info[j].hp_cores)
- break;
-
- print = 1;
- }
- if (!print) {
- isst_display_error_info_message(1, "Invalid bucket", 0, 0);
- return -1;
- }
-
- return 0;
+ CHECK_CB(get_fact_info);
+ return isst_ops->get_fact_info(id, level, fact_bucket, fact_info);
}
int isst_get_trl(struct isst_id *id, unsigned long long *trl)
diff --git a/tools/power/x86/intel-speed-select/isst.h b/tools/power/x86/intel-speed-select/isst.h
index e8251a1c34ca..4fd901ef2437 100644
--- a/tools/power/x86/intel-speed-select/isst.h
+++ b/tools/power/x86/intel-speed-select/isst.h
@@ -196,6 +196,7 @@ struct isst_platform_ops {
int (*set_tdp_level)(struct isst_id *id, int tdp_level);
int (*get_pbf_info)(struct isst_id *id, int level, struct isst_pbf_info *pbf_info);
int (*set_pbf_fact_status)(struct isst_id *id, int pbf, int enable);
+ int (*get_fact_info)(struct isst_id *id, int level, int fact_bucket, struct isst_fact_info *fact_info);
};
extern int is_cpu_in_power_domain(int cpu, struct isst_id *id);
@@ -256,8 +257,6 @@ extern int isst_get_pbf_info(struct isst_id *id, int level,
struct isst_pbf_info *pbf_info);
extern int isst_get_fact_info(struct isst_id *id, int level, int fact_bucket,
struct isst_fact_info *fact_info);
-extern int isst_get_fact_bucket_info(struct isst_id *id, int level,
- struct isst_fact_bucket_info *bucket_info);
extern void isst_fact_display_information(struct isst_id *id, FILE *outf, int level,
int fact_bucket, int fact_avx,
struct isst_fact_info *fact_info);