Commit 096575db authored by Hans de Goede's avatar Hans de Goede

Merge remote-tracking branch 'intel-sst/intel-sst' into review-hans

parents 7f1ea75d 97ec890d
......@@ -181,7 +181,10 @@ struct perf_cap {
static void process_hfi_event(struct perf_cap *perf_cap)
{
process_level_change(perf_cap->cpu);
struct isst_id id;
set_isst_id(&id, perf_cap->cpu);
process_level_change(&id);
}
static int handle_event(struct nl_msg *n, void *arg)
......
......@@ -32,62 +32,60 @@ static void init_levels(void)
per_package_levels_info[i][j] = -1;
}
void process_level_change(int cpu)
void process_level_change(struct isst_id *id)
{
struct isst_pkg_ctdp_level_info ctdp_level;
int pkg_id = get_physical_package_id(cpu);
int die_id = get_physical_die_id(cpu);
struct isst_pkg_ctdp pkg_dev;
time_t tm;
int ret;
if (pkg_id >= MAX_PACKAGE_COUNT || die_id >= MAX_DIE_PER_PACKAGE) {
debug_printf("Invalid package/die info for cpu:%d\n", cpu);
if (id->pkg < 0 || id->die < 0) {
debug_printf("Invalid package/die info for cpu:%d\n", id->cpu);
return;
}
tm = time(NULL);
if (tm - per_package_levels_tm[pkg_id][die_id] < 2 )
if (tm - per_package_levels_tm[id->pkg][id->die] < 2)
return;
per_package_levels_tm[pkg_id][die_id] = tm;
per_package_levels_tm[id->pkg][id->die] = tm;
ret = isst_get_ctdp_levels(cpu, &pkg_dev);
ret = isst_get_ctdp_levels(id, &pkg_dev);
if (ret) {
debug_printf("Can't get tdp levels for cpu:%d\n", cpu);
debug_printf("Can't get tdp levels for cpu:%d\n", id->cpu);
return;
}
debug_printf("Get Config level %d pkg:%d die:%d current_level:%d \n", cpu,
pkg_id, die_id, pkg_dev.current_level);
debug_printf("Get Config level %d pkg:%d die:%d current_level:%d\n", id->cpu,
id->pkg, id->die, pkg_dev.current_level);
if (pkg_dev.locked) {
debug_printf("config TDP s locked \n");
return;
}
if (per_package_levels_info[pkg_id][die_id] == pkg_dev.current_level)
if (per_package_levels_info[id->pkg][id->die] == pkg_dev.current_level)
return;
debug_printf("**Config level change for cpu:%d pkg:%d die:%d from %d to %d\n",
cpu, pkg_id, die_id, per_package_levels_info[pkg_id][die_id],
id->cpu, id->pkg, id->die, per_package_levels_info[id->pkg][id->die],
pkg_dev.current_level);
per_package_levels_info[pkg_id][die_id] = pkg_dev.current_level;
per_package_levels_info[id->pkg][id->die] = pkg_dev.current_level;
ctdp_level.core_cpumask_size =
alloc_cpu_set(&ctdp_level.core_cpumask);
ret = isst_get_coremask_info(cpu, pkg_dev.current_level, &ctdp_level);
ret = isst_get_coremask_info(id, pkg_dev.current_level, &ctdp_level);
if (ret) {
free_cpu_set(ctdp_level.core_cpumask);
debug_printf("Can't get core_mask:%d\n", cpu);
debug_printf("Can't get core_mask:%d\n", id->cpu);
return;
}
if (ctdp_level.cpu_count) {
int i, max_cpus = get_topo_max_cpus();
for (i = 0; i < max_cpus; ++i) {
if (pkg_id != get_physical_package_id(i) || die_id != get_physical_die_id(i))
if (!is_cpu_in_power_domain(i, id))
continue;
if (CPU_ISSET_S(i, ctdp_level.core_cpumask_size, ctdp_level.core_cpumask)) {
fprintf(stderr, "online cpu %d\n", i);
......@@ -102,10 +100,10 @@ void process_level_change(int cpu)
free_cpu_set(ctdp_level.core_cpumask);
}
static void _poll_for_config_change(int cpu, void *arg1, void *arg2,
static void _poll_for_config_change(struct isst_id *id, void *arg1, void *arg2,
void *arg3, void *arg4)
{
process_level_change(cpu);
process_level_change(id);
}
static void poll_for_config_change(void)
......
......@@ -166,29 +166,27 @@ static void format_and_print(FILE *outf, int level, char *header, char *value)
last_level = level;
}
static int print_package_info(int cpu, FILE *outf)
static int print_package_info(struct isst_id *id, FILE *outf)
{
char header[256];
if (out_format_is_json()) {
snprintf(header, sizeof(header), "package-%d:die-%d:cpu-%d",
get_physical_package_id(cpu), get_physical_die_id(cpu),
cpu);
id->pkg, id->die, id->cpu);
format_and_print(outf, 1, header, NULL);
return 1;
}
snprintf(header, sizeof(header), "package-%d",
get_physical_package_id(cpu));
snprintf(header, sizeof(header), "package-%d", id->pkg);
format_and_print(outf, 1, header, NULL);
snprintf(header, sizeof(header), "die-%d", get_physical_die_id(cpu));
snprintf(header, sizeof(header), "die-%d", id->die);
format_and_print(outf, 2, header, NULL);
snprintf(header, sizeof(header), "cpu-%d", cpu);
snprintf(header, sizeof(header), "cpu-%d", id->cpu);
format_and_print(outf, 3, header, NULL);
return 3;
}
static void _isst_pbf_display_information(int cpu, FILE *outf, int level,
static void _isst_pbf_display_information(struct isst_id *id, FILE *outf, int level,
struct isst_pbf_info *pbf_info,
int disp_level)
{
......@@ -231,7 +229,7 @@ static void _isst_pbf_display_information(int cpu, FILE *outf, int level,
format_and_print(outf, disp_level + 1, header, value);
}
static void _isst_fact_display_information(int cpu, FILE *outf, int level,
static 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,
int base_level)
......@@ -319,7 +317,7 @@ static void _isst_fact_display_information(int cpu, FILE *outf, int level,
format_and_print(outf, base_level + 2, header, value);
}
void isst_ctdp_display_core_info(int cpu, FILE *outf, char *prefix,
void isst_ctdp_display_core_info(struct isst_id *id, FILE *outf, char *prefix,
unsigned int val, char *str0, char *str1)
{
char header[256];
......@@ -328,17 +326,14 @@ void isst_ctdp_display_core_info(int cpu, FILE *outf, char *prefix,
if (out_format_is_json()) {
snprintf(header, sizeof(header), "package-%d:die-%d:cpu-%d",
get_physical_package_id(cpu), get_physical_die_id(cpu),
cpu);
id->pkg, id->die, id->cpu);
format_and_print(outf, level++, header, NULL);
} else {
snprintf(header, sizeof(header), "package-%d",
get_physical_package_id(cpu));
snprintf(header, sizeof(header), "package-%d", id->pkg);
format_and_print(outf, level++, header, NULL);
snprintf(header, sizeof(header), "die-%d",
get_physical_die_id(cpu));
snprintf(header, sizeof(header), "die-%d", id->die);
format_and_print(outf, level++, header, NULL);
snprintf(header, sizeof(header), "cpu-%d", cpu);
snprintf(header, sizeof(header), "cpu-%d", id->cpu);
format_and_print(outf, level++, header, NULL);
}
......@@ -353,7 +348,7 @@ void isst_ctdp_display_core_info(int cpu, FILE *outf, char *prefix,
format_and_print(outf, 1, NULL, NULL);
}
void isst_ctdp_display_information(int cpu, FILE *outf, int tdp_level,
void isst_ctdp_display_information(struct isst_id *id, FILE *outf, int tdp_level,
struct isst_pkg_ctdp *pkg_dev)
{
char header[256];
......@@ -362,7 +357,7 @@ void isst_ctdp_display_information(int cpu, FILE *outf, int tdp_level,
int i;
if (pkg_dev->processed)
level = print_package_info(cpu, outf);
level = print_package_info(id, outf);
for (i = 0; i <= pkg_dev->levels; ++i) {
struct isst_pkg_ctdp_level_info *ctdp_level;
......@@ -377,8 +372,7 @@ void isst_ctdp_display_information(int cpu, FILE *outf, int tdp_level,
format_and_print(outf, level + 1, header, NULL);
snprintf(header, sizeof(header), "cpu-count");
j = get_cpu_count(get_physical_die_id(cpu),
get_physical_die_id(cpu));
j = get_cpu_count(id);
snprintf(value, sizeof(value), "%d", j);
format_and_print(outf, level + 2, header, value);
......@@ -485,7 +479,7 @@ void isst_ctdp_display_information(int cpu, FILE *outf, int tdp_level,
if (is_clx_n_platform()) {
if (ctdp_level->pbf_support)
_isst_pbf_display_information(cpu, outf,
_isst_pbf_display_information(id, outf,
tdp_level,
&ctdp_level->pbf_info,
level + 2);
......@@ -557,11 +551,11 @@ void isst_ctdp_display_information(int cpu, FILE *outf, int tdp_level,
}
if (ctdp_level->pbf_support)
_isst_pbf_display_information(cpu, outf, i,
_isst_pbf_display_information(id, outf, i,
&ctdp_level->pbf_info,
level + 2);
if (ctdp_level->fact_support)
_isst_fact_display_information(cpu, outf, i, 0xff, 0xff,
_isst_fact_display_information(id, outf, i, 0xff, 0xff,
&ctdp_level->fact_info,
level + 2);
}
......@@ -583,36 +577,36 @@ void isst_ctdp_display_information_end(FILE *outf)
start = 0;
}
void isst_pbf_display_information(int cpu, FILE *outf, int level,
void isst_pbf_display_information(struct isst_id *id, FILE *outf, int level,
struct isst_pbf_info *pbf_info)
{
int _level;
_level = print_package_info(cpu, outf);
_isst_pbf_display_information(cpu, outf, level, pbf_info, _level + 1);
_level = print_package_info(id, outf);
_isst_pbf_display_information(id, outf, level, pbf_info, _level + 1);
format_and_print(outf, 1, NULL, NULL);
}
void isst_fact_display_information(int cpu, FILE *outf, int level,
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)
{
int _level;
_level = print_package_info(cpu, outf);
_isst_fact_display_information(cpu, outf, level, fact_bucket, fact_avx,
_level = print_package_info(id, outf);
_isst_fact_display_information(id, outf, level, fact_bucket, fact_avx,
fact_info, _level + 1);
format_and_print(outf, 1, NULL, NULL);
}
void isst_clos_display_information(int cpu, FILE *outf, int clos,
void isst_clos_display_information(struct isst_id *id, FILE *outf, int clos,
struct isst_clos_config *clos_config)
{
char header[256];
char value[256];
int level;
level = print_package_info(cpu, outf);
level = print_package_info(id, outf);
snprintf(header, sizeof(header), "core-power");
format_and_print(outf, level + 1, header, NULL);
......@@ -647,7 +641,7 @@ void isst_clos_display_information(int cpu, FILE *outf, int clos,
format_and_print(outf, level, NULL, NULL);
}
void isst_clos_display_clos_information(int cpu, FILE *outf,
void isst_clos_display_clos_information(struct isst_id *id, FILE *outf,
int clos_enable, int type,
int state, int cap)
{
......@@ -655,7 +649,7 @@ void isst_clos_display_clos_information(int cpu, FILE *outf,
char value[256];
int level;
level = print_package_info(cpu, outf);
level = print_package_info(id, outf);
snprintf(header, sizeof(header), "core-power");
format_and_print(outf, level + 1, header, NULL);
......@@ -691,13 +685,13 @@ void isst_clos_display_clos_information(int cpu, FILE *outf,
format_and_print(outf, level, NULL, NULL);
}
void isst_clos_display_assoc_information(int cpu, FILE *outf, int clos)
void isst_clos_display_assoc_information(struct isst_id *id, FILE *outf, int clos)
{
char header[256];
char value[256];
int level;
level = print_package_info(cpu, outf);
level = print_package_info(id, outf);
snprintf(header, sizeof(header), "get-assoc");
format_and_print(outf, level + 1, header, NULL);
......@@ -709,15 +703,15 @@ void isst_clos_display_assoc_information(int cpu, FILE *outf, int clos)
format_and_print(outf, level, NULL, NULL);
}
void isst_display_result(int cpu, FILE *outf, char *feature, char *cmd,
void isst_display_result(struct isst_id *id, FILE *outf, char *feature, char *cmd,
int result)
{
char header[256];
char value[256];
int level = 3;
if (cpu >= 0)
level = print_package_info(cpu, outf);
if (id->cpu >= 0)
level = print_package_info(id, outf);
snprintf(header, sizeof(header), "%s", feature);
format_and_print(outf, level + 1, header, NULL);
......@@ -772,13 +766,13 @@ void isst_display_error_info_message(int error, char *msg, int arg_valid, int ar
format_and_print(outf, 0, NULL, NULL);
}
void isst_trl_display_information(int cpu, FILE *outf, unsigned long long trl)
void isst_trl_display_information(struct isst_id *id, FILE *outf, unsigned long long trl)
{
char header[256];
char value[256];
int level;
level = print_package_info(cpu, outf);
level = print_package_info(id, outf);
snprintf(header, sizeof(header), "get-trl");
format_and_print(outf, level + 1, header, NULL);
......
......@@ -79,9 +79,14 @@
#define MAX_PACKAGE_COUNT 8
#define MAX_DIE_PER_PACKAGE 2
/* Unified structure to specific a CPU or a Power Domain */
struct isst_id {
int cpu;
int pkg;
int die;
};
struct isst_clos_config {
int pkg_id;
int die_id;
unsigned char epp;
unsigned char clos_prop_prio;
unsigned char clos_min;
......@@ -171,22 +176,20 @@ struct isst_pkg_ctdp {
struct isst_pkg_ctdp_level_info ctdp_level[ISST_MAX_TDP_LEVELS];
};
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(int pkg_id, int die_id);
extern int get_max_punit_core_id(int pkg_id, int die_id);
extern int get_cpu_count(struct isst_id *id);
extern int get_max_punit_core_id(struct isst_id *id);
/* Common interfaces */
FILE *get_output_file(void);
extern void debug_printf(const char *format, ...);
extern int out_format_is_json(void);
extern int get_physical_package_id(int cpu);
extern int get_physical_die_id(int cpu);
extern void set_isst_id(struct isst_id *id, int cpu);
extern size_t alloc_cpu_set(cpu_set_t **cpu_set);
extern void free_cpu_set(cpu_set_t *cpu_set);
extern int find_logical_cpu(int pkg_id, int die_id, int phy_cpu);
extern int find_phy_cpu_num(int logical_cpu);
extern int find_phy_core_num(int logical_cpu);
extern void set_cpu_mask_from_punit_coremask(int cpu,
extern void set_cpu_mask_from_punit_coremask(struct isst_id *id,
unsigned long long core_mask,
size_t core_cpumask_size,
cpu_set_t *core_cpumask,
......@@ -200,77 +203,74 @@ 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_get_ctdp_levels(int cpu, struct isst_pkg_ctdp *pkg_dev);
extern int isst_get_ctdp_control(int cpu, int config_index,
extern int isst_get_ctdp_levels(struct isst_id *id, struct isst_pkg_ctdp *pkg_dev);
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(int cpu, int config_index,
extern int isst_get_coremask_info(struct isst_id *id, int config_index,
struct isst_pkg_ctdp_level_info *ctdp_level);
extern int isst_get_process_ctdp(int cpu, int tdp_level,
extern int isst_get_process_ctdp(struct isst_id *id, int tdp_level,
struct isst_pkg_ctdp *pkg_dev);
extern void isst_get_process_ctdp_complete(int cpu,
extern void isst_get_process_ctdp_complete(struct isst_id *id,
struct isst_pkg_ctdp *pkg_dev);
extern void isst_ctdp_display_information(int cpu, FILE *outf, int tdp_level,
extern void isst_ctdp_display_information(struct isst_id *id, FILE *outf, int tdp_level,
struct isst_pkg_ctdp *pkg_dev);
extern void isst_ctdp_display_core_info(int cpu, FILE *outf, char *prefix,
extern void isst_ctdp_display_core_info(struct isst_id *id, FILE *outf, char *prefix,
unsigned int val, char *str0, char *str1);
extern void isst_ctdp_display_information_start(FILE *outf);
extern void isst_ctdp_display_information_end(FILE *outf);
extern void isst_pbf_display_information(int cpu, FILE *outf, int level,
extern void isst_pbf_display_information(struct isst_id *id, FILE *outf, int level,
struct isst_pbf_info *info);
extern int isst_set_tdp_level(int cpu, int tdp_level);
extern int isst_set_tdp_level_msr(int cpu, int tdp_level);
extern int isst_set_pbf_fact_status(int cpu, int pbf, int enable);
extern int isst_get_pbf_info(int cpu, int level,
extern int isst_set_tdp_level(struct isst_id *id, int tdp_level);
extern int isst_set_pbf_fact_status(struct isst_id *id, int pbf, int enable);
extern int isst_get_pbf_info(struct isst_id *id, int level,
struct isst_pbf_info *pbf_info);
extern void isst_get_pbf_info_complete(struct isst_pbf_info *pbf_info);
extern int isst_get_fact_info(int cpu, int level, int fact_bucket,
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(int cpu, int level,
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(int cpu, FILE *outf, int level,
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);
extern int isst_set_trl(int cpu, unsigned long long trl);
extern int isst_get_trl(int cpu, unsigned long long *trl);
extern int isst_set_trl_from_current_tdp(int cpu, unsigned long long trl);
extern int isst_get_config_tdp_lock_status(int cpu);
extern int isst_set_trl(struct isst_id *id, unsigned long long trl);
extern int isst_get_trl(struct isst_id *id, unsigned long long *trl);
extern int isst_set_trl_from_current_tdp(struct isst_id *id, unsigned long long trl);
extern int isst_get_config_tdp_lock_status(struct isst_id *id);
extern int isst_pm_qos_config(int cpu, int enable_clos, int priority_type);
extern int isst_pm_get_clos(int cpu, int clos,
extern int isst_pm_qos_config(struct isst_id *id, int enable_clos, int priority_type);
extern int isst_pm_get_clos(struct isst_id *id, int clos,
struct isst_clos_config *clos_config);
extern int isst_set_clos(int cpu, int clos,
extern int isst_set_clos(struct isst_id *id, int clos,
struct isst_clos_config *clos_config);
extern int isst_clos_associate(int cpu, int clos);
extern int isst_clos_get_assoc_status(int cpu, int *clos_id);
extern void isst_clos_display_information(int cpu, FILE *outf, int clos,
extern int isst_clos_associate(struct isst_id *id, int clos);
extern int isst_clos_get_assoc_status(struct isst_id *id, int *clos_id);
extern void isst_clos_display_information(struct isst_id *id, FILE *outf, int clos,
struct isst_clos_config *clos_config);
extern void isst_clos_display_assoc_information(int cpu, FILE *outf, int clos);
extern int isst_read_reg(unsigned short reg, unsigned int *val);
extern int isst_write_reg(int reg, unsigned int val);
extern void isst_clos_display_assoc_information(struct isst_id *id, FILE *outf, int clos);
extern void isst_display_result(int cpu, FILE *outf, char *feature, char *cmd,
extern void isst_display_result(struct isst_id *id, FILE *outf, char *feature, char *cmd,
int result);
extern int isst_clos_get_clos_information(int cpu, int *enable, int *type);
extern void isst_clos_display_clos_information(int cpu, FILE *outf,
extern int isst_clos_get_clos_information(struct isst_id *id, int *enable, int *type);
extern void isst_clos_display_clos_information(struct isst_id *id, FILE *outf,
int clos_enable, int type,
int state, int cap);
extern int is_clx_n_platform(void);
extern int get_cpufreq_base_freq(int cpu);
extern int isst_read_pm_config(int cpu, int *cp_state, int *cp_cap);
extern int isst_read_pm_config(struct isst_id *id, int *cp_state, int *cp_cap);
extern void isst_display_error_info_message(int error, char *msg, int arg_valid, int arg);
extern int is_skx_based_platform(void);
extern int is_spr_platform(void);
extern int is_icx_platform(void);
extern void isst_trl_display_information(int cpu, FILE *outf, unsigned long long trl);
extern void isst_trl_display_information(struct isst_id *id, FILE *outf, unsigned long long trl);
extern void set_cpu_online_offline(int cpu, int state);
extern void for_each_online_package_in_set(void (*callback)(int, void *, void *,
extern void for_each_online_package_in_set(void (*callback)(struct isst_id *, void *, void *,
void *, void *),
void *arg1, void *arg2, void *arg3,
void *arg4);
extern int isst_daemon(int debug_mode, int poll_interval, int no_daemon);
extern void process_level_change(int cpu);
extern void process_level_change(struct isst_id *id);
extern int hfi_main(void);
extern void hfi_exit(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