Resguardo inicial

This commit is contained in:
lastdragon
2026-09-06 12:53:21 -06:00
parent 662efe3c2a
commit ad2088d178
94853 changed files with 43200404 additions and 0 deletions
@@ -0,0 +1,3 @@
# SPDX-License-Identifier: GPL-2.0-only
include/
intel-speed-select
@@ -0,0 +1 @@
intel-speed-select-y += isst-config.o isst-core.o isst-display.o isst-daemon.o hfi-events.o isst-core-mbox.o isst-core-tpmi.o
@@ -0,0 +1,66 @@
# SPDX-License-Identifier: GPL-2.0
include ../../../scripts/Makefile.include
bindir ?= /usr/bin
ifeq ($(srctree),)
srctree := $(patsubst %/,%,$(dir $(CURDIR)))
srctree := $(patsubst %/,%,$(dir $(srctree)))
srctree := $(patsubst %/,%,$(dir $(srctree)))
srctree := $(patsubst %/,%,$(dir $(srctree)))
endif
# Do not use make's built-in rules
# (this improves performance and avoids hard-to-debug behaviour);
MAKEFLAGS += -r
NL3_CFLAGS = $(shell pkg-config --cflags libnl-3.0 2>/dev/null)
ifeq ($(NL3_CFLAGS),)
NL3_CFLAGS = -I/usr/include/libnl3
endif
override CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include $(NL3_CFLAGS)
override LDFLAGS += -lnl-genl-3 -lnl-3
ALL_TARGETS := intel-speed-select
ALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS))
all: $(ALL_PROGRAMS)
export srctree OUTPUT CC LD CFLAGS
include $(srctree)/tools/build/Makefile.include
#
# We need the following to be outside of kernel tree
#
$(OUTPUT)include/linux/isst_if.h: ../../../../include/uapi/linux/isst_if.h
mkdir -p $(OUTPUT)include/linux 2>&1 || true
ln -sf $(CURDIR)/../../../../include/uapi/linux/isst_if.h $@
$(OUTPUT)include/linux/thermal.h: ../../../../include/uapi/linux/thermal.h
mkdir -p $(OUTPUT)include/linux 2>&1 || true
ln -sf $(CURDIR)/../../../../include/uapi/linux/thermal.h $@
prepare: $(OUTPUT)include/linux/isst_if.h $(OUTPUT)include/linux/thermal.h
ISST_IN := $(OUTPUT)intel-speed-select-in.o
$(ISST_IN): prepare FORCE
$(Q)$(MAKE) $(build)=intel-speed-select
$(OUTPUT)intel-speed-select: $(ISST_IN)
$(QUIET_LINK)$(CC) $(CFLAGS) $< $(LDFLAGS) -o $@
clean:
rm -f $(ALL_PROGRAMS)
rm -rf $(OUTPUT)include/linux/isst_if.h
find $(or $(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete
install: $(ALL_PROGRAMS)
install -d -m 755 $(DESTDIR)$(bindir); \
for program in $(ALL_PROGRAMS); do \
install $$program $(DESTDIR)$(bindir); \
done
FORCE:
.PHONY: all install clean FORCE prepare
@@ -0,0 +1,308 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Intel Speed Select -- Read HFI events for OOB
* Copyright (c) 2022 Intel Corporation.
*/
/*
* This file incorporates work covered by the following copyright and
* permission notice:
* WPA Supplicant - driver interaction with Linux nl80211/cfg80211
* Copyright (c) 2003-2008, Jouni Malinen <j@w1.fi>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* Alternatively, this software may be distributed under the terms of
* BSD license.
*
* Requires
* libnl-genl-3-dev
*
* For Fedora/CenOS
* dnf install libnl3-devel
* For Ubuntu
* apt install libnl-3-dev libnl-genl-3-dev
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/file.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <getopt.h>
#include <signal.h>
#include <netlink/genl/genl.h>
#include <netlink/genl/family.h>
#include <netlink/genl/ctrl.h>
#include <linux/thermal.h>
#include "isst.h"
struct hfi_event_data {
struct nl_sock *nl_handle;
struct nl_cb *nl_cb;
};
struct hfi_event_data drv;
static int ack_handler(struct nl_msg *msg, void *arg)
{
int *err = arg;
*err = 0;
return NL_STOP;
}
static int finish_handler(struct nl_msg *msg, void *arg)
{
int *ret = arg;
*ret = 0;
return NL_SKIP;
}
static int error_handler(struct sockaddr_nl *nla, struct nlmsgerr *err,
void *arg)
{
int *ret = arg;
*ret = err->error;
return NL_SKIP;
}
static int seq_check_handler(struct nl_msg *msg, void *arg)
{
return NL_OK;
}
static int send_and_recv_msgs(struct hfi_event_data *drv,
struct nl_msg *msg,
int (*valid_handler)(struct nl_msg *, void *),
void *valid_data)
{
struct nl_cb *cb;
int err = -ENOMEM;
cb = nl_cb_clone(drv->nl_cb);
if (!cb)
goto out;
err = nl_send_auto_complete(drv->nl_handle, msg);
if (err < 0)
goto out;
err = 1;
nl_cb_err(cb, NL_CB_CUSTOM, error_handler, &err);
nl_cb_set(cb, NL_CB_FINISH, NL_CB_CUSTOM, finish_handler, &err);
nl_cb_set(cb, NL_CB_ACK, NL_CB_CUSTOM, ack_handler, &err);
if (valid_handler)
nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM,
valid_handler, valid_data);
while (err > 0)
nl_recvmsgs(drv->nl_handle, cb);
out:
nl_cb_put(cb);
nlmsg_free(msg);
return err;
}
struct family_data {
const char *group;
int id;
};
static int family_handler(struct nl_msg *msg, void *arg)
{
struct family_data *res = arg;
struct nlattr *tb[CTRL_ATTR_MAX + 1];
struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
struct nlattr *mcgrp;
int i;
nla_parse(tb, CTRL_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
genlmsg_attrlen(gnlh, 0), NULL);
if (!tb[CTRL_ATTR_MCAST_GROUPS])
return NL_SKIP;
nla_for_each_nested(mcgrp, tb[CTRL_ATTR_MCAST_GROUPS], i) {
struct nlattr *tb2[CTRL_ATTR_MCAST_GRP_MAX + 1];
nla_parse(tb2, CTRL_ATTR_MCAST_GRP_MAX, nla_data(mcgrp),
nla_len(mcgrp), NULL);
if (!tb2[CTRL_ATTR_MCAST_GRP_NAME] ||
!tb2[CTRL_ATTR_MCAST_GRP_ID] ||
strncmp(nla_data(tb2[CTRL_ATTR_MCAST_GRP_NAME]),
res->group,
nla_len(tb2[CTRL_ATTR_MCAST_GRP_NAME])) != 0)
continue;
res->id = nla_get_u32(tb2[CTRL_ATTR_MCAST_GRP_ID]);
break;
}
return 0;
}
static int nl_get_multicast_id(struct hfi_event_data *drv,
const char *family, const char *group)
{
struct nl_msg *msg;
int ret = -1;
struct family_data res = { group, -ENOENT };
msg = nlmsg_alloc();
if (!msg)
return -ENOMEM;
genlmsg_put(msg, 0, 0, genl_ctrl_resolve(drv->nl_handle, "nlctrl"),
0, 0, CTRL_CMD_GETFAMILY, 0);
NLA_PUT_STRING(msg, CTRL_ATTR_FAMILY_NAME, family);
ret = send_and_recv_msgs(drv, msg, family_handler, &res);
msg = NULL;
if (ret == 0)
ret = res.id;
nla_put_failure:
nlmsg_free(msg);
return ret;
}
struct perf_cap {
int cpu;
int perf;
int eff;
};
static void process_hfi_event(struct perf_cap *perf_cap)
{
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)
{
struct nlmsghdr *nlh = nlmsg_hdr(n);
struct genlmsghdr *genlhdr = genlmsg_hdr(nlh);
struct nlattr *attrs[THERMAL_GENL_ATTR_MAX + 1];
int ret;
struct perf_cap perf_cap = {0};
ret = genlmsg_parse(nlh, 0, attrs, THERMAL_GENL_ATTR_MAX, NULL);
debug_printf("Received event %d parse_rer:%d\n", genlhdr->cmd, ret);
if (genlhdr->cmd == THERMAL_GENL_EVENT_CPU_CAPABILITY_CHANGE) {
struct nlattr *cap;
int j, index = 0;
debug_printf("THERMAL_GENL_EVENT_CPU_CAPABILITY_CHANGE\n");
nla_for_each_nested(cap, attrs[THERMAL_GENL_ATTR_CPU_CAPABILITY], j) {
switch (index) {
case 0:
perf_cap.cpu = nla_get_u32(cap);
break;
case 1:
perf_cap.perf = nla_get_u32(cap);
break;
case 2:
perf_cap.eff = nla_get_u32(cap);
break;
default:
break;
}
++index;
if (index == 3) {
index = 0;
process_hfi_event(&perf_cap);
}
}
}
return 0;
}
static int _hfi_exit;
static int check_hf_suport(void)
{
unsigned int eax = 0, ebx = 0, ecx = 0, edx = 0;
__cpuid(6, eax, ebx, ecx, edx);
if (eax & BIT(19))
return 1;
return 0;
}
int hfi_main(void)
{
struct nl_sock *sock;
struct nl_cb *cb;
int err = 0;
int mcast_id;
if (!check_hf_suport()) {
fprintf(stderr, "CPU Doesn't support HFI\n");
return -1;
}
sock = nl_socket_alloc();
if (!sock) {
fprintf(stderr, "nl_socket_alloc failed\n");
return -1;
}
if (genl_connect(sock)) {
fprintf(stderr, "genl_connect(sk_event) failed\n");
goto free_sock;
}
drv.nl_handle = sock;
drv.nl_cb = cb = nl_cb_alloc(NL_CB_DEFAULT);
if (drv.nl_cb == NULL) {
printf("Failed to allocate netlink callbacks");
goto free_sock;
}
mcast_id = nl_get_multicast_id(&drv, THERMAL_GENL_FAMILY_NAME,
THERMAL_GENL_EVENT_GROUP_NAME);
if (mcast_id < 0) {
fprintf(stderr, "nl_get_multicast_id failed\n");
goto free_sock;
}
if (nl_socket_add_membership(sock, mcast_id)) {
fprintf(stderr, "nl_socket_add_membership failed");
goto free_sock;
}
nl_cb_set(cb, NL_CB_SEQ_CHECK, NL_CB_CUSTOM, seq_check_handler, 0);
nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, handle_event, NULL);
debug_printf("hfi is initialized\n");
while (!_hfi_exit && !err) {
err = nl_recvmsgs(sock, cb);
debug_printf("nl_recv_message err:%d\n", err);
}
return 0;
/* Netlink library doesn't have calls to dealloc cb or disconnect */
free_sock:
nl_socket_free(sock);
return -1;
}
void hfi_exit(void)
{
_hfi_exit = 1;
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,874 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Intel Speed Select -- Enumerate and control features for TPMI Interface
* Copyright (c) 2022 Intel Corporation.
*/
#include <linux/isst_if.h>
#include "isst.h"
int tpmi_process_ioctl(int ioctl_no, void *info)
{
const char *pathname = "/dev/isst_interface";
int fd;
if (is_debug_enabled()) {
debug_printf("Issue IOCTL: ");
switch (ioctl_no) {
case ISST_IF_CORE_POWER_STATE:
debug_printf("ISST_IF_CORE_POWER_STATE\n");
break;
case ISST_IF_CLOS_PARAM:
debug_printf("ISST_IF_CLOS_PARAM\n");
break;
case ISST_IF_CLOS_ASSOC:
debug_printf("ISST_IF_CLOS_ASSOC\n");
break;
case ISST_IF_PERF_LEVELS:
debug_printf("ISST_IF_PERF_LEVELS\n");
break;
case ISST_IF_PERF_SET_LEVEL:
debug_printf("ISST_IF_PERF_SET_LEVEL\n");
break;
case ISST_IF_PERF_SET_FEATURE:
debug_printf("ISST_IF_PERF_SET_FEATURE\n");
break;
case ISST_IF_GET_PERF_LEVEL_INFO:
debug_printf("ISST_IF_GET_PERF_LEVEL_INFO\n");
break;
case ISST_IF_GET_PERF_LEVEL_CPU_MASK:
debug_printf("ISST_IF_GET_PERF_LEVEL_CPU_MASK\n");
break;
case ISST_IF_GET_BASE_FREQ_INFO:
debug_printf("ISST_IF_GET_BASE_FREQ_INFO\n");
break;
case ISST_IF_GET_BASE_FREQ_CPU_MASK:
debug_printf("ISST_IF_GET_BASE_FREQ_CPU_MASK\n");
break;
case ISST_IF_GET_TURBO_FREQ_INFO:
debug_printf("ISST_IF_GET_TURBO_FREQ_INFO\n");
break;
case ISST_IF_COUNT_TPMI_INSTANCES:
debug_printf("ISST_IF_COUNT_TPMI_INSTANCES\n");
break;
default:
debug_printf("%d\n", ioctl_no);
break;
}
}
fd = open(pathname, O_RDWR);
if (fd < 0)
return -1;
if (ioctl(fd, ioctl_no, info) == -1) {
debug_printf("IOCTL %d Failed\n", ioctl_no);
close(fd);
return -1;
}
close(fd);
return 0;
}
static int tpmi_get_disp_freq_multiplier(void)
{
return 1;
}
static int tpmi_get_trl_max_levels(void)
{
return TRL_MAX_LEVELS;
}
static char *tpmi_get_trl_level_name(int level)
{
switch (level) {
case 0:
return "level-0";
case 1:
return "level-1";
case 2:
return "level-2";
case 3:
return "level-3";
case 4:
return "level-4";
case 5:
return "level-5";
case 6:
return "level-6";
case 7:
return "level-7";
default:
return NULL;
}
}
static void tpmi_update_platform_param(enum isst_platform_param param, int value)
{
/* No params need to be updated for now */
}
static int tpmi_is_punit_valid(struct isst_id *id)
{
struct isst_tpmi_instance_count info;
int ret;
if (id->punit < 0)
return 0;
info.socket_id = id->pkg;
ret = tpmi_process_ioctl(ISST_IF_COUNT_TPMI_INSTANCES, &info);
if (ret == -1)
return 0;
if (info.valid_mask & BIT(id->punit))
return 1;
return 0;
}
static int tpmi_read_pm_config(struct isst_id *id, int *cp_state, int *cp_cap)
{
struct isst_core_power info;
int ret;
info.get_set = 0;
info.socket_id = id->pkg;
info.power_domain_id = id->punit;
ret = tpmi_process_ioctl(ISST_IF_CORE_POWER_STATE, &info);
if (ret == -1)
return ret;
*cp_state = info.enable;
*cp_cap = info.supported;
return 0;
}
int tpmi_get_config_levels(struct isst_id *id, struct isst_pkg_ctdp *pkg_dev)
{
struct isst_perf_level_info info;
int ret;
info.socket_id = id->pkg;
info.power_domain_id = id->punit;
ret = tpmi_process_ioctl(ISST_IF_PERF_LEVELS, &info);
if (ret == -1)
return ret;
pkg_dev->version = info.feature_rev;
pkg_dev->levels = info.max_level;
pkg_dev->locked = info.locked;
pkg_dev->current_level = info.current_level;
pkg_dev->locked = info.locked;
pkg_dev->enabled = info.enabled;
return 0;
}
static int tpmi_get_ctdp_control(struct isst_id *id, int config_index,
struct isst_pkg_ctdp_level_info *ctdp_level)
{
struct isst_core_power core_power_info;
struct isst_perf_level_info info;
int level_mask;
int ret;
info.socket_id = id->pkg;
info.power_domain_id = id->punit;
ret = tpmi_process_ioctl(ISST_IF_PERF_LEVELS, &info);
if (ret == -1)
return -1;
if (config_index != 0xff)
level_mask = 1 << config_index;
else
level_mask = config_index;
if (!(info.level_mask & level_mask))
return -1;
if (api_version() > 2) {
ctdp_level->fact_support = info.sst_tf_support & BIT(config_index);
ctdp_level->pbf_support = info.sst_bf_support & BIT(config_index);
} else {
ctdp_level->fact_support = info.sst_tf_support;
ctdp_level->pbf_support = info.sst_bf_support;
}
ctdp_level->fact_enabled = !!(info.feature_state & BIT(1));
ctdp_level->pbf_enabled = !!(info.feature_state & BIT(0));
core_power_info.get_set = 0;
core_power_info.socket_id = id->pkg;
core_power_info.power_domain_id = id->punit;
ret = tpmi_process_ioctl(ISST_IF_CORE_POWER_STATE, &core_power_info);
if (ret == -1)
return ret;
ctdp_level->sst_cp_support = core_power_info.supported;
ctdp_level->sst_cp_enabled = core_power_info.enable;
debug_printf
("cpu:%d CONFIG_TDP_GET_TDP_CONTROL fact_support:%d pbf_support: %d fact_enabled:%d pbf_enabled:%d\n",
id->cpu, ctdp_level->fact_support, ctdp_level->pbf_support,
ctdp_level->fact_enabled, ctdp_level->pbf_enabled);
return 0;
}
static int tpmi_get_tdp_info(struct isst_id *id, int config_index,
struct isst_pkg_ctdp_level_info *ctdp_level)
{
struct isst_perf_level_fabric_info fabric_info;
struct isst_perf_level_data_info info;
int ret;
info.socket_id = id->pkg;
info.power_domain_id = id->punit;
info.level = config_index;
ret = tpmi_process_ioctl(ISST_IF_GET_PERF_LEVEL_INFO, &info);
if (ret == -1)
return ret;
ctdp_level->pkg_tdp = info.thermal_design_power_w;
ctdp_level->tdp_ratio = info.tdp_ratio;
ctdp_level->sse_p1 = info.base_freq_mhz;
ctdp_level->avx2_p1 = info.base_freq_avx2_mhz;
ctdp_level->avx512_p1 = info.base_freq_avx512_mhz;
ctdp_level->amx_p1 = info.base_freq_amx_mhz;
ctdp_level->t_proc_hot = info.tjunction_max_c;
ctdp_level->mem_freq = info.max_memory_freq_mhz;
ctdp_level->cooling_type = info.cooling_type;
ctdp_level->uncore_p0 = info.p0_fabric_freq_mhz;
ctdp_level->uncore_p1 = info.p1_fabric_freq_mhz;
ctdp_level->uncore_pm = info.pm_fabric_freq_mhz;
fabric_info.socket_id = id->pkg;
fabric_info.power_domain_id = id->punit;
fabric_info.level = config_index;
ret = tpmi_process_ioctl(ISST_IF_GET_PERF_LEVEL_FABRIC_INFO, &fabric_info);
if (ret != -1) {
ctdp_level->uncore1_p0 = fabric_info.p0_fabric_freq_mhz[1];
ctdp_level->uncore1_p1 = fabric_info.p1_fabric_freq_mhz[1];
ctdp_level->uncore1_pm = fabric_info.pm_fabric_freq_mhz[1];
}
debug_printf
("cpu:%d ctdp:%d CONFIG_TDP_GET_TDP_INFO tdp_ratio:%d pkg_tdp:%d ctdp_level->t_proc_hot:%d\n",
id->cpu, config_index, ctdp_level->tdp_ratio, ctdp_level->pkg_tdp,
ctdp_level->t_proc_hot);
return 0;
}
static int tpmi_get_pwr_info(struct isst_id *id, int config_index,
struct isst_pkg_ctdp_level_info *ctdp_level)
{
/* TBD */
ctdp_level->pkg_max_power = 0;
ctdp_level->pkg_min_power = 0;
debug_printf
("cpu:%d ctdp:%d CONFIG_TDP_GET_PWR_INFO pkg_max_power:%d pkg_min_power:%d\n",
id->cpu, config_index, ctdp_level->pkg_max_power,
ctdp_level->pkg_min_power);
return 0;
}
int tpmi_get_coremask_info(struct isst_id *id, int config_index,
struct isst_pkg_ctdp_level_info *ctdp_level)
{
struct isst_perf_level_cpu_mask info;
int ret, cpu_count;
info.socket_id = id->pkg;
info.power_domain_id = id->punit;
info.level = config_index;
info.punit_cpu_map = 1;
ret = tpmi_process_ioctl(ISST_IF_GET_PERF_LEVEL_CPU_MASK, &info);
if (ret == -1)
return ret;
set_cpu_mask_from_punit_coremask(id, info.mask,
ctdp_level->core_cpumask_size,
ctdp_level->core_cpumask, &cpu_count);
ctdp_level->cpu_count = cpu_count;
debug_printf("cpu:%d ctdp:%d core_mask ino cpu count:%d\n",
id->cpu, config_index, ctdp_level->cpu_count);
return 0;
}
static int tpmi_get_get_trls(struct isst_id *id, int config_index,
struct isst_pkg_ctdp_level_info *ctdp_level)
{
struct isst_perf_level_data_info info;
int ret, i, j;
info.socket_id = id->pkg;
info.power_domain_id = id->punit;
info.level = config_index;
ret = tpmi_process_ioctl(ISST_IF_GET_PERF_LEVEL_INFO, &info);
if (ret == -1)
return ret;
if (info.max_buckets > TRL_MAX_BUCKETS)
info.max_buckets = TRL_MAX_BUCKETS;
if (info.max_trl_levels > TRL_MAX_LEVELS)
info.max_trl_levels = TRL_MAX_LEVELS;
for (i = 0; i < info.max_trl_levels; ++i)
for (j = 0; j < info.max_buckets; ++j)
ctdp_level->trl_ratios[i][j] = info.trl_freq_mhz[i][j];
return 0;
}
static int tpmi_get_get_trl(struct isst_id *id, int config_index, int level,
int *trl)
{
struct isst_pkg_ctdp_level_info ctdp_level;
int ret, i;
ret = tpmi_get_get_trls(id, config_index, &ctdp_level);
if (ret)
return ret;
/* FIX ME: Just return for level 0 */
for (i = 0; i < 8; ++i)
trl[i] = ctdp_level.trl_ratios[0][i];
return 0;
}
static int tpmi_get_trl_bucket_info(struct isst_id *id, int config_index,
unsigned long long *buckets_info)
{
struct isst_perf_level_data_info info;
unsigned char *mask = (unsigned char *)buckets_info;
int ret, i;
info.socket_id = id->pkg;
info.power_domain_id = id->punit;
info.level = config_index;
ret = tpmi_process_ioctl(ISST_IF_GET_PERF_LEVEL_INFO, &info);
if (ret == -1)
return ret;
if (info.max_buckets > TRL_MAX_BUCKETS)
info.max_buckets = TRL_MAX_BUCKETS;
for (i = 0; i < info.max_buckets; ++i)
mask[i] = info.bucket_core_counts[i];
debug_printf("cpu:%d TRL bucket info: 0x%llx\n", id->cpu,
*buckets_info);
return 0;
}
static int tpmi_set_tdp_level(struct isst_id *id, int tdp_level)
{
struct isst_perf_level_control info;
int ret;
info.socket_id = id->pkg;
info.power_domain_id = id->punit;
info.level = tdp_level;
ret = tpmi_process_ioctl(ISST_IF_PERF_SET_LEVEL, &info);
if (ret == -1)
return ret;
return 0;
}
static int _pbf_get_coremask_info(struct isst_id *id, int config_index,
struct isst_pbf_info *pbf_info)
{
struct isst_perf_level_cpu_mask info;
int ret, cpu_count;
info.socket_id = id->pkg;
info.power_domain_id = id->punit;
info.level = config_index;
info.punit_cpu_map = 1;
ret = tpmi_process_ioctl(ISST_IF_GET_BASE_FREQ_CPU_MASK, &info);
if (ret == -1)
return ret;
set_cpu_mask_from_punit_coremask(id, info.mask,
pbf_info->core_cpumask_size,
pbf_info->core_cpumask, &cpu_count);
debug_printf("cpu:%d ctdp:%d pbf core_mask info cpu count:%d\n",
id->cpu, config_index, cpu_count);
return 0;
}
static int tpmi_get_pbf_info(struct isst_id *id, int level,
struct isst_pbf_info *pbf_info)
{
struct isst_base_freq_info info;
int ret;
info.socket_id = id->pkg;
info.power_domain_id = id->punit;
info.level = level;
ret = tpmi_process_ioctl(ISST_IF_GET_BASE_FREQ_INFO, &info);
if (ret == -1)
return ret;
pbf_info->p1_low = info.low_base_freq_mhz;
pbf_info->p1_high = info.high_base_freq_mhz;
pbf_info->tdp = info.thermal_design_power_w;
pbf_info->t_prochot = info.tjunction_max_c;
debug_printf("cpu:%d ctdp:%d pbf info:%d:%d:%d:%d\n",
id->cpu, level, pbf_info->p1_low, pbf_info->p1_high,
pbf_info->tdp, pbf_info->t_prochot);
return _pbf_get_coremask_info(id, level, pbf_info);
}
#define FEATURE_ENABLE_WAIT_US 1000
#define FEATURE_ENABLE_RETRIES 5
static int tpmi_set_pbf_fact_status(struct isst_id *id, int pbf, int enable)
{
struct isst_pkg_ctdp pkg_dev;
struct isst_pkg_ctdp_level_info ctdp_level;
int current_level;
struct isst_perf_feature_control info;
int ret, i;
ret = isst_get_ctdp_levels(id, &pkg_dev);
if (ret)
debug_printf("cpu:%d No support for dynamic ISST\n", id->cpu);
current_level = pkg_dev.current_level;
ret = isst_get_ctdp_control(id, current_level, &ctdp_level);
if (ret)
return ret;
info.socket_id = id->pkg;
info.power_domain_id = id->punit;
info.feature = 0;
if (pbf) {
if (ctdp_level.fact_enabled)
info.feature |= BIT(1);
if (enable)
info.feature |= BIT(0);
else
info.feature &= ~BIT(0);
} else {
if (enable && !ctdp_level.sst_cp_enabled)
isst_display_error_info_message(0,
"Make sure to execute before: core-power enable",
0, 0);
if (ctdp_level.pbf_enabled)
info.feature |= BIT(0);
if (enable)
info.feature |= BIT(1);
else
info.feature &= ~BIT(1);
}
ret = tpmi_process_ioctl(ISST_IF_PERF_SET_FEATURE, &info);
if (ret == -1)
return ret;
for (i = 0; i < FEATURE_ENABLE_RETRIES; ++i) {
usleep(FEATURE_ENABLE_WAIT_US);
/* Check status */
ret = isst_get_ctdp_control(id, current_level, &ctdp_level);
if (ret)
return ret;
debug_printf("pbf_enabled:%d fact_enabled:%d\n",
ctdp_level.pbf_enabled, ctdp_level.fact_enabled);
if (pbf) {
if (ctdp_level.pbf_enabled == enable)
break;
} else {
if (ctdp_level.fact_enabled == enable)
break;
}
}
if (i == FEATURE_ENABLE_RETRIES)
return -1;
return 0;
}
static int tpmi_get_fact_info(struct isst_id *id, int level, int fact_bucket,
struct isst_fact_info *fact_info)
{
struct isst_turbo_freq_info info;
int i, j;
int ret;
memset(&info, 0, sizeof(info));
info.socket_id = id->pkg;
info.power_domain_id = id->punit;
info.level = level;
ret = tpmi_process_ioctl(ISST_IF_GET_TURBO_FREQ_INFO, &info);
if (ret == -1)
return ret;
for (i = 0; i < info.max_clip_freqs; ++i)
fact_info->lp_ratios[i] = info.lp_clip_freq_mhz[i];
if (info.max_buckets > TRL_MAX_BUCKETS)
info.max_buckets = TRL_MAX_BUCKETS;
if (info.max_trl_levels > TRL_MAX_LEVELS)
info.max_trl_levels = TRL_MAX_LEVELS;
for (i = 0; i < info.max_trl_levels; ++i) {
for (j = 0; j < info.max_buckets; ++j)
fact_info->bucket_info[j].hp_ratios[i] =
info.trl_freq_mhz[i][j];
}
for (i = 0; i < info.max_buckets; ++i)
fact_info->bucket_info[i].hp_cores = info.bucket_core_counts[i];
return 0;
}
static void _set_uncore_min_max(struct isst_id *id, int max, int freq)
{
DIR *dir;
FILE *filep;
struct dirent *entry;
char buffer[512];
unsigned int tmp_id;
int ret;
dir = opendir("/sys/devices/system/cpu/intel_uncore_frequency/");
if (!dir)
return;
while ((entry = readdir(dir)) != NULL ) {
/* Check domain_id */
snprintf(buffer, sizeof(buffer),
"/sys/devices/system/cpu/intel_uncore_frequency/%s/domain_id", entry->d_name);
filep = fopen(buffer, "r");
if (!filep)
goto end;
ret = fscanf(filep, "%u", &tmp_id);
fclose(filep);
if (ret != 1)
goto end;
if (tmp_id != id->punit)
continue;
/* Check package_id */
snprintf(buffer, sizeof(buffer),
"/sys/devices/system/cpu/intel_uncore_frequency/%s/package_id", entry->d_name);
filep = fopen(buffer, "r");
if (!filep)
goto end;
ret = fscanf(filep, "%u", &tmp_id);
fclose(filep);
if (ret != 1)
goto end;
if (tmp_id != id->pkg)
continue;
/* Found the right sysfs path, adjust and quit */
if (max)
snprintf(buffer, sizeof(buffer),
"/sys/devices/system/cpu/intel_uncore_frequency/%s/max_freq_khz", entry->d_name);
else
snprintf(buffer, sizeof(buffer),
"/sys/devices/system/cpu/intel_uncore_frequency/%s/min_freq_khz", entry->d_name);
filep = fopen(buffer, "w");
if (!filep)
goto end;
fprintf(filep, "%d\n", freq);
fclose(filep);
break;
}
end:
closedir(dir);
}
static void tpmi_adjust_uncore_freq(struct isst_id *id, int config_index,
struct isst_pkg_ctdp_level_info *ctdp_level)
{
struct isst_perf_level_data_info info;
int ret;
info.socket_id = id->pkg;
info.power_domain_id = id->punit;
info.level = config_index;
ret = tpmi_process_ioctl(ISST_IF_GET_PERF_LEVEL_INFO, &info);
if (ret == -1)
return;
ctdp_level->uncore_p0 = info.p0_fabric_freq_mhz;
ctdp_level->uncore_p1 = info.p1_fabric_freq_mhz;
ctdp_level->uncore_pm = info.pm_fabric_freq_mhz;
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);
return;
}
static int tpmi_get_clos_information(struct isst_id *id, int *enable, int *type)
{
struct isst_core_power info;
int ret;
info.get_set = 0;
info.socket_id = id->pkg;
info.power_domain_id = id->punit;
ret = tpmi_process_ioctl(ISST_IF_CORE_POWER_STATE, &info);
if (ret == -1)
return ret;
*enable = info.enable;
*type = info.priority_type;
return 0;
}
static int tpmi_pm_qos_config(struct isst_id *id, int enable_clos,
int priority_type)
{
struct isst_core_power info;
int cp_state = 0, cp_cap = 0;
int i, j, ret, saved_punit;
info.get_set = 1;
info.socket_id = id->pkg;
info.power_domain_id = id->punit;
info.enable = enable_clos;
info.priority_type = priority_type;
saved_punit = id->punit;
/* Set for all other dies also. This is per package setting */
for (i = 0; i < MAX_PUNIT_PER_DIE; i++) {
id->punit = i;
if (isst_is_punit_valid(id)) {
info.power_domain_id = i;
ret = tpmi_process_ioctl(ISST_IF_CORE_POWER_STATE, &info);
if (ret == -1) {
id->punit = saved_punit;
return ret;
}
/* Get status */
for (j = 0; j < FEATURE_ENABLE_RETRIES; ++j) {
usleep(FEATURE_ENABLE_WAIT_US);
ret = tpmi_read_pm_config(id, &cp_state, &cp_cap);
debug_printf("ret:%d cp_state:%d enable_clos:%d\n", ret,
cp_state, enable_clos);
if (ret || cp_state == enable_clos)
break;
}
if (j == FEATURE_ENABLE_RETRIES) {
id->punit = saved_punit;
return -1;
}
}
}
id->punit = saved_punit;
return 0;
}
int tpmi_pm_get_clos(struct isst_id *id, int clos,
struct isst_clos_config *clos_config)
{
struct isst_clos_param info;
int ret;
info.get_set = 0;
info.socket_id = id->pkg;
info.power_domain_id = id->punit;
info.clos = clos;
ret = tpmi_process_ioctl(ISST_IF_CLOS_PARAM, &info);
if (ret == -1)
return ret;
clos_config->epp = 0;
clos_config->clos_prop_prio = info.prop_prio;
clos_config->clos_min = info.min_freq_mhz;
clos_config->clos_max = info.max_freq_mhz;
clos_config->clos_desired = 0;
debug_printf("cpu:%d clos:%d min:%d max:%d\n", id->cpu, clos,
clos_config->clos_min, clos_config->clos_max);
return 0;
}
int tpmi_set_clos(struct isst_id *id, int clos,
struct isst_clos_config *clos_config)
{
struct isst_clos_param info;
int i, ret, saved_punit;
info.get_set = 1;
info.socket_id = id->pkg;
info.power_domain_id = id->punit;
info.clos = clos;
info.prop_prio = clos_config->clos_prop_prio;
info.min_freq_mhz = clos_config->clos_min;
info.max_freq_mhz = clos_config->clos_max;
if (info.min_freq_mhz <= 0xff)
info.min_freq_mhz *= 100;
if (info.max_freq_mhz <= 0xff)
info.max_freq_mhz *= 100;
saved_punit = id->punit;
/* Set for all other dies also. This is per package setting */
for (i = 0; i < MAX_PUNIT_PER_DIE; i++) {
id->punit = i;
if (isst_is_punit_valid(id)) {
info.power_domain_id = i;
ret = tpmi_process_ioctl(ISST_IF_CLOS_PARAM, &info);
if (ret == -1) {
id->punit = saved_punit;
return ret;
}
}
}
id->punit = saved_punit;
debug_printf("set cpu:%d clos:%d min:%d max:%d\n", id->cpu, clos,
clos_config->clos_min, clos_config->clos_max);
return 0;
}
static int tpmi_clos_get_assoc_status(struct isst_id *id, int *clos_id)
{
struct isst_if_clos_assoc_cmds assoc_cmds;
int ret;
assoc_cmds.cmd_count = 1;
assoc_cmds.get_set = 0;
assoc_cmds.punit_cpu_map = 1;
assoc_cmds.assoc_info[0].logical_cpu = find_phy_core_num(id->cpu);
assoc_cmds.assoc_info[0].socket_id = id->pkg;
assoc_cmds.assoc_info[0].power_domain_id = id->punit;
ret = tpmi_process_ioctl(ISST_IF_CLOS_ASSOC, &assoc_cmds);
if (ret == -1)
return ret;
*clos_id = assoc_cmds.assoc_info[0].clos;
return 0;
}
static int tpmi_clos_associate(struct isst_id *id, int clos_id)
{
struct isst_if_clos_assoc_cmds assoc_cmds;
int ret;
assoc_cmds.cmd_count = 1;
assoc_cmds.get_set = 1;
assoc_cmds.punit_cpu_map = 1;
assoc_cmds.assoc_info[0].logical_cpu = find_phy_core_num(id->cpu);
assoc_cmds.assoc_info[0].clos = clos_id;
assoc_cmds.assoc_info[0].socket_id = id->pkg;
assoc_cmds.assoc_info[0].power_domain_id = id->punit;
ret = tpmi_process_ioctl(ISST_IF_CLOS_ASSOC, &assoc_cmds);
if (ret == -1)
return ret;
return 0;
}
static struct isst_platform_ops tpmi_ops = {
.get_disp_freq_multiplier = tpmi_get_disp_freq_multiplier,
.get_trl_max_levels = tpmi_get_trl_max_levels,
.get_trl_level_name = tpmi_get_trl_level_name,
.update_platform_param = tpmi_update_platform_param,
.is_punit_valid = tpmi_is_punit_valid,
.read_pm_config = tpmi_read_pm_config,
.get_config_levels = tpmi_get_config_levels,
.get_ctdp_control = tpmi_get_ctdp_control,
.get_tdp_info = tpmi_get_tdp_info,
.get_pwr_info = tpmi_get_pwr_info,
.get_coremask_info = tpmi_get_coremask_info,
.get_get_trl = tpmi_get_get_trl,
.get_get_trls = tpmi_get_get_trls,
.get_trl_bucket_info = tpmi_get_trl_bucket_info,
.set_tdp_level = tpmi_set_tdp_level,
.get_pbf_info = tpmi_get_pbf_info,
.set_pbf_fact_status = tpmi_set_pbf_fact_status,
.get_fact_info = tpmi_get_fact_info,
.adjust_uncore_freq = tpmi_adjust_uncore_freq,
.get_clos_information = tpmi_get_clos_information,
.pm_qos_config = tpmi_pm_qos_config,
.pm_get_clos = tpmi_pm_get_clos,
.set_clos = tpmi_set_clos,
.clos_get_assoc_status = tpmi_clos_get_assoc_status,
.clos_associate = tpmi_clos_associate,
};
struct isst_platform_ops *tpmi_get_platform_ops(void)
{
return &tpmi_ops;
}
@@ -0,0 +1,505 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Intel Speed Select -- Enumerate and control features
* Copyright (c) 2019 Intel Corporation.
*/
#include "isst.h"
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(int api_version)
{
switch (api_version) {
case 1:
isst_ops = mbox_get_platform_ops();
break;
case 2:
case 3:
isst_ops = tpmi_get_platform_ops();
break;
default:
isst_ops = NULL;
break;
}
if (!isst_ops)
return -1;
return 0;
}
void isst_update_platform_param(enum isst_platform_param param, int value)
{
CHECK_CB(update_platform_param);
isst_ops->update_platform_param(param, value);
}
int isst_get_disp_freq_multiplier(void)
{
CHECK_CB(get_disp_freq_multiplier);
return isst_ops->get_disp_freq_multiplier();
}
int isst_get_trl_max_levels(void)
{
CHECK_CB(get_trl_max_levels);
return isst_ops->get_trl_max_levels();
}
char *isst_get_trl_level_name(int level)
{
CHECK_CB(get_trl_level_name);
return isst_ops->get_trl_level_name(level);
}
int isst_is_punit_valid(struct isst_id *id)
{
CHECK_CB(is_punit_valid);
return isst_ops->is_punit_valid(id);
}
int isst_send_msr_command(unsigned int cpu, unsigned int msr, int write,
unsigned long long *req_resp)
{
struct isst_if_msr_cmds msr_cmds;
const char *pathname = "/dev/isst_interface";
FILE *outf = get_output_file();
int fd;
fd = open(pathname, O_RDWR);
if (fd < 0)
err(-1, "%s open failed", pathname);
msr_cmds.cmd_count = 1;
msr_cmds.msr_cmd[0].logical_cpu = cpu;
msr_cmds.msr_cmd[0].msr = msr;
msr_cmds.msr_cmd[0].read_write = write;
if (write)
msr_cmds.msr_cmd[0].data = *req_resp;
if (ioctl(fd, ISST_IF_MSR_COMMAND, &msr_cmds) == -1) {
perror("ISST_IF_MSR_COMMAND");
fprintf(outf, "Error: msr_cmd cpu:%d msr:%x read_write:%d\n",
cpu, msr, write);
} else {
if (!write)
*req_resp = msr_cmds.msr_cmd[0].data;
debug_printf(
"msr_cmd response: cpu:%d msr:%x rd_write:%x resp:%llx %llx\n",
cpu, msr, write, *req_resp, msr_cmds.msr_cmd[0].data);
}
close(fd);
return 0;
}
int isst_read_pm_config(struct isst_id *id, int *cp_state, int *cp_cap)
{
CHECK_CB(read_pm_config);
return isst_ops->read_pm_config(id, cp_state, cp_cap);
}
int isst_get_ctdp_levels(struct isst_id *id, struct isst_pkg_ctdp *pkg_dev)
{
CHECK_CB(get_config_levels);
return isst_ops->get_config_levels(id, pkg_dev);
}
int isst_get_ctdp_control(struct isst_id *id, int config_index,
struct isst_pkg_ctdp_level_info *ctdp_level)
{
CHECK_CB(get_ctdp_control);
return isst_ops->get_ctdp_control(id, config_index, ctdp_level);
}
int isst_get_tdp_info(struct isst_id *id, int config_index,
struct isst_pkg_ctdp_level_info *ctdp_level)
{
CHECK_CB(get_tdp_info);
return isst_ops->get_tdp_info(id, config_index, ctdp_level);
}
int isst_get_pwr_info(struct isst_id *id, int config_index,
struct isst_pkg_ctdp_level_info *ctdp_level)
{
CHECK_CB(get_pwr_info);
return isst_ops->get_pwr_info(id, config_index, ctdp_level);
}
int isst_get_coremask_info(struct isst_id *id, int config_index,
struct isst_pkg_ctdp_level_info *ctdp_level)
{
CHECK_CB(get_coremask_info);
return isst_ops->get_coremask_info(id, config_index, ctdp_level);
}
int isst_get_get_trl_from_msr(struct isst_id *id, int *trl)
{
unsigned long long msr_trl;
int ret;
ret = isst_send_msr_command(id->cpu, 0x1AD, 0, &msr_trl);
if (ret)
return ret;
trl[0] = msr_trl & GENMASK(7, 0);
trl[1] = (msr_trl & GENMASK(15, 8)) >> 8;
trl[2] = (msr_trl & GENMASK(23, 16)) >> 16;
trl[3] = (msr_trl & GENMASK(31, 24)) >> 24;
trl[4] = (msr_trl & GENMASK(39, 32)) >> 32;
trl[5] = (msr_trl & GENMASK(47, 40)) >> 40;
trl[6] = (msr_trl & GENMASK(55, 48)) >> 48;
trl[7] = (msr_trl & GENMASK(63, 56)) >> 56;
return 0;
}
int isst_get_get_trl(struct isst_id *id, int level, int avx_level, int *trl)
{
CHECK_CB(get_get_trl);
return isst_ops->get_get_trl(id, level, avx_level, trl);
}
int isst_get_get_trls(struct isst_id *id, int level, struct isst_pkg_ctdp_level_info *ctdp_level)
{
CHECK_CB(get_get_trls);
return isst_ops->get_get_trls(id, level, ctdp_level);
}
int isst_get_trl_bucket_info(struct isst_id *id, int level, unsigned long long *buckets_info)
{
CHECK_CB(get_trl_bucket_info);
return isst_ops->get_trl_bucket_info(id, level, buckets_info);
}
int isst_set_tdp_level(struct isst_id *id, int tdp_level)
{
CHECK_CB(set_tdp_level);
return isst_ops->set_tdp_level(id, tdp_level);
}
int isst_get_pbf_info(struct isst_id *id, int level, struct isst_pbf_info *pbf_info)
{
struct isst_pkg_ctdp_level_info ctdp_level;
struct isst_pkg_ctdp pkg_dev;
int ret;
ret = isst_get_ctdp_levels(id, &pkg_dev);
if (ret) {
isst_display_error_info_message(1, "Failed to get number of levels", 0, 0);
return ret;
}
if (level > pkg_dev.levels) {
isst_display_error_info_message(1, "Invalid level", 1, level);
return -1;
}
ret = isst_get_ctdp_control(id, level, &ctdp_level);
if (ret)
return ret;
if (!ctdp_level.pbf_support) {
isst_display_error_info_message(1, "base-freq feature is not present at this level", 1, level);
return -1;
}
pbf_info->core_cpumask_size = alloc_cpu_set(&pbf_info->core_cpumask);
CHECK_CB(get_pbf_info);
return isst_ops->get_pbf_info(id, level, pbf_info);
}
int isst_set_pbf_fact_status(struct isst_id *id, int pbf, int enable)
{
CHECK_CB(set_pbf_fact_status);
return isst_ops->set_pbf_fact_status(id, pbf, enable);
}
int isst_get_fact_info(struct isst_id *id, int level, int fact_bucket, struct isst_fact_info *fact_info)
{
struct isst_pkg_ctdp_level_info ctdp_level;
struct isst_pkg_ctdp pkg_dev;
int ret;
ret = isst_get_ctdp_levels(id, &pkg_dev);
if (ret) {
isst_display_error_info_message(1, "Failed to get number of levels", 0, 0);
return ret;
}
if (level > pkg_dev.levels) {
isst_display_error_info_message(1, "Invalid level", 1, level);
return -1;
}
ret = isst_get_ctdp_control(id, level, &ctdp_level);
if (ret)
return ret;
if (!ctdp_level.fact_support) {
isst_display_error_info_message(1, "turbo-freq feature is not present at this level", 1, level);
return -1;
}
CHECK_CB(get_fact_info);
return isst_ops->get_fact_info(id, level, fact_bucket, fact_info);
}
int isst_get_trl(struct isst_id *id, unsigned long long *trl)
{
int ret;
ret = isst_send_msr_command(id->cpu, 0x1AD, 0, trl);
if (ret)
return ret;
return 0;
}
int isst_set_trl(struct isst_id *id, unsigned long long trl)
{
int ret;
if (!trl)
trl = 0xFFFFFFFFFFFFFFFFULL;
ret = isst_send_msr_command(id->cpu, 0x1AD, 1, &trl);
if (ret)
return ret;
return 0;
}
#define MSR_TRL_FREQ_MULTIPLIER 100
int isst_set_trl_from_current_tdp(struct isst_id *id, unsigned long long trl)
{
unsigned long long msr_trl;
int ret;
if (id->cpu < 0)
return 0;
if (trl) {
msr_trl = trl;
} else {
struct isst_pkg_ctdp pkg_dev;
int trl[8];
int i;
ret = isst_get_ctdp_levels(id, &pkg_dev);
if (ret)
return ret;
ret = isst_get_get_trl(id, pkg_dev.current_level, 0, trl);
if (ret)
return ret;
msr_trl = 0;
for (i = 0; i < 8; ++i) {
unsigned long long _trl = trl[i];
/* MSR is always in 100 MHz unit */
if (isst_get_disp_freq_multiplier() == 1)
_trl /= MSR_TRL_FREQ_MULTIPLIER;
msr_trl |= (_trl << (i * 8));
}
}
ret = isst_send_msr_command(id->cpu, 0x1AD, 1, &msr_trl);
if (ret)
return ret;
return 0;
}
/* Return 1 if locked */
int isst_get_config_tdp_lock_status(struct isst_id *id)
{
unsigned long long tdp_control = 0;
int ret;
ret = isst_send_msr_command(id->cpu, 0x64b, 0, &tdp_control);
if (ret)
return ret;
ret = !!(tdp_control & BIT(31));
return ret;
}
void isst_get_process_ctdp_complete(struct isst_id *id, struct isst_pkg_ctdp *pkg_dev)
{
int i;
if (!pkg_dev->processed)
return;
for (i = 0; i < pkg_dev->levels; ++i) {
struct isst_pkg_ctdp_level_info *ctdp_level;
ctdp_level = &pkg_dev->ctdp_level[i];
if (ctdp_level->pbf_support)
free_cpu_set(ctdp_level->pbf_info.core_cpumask);
free_cpu_set(ctdp_level->core_cpumask);
}
}
void isst_adjust_uncore_freq(struct isst_id *id, int config_index,
struct isst_pkg_ctdp_level_info *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)
{
int i, ret, valid = 0;
if (pkg_dev->processed)
return 0;
ret = isst_get_ctdp_levels(id, pkg_dev);
if (ret)
return ret;
debug_printf("cpu: %d ctdp enable:%d current level: %d levels:%d\n",
id->cpu, pkg_dev->enabled, pkg_dev->current_level,
pkg_dev->levels);
if (tdp_level != 0xff && tdp_level > pkg_dev->levels) {
isst_display_error_info_message(1, "Invalid level", 0, 0);
return -1;
}
if (!pkg_dev->enabled)
isst_display_error_info_message(0, "perf-profile feature is not supported, just base-config level 0 is valid", 0, 0);
for (i = 0; i <= pkg_dev->levels; ++i) {
struct isst_pkg_ctdp_level_info *ctdp_level;
if (tdp_level != 0xff && i != tdp_level)
continue;
debug_printf("cpu:%d Get Information for TDP level:%d\n", id->cpu,
i);
ctdp_level = &pkg_dev->ctdp_level[i];
ctdp_level->level = i;
ctdp_level->control_cpu = id->cpu;
ctdp_level->pkg_id = id->pkg;
ctdp_level->die_id = id->die;
ret = isst_get_ctdp_control(id, i, ctdp_level);
if (ret)
continue;
valid = 1;
pkg_dev->processed = 1;
ctdp_level->processed = 1;
if (ctdp_level->pbf_support) {
ret = isst_get_pbf_info(id, i, &ctdp_level->pbf_info);
if (!ret)
ctdp_level->pbf_found = 1;
}
if (ctdp_level->fact_support) {
ret = isst_get_fact_info(id, i, 0xff,
&ctdp_level->fact_info);
if (ret)
return ret;
}
if (!pkg_dev->enabled && is_skx_based_platform()) {
int freq;
freq = get_cpufreq_base_freq(id->cpu);
if (freq > 0) {
ctdp_level->sse_p1 = freq / 100000;
ctdp_level->tdp_ratio = ctdp_level->sse_p1;
}
isst_get_get_trl_from_msr(id, ctdp_level->trl_ratios[0]);
isst_get_trl_bucket_info(id, i, &ctdp_level->trl_cores);
continue;
}
ret = isst_get_tdp_info(id, i, ctdp_level);
if (ret)
return ret;
ret = isst_get_pwr_info(id, i, ctdp_level);
if (ret)
return ret;
ctdp_level->core_cpumask_size =
alloc_cpu_set(&ctdp_level->core_cpumask);
ret = isst_get_coremask_info(id, i, ctdp_level);
if (ret)
return ret;
ret = isst_get_trl_bucket_info(id, i, &ctdp_level->trl_cores);
if (ret)
return ret;
ret = isst_get_get_trls(id, i, ctdp_level);
if (ret)
return ret;
}
if (!valid)
isst_display_error_info_message(0, "Invalid level, Can't get TDP control information at specified levels on cpu", 1, id->cpu);
return 0;
}
int isst_clos_get_clos_information(struct isst_id *id, int *enable, int *type)
{
CHECK_CB(get_clos_information);
return isst_ops->get_clos_information(id, enable, type);
}
int isst_pm_qos_config(struct isst_id *id, int enable_clos, int priority_type)
{
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)
{
CHECK_CB(pm_get_clos);
return isst_ops->pm_get_clos(id, clos, clos_config);
}
int isst_set_clos(struct isst_id *id, int clos, struct isst_clos_config *clos_config)
{
CHECK_CB(set_clos);
return isst_ops->set_clos(id, clos, clos_config);
}
int isst_clos_get_assoc_status(struct isst_id *id, int *clos_id)
{
CHECK_CB(clos_get_assoc_status);
return isst_ops->clos_get_assoc_status(id, clos_id);
}
int isst_clos_associate(struct isst_id *id, int clos_id)
{
CHECK_CB(clos_associate);
return isst_ops->clos_associate(id, clos_id);
}
@@ -0,0 +1,263 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Intel Speed Select -- Allow speed select to daemonize
* Copyright (c) 2022 Intel Corporation.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/file.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <getopt.h>
#include <signal.h>
#include <time.h>
#include "isst.h"
static int per_package_levels_info[MAX_PACKAGE_COUNT][MAX_DIE_PER_PACKAGE][MAX_PUNIT_PER_DIE];
static time_t per_package_levels_tm[MAX_PACKAGE_COUNT][MAX_DIE_PER_PACKAGE][MAX_PUNIT_PER_DIE];
static void init_levels(void)
{
int i, j, k;
for (i = 0; i < MAX_PACKAGE_COUNT; ++i)
for (j = 0; j < MAX_DIE_PER_PACKAGE; ++j)
for (k = 0; k < MAX_PUNIT_PER_DIE; ++k)
per_package_levels_info[i][j][k] = -1;
}
void process_level_change(struct isst_id *id)
{
struct isst_pkg_ctdp_level_info ctdp_level;
struct isst_pkg_ctdp pkg_dev;
time_t tm;
int ret;
if (id->pkg < 0 || id->die < 0 || id->punit < 0) {
debug_printf("Invalid package/die info for cpu:%d\n", id->cpu);
return;
}
tm = time(NULL);
if (tm - per_package_levels_tm[id->pkg][id->die][id->punit] < 2)
return;
per_package_levels_tm[id->pkg][id->die][id->punit] = tm;
ret = isst_get_ctdp_levels(id, &pkg_dev);
if (ret) {
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", 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[id->pkg][id->die][id->punit] == pkg_dev.current_level)
return;
debug_printf("**Config level change for cpu:%d pkg:%d die:%d from %d to %d\n",
id->cpu, id->pkg, id->die, per_package_levels_info[id->pkg][id->die][id->punit],
pkg_dev.current_level);
per_package_levels_info[id->pkg][id->die][id->punit] = pkg_dev.current_level;
ctdp_level.core_cpumask_size =
alloc_cpu_set(&ctdp_level.core_cpumask);
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", id->cpu);
return;
}
if (use_cgroupv2()) {
int ret;
ret = enable_cpuset_controller();
if (ret)
goto use_offline;
isolate_cpus(id, ctdp_level.core_cpumask_size, ctdp_level.core_cpumask,
pkg_dev.current_level, 0);
goto free_mask;
}
use_offline:
if (ctdp_level.cpu_count) {
int i, max_cpus = get_topo_max_cpus();
for (i = 0; i < max_cpus; ++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);
set_cpu_online_offline(i, 1);
} else {
fprintf(stderr, "offline cpu %d\n", i);
set_cpu_online_offline(i, 0);
}
}
}
free_mask:
free_cpu_set(ctdp_level.core_cpumask);
}
static void _poll_for_config_change(struct isst_id *id, void *arg1, void *arg2,
void *arg3, void *arg4)
{
process_level_change(id);
}
static void poll_for_config_change(void)
{
for_each_online_power_domain_in_set(_poll_for_config_change, NULL, NULL,
NULL, NULL);
}
static int done = 0;
static int pid_file_handle;
static void signal_handler(int sig)
{
switch (sig) {
case SIGINT:
case SIGTERM:
done = 1;
hfi_exit();
exit(0);
break;
default:
break;
}
}
static void daemonize(char *rundir, char *pidfile)
{
int pid, sid, i;
char str[10];
struct stat st;
struct sigaction sig_actions;
sigset_t sig_set;
int ret;
if (getppid() == 1)
return;
sigemptyset(&sig_set);
sigaddset(&sig_set, SIGCHLD);
sigaddset(&sig_set, SIGTSTP);
sigaddset(&sig_set, SIGTTOU);
sigaddset(&sig_set, SIGTTIN);
sigprocmask(SIG_BLOCK, &sig_set, NULL);
sig_actions.sa_handler = signal_handler;
sigemptyset(&sig_actions.sa_mask);
sig_actions.sa_flags = 0;
sigaction(SIGHUP, &sig_actions, NULL);
sigaction(SIGTERM, &sig_actions, NULL);
sigaction(SIGINT, &sig_actions, NULL);
pid = fork();
if (pid < 0) {
/* Could not fork */
exit(EXIT_FAILURE);
}
if (pid > 0)
exit(EXIT_SUCCESS);
umask(027);
sid = setsid();
if (sid < 0)
exit(EXIT_FAILURE);
/* close all descriptors */
for (i = getdtablesize(); i >= 0; --i)
close(i);
i = open("/dev/null", O_RDWR);
if (i < 0)
exit(EXIT_FAILURE);
ret = dup(i);
if (ret == -1)
exit(EXIT_FAILURE);
ret = chdir(rundir);
if (ret == -1)
exit(EXIT_FAILURE);
pid_file_handle = open(pidfile, O_RDWR | O_CREAT | O_NOFOLLOW, 0600);
if (pid_file_handle == -1) {
/* Couldn't open lock file */
exit(1);
}
if (fstat(pid_file_handle, &st) == -1)
exit(1);
if (!S_ISREG(st.st_mode))
exit(1);
/* Try to lock file */
#ifdef LOCKF_SUPPORT
if (lockf(pid_file_handle, F_TLOCK, 0) == -1) {
#else
if (flock(pid_file_handle, LOCK_EX|LOCK_NB) < 0) {
#endif
/* Couldn't get lock on lock file */
fprintf(stderr, "Couldn't get lock file %d\n", getpid());
exit(1);
}
snprintf(str, sizeof(str), "%d\n", getpid());
ret = write(pid_file_handle, str, strlen(str));
if (ret == -1)
exit(EXIT_FAILURE);
close(i);
}
int isst_daemon(int debug_mode, int poll_interval, int no_daemon)
{
int ret;
if (!no_daemon && poll_interval < 0 && !debug_mode) {
fprintf(stderr, "OOB mode is enabled and will run as daemon\n");
daemonize((char *) "/tmp/",
(char *)"/tmp/hfi-events.pid");
} else {
signal(SIGINT, signal_handler);
}
init_levels();
if (poll_interval < 0) {
ret = hfi_main();
if (ret) {
fprintf(stderr, "HFI initialization failed\n");
}
fprintf(stderr, "Must specify poll-interval\n");
return ret;
}
debug_printf("Starting loop\n");
while (!done) {
sleep(poll_interval);
poll_for_config_change();
}
return 0;
}
@@ -0,0 +1,804 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Intel dynamic_speed_select -- Enumerate and control features
* Copyright (c) 2019 Intel Corporation.
*/
#include "isst.h"
static void printcpulist(int str_len, char *str, int mask_size,
cpu_set_t *cpu_mask)
{
int i, first, curr_index, index;
if (!CPU_COUNT_S(mask_size, cpu_mask)) {
snprintf(str, str_len, "none");
return;
}
curr_index = 0;
first = 1;
for (i = 0; i < get_topo_max_cpus(); ++i) {
if (!CPU_ISSET_S(i, mask_size, cpu_mask))
continue;
if (!first) {
index = snprintf(&str[curr_index],
str_len - curr_index, ",");
curr_index += index;
if (curr_index >= str_len)
break;
}
index = snprintf(&str[curr_index], str_len - curr_index, "%d",
i);
curr_index += index;
if (curr_index >= str_len)
break;
first = 0;
}
}
static void printcpumask(int str_len, char *str, int mask_size,
cpu_set_t *cpu_mask)
{
int i, max_cpus = get_topo_max_cpus();
unsigned int *mask;
int size, index, curr_index;
size = max_cpus / (sizeof(unsigned int) * 8);
if (max_cpus % (sizeof(unsigned int) * 8))
size++;
mask = calloc(size, sizeof(unsigned int));
if (!mask)
return;
for (i = 0; i < max_cpus; ++i) {
int mask_index, bit_index;
if (!CPU_ISSET_S(i, mask_size, cpu_mask))
continue;
mask_index = i / (sizeof(unsigned int) * 8);
bit_index = i % (sizeof(unsigned int) * 8);
mask[mask_index] |= BIT(bit_index);
}
curr_index = 0;
for (i = size - 1; i >= 0; --i) {
index = snprintf(&str[curr_index], str_len - curr_index, "%08x",
mask[i]);
curr_index += index;
if (curr_index >= str_len)
break;
if (i) {
strncat(&str[curr_index], ",", str_len - curr_index);
curr_index++;
}
if (curr_index >= str_len)
break;
}
free(mask);
}
static void format_and_print_txt(FILE *outf, int level, char *header,
char *value)
{
char *spaces = " ";
static char delimiters[256];
int i, j = 0;
if (!level)
return;
if (level == 1) {
strcpy(delimiters, " ");
} else {
for (i = 0; i < level - 1; ++i)
j += snprintf(&delimiters[j], sizeof(delimiters) - j,
"%s", spaces);
}
if (header && value) {
fprintf(outf, "%s", delimiters);
fprintf(outf, "%s:%s\n", header, value);
} else if (header) {
fprintf(outf, "%s", delimiters);
fprintf(outf, "%s\n", header);
}
}
static int last_level;
static void format_and_print(FILE *outf, int level, char *header, char *value)
{
char *spaces = " ";
static char delimiters[256];
int i;
if (!out_format_is_json()) {
format_and_print_txt(outf, level, header, value);
return;
}
if (level == 0) {
if (header)
fprintf(outf, "{");
else
fprintf(outf, "\n}\n");
} else {
int j = 0;
for (i = 0; i < level; ++i)
j += snprintf(&delimiters[j], sizeof(delimiters) - j,
"%s", spaces);
if (last_level == level)
fprintf(outf, ",\n");
if (value) {
if (last_level != level)
fprintf(outf, "\n");
fprintf(outf, "%s\"%s\": ", delimiters, header);
fprintf(outf, "\"%s\"", value);
} else {
for (i = last_level - 1; i >= level; --i) {
int k = 0;
for (j = i; j > 0; --j)
k += snprintf(&delimiters[k],
sizeof(delimiters) - k,
"%s", spaces);
if (i == level && header)
fprintf(outf, "\n%s},", delimiters);
else
fprintf(outf, "\n%s}", delimiters);
}
if (abs(last_level - level) < 3)
fprintf(outf, "\n");
if (header)
fprintf(outf, "%s\"%s\": {", delimiters,
header);
}
}
last_level = level;
}
static int print_package_info(struct isst_id *id, FILE *outf)
{
char header[256];
int level = 1;
if (out_format_is_json()) {
if (api_version() > 1) {
if (id->die < 0 && id->cpu < 0)
snprintf(header, sizeof(header),
"package-%d:die-IO:powerdomain-%d:cpu-None",
id->pkg, id->punit);
else if (id->cpu < 0)
snprintf(header, sizeof(header),
"package-%d:die-%d:powerdomain-%d:cpu-None",
id->pkg, id->die, id->punit);
else
snprintf(header, sizeof(header),
"package-%d:die-%d:powerdomain-%d:cpu-%d",
id->pkg, id->die, id->punit, id->cpu);
} else {
snprintf(header, sizeof(header), "package-%d:die-%d:cpu-%d",
id->pkg, id->die, id->cpu);
}
format_and_print(outf, level, header, NULL);
return 1;
}
snprintf(header, sizeof(header), "package-%d", id->pkg);
format_and_print(outf, level++, header, NULL);
if (id->die < 0)
snprintf(header, sizeof(header), "die-IO");
else
snprintf(header, sizeof(header), "die-%d", id->die);
format_and_print(outf, level++, header, NULL);
if (api_version() > 1) {
snprintf(header, sizeof(header), "powerdomain-%d", id->punit);
format_and_print(outf, level++, header, NULL);
}
if (id->cpu < 0)
snprintf(header, sizeof(header), "cpu-None");
else
snprintf(header, sizeof(header), "cpu-%d", id->cpu);
format_and_print(outf, level, header, NULL);
return level;
}
static void _isst_pbf_display_information(struct isst_id *id, FILE *outf, int level,
struct isst_pbf_info *pbf_info,
int disp_level)
{
static char header[256];
static char value[1024];
snprintf(header, sizeof(header), "speed-select-base-freq-properties");
format_and_print(outf, disp_level, header, NULL);
snprintf(header, sizeof(header), "high-priority-base-frequency(MHz)");
snprintf(value, sizeof(value), "%d",
pbf_info->p1_high * isst_get_disp_freq_multiplier());
format_and_print(outf, disp_level + 1, header, value);
snprintf(header, sizeof(header), "high-priority-cpu-mask");
printcpumask(sizeof(value), value, pbf_info->core_cpumask_size,
pbf_info->core_cpumask);
format_and_print(outf, disp_level + 1, header, value);
snprintf(header, sizeof(header), "high-priority-cpu-list");
printcpulist(sizeof(value), value,
pbf_info->core_cpumask_size,
pbf_info->core_cpumask);
format_and_print(outf, disp_level + 1, header, value);
snprintf(header, sizeof(header), "low-priority-base-frequency(MHz)");
snprintf(value, sizeof(value), "%d",
pbf_info->p1_low * isst_get_disp_freq_multiplier());
format_and_print(outf, disp_level + 1, header, value);
if (is_clx_n_platform())
return;
snprintf(header, sizeof(header), "tjunction-temperature(C)");
snprintf(value, sizeof(value), "%d", pbf_info->t_prochot);
format_and_print(outf, disp_level + 1, header, value);
snprintf(header, sizeof(header), "thermal-design-power(W)");
snprintf(value, sizeof(value), "%d", pbf_info->tdp);
format_and_print(outf, disp_level + 1, header, value);
}
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)
{
struct isst_fact_bucket_info *bucket_info = fact_info->bucket_info;
int trl_max_levels = isst_get_trl_max_levels();
char header[256];
char value[256];
int print = 0, j;
for (j = 0; j < ISST_FACT_MAX_BUCKETS; ++j) {
if (fact_bucket != 0xff && fact_bucket != j)
continue;
/* core count must be valid for CPU power domain */
if (!bucket_info[j].hp_cores && id->cpu >= 0)
break;
print = 1;
}
if (!print) {
fprintf(stderr, "Invalid bucket\n");
return;
}
snprintf(header, sizeof(header), "speed-select-turbo-freq-properties");
format_and_print(outf, base_level, header, NULL);
for (j = 0; j < ISST_FACT_MAX_BUCKETS; ++j) {
int i;
if (fact_bucket != 0xff && fact_bucket != j)
continue;
if (!bucket_info[j].hp_cores)
break;
snprintf(header, sizeof(header), "bucket-%d", j);
format_and_print(outf, base_level + 1, header, NULL);
snprintf(header, sizeof(header), "high-priority-cores-count");
snprintf(value, sizeof(value), "%d",
bucket_info[j].hp_cores);
format_and_print(outf, base_level + 2, header, value);
for (i = 0; i < trl_max_levels; i++) {
if (!bucket_info[j].hp_ratios[i] || (fact_avx != 0xFF && !(fact_avx & (1 << i))))
continue;
if (i == 0 && api_version() == 1 && !is_emr_platform())
snprintf(header, sizeof(header),
"high-priority-max-frequency(MHz)");
else
snprintf(header, sizeof(header),
"high-priority-max-%s-frequency(MHz)", isst_get_trl_level_name(i));
snprintf(value, sizeof(value), "%d",
bucket_info[j].hp_ratios[i] * isst_get_disp_freq_multiplier());
format_and_print(outf, base_level + 2, header, value);
}
}
snprintf(header, sizeof(header),
"speed-select-turbo-freq-clip-frequencies");
format_and_print(outf, base_level + 1, header, NULL);
for (j = 0; j < trl_max_levels; j++) {
if (!fact_info->lp_ratios[j])
continue;
/* No AVX level name for SSE to be consistent with previous formatting */
if (j == 0 && api_version() == 1 && !is_emr_platform())
snprintf(header, sizeof(header), "low-priority-max-frequency(MHz)");
else
snprintf(header, sizeof(header), "low-priority-max-%s-frequency(MHz)",
isst_get_trl_level_name(j));
snprintf(value, sizeof(value), "%d",
fact_info->lp_ratios[j] * isst_get_disp_freq_multiplier());
format_and_print(outf, base_level + 2, header, value);
}
}
void isst_ctdp_display_core_info(struct isst_id *id, FILE *outf, char *prefix,
unsigned int val, char *str0, char *str1)
{
char value[256];
int level = print_package_info(id, outf);
level++;
if (str0 && !val)
snprintf(value, sizeof(value), "%s", str0);
else if (str1 && val)
snprintf(value, sizeof(value), "%s", str1);
else
snprintf(value, sizeof(value), "%u", val);
format_and_print(outf, level, prefix, value);
format_and_print(outf, 1, NULL, NULL);
}
void isst_ctdp_display_information(struct isst_id *id, FILE *outf, int tdp_level,
struct isst_pkg_ctdp *pkg_dev)
{
static char header[256];
static char value[1024];
static int level;
int trl_max_levels = isst_get_trl_max_levels();
int i;
if (pkg_dev->processed)
level = print_package_info(id, outf);
for (i = 0; i <= pkg_dev->levels; ++i) {
struct isst_pkg_ctdp_level_info *ctdp_level;
int j, k;
ctdp_level = &pkg_dev->ctdp_level[i];
if (!ctdp_level->processed)
continue;
snprintf(header, sizeof(header), "perf-profile-level-%d",
ctdp_level->level);
format_and_print(outf, level + 1, header, NULL);
if (id->cpu >= 0) {
snprintf(header, sizeof(header), "cpu-count");
j = get_cpu_count(id);
snprintf(value, sizeof(value), "%d", j);
format_and_print(outf, level + 2, header, value);
j = CPU_COUNT_S(ctdp_level->core_cpumask_size,
ctdp_level->core_cpumask);
if (j) {
snprintf(header, sizeof(header), "enable-cpu-count");
snprintf(value, sizeof(value), "%d", j);
format_and_print(outf, level + 2, header, value);
}
if (ctdp_level->core_cpumask_size) {
snprintf(header, sizeof(header), "enable-cpu-mask");
printcpumask(sizeof(value), value,
ctdp_level->core_cpumask_size,
ctdp_level->core_cpumask);
format_and_print(outf, level + 2, header, value);
snprintf(header, sizeof(header), "enable-cpu-list");
printcpulist(sizeof(value), value,
ctdp_level->core_cpumask_size,
ctdp_level->core_cpumask);
format_and_print(outf, level + 2, header, value);
}
}
snprintf(header, sizeof(header), "thermal-design-power-ratio");
snprintf(value, sizeof(value), "%d", ctdp_level->tdp_ratio);
format_and_print(outf, level + 2, header, value);
snprintf(header, sizeof(header), "base-frequency(MHz)");
if (!ctdp_level->sse_p1)
ctdp_level->sse_p1 = ctdp_level->tdp_ratio;
snprintf(value, sizeof(value), "%d",
ctdp_level->sse_p1 * isst_get_disp_freq_multiplier());
format_and_print(outf, level + 2, header, value);
if (ctdp_level->avx2_p1) {
snprintf(header, sizeof(header), "base-frequency-avx2(MHz)");
snprintf(value, sizeof(value), "%d",
ctdp_level->avx2_p1 * isst_get_disp_freq_multiplier());
format_and_print(outf, level + 2, header, value);
}
if (ctdp_level->avx512_p1) {
snprintf(header, sizeof(header), "base-frequency-avx512(MHz)");
snprintf(value, sizeof(value), "%d",
ctdp_level->avx512_p1 * isst_get_disp_freq_multiplier());
format_and_print(outf, level + 2, header, value);
}
if (ctdp_level->uncore_pm) {
snprintf(header, sizeof(header), "uncore-frequency-min(MHz)");
snprintf(value, sizeof(value), "%d",
ctdp_level->uncore_pm * isst_get_disp_freq_multiplier());
format_and_print(outf, level + 2, header, value);
}
if (ctdp_level->uncore_p0) {
snprintf(header, sizeof(header), "uncore-frequency-max(MHz)");
snprintf(value, sizeof(value), "%d",
ctdp_level->uncore_p0 * isst_get_disp_freq_multiplier());
format_and_print(outf, level + 2, header, value);
}
if (ctdp_level->amx_p1) {
snprintf(header, sizeof(header), "base-frequency-amx(MHz)");
snprintf(value, sizeof(value), "%d",
ctdp_level->amx_p1 * isst_get_disp_freq_multiplier());
format_and_print(outf, level + 2, header, value);
}
if (ctdp_level->uncore_p1) {
snprintf(header, sizeof(header), "uncore-frequency-base(MHz)");
snprintf(value, sizeof(value), "%d",
ctdp_level->uncore_p1 * isst_get_disp_freq_multiplier());
format_and_print(outf, level + 2, header, value);
}
if (ctdp_level->uncore1_p1) {
snprintf(header, sizeof(header), "uncore-1-frequency-base(MHz)");
snprintf(value, sizeof(value), "%d",
ctdp_level->uncore1_p1 * isst_get_disp_freq_multiplier());
format_and_print(outf, level + 2, header, value);
}
if (ctdp_level->uncore1_pm) {
snprintf(header, sizeof(header), "uncore-1-frequency-min(MHz)");
snprintf(value, sizeof(value), "%d",
ctdp_level->uncore1_pm * isst_get_disp_freq_multiplier());
format_and_print(outf, level + 2, header, value);
}
if (ctdp_level->uncore1_p0) {
snprintf(header, sizeof(header), "uncore-1-frequency-max(MHz)");
snprintf(value, sizeof(value), "%d",
ctdp_level->uncore1_p0 * isst_get_disp_freq_multiplier());
format_and_print(outf, level + 2, header, value);
}
if (ctdp_level->mem_freq) {
snprintf(header, sizeof(header), "max-mem-frequency(MHz)");
snprintf(value, sizeof(value), "%d",
ctdp_level->mem_freq);
format_and_print(outf, level + 2, header, value);
}
if (api_version() > 1) {
snprintf(header, sizeof(header), "cooling_type");
snprintf(value, sizeof(value), "%d",
ctdp_level->cooling_type);
format_and_print(outf, level + 2, header, value);
}
snprintf(header, sizeof(header),
"speed-select-turbo-freq");
if (ctdp_level->fact_support) {
if (ctdp_level->fact_enabled)
snprintf(value, sizeof(value), "enabled");
else
snprintf(value, sizeof(value), "disabled");
} else
snprintf(value, sizeof(value), "unsupported");
format_and_print(outf, level + 2, header, value);
snprintf(header, sizeof(header),
"speed-select-base-freq");
if (ctdp_level->pbf_support) {
if (ctdp_level->pbf_enabled)
snprintf(value, sizeof(value), "enabled");
else
snprintf(value, sizeof(value), "disabled");
} else
snprintf(value, sizeof(value), "unsupported");
format_and_print(outf, level + 2, header, value);
snprintf(header, sizeof(header),
"speed-select-core-power");
if (ctdp_level->sst_cp_support) {
if (ctdp_level->sst_cp_enabled)
snprintf(value, sizeof(value), "enabled");
else
snprintf(value, sizeof(value), "disabled");
} else
snprintf(value, sizeof(value), "unsupported");
format_and_print(outf, level + 2, header, value);
if (is_clx_n_platform()) {
if (ctdp_level->pbf_support)
_isst_pbf_display_information(id, outf,
tdp_level,
&ctdp_level->pbf_info,
level + 2);
continue;
}
if (ctdp_level->pkg_tdp) {
snprintf(header, sizeof(header), "thermal-design-power(W)");
snprintf(value, sizeof(value), "%d", ctdp_level->pkg_tdp);
format_and_print(outf, level + 2, header, value);
}
if (ctdp_level->t_proc_hot) {
snprintf(header, sizeof(header), "tjunction-max(C)");
snprintf(value, sizeof(value), "%d", ctdp_level->t_proc_hot);
format_and_print(outf, level + 2, header, value);
}
for (k = 0; k < trl_max_levels; k++) {
if (!ctdp_level->trl_ratios[k][0])
continue;
snprintf(header, sizeof(header), "turbo-ratio-limits-%s", isst_get_trl_level_name(k));
format_and_print(outf, level + 2, header, NULL);
for (j = 0; j < 8; ++j) {
snprintf(header, sizeof(header), "bucket-%d", j);
format_and_print(outf, level + 3, header, NULL);
snprintf(header, sizeof(header), "core-count");
snprintf(value, sizeof(value), "%llu", (ctdp_level->trl_cores >> (j * 8)) & 0xff);
format_and_print(outf, level + 4, header, value);
snprintf(header, sizeof(header), "max-turbo-frequency(MHz)");
snprintf(value, sizeof(value), "%d", ctdp_level->trl_ratios[k][j] * isst_get_disp_freq_multiplier());
format_and_print(outf, level + 4, header, value);
}
}
if (ctdp_level->pbf_support)
_isst_pbf_display_information(id, outf, i,
&ctdp_level->pbf_info,
level + 2);
if (ctdp_level->fact_support)
_isst_fact_display_information(id, outf, i, 0xff, 0xff,
&ctdp_level->fact_info,
level + 2);
}
format_and_print(outf, 1, NULL, NULL);
}
static int start;
void isst_ctdp_display_information_start(FILE *outf)
{
last_level = 0;
format_and_print(outf, 0, "start", NULL);
start = 1;
}
void isst_ctdp_display_information_end(FILE *outf)
{
format_and_print(outf, 0, NULL, NULL);
start = 0;
}
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(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(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(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(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(id, outf);
snprintf(header, sizeof(header), "core-power");
format_and_print(outf, level + 1, header, NULL);
snprintf(header, sizeof(header), "clos");
snprintf(value, sizeof(value), "%d", clos);
format_and_print(outf, level + 2, header, value);
snprintf(header, sizeof(header), "epp");
snprintf(value, sizeof(value), "%d", clos_config->epp);
format_and_print(outf, level + 2, header, value);
snprintf(header, sizeof(header), "clos-proportional-priority");
snprintf(value, sizeof(value), "%d", clos_config->clos_prop_prio);
format_and_print(outf, level + 2, header, value);
snprintf(header, sizeof(header), "clos-min");
snprintf(value, sizeof(value), "%d MHz", clos_config->clos_min * isst_get_disp_freq_multiplier());
format_and_print(outf, level + 2, header, value);
snprintf(header, sizeof(header), "clos-max");
if ((clos_config->clos_max * isst_get_disp_freq_multiplier()) == 25500)
snprintf(value, sizeof(value), "Max Turbo frequency");
else
snprintf(value, sizeof(value), "%d MHz", clos_config->clos_max * isst_get_disp_freq_multiplier());
format_and_print(outf, level + 2, header, value);
snprintf(header, sizeof(header), "clos-desired");
snprintf(value, sizeof(value), "%d MHz", clos_config->clos_desired * isst_get_disp_freq_multiplier());
format_and_print(outf, level + 2, header, value);
format_and_print(outf, level, NULL, NULL);
}
void isst_clos_display_clos_information(struct isst_id *id, FILE *outf,
int clos_enable, int type,
int state, int cap)
{
char header[256];
char value[256];
int level;
level = print_package_info(id, outf);
snprintf(header, sizeof(header), "core-power");
format_and_print(outf, level + 1, header, NULL);
snprintf(header, sizeof(header), "support-status");
if (cap)
snprintf(value, sizeof(value), "supported");
else
snprintf(value, sizeof(value), "unsupported");
format_and_print(outf, level + 2, header, value);
snprintf(header, sizeof(header), "enable-status");
if (state)
snprintf(value, sizeof(value), "enabled");
else
snprintf(value, sizeof(value), "disabled");
format_and_print(outf, level + 2, header, value);
snprintf(header, sizeof(header), "clos-enable-status");
if (clos_enable)
snprintf(value, sizeof(value), "enabled");
else
snprintf(value, sizeof(value), "disabled");
format_and_print(outf, level + 2, header, value);
snprintf(header, sizeof(header), "priority-type");
if (type)
snprintf(value, sizeof(value), "ordered");
else
snprintf(value, sizeof(value), "proportional");
format_and_print(outf, level + 2, header, value);
format_and_print(outf, level, NULL, NULL);
}
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(id, outf);
snprintf(header, sizeof(header), "get-assoc");
format_and_print(outf, level + 1, header, NULL);
snprintf(header, sizeof(header), "clos");
snprintf(value, sizeof(value), "%d", clos);
format_and_print(outf, level + 2, header, value);
format_and_print(outf, level, NULL, NULL);
}
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;
level = print_package_info(id, outf);
snprintf(header, sizeof(header), "%s", feature);
format_and_print(outf, level + 1, header, NULL);
snprintf(header, sizeof(header), "%s", cmd);
if (!result)
snprintf(value, sizeof(value), "success");
else
snprintf(value, sizeof(value), "failed(error %d)", result);
format_and_print(outf, level + 2, header, value);
format_and_print(outf, level, NULL, NULL);
}
void isst_display_error_info_message(int error, char *msg, int arg_valid, int arg)
{
FILE *outf = get_output_file();
static int error_index;
char header[256];
char value[256];
if (!out_format_is_json()) {
if (arg_valid)
snprintf(value, sizeof(value), "%s %d", msg, arg);
else
snprintf(value, sizeof(value), "%s", msg);
if (error)
fprintf(outf, "Error: %s\n", value);
else
fprintf(outf, "Information: %s\n", value);
return;
}
if (!start)
format_and_print(outf, 0, "start", NULL);
if (error)
snprintf(header, sizeof(header), "Error%d", error_index++);
else
snprintf(header, sizeof(header), "Information:%d", error_index++);
format_and_print(outf, 1, header, NULL);
snprintf(header, sizeof(header), "message");
if (arg_valid)
snprintf(value, sizeof(value), "%s %d", msg, arg);
else
snprintf(value, sizeof(value), "%s", msg);
format_and_print(outf, 2, header, value);
format_and_print(outf, 1, NULL, NULL);
if (!start)
format_and_print(outf, 0, NULL, NULL);
}
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(id, outf);
snprintf(header, sizeof(header), "get-trl");
format_and_print(outf, level + 1, header, NULL);
snprintf(header, sizeof(header), "trl");
snprintf(value, sizeof(value), "0x%llx", trl);
format_and_print(outf, level + 2, header, value);
format_and_print(outf, level, NULL, NULL);
}
@@ -0,0 +1,328 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Intel Speed Select -- Enumerate and control features
* Copyright (c) 2019 Intel Corporation.
*/
#ifndef _ISST_H_
#define _ISST_H_
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sched.h>
#include <sys/stat.h>
#include <sys/resource.h>
#include <getopt.h>
#include <err.h>
#include <fcntl.h>
#include <signal.h>
#include <sys/time.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include <cpuid.h>
#include <dirent.h>
#include <errno.h>
#include <stdarg.h>
#include <sys/ioctl.h>
#include <linux/isst_if.h>
#define BIT(x) (1 << (x))
#define BIT_ULL(nr) (1ULL << (nr))
#define GENMASK(h, l) (((~0UL) << (l)) & (~0UL >> (sizeof(long) * 8 - 1 - (h))))
#define GENMASK_ULL(h, l) \
(((~0ULL) << (l)) & (~0ULL >> (sizeof(long long) * 8 - 1 - (h))))
#define CONFIG_TDP 0x7f
#define CONFIG_TDP_GET_LEVELS_INFO 0x00
#define CONFIG_TDP_GET_TDP_CONTROL 0x01
#define CONFIG_TDP_SET_TDP_CONTROL 0x02
#define CONFIG_TDP_GET_TDP_INFO 0x03
#define CONFIG_TDP_GET_PWR_INFO 0x04
#define CONFIG_TDP_GET_TJMAX_INFO 0x05
#define CONFIG_TDP_GET_CORE_MASK 0x06
#define CONFIG_TDP_GET_TURBO_LIMIT_RATIOS 0x07
#define CONFIG_TDP_SET_LEVEL 0x08
#define CONFIG_TDP_GET_UNCORE_P0_P1_INFO 0X09
#define CONFIG_TDP_GET_P1_INFO 0x0a
#define CONFIG_TDP_GET_MEM_FREQ 0x0b
#define CONFIG_TDP_GET_RATIO_INFO 0x0c
#define CONFIG_TDP_GET_FACT_HP_TURBO_LIMIT_NUMCORES 0x10
#define CONFIG_TDP_GET_FACT_HP_TURBO_LIMIT_RATIOS 0x11
#define CONFIG_TDP_GET_FACT_LP_CLIPPING_RATIO 0x12
#define CONFIG_TDP_PBF_GET_CORE_MASK_INFO 0x20
#define CONFIG_TDP_PBF_GET_P1HI_P1LO_INFO 0x21
#define CONFIG_TDP_PBF_GET_TJ_MAX_INFO 0x22
#define CONFIG_TDP_PBF_GET_TDP_INFO 0X23
#define CONFIG_CLOS 0xd0
#define CLOS_PQR_ASSOC 0x00
#define CLOS_PM_CLOS 0x01
#define CLOS_PM_QOS_CONFIG 0x02
#define CLOS_STATUS 0x03
#define MBOX_CMD_WRITE_BIT 0x08
#define PM_QOS_INFO_OFFSET 0x00
#define PM_QOS_CONFIG_OFFSET 0x04
#define PM_CLOS_OFFSET 0x08
#define PQR_ASSOC_OFFSET 0x20
#define READ_PM_CONFIG 0x94
#define WRITE_PM_CONFIG 0x95
#define PM_FEATURE 0x03
#define DISP_FREQ_MULTIPLIER 100
#define MAX_PACKAGE_COUNT 32
#define MAX_DIE_PER_PACKAGE 16
#define MAX_PUNIT_PER_DIE 8
/* Unified structure to specific a CPU or a Power Domain */
struct isst_id {
int cpu;
int pkg;
int die;
int punit;
};
struct isst_clos_config {
unsigned int clos_min;
unsigned int clos_max;
unsigned char epp;
unsigned char clos_prop_prio;
unsigned char clos_desired;
};
struct isst_fact_bucket_info {
int hp_cores;
int hp_ratios[TRL_MAX_LEVELS];
};
struct isst_pbf_info {
int pbf_acticated;
int pbf_available;
size_t core_cpumask_size;
cpu_set_t *core_cpumask;
int p1_high;
int p1_low;
int t_control;
int t_prochot;
int tdp;
};
#define ISST_TRL_MAX_ACTIVE_CORES 8
#define ISST_FACT_MAX_BUCKETS 8
struct isst_fact_info {
int lp_ratios[TRL_MAX_LEVELS];
struct isst_fact_bucket_info bucket_info[ISST_FACT_MAX_BUCKETS];
};
struct isst_pkg_ctdp_level_info {
int processed;
int control_cpu;
int pkg_id;
int die_id;
int level;
int fact_support;
int pbf_support;
int fact_enabled;
int pbf_enabled;
int sst_cp_support;
int sst_cp_enabled;
int tdp_ratio;
int active;
int tdp_control;
int pkg_tdp;
int pkg_min_power;
int pkg_max_power;
int fact;
int t_proc_hot;
int cooling_type;
int uncore_p0;
int uncore_p1;
int uncore_pm;
int uncore1_p0;
int uncore1_p1;
int uncore1_pm;
int sse_p1;
int avx2_p1;
int avx512_p1;
int amx_p1;
int mem_freq;
size_t core_cpumask_size;
cpu_set_t *core_cpumask;
int cpu_count;
unsigned long long trl_cores; /* Buckets info */
int trl_ratios[TRL_MAX_LEVELS][ISST_TRL_MAX_ACTIVE_CORES];
int kobj_bucket_index;
int active_bucket;
int fact_max_index;
int fact_max_config;
int pbf_found;
int pbf_active;
struct isst_pbf_info pbf_info;
struct isst_fact_info fact_info;
};
#define ISST_MAX_TDP_LEVELS (4 + 1) /* +1 for base config */
struct isst_pkg_ctdp {
int locked;
int version;
int processed;
int levels;
int current_level;
int enabled;
struct isst_pkg_ctdp_level_info ctdp_level[ISST_MAX_TDP_LEVELS];
};
enum isst_platform_param {
ISST_PARAM_MBOX_DELAY,
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);
void (*update_platform_param)(enum isst_platform_param param, int value);
int (*is_punit_valid)(struct isst_id *id);
int (*read_pm_config)(struct isst_id *id, int *cp_state, int *cp_cap);
int (*get_config_levels)(struct isst_id *id, struct isst_pkg_ctdp *pkg_ctdp);
int (*get_ctdp_control)(struct isst_id *id, int config_index, struct isst_pkg_ctdp_level_info *ctdp_level);
int (*get_tdp_info)(struct isst_id *id, int config_index, struct isst_pkg_ctdp_level_info *ctdp_level);
int (*get_pwr_info)(struct isst_id *id, int config_index, struct isst_pkg_ctdp_level_info *ctdp_level);
int (*get_coremask_info)(struct isst_id *id, int config_index, struct isst_pkg_ctdp_level_info *ctdp_level);
int (*get_get_trl)(struct isst_id *id, int level, int avx_level, int *trl);
int (*get_get_trls)(struct isst_id *id, int level, struct isst_pkg_ctdp_level_info *ctdp_level);
int (*get_trl_bucket_info)(struct isst_id *id, int level, unsigned long long *buckets_info);
int (*set_tdp_level)(struct isst_id *id, int tdp_level);
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 (*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);
int (*set_clos)(struct isst_id *id, int clos, struct isst_clos_config *clos_config);
int (*clos_get_assoc_status)(struct isst_id *id, int *clos_id);
int (*clos_associate)(struct isst_id *id, int clos_id);
};
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);
extern int get_max_punit_core_id(struct isst_id *id);
extern int api_version(void);
/* Common interfaces */
FILE *get_output_file(void);
extern int is_debug_enabled(void);
extern void debug_printf(const char *format, ...);
extern int out_format_is_json(void);
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_phy_core_num(int logical_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,
int *cpu_cnt);
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(int api_version);
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);
extern char *isst_get_trl_level_name(int level);
extern int isst_is_punit_valid(struct isst_id *id);
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(struct isst_id *id, int config_index,
struct isst_pkg_ctdp_level_info *ctdp_level);
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);
extern void isst_get_process_ctdp_complete(struct isst_id *id,
struct isst_pkg_ctdp *pkg_dev);
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(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(struct isst_id *id, FILE *outf, int level,
struct isst_pbf_info *info);
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 int isst_get_fact_info(struct isst_id *id, int level, int fact_bucket,
struct isst_fact_info *fact_info);
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(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(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(struct isst_id *id, int clos,
struct isst_clos_config *clos_config);
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(struct isst_id *id, FILE *outf, int clos);
extern void isst_display_result(struct isst_id *id, FILE *outf, char *feature, char *cmd,
int result);
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(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_emr_platform(void);
extern int is_icx_platform(void);
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_power_domain_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(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);
extern struct isst_platform_ops *tpmi_get_platform_ops(void);
/* Cgroup related interface */
extern int enable_cpuset_controller(void);
extern int isolate_cpus(struct isst_id *id, int mask_size, cpu_set_t *cpu_mask,
int level, int cpu_0_only);
extern int use_cgroupv2(void);
#endif