aboutsummaryrefslogtreecommitdiffstats
path: root/tools/power
diff options
context:
space:
mode:
authorZhang Rui <rui.zhang@intel.com>2022-08-08 22:46:57 +0800
committerSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>2023-03-22 13:36:52 -0700
commit904d2baa8b04691613a5e1e94061f99f0db2832c (patch)
tree4246979cb664751d8fe66b13aaa236f4b17f52db /tools/power
parenta07bdb81c1434f41eb444e51c2a4028ca2d21b30 (diff)
downloadlinux-904d2baa8b04691613a5e1e94061f99f0db2832c.tar.gz
tools/power/x86/intel-speed-select: Abstract pm_qos_config
Allow platform specific implementation to set CLOS config settings. 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.c90
-rw-r--r--tools/power/x86/intel-speed-select/isst-core.c86
-rw-r--r--tools/power/x86/intel-speed-select/isst.h1
3 files changed, 93 insertions, 84 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 a96d6bcf7d930..27d802173d101 100644
--- a/tools/power/x86/intel-speed-select/isst-core-mbox.c
+++ b/tools/power/x86/intel-speed-select/isst-core-mbox.c
@@ -624,6 +624,95 @@ static int mbox_get_clos_information(struct isst_id *id, int *enable, int *type)
return 0;
}
+
+static int _write_pm_config(struct isst_id *id, int cp_state)
+{
+ unsigned int req, resp;
+ int ret;
+
+ if (cp_state)
+ req = BIT(16);
+ else
+ req = 0;
+
+ ret = isst_send_mbox_command(id->cpu, WRITE_PM_CONFIG, PM_FEATURE, 0, req,
+ &resp);
+ if (ret)
+ return ret;
+
+ debug_printf("cpu:%d WRITE_PM_CONFIG resp:%x\n", id->cpu, resp);
+
+ return 0;
+}
+
+static int mbox_pm_qos_config(struct isst_id *id, int enable_clos, int priority_type)
+{
+ unsigned int req, resp;
+ int ret;
+
+ if (!enable_clos) {
+ struct isst_pkg_ctdp pkg_dev;
+ struct isst_pkg_ctdp_level_info ctdp_level;
+
+ ret = isst_get_ctdp_levels(id, &pkg_dev);
+ if (ret) {
+ debug_printf("isst_get_ctdp_levels\n");
+ return ret;
+ }
+
+ ret = isst_get_ctdp_control(id, pkg_dev.current_level,
+ &ctdp_level);
+ if (ret)
+ return ret;
+
+ if (ctdp_level.fact_enabled) {
+ isst_display_error_info_message(1, "Ignoring request, turbo-freq feature is still enabled", 0, 0);
+ return -EINVAL;
+ }
+ ret = _write_pm_config(id, 0);
+ if (ret)
+ isst_display_error_info_message(0, "WRITE_PM_CONFIG command failed, ignoring error", 0, 0);
+ } else {
+ ret = _write_pm_config(id, 1);
+ if (ret)
+ isst_display_error_info_message(0, "WRITE_PM_CONFIG command failed, ignoring error", 0, 0);
+ }
+
+ ret = isst_send_mbox_command(id->cpu, CONFIG_CLOS, CLOS_PM_QOS_CONFIG, 0, 0,
+ &resp);
+ if (ret) {
+ isst_display_error_info_message(1, "CLOS_PM_QOS_CONFIG command failed", 0, 0);
+ return ret;
+ }
+
+ debug_printf("cpu:%d CLOS_PM_QOS_CONFIG resp:%x\n", id->cpu, resp);
+
+ req = resp;
+
+ if (enable_clos)
+ req = req | BIT(1);
+ else
+ req = req & ~BIT(1);
+
+ if (priority_type > 1)
+ isst_display_error_info_message(1, "Invalid priority type: Changing type to ordered", 0, 0);
+
+ if (priority_type)
+ req = req | BIT(2);
+ else
+ req = req & ~BIT(2);
+
+ ret = isst_send_mbox_command(id->cpu, CONFIG_CLOS, CLOS_PM_QOS_CONFIG,
+ BIT(MBOX_CMD_WRITE_BIT), req, &resp);
+ if (ret)
+ return ret;
+
+ debug_printf("cpu:%d CLOS_PM_QOS_CONFIG priority type:%d req:%x\n", id->cpu,
+ priority_type, req);
+
+ 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,
@@ -643,6 +732,7 @@ static struct isst_platform_ops mbox_ops = {
.get_fact_info = mbox_get_fact_info,
.get_uncore_p0_p1_info = mbox_get_uncore_p0_p1_info,
.get_clos_information = mbox_get_clos_information,
+ .pm_qos_config = mbox_pm_qos_config,
};
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 33ee086458e98..39b9842ee6666 100644
--- a/tools/power/x86/intel-speed-select/isst-core.c
+++ b/tools/power/x86/intel-speed-select/isst-core.c
@@ -247,26 +247,6 @@ int isst_send_msr_command(unsigned int cpu, unsigned int msr, int write,
return 0;
}
-int isst_write_pm_config(struct isst_id *id, int cp_state)
-{
- unsigned int req, resp;
- int ret;
-
- if (cp_state)
- req = BIT(16);
- else
- req = 0;
-
- ret = isst_send_mbox_command(id->cpu, WRITE_PM_CONFIG, PM_FEATURE, 0, req,
- &resp);
- if (ret)
- return ret;
-
- debug_printf("cpu:%d WRITE_PM_CONFIG resp:%x\n", id->cpu, resp);
-
- return 0;
-}
-
int isst_read_pm_config(struct isst_id *id, int *cp_state, int *cp_cap)
{
unsigned int resp;
@@ -641,70 +621,8 @@ int isst_clos_get_clos_information(struct isst_id *id, int *enable, int *type)
int isst_pm_qos_config(struct isst_id *id, int enable_clos, int priority_type)
{
- unsigned int req, resp;
- int ret;
-
- if (!enable_clos) {
- struct isst_pkg_ctdp pkg_dev;
- struct isst_pkg_ctdp_level_info ctdp_level;
-
- ret = isst_get_ctdp_levels(id, &pkg_dev);
- if (ret) {
- debug_printf("isst_get_ctdp_levels\n");
- return ret;
- }
-
- ret = isst_get_ctdp_control(id, pkg_dev.current_level,
- &ctdp_level);
- if (ret)
- return ret;
-
- if (ctdp_level.fact_enabled) {
- isst_display_error_info_message(1, "Ignoring request, turbo-freq feature is still enabled", 0, 0);
- return -EINVAL;
- }
- ret = isst_write_pm_config(id, 0);
- if (ret)
- isst_display_error_info_message(0, "WRITE_PM_CONFIG command failed, ignoring error", 0, 0);
- } else {
- ret = isst_write_pm_config(id, 1);
- if (ret)
- isst_display_error_info_message(0, "WRITE_PM_CONFIG command failed, ignoring error", 0, 0);
- }
-
- ret = isst_send_mbox_command(id->cpu, CONFIG_CLOS, CLOS_PM_QOS_CONFIG, 0, 0,
- &resp);
- if (ret) {
- isst_display_error_info_message(1, "CLOS_PM_QOS_CONFIG command failed", 0, 0);
- return ret;
- }
-
- debug_printf("cpu:%d CLOS_PM_QOS_CONFIG resp:%x\n", id->cpu, resp);
-
- req = resp;
-
- if (enable_clos)
- req = req | BIT(1);
- else
- req = req & ~BIT(1);
-
- if (priority_type > 1)
- isst_display_error_info_message(1, "Invalid priority type: Changing type to ordered", 0, 0);
-
- if (priority_type)
- req = req | BIT(2);
- else
- req = req & ~BIT(2);
-
- ret = isst_send_mbox_command(id->cpu, CONFIG_CLOS, CLOS_PM_QOS_CONFIG,
- BIT(MBOX_CMD_WRITE_BIT), req, &resp);
- if (ret)
- return ret;
-
- debug_printf("cpu:%d CLOS_PM_QOS_CONFIG priority type:%d req:%x\n", id->cpu,
- priority_type, req);
-
- return 0;
+ CHECK_CB(pm_qos_config);
+ return isst_ops->pm_qos_config(id, enable_clos, priority_type);
}
int isst_pm_get_clos(struct isst_id *id, int clos, struct isst_clos_config *clos_config)
diff --git a/tools/power/x86/intel-speed-select/isst.h b/tools/power/x86/intel-speed-select/isst.h
index d6cbc0bcc1e31..1f60acef0950b 100644
--- a/tools/power/x86/intel-speed-select/isst.h
+++ b/tools/power/x86/intel-speed-select/isst.h
@@ -200,6 +200,7 @@ struct isst_platform_ops {
int (*get_fact_info)(struct isst_id *id, int level, int fact_bucket, struct isst_fact_info *fact_info);
void (*get_uncore_p0_p1_info)(struct isst_id *id, int config_index, struct isst_pkg_ctdp_level_info *ctdp_level);
int (*get_clos_information)(struct isst_id *id, int *enable, int *type);
+ int (*pm_qos_config)(struct isst_id *id, int enable_clos, int priority_type);
};
extern int is_cpu_in_power_domain(int cpu, struct isst_id *id);