Commit d0d1a603 authored by Zhang Rui's avatar Zhang Rui Committed by Srinivas Pandruvada

tools/power/x86/intel-speed-select: Introduce isst-core-mbox.c

isst-core.c should contain generic core APIs only.
Platform specific implementations/configurations should be removed from
this file.

Introduce isst-core-mbox.c and move all mbox/mmio specific functions to
this file.

Introduce struct isst_platform_ops which contains a series of callbacks
that used by the core APIs but need platform specific implementation.

No functional changes are expected.
Signed-off-by: default avatarZhang Rui <rui.zhang@intel.com>
[srinivas.pandruvada@linux.intel.com: changelog edits]
Signed-off-by: default avatarSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
parent e9f79348
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
......@@ -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;
}
......
// 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;
}
......@@ -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)
......
......@@ -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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment