summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools/power/x86/intel-speed-select/Build2
-rw-r--r--tools/power/x86/intel-speed-select/isst-config.c8
-rw-r--r--tools/power/x86/intel-speed-select/isst-core-mbox.c43
-rw-r--r--tools/power/x86/intel-speed-select/isst-core.c37
-rw-r--r--tools/power/x86/intel-speed-select/isst.h11
5 files changed, 87 insertions, 14 deletions
diff --git a/tools/power/x86/intel-speed-select/Build b/tools/power/x86/intel-speed-select/Build
index 81e36bd578b1..32a2493b5233 100644
--- a/tools/power/x86/intel-speed-select/Build
+++ b/tools/power/x86/intel-speed-select/Build
@@ -1 +1 @@
-intel-speed-select-y += isst-config.o isst-core.o isst-display.o isst-daemon.o hfi-events.o
+intel-speed-select-y += isst-config.o isst-core.o isst-display.o isst-daemon.o hfi-events.o isst-core-mbox.o
diff --git a/tools/power/x86/intel-speed-select/isst-config.c b/tools/power/x86/intel-speed-select/isst-config.c
index d4567b8d72db..1f357d499c89 100644
--- a/tools/power/x86/intel-speed-select/isst-config.c
+++ b/tools/power/x86/intel-speed-select/isst-config.c
@@ -804,7 +804,7 @@ static int isst_fill_platform_info(void)
int fd;
if (is_clx_n_platform())
- return 0;
+ goto set_platform_ops;
fd = open(pathname, O_RDWR);
if (fd < 0)
@@ -822,6 +822,12 @@ static int isst_fill_platform_info(void)
printf("Incompatible API versions; Upgrade of tool is required\n");
return -1;
}
+
+set_platform_ops:
+ if (isst_set_platform_ops()) {
+ fprintf(stderr, "Failed to set platform callbacks\n");
+ exit(0);
+ }
return 0;
}
diff --git a/tools/power/x86/intel-speed-select/isst-core-mbox.c b/tools/power/x86/intel-speed-select/isst-core-mbox.c
new file mode 100644
index 000000000000..221caa35c10c
--- /dev/null
+++ b/tools/power/x86/intel-speed-select/isst-core-mbox.c
@@ -0,0 +1,43 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Intel Speed Select -- Enumerate and control features for Mailbox Interface
+ * Copyright (c) 2023 Intel Corporation.
+ */
+#include "isst.h"
+
+static int mbox_get_disp_freq_multiplier(void)
+{
+ return DISP_FREQ_MULTIPLIER;
+}
+
+static int mbox_get_trl_max_levels(void)
+{
+ return 3;
+}
+
+static char *mbox_get_trl_level_name(int level)
+{
+ switch (level) {
+ case 0:
+ return "sse";
+ case 1:
+ return "avx2";
+ case 2:
+ return "avx512";
+ default:
+ return NULL;
+ }
+}
+
+
+
+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,
+ .get_trl_level_name = mbox_get_trl_level_name,
+};
+
+struct isst_platform_ops *mbox_get_platform_ops(void)
+{
+ return &mbox_ops;
+}
diff --git a/tools/power/x86/intel-speed-select/isst-core.c b/tools/power/x86/intel-speed-select/isst-core.c
index 8d63db2bf07c..bf7b667d5ffa 100644
--- a/tools/power/x86/intel-speed-select/isst-core.c
+++ b/tools/power/x86/intel-speed-select/isst-core.c
@@ -9,6 +9,25 @@
static int mbox_delay;
static int mbox_retries = 3;
+static struct isst_platform_ops *isst_ops;
+
+#define CHECK_CB(_name) \
+ do { \
+ if (!isst_ops || !isst_ops->_name) { \
+ fprintf(stderr, "Invalid ops\n"); \
+ exit(0); \
+ } \
+ } while (0)
+
+int isst_set_platform_ops(void)
+{
+ isst_ops = mbox_get_platform_ops();
+
+ if (!isst_ops)
+ return -1;
+ return 0;
+}
+
void isst_update_platform_param(enum isst_platform_param param, int value)
{
switch (param) {
@@ -25,26 +44,20 @@ void isst_update_platform_param(enum isst_platform_param param, int value)
int isst_get_disp_freq_multiplier(void)
{
- return DISP_FREQ_MULTIPLIER;
+ CHECK_CB(get_disp_freq_multiplier);
+ return isst_ops->get_disp_freq_multiplier();
}
int isst_get_trl_max_levels(void)
{
- return 3;
+ CHECK_CB(get_trl_max_levels);
+ return isst_ops->get_trl_max_levels();
}
char *isst_get_trl_level_name(int level)
{
- switch (level) {
- case 0:
- return "sse";
- case 1:
- return "avx2";
- case 2:
- return "avx512";
- default:
- return NULL;
- }
+ CHECK_CB(get_trl_level_name);
+ return isst_ops->get_trl_level_name(level);
}
int isst_is_punit_valid(struct isst_id *id)
diff --git a/tools/power/x86/intel-speed-select/isst.h b/tools/power/x86/intel-speed-select/isst.h
index 8de9dd479884..7bb74d0912c2 100644
--- a/tools/power/x86/intel-speed-select/isst.h
+++ b/tools/power/x86/intel-speed-select/isst.h
@@ -181,6 +181,12 @@ enum isst_platform_param {
ISST_PARAM_MBOX_RETRIES,
};
+struct isst_platform_ops {
+ int (*get_disp_freq_multiplier)(void);
+ int (*get_trl_max_levels)(void);
+ char *(*get_trl_level_name)(int level);
+};
+
extern int is_cpu_in_power_domain(int cpu, struct isst_id *id);
extern int get_topo_max_cpus(void);
extern int get_cpu_count(struct isst_id *id);
@@ -207,6 +213,7 @@ extern int isst_send_mbox_command(unsigned int cpu, unsigned char command,
extern int isst_send_msr_command(unsigned int cpu, unsigned int command,
int write, unsigned long long *req_resp);
+extern int isst_set_platform_ops(void);
extern void isst_update_platform_param(enum isst_platform_param, int vale);
extern int isst_get_disp_freq_multiplier(void);
extern int isst_get_trl_max_levels(void);
@@ -285,4 +292,8 @@ extern int isst_daemon(int debug_mode, int poll_interval, int no_daemon);
extern void process_level_change(struct isst_id *id);
extern int hfi_main(void);
extern void hfi_exit(void);
+
+/* Interface specific callbacks */
+extern struct isst_platform_ops *mbox_get_platform_ops(void);
+
#endif