summaryrefslogtreecommitdiff
path: root/tools/power
diff options
context:
space:
mode:
authorZhang Rui <rui.zhang@intel.com>2023-02-02 15:52:42 +0800
committerSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>2023-03-22 13:36:52 -0700
commit73452ccc190a416929ccf7da4061365a5eaff627 (patch)
tree64f7db7b84eacea3e9c4d3619e3a9718d2225a61 /tools/power
parent8f54104f7a9548466027e1ee8482b18c2a72656a (diff)
tools/power/x86/intel-speed-select: Abstract adjust_uncore_freq
Allow platform specific implementation to adjust the uncore frequency. 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-config.c35
-rw-r--r--tools/power/x86/intel-speed-select/isst-core-mbox.c45
-rw-r--r--tools/power/x86/intel-speed-select/isst-core.c6
-rw-r--r--tools/power/x86/intel-speed-select/isst.h4
4 files changed, 48 insertions, 42 deletions
diff --git a/tools/power/x86/intel-speed-select/isst-config.c b/tools/power/x86/intel-speed-select/isst-config.c
index 71e00d03062f..346f8271b00f 100644
--- a/tools/power/x86/intel-speed-select/isst-config.c
+++ b/tools/power/x86/intel-speed-select/isst-config.c
@@ -1187,34 +1187,6 @@ static void dump_isst_config(int arg)
isst_ctdp_display_information_end(outf);
}
-static int set_uncore_min_max(struct isst_id *id, int max, int freq)
-{
- char buffer[128], freq_str[16];
- int fd, ret, len;
-
- if (max)
- snprintf(buffer, sizeof(buffer),
- "/sys/devices/system/cpu/intel_uncore_frequency/package_%02d_die_%02d/max_freq_khz", id->pkg, id->die);
- else
- snprintf(buffer, sizeof(buffer),
- "/sys/devices/system/cpu/intel_uncore_frequency/package_%02d_die_%02d/min_freq_khz", id->pkg, id->die);
-
- fd = open(buffer, O_WRONLY);
- if (fd < 0)
- return fd;
-
- snprintf(freq_str, sizeof(freq_str), "%d", freq);
- len = strlen(freq_str);
- ret = write(fd, freq_str, len);
- if (ret == -1) {
- close(fd);
- return ret;
- }
- close(fd);
-
- return 0;
-}
-
static void adjust_scaling_max_from_base_freq(int cpu);
static void set_tdp_level_for_cpu(struct isst_id *id, void *arg1, void *arg2, void *arg3,
@@ -1237,12 +1209,7 @@ static void set_tdp_level_for_cpu(struct isst_id *id, void *arg1, void *arg2, vo
usleep(2000);
/* Adjusting uncore freq */
- isst_get_uncore_p0_p1_info(id, tdp_level, &ctdp_level);
- if (ctdp_level.uncore_pm)
- set_uncore_min_max(id, 0, ctdp_level.uncore_pm * 100000);
-
- if (ctdp_level.uncore_p0)
- set_uncore_min_max(id, 1, ctdp_level.uncore_p0 * 100000);
+ isst_adjust_uncore_freq(id, tdp_level, &ctdp_level);
fprintf(stderr, "Option is set to online/offline\n");
ctdp_level.core_cpumask_size =
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 2169ceddebeb..8e224d154e04 100644
--- a/tools/power/x86/intel-speed-select/isst-core-mbox.c
+++ b/tools/power/x86/intel-speed-select/isst-core-mbox.c
@@ -120,7 +120,7 @@ static int mbox_get_ctdp_control(struct isst_id *id, int config_index,
return 0;
}
-static void mbox_get_uncore_p0_p1_info(struct isst_id *id, int config_index,
+static void _get_uncore_p0_p1_info(struct isst_id *id, int config_index,
struct isst_pkg_ctdp_level_info *ctdp_level)
{
unsigned int resp;
@@ -166,6 +166,45 @@ try_uncore_mbox:
ctdp_level->uncore_p1);
}
+static int _set_uncore_min_max(struct isst_id *id, int max, int freq)
+{
+ char buffer[128], freq_str[16];
+ int fd, ret, len;
+
+ if (max)
+ snprintf(buffer, sizeof(buffer),
+ "/sys/devices/system/cpu/intel_uncore_frequency/package_%02d_die_%02d/max_freq_khz", id->pkg, id->die);
+ else
+ snprintf(buffer, sizeof(buffer),
+ "/sys/devices/system/cpu/intel_uncore_frequency/package_%02d_die_%02d/min_freq_khz", id->pkg, id->die);
+
+ fd = open(buffer, O_WRONLY);
+ if (fd < 0)
+ return fd;
+
+ snprintf(freq_str, sizeof(freq_str), "%d", freq);
+ len = strlen(freq_str);
+ ret = write(fd, freq_str, len);
+ if (ret == -1) {
+ close(fd);
+ return ret;
+ }
+ close(fd);
+
+ return 0;
+}
+
+static void mbox_adjust_uncore_freq(struct isst_id *id, int config_index,
+ struct isst_pkg_ctdp_level_info *ctdp_level)
+{
+ _get_uncore_p0_p1_info(id, config_index, ctdp_level);
+ if (ctdp_level->uncore_pm)
+ _set_uncore_min_max(id, 0, ctdp_level->uncore_pm * 100000);
+
+ if (ctdp_level->uncore_p0)
+ _set_uncore_min_max(id, 1, ctdp_level->uncore_p0 * 100000);
+}
+
static void _get_p1_info(struct isst_id *id, int config_index,
struct isst_pkg_ctdp_level_info *ctdp_level)
{
@@ -250,7 +289,7 @@ static int mbox_get_tdp_info(struct isst_id *id, int config_index,
ctdp_level->t_proc_hot = resp & GENMASK(7, 0);
- mbox_get_uncore_p0_p1_info(id, config_index, ctdp_level);
+ _get_uncore_p0_p1_info(id, config_index, ctdp_level);
_get_p1_info(id, config_index, ctdp_level);
_get_uncore_mem_freq(id, config_index, ctdp_level);
@@ -834,7 +873,7 @@ static struct isst_platform_ops mbox_ops = {
.get_pbf_info = mbox_get_pbf_info,
.set_pbf_fact_status = mbox_set_pbf_fact_status,
.get_fact_info = mbox_get_fact_info,
- .get_uncore_p0_p1_info = mbox_get_uncore_p0_p1_info,
+ .adjust_uncore_freq = mbox_adjust_uncore_freq,
.get_clos_information = mbox_get_clos_information,
.pm_qos_config = mbox_pm_qos_config,
.pm_get_clos = mbox_pm_get_clos,
diff --git a/tools/power/x86/intel-speed-select/isst-core.c b/tools/power/x86/intel-speed-select/isst-core.c
index c31ab8f5f6dc..24b2c041bfe0 100644
--- a/tools/power/x86/intel-speed-select/isst-core.c
+++ b/tools/power/x86/intel-speed-select/isst-core.c
@@ -492,11 +492,11 @@ void isst_get_process_ctdp_complete(struct isst_id *id, struct isst_pkg_ctdp *pk
}
}
-void isst_get_uncore_p0_p1_info(struct isst_id *id, int config_index,
+void isst_adjust_uncore_freq(struct isst_id *id, int config_index,
struct isst_pkg_ctdp_level_info *ctdp_level)
{
- CHECK_CB(get_uncore_p0_p1_info);
- return isst_ops->get_uncore_p0_p1_info(id, config_index, ctdp_level);
+ CHECK_CB(adjust_uncore_freq);
+ return isst_ops->adjust_uncore_freq(id, config_index, ctdp_level);
}
int isst_get_process_ctdp(struct isst_id *id, int tdp_level, struct isst_pkg_ctdp *pkg_dev)
diff --git a/tools/power/x86/intel-speed-select/isst.h b/tools/power/x86/intel-speed-select/isst.h
index c64af51a44aa..8192e683ac92 100644
--- a/tools/power/x86/intel-speed-select/isst.h
+++ b/tools/power/x86/intel-speed-select/isst.h
@@ -199,7 +199,7 @@ struct isst_platform_ops {
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);
- void (*get_uncore_p0_p1_info)(struct isst_id *id, int config_index, struct isst_pkg_ctdp_level_info *ctdp_level);
+ void (*adjust_uncore_freq)(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);
int (*pm_get_clos)(struct isst_id *id, int clos, struct isst_clos_config *clos_config);
@@ -246,7 +246,7 @@ extern int isst_get_ctdp_control(struct isst_id *id, int config_index,
struct isst_pkg_ctdp_level_info *ctdp_level);
extern int isst_get_coremask_info(struct isst_id *id, int config_index,
struct isst_pkg_ctdp_level_info *ctdp_level);
-extern void isst_get_uncore_p0_p1_info(struct isst_id *id, int config_index,
+extern void isst_adjust_uncore_freq(struct isst_id *id, int config_index,
struct isst_pkg_ctdp_level_info *ctdp_level);
extern int isst_get_process_ctdp(struct isst_id *id, int tdp_level,
struct isst_pkg_ctdp *pkg_dev);