From 39736372ea8b69efd27992838dc69a3a62e55be0 Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Tue, 6 May 2025 09:35:29 -0700 Subject: [PATCH 01/45] platform/x86: ISST: Support SST-TF revision 2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit commit 885d1c2a30b73e50d0bbc098ddd717e22ccff266 upstream. SST-TF revision 2 supports a higher number of cores per bucket, as the current limit of 256 cores may be insufficient. To accommodate this, a new offset, "SST_TF_INFO-8," is introduced, allowing for a higher core count. Utilize this offset instead of the current "SST_TF_INFO-1" offset, based on SST-TF revision 2 or higher, and if there is a non-zero core count in any bucket. Intel-SIG: commit 885d1c2a30b7 platform/x86: ISST: Support SST-TF revision 2 Backport SST support for DMR Signed-off-by: Srinivas Pandruvada Link: https://lore.kernel.org/r/20250506163531.1061185-2-srinivas.pandruvada@linux.intel.com Reviewed-by: Ilpo Järvinen Signed-off-by: Ilpo Järvinen [ Zhang Rui: amend commit log ] Signed-off-by: Zhang Rui --- .../intel/speed_select_if/isst_tpmi_core.c | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c b/drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c index 1f0774fef26f..2947d2fdec52 100644 --- a/drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c +++ b/drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c @@ -1329,9 +1329,14 @@ static int isst_if_get_tpmi_instance_count(void __user *argp) #define SST_TF_INFO_0_OFFSET 0 #define SST_TF_INFO_1_OFFSET 8 #define SST_TF_INFO_2_OFFSET 16 +#define SST_TF_INFO_8_OFFSET 64 +#define SST_TF_INFO_8_BUCKETS 3 #define SST_TF_MAX_LP_CLIP_RATIOS TRL_MAX_LEVELS +#define SST_TF_FEATURE_REV_START 4 +#define SST_TF_FEATURE_REV_WIDTH 8 + #define SST_TF_LP_CLIP_RATIO_0_START 16 #define SST_TF_LP_CLIP_RATIO_0_WIDTH 8 @@ -1341,10 +1346,14 @@ static int isst_if_get_tpmi_instance_count(void __user *argp) #define SST_TF_NUM_CORE_0_START 0 #define SST_TF_NUM_CORE_0_WIDTH 8 +#define SST_TF_NUM_MOD_0_START 0 +#define SST_TF_NUM_MOD_0_WIDTH 16 + static int isst_if_get_turbo_freq_info(void __user *argp) { static struct isst_turbo_freq_info turbo_freq; struct tpmi_per_power_domain_info *power_domain_info; + u8 feature_rev; int i, j; if (copy_from_user(&turbo_freq, argp, sizeof(turbo_freq))) @@ -1361,6 +1370,10 @@ static int isst_if_get_turbo_freq_info(void __user *argp) turbo_freq.max_trl_levels = TRL_MAX_LEVELS; turbo_freq.max_clip_freqs = SST_TF_MAX_LP_CLIP_RATIOS; + _read_tf_level_info("feature_rev", feature_rev, turbo_freq.level, + SST_TF_INFO_0_OFFSET, SST_TF_FEATURE_REV_START, + SST_TF_FEATURE_REV_WIDTH, SST_MUL_FACTOR_NONE); + for (i = 0; i < turbo_freq.max_clip_freqs; ++i) _read_tf_level_info("lp_clip*", turbo_freq.lp_clip_freq_mhz[i], turbo_freq.level, SST_TF_INFO_0_OFFSET, @@ -1377,12 +1390,32 @@ static int isst_if_get_turbo_freq_info(void __user *argp) SST_MUL_FACTOR_FREQ) } + if (feature_rev >= 2) { + bool has_tf_info_8 = false; + + for (i = 0; i < SST_TF_INFO_8_BUCKETS; ++i) { + _read_tf_level_info("bucket_*_mod_count", turbo_freq.bucket_core_counts[i], + turbo_freq.level, SST_TF_INFO_8_OFFSET, + SST_TF_NUM_MOD_0_WIDTH * i, SST_TF_NUM_MOD_0_WIDTH, + SST_MUL_FACTOR_NONE) + + if (turbo_freq.bucket_core_counts[i]) + has_tf_info_8 = true; + } + + if (has_tf_info_8) + goto done_core_count; + } + for (i = 0; i < TRL_MAX_BUCKETS; ++i) _read_tf_level_info("bucket_*_core_count", turbo_freq.bucket_core_counts[i], turbo_freq.level, SST_TF_INFO_1_OFFSET, SST_TF_NUM_CORE_0_WIDTH * i, SST_TF_NUM_CORE_0_WIDTH, SST_MUL_FACTOR_NONE) + +done_core_count: + if (copy_to_user(argp, &turbo_freq, sizeof(turbo_freq))) return -EFAULT; From c115631225fcf0069d7ec254214c90ef485f8191 Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Tue, 6 May 2025 09:35:30 -0700 Subject: [PATCH 02/45] platform/x86: ISST: Support SST-PP revision 2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit commit d6644d737bec473a38dbd44a71553cacd636a920 upstream. SST PP revision 2 added fabric 1 P0, P1 and Pm frequencies. Export them by using a new IOCTL ISST_IF_GET_PERF_LEVEL_FABRIC_INFO. This IOCTL requires platforms with SST PP revision 2 or higher. To accommodate potential future increases in fabric count and avoid ABI changes, support is extended for up to 8 fabrics. Intel-SIG: commit d6644d737bec platform/x86: ISST: Support SST-PP revision 2 Backport SST support for DMR Signed-off-by: Srinivas Pandruvada Link: https://lore.kernel.org/r/20250506163531.1061185-3-srinivas.pandruvada@linux.intel.com Reviewed-by: Ilpo Järvinen Signed-off-by: Ilpo Järvinen [ Zhang Rui: amend commit log ] Signed-off-by: Zhang Rui --- .../intel/speed_select_if/isst_tpmi_core.c | 66 +++++++++++++++++++ include/uapi/linux/isst_if.h | 26 ++++++++ 2 files changed, 92 insertions(+) diff --git a/drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c b/drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c index 2947d2fdec52..e0aaa9a8fd68 100644 --- a/drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c +++ b/drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c @@ -1017,6 +1017,7 @@ static int isst_if_set_perf_feature(void __user *argp) #define SST_PP_INFO_10_OFFSET 80 #define SST_PP_INFO_11_OFFSET 88 +#define SST_PP_INFO_12_OFFSET 96 #define SST_PP_P1_SSE_START 0 #define SST_PP_P1_SSE_WIDTH 8 @@ -1069,6 +1070,15 @@ static int isst_if_set_perf_feature(void __user *argp) #define SST_PP_CORE_RATIO_PM_FABRIC_START 48 #define SST_PP_CORE_RATIO_PM_FABRIC_WIDTH 8 +#define SST_PP_CORE_RATIO_P0_FABRIC_1_START 0 +#define SST_PP_CORE_RATIO_P0_FABRIC_1_WIDTH 8 + +#define SST_PP_CORE_RATIO_P1_FABRIC_1_START 8 +#define SST_PP_CORE_RATIO_P1_FABRIC_1_WIDTH 8 + +#define SST_PP_CORE_RATIO_PM_FABRIC_1_START 16 +#define SST_PP_CORE_RATIO_PM_FABRIC_1_WIDTH 8 + static int isst_if_get_perf_level_info(void __user *argp) { struct isst_perf_level_data_info perf_level; @@ -1168,6 +1178,59 @@ static int isst_if_get_perf_level_info(void __user *argp) return 0; } +static int isst_if_get_perf_level_fabric_info(void __user *argp) +{ + struct isst_perf_level_fabric_info perf_level_fabric; + struct tpmi_per_power_domain_info *power_domain_info; + int start = SST_PP_CORE_RATIO_P0_FABRIC_START; + int width = SST_PP_CORE_RATIO_P0_FABRIC_WIDTH; + int offset = SST_PP_INFO_11_OFFSET; + int i; + + if (copy_from_user(&perf_level_fabric, argp, sizeof(perf_level_fabric))) + return -EFAULT; + + power_domain_info = get_instance(perf_level_fabric.socket_id, + perf_level_fabric.power_domain_id); + if (!power_domain_info) + return -EINVAL; + + if (perf_level_fabric.level > power_domain_info->max_level) + return -EINVAL; + + if (power_domain_info->pp_header.feature_rev < 2) + return -EINVAL; + + if (!(power_domain_info->pp_header.level_en_mask & BIT(perf_level_fabric.level))) + return -EINVAL; + + /* For revision 2, maximum number of fabrics is 2 */ + perf_level_fabric.max_fabrics = 2; + + for (i = 0; i < perf_level_fabric.max_fabrics; i++) { + _read_pp_level_info("p0_fabric_freq_mhz", perf_level_fabric.p0_fabric_freq_mhz[i], + perf_level_fabric.level, offset, start, width, + SST_MUL_FACTOR_FREQ) + start += width; + + _read_pp_level_info("p1_fabric_freq_mhz", perf_level_fabric.p1_fabric_freq_mhz[i], + perf_level_fabric.level, offset, start, width, + SST_MUL_FACTOR_FREQ) + start += width; + + _read_pp_level_info("pm_fabric_freq_mhz", perf_level_fabric.pm_fabric_freq_mhz[i], + perf_level_fabric.level, offset, start, width, + SST_MUL_FACTOR_FREQ) + offset = SST_PP_INFO_12_OFFSET; + start = SST_PP_CORE_RATIO_P0_FABRIC_1_START; + } + + if (copy_to_user(argp, &perf_level_fabric, sizeof(perf_level_fabric))) + return -EFAULT; + + return 0; +} + #define SST_PP_FUSED_CORE_COUNT_START 0 #define SST_PP_FUSED_CORE_COUNT_WIDTH 8 @@ -1454,6 +1517,9 @@ static long isst_if_def_ioctl(struct file *file, unsigned int cmd, case ISST_IF_GET_PERF_LEVEL_INFO: ret = isst_if_get_perf_level_info(argp); break; + case ISST_IF_GET_PERF_LEVEL_FABRIC_INFO: + ret = isst_if_get_perf_level_fabric_info(argp); + break; case ISST_IF_GET_PERF_LEVEL_CPU_MASK: ret = isst_if_get_perf_level_mask(argp); break; diff --git a/include/uapi/linux/isst_if.h b/include/uapi/linux/isst_if.h index 0df1a1c3caf4..8197a4800604 100644 --- a/include/uapi/linux/isst_if.h +++ b/include/uapi/linux/isst_if.h @@ -375,6 +375,30 @@ struct isst_perf_level_data_info { __u16 trl_freq_mhz[TRL_MAX_LEVELS][TRL_MAX_BUCKETS]; }; +#define MAX_FABRIC_COUNT 8 + +/** + * struct isst_perf_level_fabric_info - Structure to get SST-PP fabric details + * @socket_id: Socket/package id + * @power_domain_id: Power Domain id + * @level: SST-PP level for which caller wants to get information + * @max_fabrics: Count of fabrics in resonse + * @p0_fabric_freq_mhz: Fabric (Uncore) maximum frequency + * @p1_fabric_freq_mhz: Fabric (Uncore) TDP frequency + * @pm_fabric_freq_mhz: Fabric (Uncore) minimum frequency + * + * Structure used to get information on frequencies for fabrics. + */ +struct isst_perf_level_fabric_info { + __u8 socket_id; + __u8 power_domain_id; + __u16 level; + __u16 max_fabrics; + __u16 p0_fabric_freq_mhz[MAX_FABRIC_COUNT]; + __u16 p1_fabric_freq_mhz[MAX_FABRIC_COUNT]; + __u16 pm_fabric_freq_mhz[MAX_FABRIC_COUNT]; +}; + /** * struct isst_perf_level_cpu_mask - Structure to get SST-PP level CPU mask * @socket_id: Socket/package id @@ -471,5 +495,7 @@ struct isst_turbo_freq_info { #define ISST_IF_GET_BASE_FREQ_INFO _IOR(ISST_IF_MAGIC, 14, struct isst_base_freq_info *) #define ISST_IF_GET_BASE_FREQ_CPU_MASK _IOR(ISST_IF_MAGIC, 15, struct isst_perf_level_cpu_mask *) #define ISST_IF_GET_TURBO_FREQ_INFO _IOR(ISST_IF_MAGIC, 16, struct isst_turbo_freq_info *) +#define ISST_IF_GET_PERF_LEVEL_FABRIC_INFO _IOR(ISST_IF_MAGIC, 17,\ + struct isst_perf_level_fabric_info *) #endif From 7ecd9f163a3b166f70242f54642b0ffb62f3d19f Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Tue, 6 May 2025 09:35:31 -0700 Subject: [PATCH 03/45] platform/x86: ISST: Update minor version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit commit c9a20142d3420a5113f560e7dea711d2f9693117 upstream. Update SST minor version after supporting SST-PP and SST-TF version 2. Intel-SIG: commit c9a20142d342 platform/x86: ISST: Update minor version Backport SST support for DMR Signed-off-by: Srinivas Pandruvada Link: https://lore.kernel.org/r/20250506163531.1061185-4-srinivas.pandruvada@linux.intel.com Reviewed-by: Ilpo Järvinen Signed-off-by: Ilpo Järvinen [ Zhang Rui: amend commit log ] Signed-off-by: Zhang Rui --- drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c b/drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c index e0aaa9a8fd68..5b42d0660edf 100644 --- a/drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c +++ b/drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c @@ -35,7 +35,7 @@ /* Supported SST hardware version by this driver */ #define ISST_MAJOR_VERSION 0 -#define ISST_MINOR_VERSION 1 +#define ISST_MINOR_VERSION 2 /* * Used to indicate if value read from MMIO needs to get multiplied @@ -381,7 +381,7 @@ static int sst_main(struct auxiliary_device *auxdev, struct tpmi_per_power_domai return -ENODEV; } - if (TPMI_MINOR_VERSION(pd_info->sst_header.interface_version) != ISST_MINOR_VERSION) + if (TPMI_MINOR_VERSION(pd_info->sst_header.interface_version) > ISST_MINOR_VERSION) dev_info(dev, "SST: Ignore: Unsupported minor version:%lx\n", TPMI_MINOR_VERSION(pd_info->sst_header.interface_version)); From 30762e3b8439b9fb12c842d08371f59db0a38a67 Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Wed, 25 Mar 2026 12:26:38 -0700 Subject: [PATCH 04/45] platform/x86: ISST: Reset core count to 0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit commit e1415b9418eb22b4a7a1ef4b4aec9dd0a49e3fa7 upstream. Based on feature revision, number of buckets can be less than the TRL_MAX_BUCKETS. In that case core counts in the remaining buckets can be set to some invalid values. Hence reset core count to 0 for all buckets before assigning correct values. Intel-SIG: commit e1415b9418eb platform/x86: ISST: Reset core count to 0 Backport SST support for DMR Fixes: 885d1c2a30b7 ("platform/x86: ISST: Support SST-TF revision 2") Signed-off-by: Srinivas Pandruvada Cc: stable@vger.kernel.org Link: https://patch.msgid.link/20260325192638.3417281-1-srinivas.pandruvada@linux.intel.com Reviewed-by: Ilpo Järvinen Signed-off-by: Ilpo Järvinen [ Zhang Rui: amend commit log ] Signed-off-by: Zhang Rui --- drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c b/drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c index 5b42d0660edf..89161ccf3f1a 100644 --- a/drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c +++ b/drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c @@ -1453,6 +1453,8 @@ static int isst_if_get_turbo_freq_info(void __user *argp) SST_MUL_FACTOR_FREQ) } + memset(turbo_freq.bucket_core_counts, 0, sizeof(turbo_freq.bucket_core_counts)); + if (feature_rev >= 2) { bool has_tf_info_8 = false; From cc38fc3d974b175d1effe265c01460aa1d65daea Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Thu, 7 Sep 2023 15:46:39 -0700 Subject: [PATCH 05/45] tools/power/x86/intel-speed-select: Sanitize integer arguments commit 61f3d868b3d6f5e23a6d25597133d76d2186eddd upstream. If the command takes some integer arguments, make sure the command contains only digits. Same for Hex arguments. Otherwise return error. Intel-SIG: commit 61f3d868b3d6 tools/power/x86/intel-speed-select: Sanitize integer arguments Sync intel-speed-select to v1.26 Signed-off-by: Srinivas Pandruvada [ Zhang Rui: amend commit log ] Signed-off-by: Zhang Rui --- .../x86/intel-speed-select/isst-config.c | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/tools/power/x86/intel-speed-select/isst-config.c b/tools/power/x86/intel-speed-select/isst-config.c index 5fcc2a92957e..9992a1cbd95d 100644 --- a/tools/power/x86/intel-speed-select/isst-config.c +++ b/tools/power/x86/intel-speed-select/isst-config.c @@ -4,6 +4,7 @@ * Copyright (c) 2019 Intel Corporation. */ +#include #include #include @@ -2730,6 +2731,43 @@ void parse_cpu_command(char *optarg) exit(-1); } +static void check_optarg(char *option, int hex) +{ + if (optarg) { + char *start = optarg; + int i; + + if (hex && strlen(optarg) < 3) { + /* At least 0x plus one character must be present */ + fprintf(stderr, "malformed arguments for:%s [%s]\n", option, optarg); + exit(0); + } + + if (hex) { + if (optarg[0] != '0' || tolower(optarg[1]) != 'x') { + fprintf(stderr, "malformed arguments for:%s [%s]\n", + option, optarg); + exit(0); + } + start = &optarg[2]; + } + + for (i = 0; i < strlen(start); ++i) { + if (hex) { + if (!isxdigit(start[i])) { + fprintf(stderr, "malformed arguments for:%s [%s]\n", + option, optarg); + exit(0); + } + } else if (!isdigit(start[i])) { + fprintf(stderr, "malformed arguments for:%s [%s]\n", + option, optarg); + exit(0); + } + } + } +} + static void parse_cmd_args(int argc, int start, char **argv) { int opt; @@ -2763,18 +2801,21 @@ static void parse_cmd_args(int argc, int start, char **argv) auto_mode = 1; break; case 'b': + check_optarg("bucket", 0); fact_bucket = atoi(optarg); break; case 'h': cmd_help = 1; break; case 'l': + check_optarg("level", 0); tdp_level = atoi(optarg); break; case 'o': force_online_offline = 1; break; case 't': + check_optarg("trl", 1); sscanf(optarg, "0x%llx", &fact_trl); break; case 'r': @@ -2791,13 +2832,16 @@ static void parse_cmd_args(int argc, int start, char **argv) break; /* CLOS related */ case 'c': + check_optarg("clos", 0); current_clos = atoi(optarg); break; case 'd': + check_optarg("desired", 0); clos_desired = atoi(optarg); clos_desired /= isst_get_disp_freq_multiplier(); break; case 'e': + check_optarg("epp", 0); clos_epp = atoi(optarg); if (is_skx_based_platform()) { isst_display_error_info_message(1, "epp can't be specified on this platform", 0, 0); @@ -2805,14 +2849,17 @@ static void parse_cmd_args(int argc, int start, char **argv) } break; case 'n': + check_optarg("min", 0); clos_min = atoi(optarg); clos_min /= isst_get_disp_freq_multiplier(); break; case 'm': + check_optarg("max", 0); clos_max = atoi(optarg); clos_max /= isst_get_disp_freq_multiplier(); break; case 'p': + check_optarg("priority", 0); clos_priority_type = atoi(optarg); if (is_skx_based_platform() && !clos_priority_type) { isst_display_error_info_message(1, "Invalid clos priority type: proportional for this platform", 0, 0); @@ -2820,6 +2867,7 @@ static void parse_cmd_args(int argc, int start, char **argv) } break; case 'w': + check_optarg("weight", 0); clos_prop_prio = atoi(optarg); if (is_skx_based_platform()) { isst_display_error_info_message(1, "weight can't be specified on this platform", 0, 0); From 8ab4fc792d558581465b62b505d7b01a22bc662b Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Thu, 7 Sep 2023 17:01:55 -0700 Subject: [PATCH 06/45] tools/power/x86/intel-speed-select: Update help for TRL commit 3076db34b5ba87bb7a3335d16415befdea056d57 upstream. TRL (turbo ratio limit) argument is passed in hex string. Clarify that in the help. Intel-SIG: commit 3076db34b5ba tools/power/x86/intel-speed-select: Update help for TRL Sync intel-speed-select to v1.26 Signed-off-by: Srinivas Pandruvada [ Zhang Rui: amend commit log ] Signed-off-by: Zhang Rui --- tools/power/x86/intel-speed-select/isst-config.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/power/x86/intel-speed-select/isst-config.c b/tools/power/x86/intel-speed-select/isst-config.c index 9992a1cbd95d..9306436bb5b0 100644 --- a/tools/power/x86/intel-speed-select/isst-config.c +++ b/tools/power/x86/intel-speed-select/isst-config.c @@ -2126,7 +2126,7 @@ static void set_fact_enable(int arg) fprintf(stderr, "Enable Intel Speed Select Technology Turbo frequency feature\n"); fprintf(stderr, - "Optional: -t|--trl : Specify turbo ratio limit\n"); + "Optional: -t|--trl : Specify turbo ratio limit in hex starting with 0x\n"); fprintf(stderr, "\tOptional Arguments: -a|--auto : Designate specified target CPUs with"); fprintf(stderr, @@ -2135,7 +2135,7 @@ static void set_fact_enable(int arg) fprintf(stderr, "Disable Intel Speed Select Technology turbo frequency feature\n"); fprintf(stderr, - "Optional: -t|--trl : Specify turbo ratio limit\n"); + "Optional: -t|--trl : Specify turbo ratio limit in hex starting with 0x\n"); fprintf(stderr, "\tOptional Arguments: -a|--auto : Also disable core-power associations\n"); } @@ -2597,7 +2597,7 @@ static void process_trl(int arg) if (cmd_help) { if (arg) { fprintf(stderr, "Set TRL (turbo ratio limits)\n"); - fprintf(stderr, "\t t|--trl: Specify turbo ratio limit for setting TRL\n"); + fprintf(stderr, "\t t|--trl: Specify turbo ratio limit for setting TRL in hex starting with 0x\n"); } else { fprintf(stderr, "Get TRL (turbo ratio limits)\n"); } From a618d3204fb169f941ff48f9ade544dbcca5b4c9 Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Thu, 7 Sep 2023 17:09:52 -0700 Subject: [PATCH 07/45] tools/power/x86/intel-speed-select: turbo-mode enable disable swapped commit 7b00d1018c8c8ed55aa1393b2ca234400eb6ca86 upstream. The command for turbo-mode enable and disable is swapped. Fix that. Previously turbo-mode enable was actually disabling and disable was enabling. Intel-SIG: commit 7b00d1018c8c tools/power/x86/intel-speed-select: turbo-mode enable disable swapped Sync intel-speed-select to v1.26 Signed-off-by: Srinivas Pandruvada [ Zhang Rui: amend commit log ] Signed-off-by: Zhang Rui --- tools/power/x86/intel-speed-select/isst-config.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/power/x86/intel-speed-select/isst-config.c b/tools/power/x86/intel-speed-select/isst-config.c index 9306436bb5b0..72be2d4db21c 100644 --- a/tools/power/x86/intel-speed-select/isst-config.c +++ b/tools/power/x86/intel-speed-select/isst-config.c @@ -2527,22 +2527,22 @@ static void set_turbo_mode_for_cpu(struct isst_id *id, int status) } if (status) { - isst_display_result(id, outf, "turbo-mode", "enable", 0); - } else { isst_display_result(id, outf, "turbo-mode", "disable", 0); + } else { + isst_display_result(id, outf, "turbo-mode", "enable", 0); } } static void set_turbo_mode(int arg) { - int i, enable = arg; + int i, disable = arg; struct isst_id id; if (cmd_help) { - if (enable) - fprintf(stderr, "Set turbo mode enable\n"); - else + if (disable) fprintf(stderr, "Set turbo mode disable\n"); + else + fprintf(stderr, "Set turbo mode enable\n"); exit(0); } @@ -2560,7 +2560,7 @@ static void set_turbo_mode(int arg) if (online) { set_isst_id(&id, i); - set_turbo_mode_for_cpu(&id, enable); + set_turbo_mode_for_cpu(&id, disable); } } From 41af44e5bf33faba6c7dbe27a1983784b848eb68 Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Thu, 7 Sep 2023 17:12:55 -0700 Subject: [PATCH 08/45] tools/power/x86/intel-speed-select: No TRL for non compute domains commit 2fe8d2d7911fb4e380c3dcb5655e1a62bb14f75e upstream. Don't call to set or get TRL for domains in which there are no CPUs. Intel-SIG: commit 2fe8d2d7911f tools/power/x86/intel-speed-select: No TRL for non compute domains Sync intel-speed-select to v1.26 Signed-off-by: Srinivas Pandruvada [ Zhang Rui: amend commit log ] Signed-off-by: Zhang Rui --- tools/power/x86/intel-speed-select/isst-config.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/power/x86/intel-speed-select/isst-config.c b/tools/power/x86/intel-speed-select/isst-config.c index 72be2d4db21c..1afaaa833a54 100644 --- a/tools/power/x86/intel-speed-select/isst-config.c +++ b/tools/power/x86/intel-speed-select/isst-config.c @@ -2574,6 +2574,9 @@ static void get_set_trl(struct isst_id *id, void *arg1, void *arg2, void *arg3, int set = *(int *)arg4; int ret; + if (id->cpu < 0) + return; + if (set && !fact_trl) { isst_display_error_info_message(1, "Invalid TRL. Specify with [-t|--trl]", 0, 0); exit(0); From c4789113a9fc48275b88350475b657631e478368 Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Thu, 7 Sep 2023 17:07:19 -0700 Subject: [PATCH 09/45] tools/power/x86/intel-speed-select: Display error for core-power support commit da4c1b9e8f22d0567e308428e588e1f9e004ce74 upstream. When core-power is getting enabled, if the feaure is not supported, display error. Intel-SIG: commit da4c1b9e8f22 tools/power/x86/intel-speed-select: Display error for core-power support Sync intel-speed-select to v1.26 Signed-off-by: Srinivas Pandruvada [ Zhang Rui: amend commit log ] Signed-off-by: Zhang Rui --- tools/power/x86/intel-speed-select/isst-config.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/power/x86/intel-speed-select/isst-config.c b/tools/power/x86/intel-speed-select/isst-config.c index 1afaaa833a54..b7bd14618128 100644 --- a/tools/power/x86/intel-speed-select/isst-config.c +++ b/tools/power/x86/intel-speed-select/isst-config.c @@ -2242,6 +2242,14 @@ static void enable_clos_qos_config(struct isst_id *id, void *arg1, void *arg2, v { int ret; int status = *(int *)arg4; + int cp_state, cp_cap; + + if (!isst_read_pm_config(id, &cp_state, &cp_cap)) { + if (!cp_cap) { + isst_display_error_info_message(1, "core-power not supported", 0, 0); + return; + } + } if (is_skx_based_platform()) clos_priority_type = 1; From 7833930f67c9de2353657a06f5300c69ca11766f Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Fri, 13 Oct 2023 11:20:56 -0700 Subject: [PATCH 10/45] tools/power/x86/intel-speed-select: Increase max CPUs in one request commit bc5370cca03ba9d1634fecd85e0cf99a0a3c0483 upstream. With the increase in the CPU count, this count needs to be updated. Increase max CPU count to 512. Intel-SIG: commit bc5370cca03b tools/power/x86/intel-speed-select: Increase max CPUs in one request Sync intel-speed-select to v1.26 Signed-off-by: Srinivas Pandruvada [ Zhang Rui: amend commit log ] Signed-off-by: Zhang Rui --- tools/power/x86/intel-speed-select/isst-config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/power/x86/intel-speed-select/isst-config.c b/tools/power/x86/intel-speed-select/isst-config.c index b7bd14618128..44e1302dd8f9 100644 --- a/tools/power/x86/intel-speed-select/isst-config.c +++ b/tools/power/x86/intel-speed-select/isst-config.c @@ -28,7 +28,7 @@ static FILE *outf; static int cpu_model; static int cpu_stepping; -#define MAX_CPUS_IN_ONE_REQ 256 +#define MAX_CPUS_IN_ONE_REQ 512 static short max_target_cpus; static unsigned short target_cpus[MAX_CPUS_IN_ONE_REQ]; From 8182014a39f1fbf996218ecd5c56d194d1bfde3a Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Tue, 3 Oct 2023 14:46:30 -0700 Subject: [PATCH 11/45] tools/power/x86/intel-speed-select: Use cgroup isolate for CPU 0 commit 3bc0f20a8c59daa79aee2da119564f668f458afd upstream. From kernel version 6.5, CPU 0 hotplug capability is deprecated. If some SST profile doesn't have CPU 0, then it is no longer possible to offline CPU 0. This means that user space threads will still run on CPU 0. To workaround this issue, use cgroup v2 isolation feature. Whenever there /sys/devices/system/cpu/cpu0/online file is absent or open fails, isolate CPU 0 via CPU cgroup v2 isolation. Also add a command line option to force even if the /sys/devices/system/cpu/cpu0/online is present. The previous commit "01bcb56f059e ("tools/power/x86/intel-speed-select: Prevent CPU 0 offline") was just warning about this issue based on the kernel version 6.5 and above. With this new approach, instead of warning take action to mitigate the issue. Intel-SIG: commit 3bc0f20a8c59 tools/power/x86/intel-speed-select: Use cgroup isolate for CPU 0 Sync intel-speed-select to v1.26 Signed-off-by: Srinivas Pandruvada [ Zhang Rui: amend commit log ] Signed-off-by: Zhang Rui --- .../x86/intel-speed-select/isst-config.c | 130 +++++++++++++----- .../x86/intel-speed-select/isst-daemon.c | 3 +- tools/power/x86/intel-speed-select/isst.h | 3 +- 3 files changed, 97 insertions(+), 39 deletions(-) diff --git a/tools/power/x86/intel-speed-select/isst-config.c b/tools/power/x86/intel-speed-select/isst-config.c index 44e1302dd8f9..b51c21ae2c83 100644 --- a/tools/power/x86/intel-speed-select/isst-config.c +++ b/tools/power/x86/intel-speed-select/isst-config.c @@ -6,7 +6,6 @@ #include #include -#include #include "isst.h" @@ -56,6 +55,8 @@ static int clos_min = -1; static int clos_max = -1; static int clos_desired = -1; static int clos_priority_type; +static int cpu_0_cgroupv2; +static int cpu_0_workaround(int isolate); struct _cpu_map { unsigned short core_id; @@ -475,42 +476,15 @@ static unsigned int is_cpu_online(int cpu) return online; } -static int get_kernel_version(int *major, int *minor) -{ - struct utsname buf; - int ret; - - ret = uname(&buf); - if (ret) - return ret; - - ret = sscanf(buf.release, "%d.%d", major, minor); - if (ret != 2) - return ret; - - return 0; -} - -#define CPU0_HOTPLUG_DEPRECATE_MAJOR_VER 6 -#define CPU0_HOTPLUG_DEPRECATE_MINOR_VER 5 - void set_cpu_online_offline(int cpu, int state) { char buffer[128]; int fd, ret; - if (!cpu) { - int major, minor; - - ret = get_kernel_version(&major, &minor); - if (!ret) { - if (major > CPU0_HOTPLUG_DEPRECATE_MAJOR_VER || (major == CPU0_HOTPLUG_DEPRECATE_MAJOR_VER && - minor >= CPU0_HOTPLUG_DEPRECATE_MINOR_VER)) { - debug_printf("Ignore CPU 0 offline/online for kernel version >= %d.%d\n", major, minor); - debug_printf("Use cgroups to isolate CPU 0\n"); - return; - } - } + if (cpu_0_cgroupv2 && !cpu) { + fprintf(stderr, "Will use cgroup v2 for CPU 0\n"); + cpu_0_workaround(!state); + return; } snprintf(buffer, sizeof(buffer), @@ -518,9 +492,10 @@ void set_cpu_online_offline(int cpu, int state) fd = open(buffer, O_WRONLY); if (fd < 0) { - if (!cpu && state) { + if (!cpu) { fprintf(stderr, "This system is not configured for CPU 0 online/offline\n"); - fprintf(stderr, "Ignoring online request for CPU 0 as this is already online\n"); + fprintf(stderr, "Will use cgroup v2\n"); + cpu_0_workaround(!state); return; } err(-1, "%s open failed", buffer); @@ -907,7 +882,7 @@ int enable_cpuset_controller(void) return 0; } -int isolate_cpus(struct isst_id *id, int mask_size, cpu_set_t *cpu_mask, int level) +int isolate_cpus(struct isst_id *id, int mask_size, cpu_set_t *cpu_mask, int level, int cpu_0_only) { int i, first, curr_index, index, ret, fd; static char str[512], dir_name[64]; @@ -950,6 +925,12 @@ int isolate_cpus(struct isst_id *id, int mask_size, cpu_set_t *cpu_mask, int lev curr_index = 0; first = 1; str[0] = '\0'; + + if (cpu_0_only) { + snprintf(str, str_len, "0"); + goto create_partition; + } + for (i = 0; i < get_topo_max_cpus(); ++i) { if (!is_cpu_in_power_domain(i, id)) continue; @@ -972,6 +953,7 @@ int isolate_cpus(struct isst_id *id, int mask_size, cpu_set_t *cpu_mask, int lev first = 0; } +create_partition: debug_printf("isolated CPUs list: package:%d curr_index:%d [%s]\n", id->pkg, curr_index ,str); snprintf(cpuset_cpus, sizeof(cpuset_cpus), "%s/cpuset.cpus", dir_name); @@ -1012,6 +994,74 @@ int isolate_cpus(struct isst_id *id, int mask_size, cpu_set_t *cpu_mask, int lev return 0; } +static int cpu_0_workaround(int isolate) +{ + int fd, fd1, len, ret; + cpu_set_t cpu_mask; + struct isst_id id; + char str[2]; + + debug_printf("isolate CPU 0 state: %d\n", isolate); + + if (isolate) + goto isolate; + + /* First check if CPU 0 was isolated to remove isolation. */ + + /* If the cpuset.cpus doesn't exist, that means that none of the CPUs are isolated*/ + fd = open("/sys/fs/cgroup/0-0-0/cpuset.cpus", O_RDONLY, 0); + if (fd < 0) + return 0; + + len = read(fd, str, sizeof(str)); + /* Error check, but unlikely to fail. If fails that means that not isolated */ + if (len == -1) + return 0; + + + /* Is CPU 0 is in isolate list, the display is sorted so first element will be CPU 0*/ + if (str[0] != '0') { + close(fd); + return 0; + } + + fd1 = open("/sys/fs/cgroup/0-0-0/cpuset.cpus.partition", O_RDONLY, 0); + /* Unlikely that, this attribute is not present, but handle error */ + if (fd1 < 0) { + close(fd); + return 0; + } + + /* Is CPU 0 already changed partition to "member" */ + len = read(fd1, str, sizeof(str)); + if (len != -1 && str[0] == 'm') { + close(fd1); + close(fd); + return 0; + } + + close(fd1); + close(fd); + + debug_printf("CPU 0 was isolated before, so remove isolation\n"); + +isolate: + ret = enable_cpuset_controller(); + if (ret) + goto isolate_fail; + + CPU_ZERO(&cpu_mask); + memset(&id, 0, sizeof(struct isst_id)); + CPU_SET(0, &cpu_mask); + + ret = isolate_cpus(&id, sizeof(cpu_mask), &cpu_mask, isolate, 1); +isolate_fail: + if (ret) + fprintf(stderr, "Can't isolate CPU 0\n"); + + return ret; +} + static int isst_fill_platform_info(void) { const char *pathname = "/dev/isst_interface"; @@ -1458,7 +1508,8 @@ static void set_tdp_level_for_cpu(struct isst_id *id, void *arg1, void *arg2, vo if (ret) goto use_offline; - ret = isolate_cpus(id, ctdp_level.core_cpumask_size, ctdp_level.core_cpumask, tdp_level); + ret = isolate_cpus(id, ctdp_level.core_cpumask_size, + ctdp_level.core_cpumask, tdp_level, 0); if (ret) goto use_offline; @@ -3054,6 +3105,7 @@ static void usage(void) printf("\t[-n|--no-daemon : Don't run as daemon. By default --oob will turn on daemon mode\n"); printf("\t[-w|--delay : Delay for reading config level state change in OOB poll mode.\n"); printf("\t[-g|--cgroupv2 : Try to use cgroup v2 CPU isolation instead of CPU online/offline.\n"); + printf("\t[-u|--cpu0-workaround : Don't try to online/offline CPU0 instead use cgroup v2.\n"); printf("\nResult format\n"); printf("\tResult display uses a common format for each command:\n"); printf("\tResults are formatted in text/JSON with\n"); @@ -3107,6 +3159,7 @@ static void cmdline(int argc, char **argv) { "no-daemon", no_argument, 0, 'n' }, { "poll-interval", required_argument, 0, 'w' }, { "cgroupv2", required_argument, 0, 'g' }, + { "cpu0-workaround", required_argument, 0, 'u' }, { 0, 0, 0, 0 } }; @@ -3137,7 +3190,7 @@ static void cmdline(int argc, char **argv) goto out; progname = argv[0]; - while ((opt = getopt_long_only(argc, argv, "+c:df:hio:vabw:ng", long_options, + while ((opt = getopt_long_only(argc, argv, "+c:df:hio:vabw:ngu", long_options, &option_index)) != -1) { switch (opt) { case 'a': @@ -3199,6 +3252,9 @@ static void cmdline(int argc, char **argv) case 'g': cgroupv2 = 1; break; + case 'u': + cpu_0_cgroupv2 = 1; + break; default: usage(); } diff --git a/tools/power/x86/intel-speed-select/isst-daemon.c b/tools/power/x86/intel-speed-select/isst-daemon.c index 12053fa43542..66df21b2b573 100644 --- a/tools/power/x86/intel-speed-select/isst-daemon.c +++ b/tools/power/x86/intel-speed-select/isst-daemon.c @@ -90,7 +90,8 @@ void process_level_change(struct isst_id *id) if (ret) goto use_offline; - isolate_cpus(id, ctdp_level.core_cpumask_size, ctdp_level.core_cpumask, pkg_dev.current_level); + isolate_cpus(id, ctdp_level.core_cpumask_size, ctdp_level.core_cpumask, + pkg_dev.current_level, 0); goto free_mask; } diff --git a/tools/power/x86/intel-speed-select/isst.h b/tools/power/x86/intel-speed-select/isst.h index 8def22dec4a2..4bddd3c66bf7 100644 --- a/tools/power/x86/intel-speed-select/isst.h +++ b/tools/power/x86/intel-speed-select/isst.h @@ -318,7 +318,8 @@ 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); +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 From ec11b5fd2d399f512a60be57efd36695ffc3620b Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Fri, 13 Oct 2023 11:15:41 -0700 Subject: [PATCH 12/45] tools/power/x86/intel-speed-select: v1.18 release commit a590ed62269a049a72484ce617fe2f34e2da66cf upstream. This version addresses issues with: - When CPU 0 hotplug is not possible, try cgroup v2 isolation without any user input - Fix turbo mode enable/disable swapped - Sanitize command line integer and hex arguments - Add more error messages - Increase CPU count in one request Intel-SIG: commit a590ed62269a tools/power/x86/intel-speed-select: v1.18 release Sync intel-speed-select to v1.26 Signed-off-by: Srinivas Pandruvada [ Zhang Rui: amend commit log ] Signed-off-by: Zhang Rui --- tools/power/x86/intel-speed-select/isst-config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/power/x86/intel-speed-select/isst-config.c b/tools/power/x86/intel-speed-select/isst-config.c index b51c21ae2c83..d865dc1f89ee 100644 --- a/tools/power/x86/intel-speed-select/isst-config.c +++ b/tools/power/x86/intel-speed-select/isst-config.c @@ -16,7 +16,7 @@ struct process_cmd_struct { int arg; }; -static const char *version_str = "v1.17"; +static const char *version_str = "v1.18"; static const int supported_api_ver = 2; static struct isst_if_platform_info isst_platform_info; From 6213eea51414e3c0f4e9ca4b25671688f0b221d7 Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Thu, 7 Mar 2024 15:45:54 -0800 Subject: [PATCH 13/45] tools/power/x86/intel-speed-select: Increase die count commit 9ea48bdfd5b19a81edfd9dcc12b8af6bb319c6d8 upstream. TPMI platform information supports up to 16 compute dies. So increase the range. Intel-SIG: commit 9ea48bdfd5b1 tools/power/x86/intel-speed-select: Increase die count Sync intel-speed-select to v1.26 Signed-off-by: Srinivas Pandruvada Signed-off-by: Hans de Goede [ Zhang Rui: amend commit log ] Signed-off-by: Zhang Rui --- tools/power/x86/intel-speed-select/isst.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/power/x86/intel-speed-select/isst.h b/tools/power/x86/intel-speed-select/isst.h index 4bddd3c66bf7..39ee75677c2c 100644 --- a/tools/power/x86/intel-speed-select/isst.h +++ b/tools/power/x86/intel-speed-select/isst.h @@ -80,7 +80,7 @@ #define DISP_FREQ_MULTIPLIER 100 #define MAX_PACKAGE_COUNT 32 -#define MAX_DIE_PER_PACKAGE 2 +#define MAX_DIE_PER_PACKAGE 16 #define MAX_PUNIT_PER_DIE 8 /* Unified structure to specific a CPU or a Power Domain */ From 4dc349dab1509552921d0b85bd86cddbcdd5fdf8 Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Thu, 7 Mar 2024 15:47:11 -0800 Subject: [PATCH 14/45] tools/power/x86/intel-speed-select: Support multiple dies commit f9264471337e1db69ffc97525bff605b8c7c442f upstream. When the die id is same as punit compute die ID, treat them same. In this case, when for_each_online_power_domain_in_set() is called, then don't loop for each punit in a die. Just loop for all punits in a package. Intel-SIG: commit f9264471337e tools/power/x86/intel-speed-select: Support multiple dies Sync intel-speed-select to v1.26 Signed-off-by: Srinivas Pandruvada Signed-off-by: Hans de Goede [ Zhang Rui: amend commit log ] Signed-off-by: Zhang Rui --- .../x86/intel-speed-select/isst-config.c | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tools/power/x86/intel-speed-select/isst-config.c b/tools/power/x86/intel-speed-select/isst-config.c index d865dc1f89ee..54c50124303e 100644 --- a/tools/power/x86/intel-speed-select/isst-config.c +++ b/tools/power/x86/intel-speed-select/isst-config.c @@ -46,6 +46,8 @@ static int force_online_offline; static int auto_mode; static int fact_enable_fail; static int cgroupv2; +static int max_die_id; +static int max_punit_id; /* clos related */ static int current_clos = -1; @@ -562,6 +564,18 @@ void for_each_online_power_domain_in_set(void (*callback)(struct isst_id *, void } for (i = 0; i < MAX_PACKAGE_COUNT; i++) { + if (max_die_id == max_punit_id) { + for (k = 0; k < MAX_PUNIT_PER_DIE && k < MAX_DIE_PER_PACKAGE; k++) { + id.cpu = cpus[i][k][k]; + id.pkg = i; + id.die = k; + id.punit = k; + if (isst_is_punit_valid(&id)) + callback(&id, arg1, arg2, arg3, arg4); + } + continue; + } + for (j = 0; j < MAX_DIE_PER_PACKAGE; j++) { /* * Fix me: @@ -795,6 +809,12 @@ static void create_cpu_map(void) cpu_cnt[pkg_id][die_id][punit_id]++; + if (max_die_id < die_id) + max_die_id = die_id; + + if (max_punit_id < cpu_map[i].punit_id) + max_punit_id = cpu_map[i].punit_id; + debug_printf( "map logical_cpu:%d core: %d die:%d pkg:%d punit:%d punit_cpu:%d punit_core:%d\n", i, cpu_map[i].core_id, cpu_map[i].die_id, From 56cbadd656b99a3af657fb7dff7906fa25fc750d Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Fri, 8 Mar 2024 16:12:33 -0800 Subject: [PATCH 15/45] tools/power/x86/intel-speed-select: Fix display for unsupported levels commit 55d5639bda6563fdfbdf0606c3c23cf5fceacd61 upstream. During call to "intel-speed-select turbo-freq info" some junk values are reported for unsupported levels. Initialize the structure fact_info with 0s, so that isst_fact_display_information() will skip "0" values in the frequency. Intel-SIG: commit 55d5639bda65 tools/power/x86/intel-speed-select: Fix display for unsupported levels Sync intel-speed-select to v1.26 Signed-off-by: Srinivas Pandruvada Signed-off-by: Hans de Goede [ Zhang Rui: amend commit log ] Signed-off-by: Zhang Rui --- tools/power/x86/intel-speed-select/isst-config.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/power/x86/intel-speed-select/isst-config.c b/tools/power/x86/intel-speed-select/isst-config.c index 54c50124303e..d7809b7c12d9 100644 --- a/tools/power/x86/intel-speed-select/isst-config.c +++ b/tools/power/x86/intel-speed-select/isst-config.c @@ -2074,6 +2074,7 @@ static void dump_fact_config_for_cpu(struct isst_id *id, void *arg1, void *arg2, struct isst_fact_info fact_info; int ret; + memset(&fact_info, 0, sizeof(fact_info)); ret = isst_get_fact_info(id, tdp_level, fact_bucket, &fact_info); if (ret) { isst_display_error_info_message(1, "Failed to get turbo-freq info at this level", 1, tdp_level); From f164bce6e9eb09b98c8211f9dbe7b006c18a3fe1 Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Fri, 8 Mar 2024 18:11:03 -0800 Subject: [PATCH 16/45] tools/power/x86/intel-speed-select: Present all TRL levels for turbo-freq commit 38fa152b3de09c01e3488debb903adb0a28580b9 upstream. For turbo-freq feature, only 3 levels of frequencies are displayed even if platform support more. Present all levels based on the CPU model. Intel-SIG: commit 38fa152b3de0 tools/power/x86/intel-speed-select: Present all TRL levels for turbo-freq Sync intel-speed-select to v1.26 Signed-off-by: Srinivas Pandruvada Signed-off-by: Hans de Goede [ Zhang Rui: amend commit log ] Signed-off-by: Zhang Rui --- tools/power/x86/intel-speed-select/isst-core-mbox.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/power/x86/intel-speed-select/isst-core-mbox.c b/tools/power/x86/intel-speed-select/isst-core-mbox.c index 24bea57f4ff5..c81ecd602bcf 100644 --- a/tools/power/x86/intel-speed-select/isst-core-mbox.c +++ b/tools/power/x86/intel-speed-select/isst-core-mbox.c @@ -746,6 +746,7 @@ static int mbox_set_pbf_fact_status(struct isst_id *id, int pbf, int enable) static int _get_fact_bucket_info(struct isst_id *id, int level, struct isst_fact_bucket_info *bucket_info) { + int trl_max_levels = isst_get_trl_max_levels(); unsigned int resp; int i, k, ret; @@ -769,7 +770,7 @@ static int _get_fact_bucket_info(struct isst_id *id, int level, } } - for (k = 0; k < 3; ++k) { + for (k = 0; k < trl_max_levels; ++k) { for (i = 0; i < 2; ++i) { int j; From ffb5850001c557d947286a5db8ec233890da7d0f Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Mon, 25 Mar 2024 13:39:36 -0700 Subject: [PATCH 17/45] tools/power/x86/intel-speed-select: Increase number of CPUs displayed commit 80a513e3f7fca0493e2760b2bb0526faa33a12cb upstream. Currently max 128 CPUs can be displayed in the enable CPU list. Double the range. Since the size is big for stack allocation, change to static. Here changing to static is fine as these functions are called in serial. Intel-SIG: commit 80a513e3f7fc tools/power/x86/intel-speed-select: Increase number of CPUs displayed Sync intel-speed-select to v1.26 Signed-off-by: Srinivas Pandruvada Signed-off-by: Hans de Goede [ Zhang Rui: amend commit log ] Signed-off-by: Zhang Rui --- tools/power/x86/intel-speed-select/isst-display.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/power/x86/intel-speed-select/isst-display.c b/tools/power/x86/intel-speed-select/isst-display.c index 14c9b037859a..e30f6355e417 100644 --- a/tools/power/x86/intel-speed-select/isst-display.c +++ b/tools/power/x86/intel-speed-select/isst-display.c @@ -199,8 +199,8 @@ static void _isst_pbf_display_information(struct isst_id *id, FILE *outf, int le struct isst_pbf_info *pbf_info, int disp_level) { - char header[256]; - char value[512]; + 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); @@ -338,8 +338,8 @@ void isst_ctdp_display_core_info(struct isst_id *id, FILE *outf, char *prefix, void isst_ctdp_display_information(struct isst_id *id, FILE *outf, int tdp_level, struct isst_pkg_ctdp *pkg_dev) { - char header[256]; - char value[512]; + static char header[256]; + static char value[1024]; static int level; int trl_max_levels = isst_get_trl_max_levels(); int i; From 1091ce8b0549ec8218dd59ca0d6f44d44fc6934c Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Tue, 26 Mar 2024 18:55:53 -0400 Subject: [PATCH 18/45] tools/power/x86/intel-speed-select: SST BF/TF support per level commit 1fcf670e50645f23f026d1dca82e59200115f925 upstream. SST BF and TF can be enabled/disabled per level. So check the current level support from the mask of supported levels. This change from a single level to mask for info.sst_tf_support and info.sst_tf_support is indicated by API version change. Use as mask for API version above 2. In this way there is no change in behavior when running on older kernel with API version 2. Since the tool can support now API version 3, update the supported API version. Intel-SIG: commit 1fcf670e5064 tools/power/x86/intel-speed-select: SST BF/TF support per level Sync intel-speed-select to v1.26 Signed-off-by: Srinivas Pandruvada Signed-off-by: Hans de Goede [ Zhang Rui: amend commit log ] Signed-off-by: Zhang Rui --- tools/power/x86/intel-speed-select/isst-config.c | 2 +- tools/power/x86/intel-speed-select/isst-core-tpmi.c | 10 ++++++++-- tools/power/x86/intel-speed-select/isst-core.c | 1 + 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/tools/power/x86/intel-speed-select/isst-config.c b/tools/power/x86/intel-speed-select/isst-config.c index d7809b7c12d9..424e708b7b20 100644 --- a/tools/power/x86/intel-speed-select/isst-config.c +++ b/tools/power/x86/intel-speed-select/isst-config.c @@ -18,7 +18,7 @@ struct process_cmd_struct { static const char *version_str = "v1.18"; -static const int supported_api_ver = 2; +static const int supported_api_ver = 3; static struct isst_if_platform_info isst_platform_info; static char *progname; static int debug_flag; diff --git a/tools/power/x86/intel-speed-select/isst-core-tpmi.c b/tools/power/x86/intel-speed-select/isst-core-tpmi.c index 3458768562e5..32ea70c7dbd8 100644 --- a/tools/power/x86/intel-speed-select/isst-core-tpmi.c +++ b/tools/power/x86/intel-speed-select/isst-core-tpmi.c @@ -194,8 +194,14 @@ static int tpmi_get_ctdp_control(struct isst_id *id, int config_index, if (!(info.level_mask & level_mask)) return -1; - ctdp_level->fact_support = info.sst_tf_support; - ctdp_level->pbf_support = info.sst_bf_support; + 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)); diff --git a/tools/power/x86/intel-speed-select/isst-core.c b/tools/power/x86/intel-speed-select/isst-core.c index f55fef4c13a7..05efffbca3b7 100644 --- a/tools/power/x86/intel-speed-select/isst-core.c +++ b/tools/power/x86/intel-speed-select/isst-core.c @@ -23,6 +23,7 @@ int isst_set_platform_ops(int api_version) isst_ops = mbox_get_platform_ops(); break; case 2: + case 3: isst_ops = tpmi_get_platform_ops(); break; default: From 3e4f2bf553109ac24fb2ea92065a9187265009a5 Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Fri, 26 Apr 2024 14:39:44 -0700 Subject: [PATCH 19/45] tools/power/x86/intel-speed-select: Display CPU as None for -1 commit 8ebc39ace34e9b9944e29110598f8343f2d8c159 upstream. When there is no CPU in a power domain, display "None" instead of -1. Intel-SIG: commit 8ebc39ace34e tools/power/x86/intel-speed-select: Display CPU as None for -1 Sync intel-speed-select to v1.26 Signed-off-by: Srinivas Pandruvada Signed-off-by: Hans de Goede [ Zhang Rui: amend commit log ] Signed-off-by: Zhang Rui --- .../x86/intel-speed-select/isst-display.c | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/tools/power/x86/intel-speed-select/isst-display.c b/tools/power/x86/intel-speed-select/isst-display.c index e30f6355e417..07ebd08f3202 100644 --- a/tools/power/x86/intel-speed-select/isst-display.c +++ b/tools/power/x86/intel-speed-select/isst-display.c @@ -172,12 +172,19 @@ static int print_package_info(struct isst_id *id, FILE *outf) int level = 1; if (out_format_is_json()) { - if (api_version() > 1) - snprintf(header, sizeof(header), "package-%d:die-%d:powerdomain-%d:cpu-%d", - id->pkg, id->die, id->punit, id->cpu); - else + if (api_version() > 1) { + 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; } @@ -189,7 +196,12 @@ static int print_package_info(struct isst_id *id, FILE *outf) snprintf(header, sizeof(header), "powerdomain-%d", id->punit); format_and_print(outf, level++, header, NULL); } - snprintf(header, sizeof(header), "cpu-%d", id->cpu); + + 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; From 57c96c3d0b2980ecb566c25713becfeaeb3bf0f6 Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Thu, 25 Apr 2024 17:36:08 -0700 Subject: [PATCH 20/45] tools/power/x86/intel-speed-select: v1.19 release commit 5cfac5abb6e23d15669d0621d991d141f4f9b7d4 upstream. This version addresses issues with: - Support of SST BF/TF support per level - Increase number of CPUs displayed - Present all TRL levels for turbo-freq - Fix display for unsupported levels - Support multiple dies - Increase die count - Change CPU display for non compute domain Intel-SIG: commit 5cfac5abb6e2 tools/power/x86/intel-speed-select: v1.19 release Sync intel-speed-select to v1.26 Signed-off-by: Srinivas Pandruvada Signed-off-by: Hans de Goede [ Zhang Rui: amend commit log ] Signed-off-by: Zhang Rui --- tools/power/x86/intel-speed-select/isst-config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/power/x86/intel-speed-select/isst-config.c b/tools/power/x86/intel-speed-select/isst-config.c index 424e708b7b20..5899c27c2e2e 100644 --- a/tools/power/x86/intel-speed-select/isst-config.c +++ b/tools/power/x86/intel-speed-select/isst-config.c @@ -16,7 +16,7 @@ struct process_cmd_struct { int arg; }; -static const char *version_str = "v1.18"; +static const char *version_str = "v1.19"; static const int supported_api_ver = 3; static struct isst_if_platform_info isst_platform_info; From 48ec333b66589d18683ac1b686a06c01141d8501 Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Sat, 6 Jul 2024 01:17:55 -0400 Subject: [PATCH 21/45] tools/power/x86/intel-speed-select: Set TRL MSR in 100 MHz units commit fd77d7fde0818bcc70b63f99c306e5a0f0d3f1a2 upstream. When SST-TF is disabled in auto mode, the performance is getting limited. This is caused by wrong programming of Turbo Ratio Limit (TRL) MSR. This MSR always accepts the frequency ratio in 100 MHz unit. When the TPMI is sending TRL in 1 MHz unit, change to 100 MHz, before updating TRL MSR. Intel-SIG: commit fd77d7fde081 tools/power/x86/intel-speed-select: Set TRL MSR in 100 MHz units Sync intel-speed-select to v1.26 Signed-off-by: Srinivas Pandruvada [ Zhang Rui: amend commit log ] Signed-off-by: Zhang Rui --- tools/power/x86/intel-speed-select/isst-core.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/power/x86/intel-speed-select/isst-core.c b/tools/power/x86/intel-speed-select/isst-core.c index 05efffbca3b7..e05561d00458 100644 --- a/tools/power/x86/intel-speed-select/isst-core.c +++ b/tools/power/x86/intel-speed-select/isst-core.c @@ -283,6 +283,8 @@ int isst_set_trl(struct isst_id *id, unsigned long long trl) 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; @@ -310,6 +312,10 @@ int isst_set_trl_from_current_tdp(struct isst_id *id, unsigned long long trl) 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)); } } From ced881a422ba38cc74629409ea3f17d46638a909 Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Sun, 7 Jul 2024 00:08:56 -0700 Subject: [PATCH 22/45] tools/power/x86/intel-speed-select: v1.20 release commit d8d4f57ed6ce9fef9b975807ae0252cf92f1c55f upstream. This version addresses one issue: - Fix updating TRL MSR after SST-TF is disabled in auto mode. Intel-SIG: commit d8d4f57ed6ce tools/power/x86/intel-speed-select: v1.20 release Sync intel-speed-select to v1.26 Signed-off-by: Srinivas Pandruvada [ Zhang Rui: amend commit log ] Signed-off-by: Zhang Rui --- tools/power/x86/intel-speed-select/isst-config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/power/x86/intel-speed-select/isst-config.c b/tools/power/x86/intel-speed-select/isst-config.c index 5899c27c2e2e..5127be34869e 100644 --- a/tools/power/x86/intel-speed-select/isst-config.c +++ b/tools/power/x86/intel-speed-select/isst-config.c @@ -16,7 +16,7 @@ struct process_cmd_struct { int arg; }; -static const char *version_str = "v1.19"; +static const char *version_str = "v1.20"; static const int supported_api_ver = 3; static struct isst_if_platform_info isst_platform_info; From f96422099be75eeeccbe8391f1bb0883312d2851 Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Wed, 20 Nov 2024 08:26:15 -0800 Subject: [PATCH 23/45] tools/power/x86/intel-speed-select: Fix TRL restore after SST-TF disable commit 991c8aacfb6e3088027b8c776ad31d2c093905b8 upstream. When SST-TF is disabled, the TRL (Turbo Ratio Limit) of config level 0 is getting restored. But the TRL of current level should be restored which may not be config level 0. This is caused by a bug in treating config level as TRL level. So arguments needs to be swapped. Intel-SIG: commit 991c8aacfb6e tools/power/x86/intel-speed-select: Fix TRL restore after SST-TF disable Sync intel-speed-select to v1.26 Signed-off-by: Srinivas Pandruvada [ Zhang Rui: amend commit log ] Signed-off-by: Zhang Rui --- tools/power/x86/intel-speed-select/isst-core-tpmi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/power/x86/intel-speed-select/isst-core-tpmi.c b/tools/power/x86/intel-speed-select/isst-core-tpmi.c index 32ea70c7dbd8..da53aaa27fc9 100644 --- a/tools/power/x86/intel-speed-select/isst-core-tpmi.c +++ b/tools/power/x86/intel-speed-select/isst-core-tpmi.c @@ -329,7 +329,7 @@ static int tpmi_get_get_trls(struct isst_id *id, int config_index, return 0; } -static int tpmi_get_get_trl(struct isst_id *id, int level, int config_index, +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; From 3af3117599cc8f5084cd82d8d818609dd6cc6dda Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Wed, 20 Nov 2024 08:35:40 -0800 Subject: [PATCH 24/45] tools/power/x86/intel-speed-select: v1.21 release commit 600c8f24319cebe671a70722df99b8006daebe21 upstream. This version has one fix: - Fix restoring TRL after SST-TF disable Intel-SIG: commit 600c8f24319c tools/power/x86/intel-speed-select: v1.21 release Sync intel-speed-select to v1.26 Signed-off-by: Srinivas Pandruvada [ Zhang Rui: amend commit log ] Signed-off-by: Zhang Rui --- tools/power/x86/intel-speed-select/isst-config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/power/x86/intel-speed-select/isst-config.c b/tools/power/x86/intel-speed-select/isst-config.c index 5127be34869e..fadfb02b8611 100644 --- a/tools/power/x86/intel-speed-select/isst-config.c +++ b/tools/power/x86/intel-speed-select/isst-config.c @@ -16,7 +16,7 @@ struct process_cmd_struct { int arg; }; -static const char *version_str = "v1.20"; +static const char *version_str = "v1.21"; static const int supported_api_ver = 3; static struct isst_if_platform_info isst_platform_info; From 511f9d7ba9a589622efc54bb6aa59461ba01e49b Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Wed, 5 Mar 2025 10:53:53 -0800 Subject: [PATCH 25/45] tools/power/x86/intel-speed-select: Prevent increasing MAX_DIE_PER_PACKAGE commit d74e6e29d2b29919253f625f0c560f4ca2606900 upstream. In the function for_each_online_power_domain_in_set() to pick one CPU from each power domain a three-dimensional array is used, which assumes that a package contains multiple dies, that means the die_id from /sys/devices/system/cpu/cpu0/topology/die_id is only local to package. If it is not unique, still there will be no functional issues in the current generation of products, but the MAX_DIE_PER_PACKAGE will need to be increased for future products with many packages. After kernel version 6.9 die ID is unique system wide not per package. Even if the CPU topology has no dies, the ID will still increment across package. In this case the die_id in package 0 will be 0 and die_id in package 1 will be 1 in a 2-package system. Since the die count must be same for packages, just count the number of dies in package 0 and calculate die index from /sys/devices/system/cpu/cpu0/topology/die_id which is only unique within a package. In this way the array size "int cpus[MAX_PACKAGE_COUNT][MAX_DIE_PER_PACKAGE][MAX_PUNIT_PER_DIE]" doesn't have to increase with increasing package count. No functional change is expected. Intel-SIG: commit d74e6e29d2b2 tools/power/x86/intel-speed-select: Prevent increasing MAX_DIE_PER_PACKAGE Sync intel-speed-select to v1.26 Signed-off-by: Srinivas Pandruvada [ Zhang Rui: amend commit log ] Signed-off-by: Zhang Rui --- tools/power/x86/intel-speed-select/isst-config.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tools/power/x86/intel-speed-select/isst-config.c b/tools/power/x86/intel-speed-select/isst-config.c index fadfb02b8611..c319bfc3b7cb 100644 --- a/tools/power/x86/intel-speed-select/isst-config.c +++ b/tools/power/x86/intel-speed-select/isst-config.c @@ -48,6 +48,7 @@ static int fact_enable_fail; static int cgroupv2; static int max_die_id; static int max_punit_id; +static int max_die_id_package_0; /* clos related */ static int current_clos = -1; @@ -557,6 +558,8 @@ void for_each_online_power_domain_in_set(void (*callback)(struct isst_id *, void if (id.pkg < 0 || id.die < 0 || id.punit < 0) continue; + id.die = id.die % (max_die_id_package_0 + 1); + valid_mask[id.pkg][id.die] = 1; if (cpus[id.pkg][id.die][id.punit] == -1) @@ -568,7 +571,7 @@ void for_each_online_power_domain_in_set(void (*callback)(struct isst_id *, void for (k = 0; k < MAX_PUNIT_PER_DIE && k < MAX_DIE_PER_PACKAGE; k++) { id.cpu = cpus[i][k][k]; id.pkg = i; - id.die = k; + id.die = get_physical_die_id(id.cpu); id.punit = k; if (isst_is_punit_valid(&id)) callback(&id, arg1, arg2, arg3, arg4); @@ -586,7 +589,10 @@ void for_each_online_power_domain_in_set(void (*callback)(struct isst_id *, void for (k = 0; k < MAX_PUNIT_PER_DIE; k++) { id.cpu = cpus[i][j][k]; id.pkg = i; - id.die = j; + if (id.cpu >= 0) + id.die = get_physical_die_id(id.cpu); + else + id.die = id.pkg; id.punit = k; if (isst_is_punit_valid(&id)) callback(&id, arg1, arg2, arg3, arg4); @@ -815,6 +821,9 @@ static void create_cpu_map(void) if (max_punit_id < cpu_map[i].punit_id) max_punit_id = cpu_map[i].punit_id; + if (!pkg_id && max_die_id_package_0 < die_id) + max_die_id_package_0 = die_id; + debug_printf( "map logical_cpu:%d core: %d die:%d pkg:%d punit:%d punit_cpu:%d punit_core:%d\n", i, cpu_map[i].core_id, cpu_map[i].die_id, From 40abc4a4927ecfd2a135dfe0b67a2f23c661c66d Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Wed, 5 Mar 2025 11:01:56 -0800 Subject: [PATCH 26/45] tools/power/x86/intel-speed-select: Fix the condition to check multi die system commit c49e805db30674293d6a595db52549addd9d611f upstream. Even when there is no die exported by CPUID leaf 0x1F, the kernel version after 6.9 will show non zero die_id in the sysfs. In that case maximum die_id can still match maximum power domain ID. So the condition to check if the power domain ID is same a die_id to prevent duplicate display doesn't hold true. The better condition is to check if the maximum die_id is more than the maximum package_id. If the die_id is exposed by CPUID leaf 0x1F, the maximum die_id will be more than maximum package_id. With this change tracking of max_punit_id is not used, so remove storing max_punit_id. Intel-SIG: commit c49e805db306 tools/power/x86/intel-speed-select: Fix the condition to check multi die system Sync intel-speed-select to v1.26 Signed-off-by: Srinivas Pandruvada [ Zhang Rui: amend commit log ] Signed-off-by: Zhang Rui --- tools/power/x86/intel-speed-select/isst-config.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tools/power/x86/intel-speed-select/isst-config.c b/tools/power/x86/intel-speed-select/isst-config.c index c319bfc3b7cb..545e9e88f998 100644 --- a/tools/power/x86/intel-speed-select/isst-config.c +++ b/tools/power/x86/intel-speed-select/isst-config.c @@ -46,8 +46,8 @@ static int force_online_offline; static int auto_mode; static int fact_enable_fail; static int cgroupv2; +static int max_pkg_id; static int max_die_id; -static int max_punit_id; static int max_die_id_package_0; /* clos related */ @@ -567,7 +567,7 @@ void for_each_online_power_domain_in_set(void (*callback)(struct isst_id *, void } for (i = 0; i < MAX_PACKAGE_COUNT; i++) { - if (max_die_id == max_punit_id) { + if (max_die_id > max_pkg_id) { for (k = 0; k < MAX_PUNIT_PER_DIE && k < MAX_DIE_PER_PACKAGE; k++) { id.cpu = cpus[i][k][k]; id.pkg = i; @@ -794,6 +794,8 @@ static void create_cpu_map(void) cpu_map[i].die_id = die_id; cpu_map[i].core_id = core_id; + if (max_pkg_id < pkg_id) + max_pkg_id = pkg_id; punit_id = 0; @@ -818,9 +820,6 @@ static void create_cpu_map(void) if (max_die_id < die_id) max_die_id = die_id; - if (max_punit_id < cpu_map[i].punit_id) - max_punit_id = cpu_map[i].punit_id; - if (!pkg_id && max_die_id_package_0 < die_id) max_die_id_package_0 = die_id; From 79d8b0d320a983fc955ccdd24f4792a2bea5b466 Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Wed, 5 Mar 2025 11:03:15 -0800 Subject: [PATCH 27/45] tools/power/x86/intel-speed-select: Die ID for IO dies commit 7ad93737ddf355d57cbdd2e769fc6a0802019b46 upstream. Instead of displaying "-1" for IO dies, display "IO". Intel-SIG: commit 7ad93737ddf3 tools/power/x86/intel-speed-select: Die ID for IO dies Sync intel-speed-select to v1.26 Signed-off-by: Srinivas Pandruvada [ Zhang Rui: amend commit log ] Signed-off-by: Zhang Rui --- tools/power/x86/intel-speed-select/isst-display.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/power/x86/intel-speed-select/isst-display.c b/tools/power/x86/intel-speed-select/isst-display.c index 07ebd08f3202..da5a59a4c545 100644 --- a/tools/power/x86/intel-speed-select/isst-display.c +++ b/tools/power/x86/intel-speed-select/isst-display.c @@ -173,7 +173,11 @@ static int print_package_info(struct isst_id *id, FILE *outf) if (out_format_is_json()) { if (api_version() > 1) { - if (id->cpu < 0) + 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); @@ -190,7 +194,10 @@ static int print_package_info(struct isst_id *id, FILE *outf) } snprintf(header, sizeof(header), "package-%d", id->pkg); format_and_print(outf, level++, header, NULL); - snprintf(header, sizeof(header), "die-%d", id->die); + 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); From d9897f33ee0fd519a7a7e850115a5cd153c4b92c Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Tue, 28 Jan 2025 19:39:32 -0800 Subject: [PATCH 28/45] tools/power/x86/intel-speed-select: Prefix header search path with sysroot commit 8d9cfb6d712b829b40bc4d9831673aa05ebfeb0e upstream. This helps when using a cross-compiler for building intel-speed-select, currently, its hardcoded to pick libnl3 headers from build host which may not be same as build target when cross compiling. cc -print-sysroot will print nothing if compiler is configured without a sysroot and result in same string as it is now. Fixes errors with gcc configured with host include poisoning e.g. cc1: error: include location "/usr/include/libnl3" is unsafe for cross-compilation [-Werror=poison-system-directories] Signed-off-by: Khem Raj [ srinivas: Changelog edits for checkpatch warning ] Intel-SIG: commit 8d9cfb6d712b tools/power/x86/intel-speed-select: Prefix header search path with sysroot Sync intel-speed-select to v1.26 Signed-off-by: Srinivas Pandruvada [ Zhang Rui: amend commit log ] Signed-off-by: Zhang Rui --- tools/power/x86/intel-speed-select/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/power/x86/intel-speed-select/Makefile b/tools/power/x86/intel-speed-select/Makefile index 7221f2f55e8b..8d3a02a20f3d 100644 --- a/tools/power/x86/intel-speed-select/Makefile +++ b/tools/power/x86/intel-speed-select/Makefile @@ -13,7 +13,7 @@ endif # Do not use make's built-in rules # (this improves performance and avoids hard-to-debug behaviour); MAKEFLAGS += -r -override CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include -I/usr/include/libnl3 +override CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include -I$(shell $(CC) -print-sysroot)/usr/include/libnl3 override LDFLAGS += -lnl-genl-3 -lnl-3 ALL_TARGETS := intel-speed-select From 4e68d8f82827abd0fa4cf1e0a582a673e31fa0a7 Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Wed, 5 Mar 2025 18:12:56 -0800 Subject: [PATCH 29/45] tools/power/x86/intel-speed-select: v1.22 release commit 7dd556365b0ccba1f3c581f4c4747ad88497f496 upstream. This version has fix for: - Display of die ID and optimize array size for multi package systems. - Fix build warning with cross compiler Intel-SIG: commit 7dd556365b0c tools/power/x86/intel-speed-select: v1.22 release Sync intel-speed-select to v1.26 Signed-off-by: Srinivas Pandruvada [ Zhang Rui: amend commit log ] Signed-off-by: Zhang Rui --- tools/power/x86/intel-speed-select/isst-config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/power/x86/intel-speed-select/isst-config.c b/tools/power/x86/intel-speed-select/isst-config.c index 545e9e88f998..eaa420ac848d 100644 --- a/tools/power/x86/intel-speed-select/isst-config.c +++ b/tools/power/x86/intel-speed-select/isst-config.c @@ -16,7 +16,7 @@ struct process_cmd_struct { int arg; }; -static const char *version_str = "v1.21"; +static const char *version_str = "v1.22"; static const int supported_api_ver = 3; static struct isst_if_platform_info isst_platform_info; From 1089bbba05555996fac03d5fad5c946afccc3869 Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Sat, 29 Mar 2025 22:34:29 -0700 Subject: [PATCH 30/45] tools/power/x86/intel-speed-select: Support SST PP revision 2 fields commit 5aa63cab70d3f9c1ff714977ecad09c62ccef731 upstream. Display fields added by SST PP revision 2. They include: uncore P0 (max frequency), P1 (base frequency) and Pm (min frequency) for uncore fabric 1. Intel-SIG: commit 5aa63cab70d3 tools/power/x86/intel-speed-select: Support SST PP revision 2 fields Sync intel-speed-select to v1.26 Signed-off-by: Srinivas Pandruvada [ Zhang Rui: amend commit log ] Signed-off-by: Zhang Rui --- .../x86/intel-speed-select/isst-core-tpmi.c | 12 +++++++++++ .../x86/intel-speed-select/isst-display.c | 20 +++++++++++++++++++ tools/power/x86/intel-speed-select/isst.h | 3 +++ 3 files changed, 35 insertions(+) diff --git a/tools/power/x86/intel-speed-select/isst-core-tpmi.c b/tools/power/x86/intel-speed-select/isst-core-tpmi.c index da53aaa27fc9..4f389e1c0525 100644 --- a/tools/power/x86/intel-speed-select/isst-core-tpmi.c +++ b/tools/power/x86/intel-speed-select/isst-core-tpmi.c @@ -227,6 +227,7 @@ static int tpmi_get_ctdp_control(struct isst_id *id, int config_index, 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; @@ -253,6 +254,17 @@ static int tpmi_get_tdp_info(struct isst_id *id, int config_index, 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, diff --git a/tools/power/x86/intel-speed-select/isst-display.c b/tools/power/x86/intel-speed-select/isst-display.c index da5a59a4c545..e4884eb02837 100644 --- a/tools/power/x86/intel-speed-select/isst-display.c +++ b/tools/power/x86/intel-speed-select/isst-display.c @@ -460,6 +460,26 @@ void isst_ctdp_display_information(struct isst_id *id, FILE *outf, int tdp_level 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", diff --git a/tools/power/x86/intel-speed-select/isst.h b/tools/power/x86/intel-speed-select/isst.h index 39ee75677c2c..960f647cfc2d 100644 --- a/tools/power/x86/intel-speed-select/isst.h +++ b/tools/power/x86/intel-speed-select/isst.h @@ -147,6 +147,9 @@ struct isst_pkg_ctdp_level_info { 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; From b9b218bfa1aa6d9be2333c6fd4270b12ec1995f9 Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Wed, 16 Apr 2025 17:26:46 -0700 Subject: [PATCH 31/45] tools/power/x86/intel-speed-select: Skip uncore frequency update commit 51272ca7c3670d37cd4c573ed0f2f54e24095a01 upstream. On SST PP level switch, skip adjusting the uncore frequency limit and allow the hardware to handle this on newer platforms. As newer generations of CPUs have changed the extended family identifier, use this identifier to exclude the update. Intel-SIG: commit 51272ca7c367 tools/power/x86/intel-speed-select: Skip uncore frequency update Sync intel-speed-select to v1.26 Signed-off-by: Srinivas Pandruvada [ Zhang Rui: amend commit log ] Signed-off-by: Zhang Rui --- tools/power/x86/intel-speed-select/isst-config.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tools/power/x86/intel-speed-select/isst-config.c b/tools/power/x86/intel-speed-select/isst-config.c index eaa420ac848d..f94bec29b1b0 100644 --- a/tools/power/x86/intel-speed-select/isst-config.c +++ b/tools/power/x86/intel-speed-select/isst-config.c @@ -26,6 +26,7 @@ static FILE *outf; static int cpu_model; static int cpu_stepping; +static int extended_family; #define MAX_CPUS_IN_ONE_REQ 512 static short max_target_cpus; @@ -143,6 +144,14 @@ int is_icx_platform(void) return 0; } +static int is_dmr_plus_platform(void) +{ + if (extended_family == 0x04) + return 1; + + return 0; +} + static int update_cpu_model(void) { unsigned int ebx, ecx, edx; @@ -150,6 +159,7 @@ static int update_cpu_model(void) __cpuid(1, fms, ebx, ecx, edx); family = (fms >> 8) & 0xf; + extended_family = (fms >> 20) & 0x0f; cpu_model = (fms >> 4) & 0xf; if (family == 6 || family == 0xf) cpu_model += ((fms >> 16) & 0xf) << 4; @@ -1517,7 +1527,8 @@ static void set_tdp_level_for_cpu(struct isst_id *id, void *arg1, void *arg2, vo usleep(2000); /* Adjusting uncore freq */ - isst_adjust_uncore_freq(id, tdp_level, &ctdp_level); + if (!is_dmr_plus_platform()) + isst_adjust_uncore_freq(id, tdp_level, &ctdp_level); fprintf(stderr, "Option is set to online/offline\n"); ctdp_level.core_cpumask_size = From a545ccd87f880633990885f1e1e158947be6772e Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Sat, 29 Mar 2025 22:43:58 -0700 Subject: [PATCH 32/45] tools/power/x86/intel-speed-select: v1.23 release commit 6dfe26cb1c290fa4b62e6fb8c05209fe5f7adb76 upstream. This version includes the following changes: - Displays SST-PP2 revision fields. - Skips updating uncore frequency limits on newer generations of CPUs. Intel-SIG: commit 6dfe26cb1c29 tools/power/x86/intel-speed-select: v1.23 release Sync intel-speed-select to v1.26 Signed-off-by: Srinivas Pandruvada [ Zhang Rui: amend commit log ] Signed-off-by: Zhang Rui --- tools/power/x86/intel-speed-select/isst-config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/power/x86/intel-speed-select/isst-config.c b/tools/power/x86/intel-speed-select/isst-config.c index f94bec29b1b0..0ce251b8d466 100644 --- a/tools/power/x86/intel-speed-select/isst-config.c +++ b/tools/power/x86/intel-speed-select/isst-config.c @@ -16,7 +16,7 @@ struct process_cmd_struct { int arg; }; -static const char *version_str = "v1.22"; +static const char *version_str = "v1.23"; static const int supported_api_ver = 3; static struct isst_if_platform_info isst_platform_info; From 45e79c22ff4be58b255a382a7600c1b7809e41ea Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Thu, 1 May 2025 12:49:36 -0700 Subject: [PATCH 33/45] tools/power/x86/intel-speed-select: Check feature status commit 6dc93d689068a2e41cca3c8977f2d3efd47146ee upstream. After change of enable/disable status of SST-CP, SST-TF and SST-BF check if the hardware status change was successful. If not successful even after retries, return failure. Intel-SIG: commit 6dc93d689068 tools/power/x86/intel-speed-select: Check feature status Sync intel-speed-select to v1.26 Signed-off-by: Srinivas Pandruvada [ Zhang Rui: amend commit log ] Signed-off-by: Zhang Rui --- .../x86/intel-speed-select/isst-core-tpmi.c | 45 ++++++++++++++++++- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/tools/power/x86/intel-speed-select/isst-core-tpmi.c b/tools/power/x86/intel-speed-select/isst-core-tpmi.c index 4f389e1c0525..544839b55977 100644 --- a/tools/power/x86/intel-speed-select/isst-core-tpmi.c +++ b/tools/power/x86/intel-speed-select/isst-core-tpmi.c @@ -452,13 +452,16 @@ static int tpmi_get_pbf_info(struct isst_id *id, int level, 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; + int ret, i; ret = isst_get_ctdp_levels(id, &pkg_dev); if (ret) @@ -503,6 +506,30 @@ static int tpmi_set_pbf_fact_status(struct isst_id *id, int pbf, int enable) 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; } @@ -659,7 +686,8 @@ static int tpmi_pm_qos_config(struct isst_id *id, int enable_clos, int priority_type) { struct isst_core_power info; - int i, ret, saved_punit; + int cp_state = 0, cp_cap = 0; + int i, j, ret, saved_punit; info.get_set = 1; info.socket_id = id->pkg; @@ -679,6 +707,19 @@ static int tpmi_pm_qos_config(struct isst_id *id, int enable_clos, 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; + } } } From 117742a998388c8c34e035662113d899f4bb7790 Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Wed, 11 Jun 2025 11:29:49 -0700 Subject: [PATCH 34/45] tools/power/x86/intel-speed-select: Reset isst_turbo_freq_info for invalid buckets commit 3bd486e2d990194bf696423f9a639b3674d8c4e5 upstream. With SST-TF version 2 only 3 buckets are present. The information in others buckets can be junk. So initialize the info structure of type isst_turbo_freq_info, before issing ioctl to get bucket information. Intel-SIG: commit 3bd486e2d990 tools/power/x86/intel-speed-select: Reset isst_turbo_freq_info for invalid buckets Sync intel-speed-select to v1.26 Signed-off-by: Srinivas Pandruvada [ Zhang Rui: amend commit log ] Signed-off-by: Zhang Rui --- tools/power/x86/intel-speed-select/isst-core-tpmi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/power/x86/intel-speed-select/isst-core-tpmi.c b/tools/power/x86/intel-speed-select/isst-core-tpmi.c index 544839b55977..ebaad0dc8ca6 100644 --- a/tools/power/x86/intel-speed-select/isst-core-tpmi.c +++ b/tools/power/x86/intel-speed-select/isst-core-tpmi.c @@ -540,6 +540,7 @@ static int tpmi_get_fact_info(struct isst_id *id, int level, int fact_bucket, int i, j; int ret; + memset(&info, 0, sizeof(info)); info.socket_id = id->pkg; info.power_domain_id = id->punit; info.level = level; From db0b1baae466254a70e31ef1549a4b36e24a87de Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Fri, 7 Nov 2025 17:03:34 -0800 Subject: [PATCH 35/45] tools/power/x86/intel-speed-select: v1.24 release commit ad374eb9b33fc4738f21e57658073a04f77d493d upstream. This version includes the following changes: - Check feature status to check if the feature enablement was successful - Reset SST-TF bucket structure to display valid bucket info Intel-SIG: commit ad374eb9b33f tools/power/x86/intel-speed-select: v1.24 release Sync intel-speed-select to v1.26 Signed-off-by: Srinivas Pandruvada [ Zhang Rui: amend commit log ] Signed-off-by: Zhang Rui --- tools/power/x86/intel-speed-select/isst-config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/power/x86/intel-speed-select/isst-config.c b/tools/power/x86/intel-speed-select/isst-config.c index 0ce251b8d466..558138eea75e 100644 --- a/tools/power/x86/intel-speed-select/isst-config.c +++ b/tools/power/x86/intel-speed-select/isst-config.c @@ -16,7 +16,7 @@ struct process_cmd_struct { int arg; }; -static const char *version_str = "v1.23"; +static const char *version_str = "v1.24"; static const int supported_api_ver = 3; static struct isst_if_platform_info isst_platform_info; From 6b36bd3498aa50cfced56bf038ff8dbcb03f677c Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Fri, 16 Jan 2026 15:30:23 -0800 Subject: [PATCH 36/45] tools/power/x86/intel-speed-select: Allow non root users commit 6588b8845e7387438d4b91ea86e7cb6d838b3108 upstream. When permitted by the file /dev/isst_interface, allow to issue commands for non root users. When user id is non root, check if "/dev/isst_interface" can still be opened. If this file can be opened, allow all read only commands. Intel-SIG: commit 6588b8845e73 tools/power/x86/intel-speed-select: Allow non root users Sync intel-speed-select to v1.26 Signed-off-by: Srinivas Pandruvada [ Zhang Rui: amend commit log ] Signed-off-by: Zhang Rui --- .../x86/intel-speed-select/isst-config.c | 39 ++++++++++++++++++- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/tools/power/x86/intel-speed-select/isst-config.c b/tools/power/x86/intel-speed-select/isst-config.c index 558138eea75e..807feb17bb81 100644 --- a/tools/power/x86/intel-speed-select/isst-config.c +++ b/tools/power/x86/intel-speed-select/isst-config.c @@ -80,6 +80,18 @@ struct cpu_topology { short die_id; }; +static int read_only; + +static void check_privilege(void) +{ + if (!read_only) + return; + + isst_display_error_info_message(1, "Insufficient privileges", 0, 0); + isst_ctdp_display_information_end(outf); + exit(1); +} + FILE *get_output_file(void) { return outf; @@ -1578,6 +1590,8 @@ static void set_tdp_level_for_cpu(struct isst_id *id, void *arg1, void *arg2, vo static void set_tdp_level(int arg) { + check_privilege(); + if (cmd_help) { fprintf(stderr, "Set Config TDP level\n"); fprintf(stderr, @@ -2046,6 +2060,8 @@ static void set_pbf_enable(int arg) { int enable = arg; + check_privilege(); + if (cmd_help) { if (enable) { fprintf(stderr, @@ -2212,6 +2228,8 @@ static void set_fact_enable(int arg) int i, ret, enable = arg; struct isst_id id; + check_privilege(); + if (cmd_help) { if (enable) { fprintf(stderr, @@ -2361,6 +2379,8 @@ static void set_clos_enable(int arg) { int enable = arg; + check_privilege(); + if (cmd_help) { if (enable) { fprintf(stderr, @@ -2491,6 +2511,8 @@ static void set_clos_config_for_cpu(struct isst_id *id, void *arg1, void *arg2, static void set_clos_config(int arg) { + check_privilege(); + if (cmd_help) { fprintf(stderr, "Set core-power configuration for one of the four clos ids\n"); @@ -2556,6 +2578,8 @@ static void set_clos_assoc_for_cpu(struct isst_id *id, void *arg1, void *arg2, v static void set_clos_assoc(int arg) { + check_privilege(); + if (cmd_help) { fprintf(stderr, "Associate a clos id to a CPU\n"); fprintf(stderr, @@ -2637,6 +2661,8 @@ static void set_turbo_mode(int arg) int i, disable = arg; struct isst_id id; + check_privilege(); + if (cmd_help) { if (disable) fprintf(stderr, "Set turbo mode disable\n"); @@ -2682,6 +2708,7 @@ static void get_set_trl(struct isst_id *id, void *arg1, void *arg2, void *arg3, } if (set) { + check_privilege(); ret = isst_set_trl(id, fact_trl); isst_display_result(id, outf, "turbo-mode", "set-trl", ret); return; @@ -3204,8 +3231,16 @@ static void cmdline(int argc, char **argv) }; if (geteuid() != 0) { - fprintf(stderr, "Must run as root\n"); - exit(0); + int fd; + + fd = open(pathname, O_RDWR); + if (fd < 0) { + fprintf(stderr, "Must run as root\n"); + exit(0); + } + fprintf(stderr, "\nNot running as root, Only read only operations are supported\n"); + close(fd); + read_only = 1; } ret = update_cpu_model(); From 60cc4f8bd304446007613146d7c619c14d2c70ab Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Mon, 29 Dec 2025 12:45:06 -0800 Subject: [PATCH 37/45] tools/power/x86/intel-speed-select: Use pkg-config for libnl-3.0 detection commit 21adcd5ec99f342489a49e9d237a987b1bd9fab5 upstream. Replace hardcoded libnl3 include path with pkg-config detection to improve portability across different distributions and build environments. The previous implementation used a fixed path constructed from the compiler's sysroot, which could fail on systems with non-standard library installations. Now the build system: - Attempts to detect libnl-3.0 include paths using pkg-config - Falls back to /usr/include/libnl3 if pkg-config is unavailable - Maintains backward compatibility with existing build configurations This ensures the tool builds correctly on a wider range of systems while preserving existing behavior when pkg-config is not present. Closes:https://bugzilla.kernel.org/show_bug.cgi?id=220819 Intel-SIG: commit 21adcd5ec99f tools/power/x86/intel-speed-select: Use pkg-config for libnl-3.0 detection Sync intel-speed-select to v1.26 Signed-off-by: Khem Raj Signed-off-by: Srinivas Pandruvada [ Zhang Rui: amend commit log ] Signed-off-by: Zhang Rui --- tools/power/x86/intel-speed-select/Makefile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/power/x86/intel-speed-select/Makefile b/tools/power/x86/intel-speed-select/Makefile index 8d3a02a20f3d..6b299aae2ded 100644 --- a/tools/power/x86/intel-speed-select/Makefile +++ b/tools/power/x86/intel-speed-select/Makefile @@ -13,7 +13,13 @@ endif # Do not use make's built-in rules # (this improves performance and avoids hard-to-debug behaviour); MAKEFLAGS += -r -override CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include -I$(shell $(CC) -print-sysroot)/usr/include/libnl3 + +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 From 47671b7eaa9cffe4551e487923caaabb675ce435 Mon Sep 17 00:00:00 2001 From: Malaya Kumar Rout Date: Thu, 15 Jan 2026 15:33:33 +0530 Subject: [PATCH 38/45] tools/power/x86/intel-speed-select: Fix file descriptor leak in isolate_cpus() commit 56c17ee151c6e1a73d77e15b82a8e2130cd8dd16 upstream. The file descriptor opened in isolate_cpus() when (!level) is true was not being closed before returning, causing a file descriptor leak in both the error path and the success path. When write() fails at line 950, the function returns at line 953 without closing the file descriptor. Similarly, on success, the function returns at line 956 without closing the file descriptor. Add close(fd) calls before both return statements to fix the resource leak. This follows the same pattern used elsewhere in the same function where file descriptors are properly closed before returning (see lines 1005 and 1027). Intel-SIG: commit 56c17ee151c6 tools/power/x86/intel-speed-select: Fix file descriptor leak in isolate_cpus() Sync intel-speed-select to v1.26 Fixes: 997074df658e ("tools/power/x86/intel-speed-select: Use cgroup v2 isolation") Signed-off-by: Malaya Kumar Rout Signed-off-by: Srinivas Pandruvada [ Zhang Rui: amend commit log ] Signed-off-by: Zhang Rui --- tools/power/x86/intel-speed-select/isst-config.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/power/x86/intel-speed-select/isst-config.c b/tools/power/x86/intel-speed-select/isst-config.c index 807feb17bb81..68c9955dd7f4 100644 --- a/tools/power/x86/intel-speed-select/isst-config.c +++ b/tools/power/x86/intel-speed-select/isst-config.c @@ -962,9 +962,11 @@ int isolate_cpus(struct isst_id *id, int mask_size, cpu_set_t *cpu_mask, int lev ret = write(fd, "member", strlen("member")); if (ret == -1) { printf("Can't update to member\n"); + close(fd); return ret; } + close(fd); return 0; } From d06dcb443d396b0dd2c147e6128910b6c4afa5b4 Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Fri, 16 Jan 2026 15:48:50 -0800 Subject: [PATCH 39/45] tools/power/x86/intel-speed-select: v1.25 release commit 6142b726e6e64870ab0c7ffb158bffa141f83bb6 upstream. This version includes the following changes: - Allow read only commands for non root users when permitted - Fix file descriptor leak in isolate_cpus() - Replace hardcoded libnl3 include path Intel-SIG: commit 6142b726e6e6 tools/power/x86/intel-speed-select: v1.25 release Sync intel-speed-select to v1.26 Signed-off-by: Srinivas Pandruvada [ Zhang Rui: amend commit log ] Signed-off-by: Zhang Rui --- tools/power/x86/intel-speed-select/isst-config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/power/x86/intel-speed-select/isst-config.c b/tools/power/x86/intel-speed-select/isst-config.c index 68c9955dd7f4..dd9056ddb016 100644 --- a/tools/power/x86/intel-speed-select/isst-config.c +++ b/tools/power/x86/intel-speed-select/isst-config.c @@ -16,7 +16,7 @@ struct process_cmd_struct { int arg; }; -static const char *version_str = "v1.24"; +static const char *version_str = "v1.25"; static const int supported_api_ver = 3; static struct isst_if_platform_info isst_platform_info; From 959b15075a66af63902e9fa63c5e68322801368a Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Thu, 12 Mar 2026 12:41:08 -0700 Subject: [PATCH 40/45] tools/power/x86/intel-speed-select: Avoid current base freq as maximum commit ae67f582398611b9f67c06961e292e3a2612346d upstream. SST-PP level change results in online/offline of CPUs with -o option. The Linux intel-pstate driver internally stores the current HWP_REQ MSR value during offline and restores them during online. It is possible that during SST-PP level change, the new HWP_CAP limits can be updated. So, when a CPU is online, the HWP_REQ MSR should be updated to new values based on HWP_CAP values. This is particularly problematic when either turbo is disabled or the current HWP_REQ value (stored before online) is less than the base frequency from the updated HWP_CAP MSR guaranteed value. If the HWP_REQ MSR is not updated, then the performance will be limited to the value before perf level change. Hence the tool updates cpufreq scaling_max_freq to the newer base_frequency value in this case. This step is not required when HWP interrupts are enabled, as the perf level change should result in a new interrupt with HWP_GUARANTEED_PERF_CHANGE_STATUS and the intel_pstate driver will update to new limits. But the tool needs to handle the case when HWP interrupts are not enabled but there is no way for the tool to know that HWP interrupts are enabled or not. So, it has to still update the scaling_max_freq. With the QOS changes in the kernel, user space writes to scaling_max_freq are treated as hard limits. So, when base frequency is increased with SST-BF enabled, the cpufreq subsystem will still not allow setting to the SST-BF high priority core frequency. So, the HWP_REQ MSR will still be capped to the user-set scaling_max_freq after SST-PP level change. To address this, instead of setting scaling_max_freq to the current HWP_CAP highest frequency, set it to the maximum integer value to set the QOS limit as unconstrained. In this case, the actual HWP_REQ maximum frequency will still be capped to HWP_CAP highest performance by the intel-pstate driver. So, it will not result in invalid HWP_REQ values. Intel-SIG: commit ae67f5823986 tools/power/x86/intel-speed-select: Avoid current base freq as maximum Sync intel-speed-select to v1.26 Signed-off-by: Srinivas Pandruvada [ Zhang Rui: amend commit log ] Signed-off-by: Zhang Rui --- tools/power/x86/intel-speed-select/isst-config.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/power/x86/intel-speed-select/isst-config.c b/tools/power/x86/intel-speed-select/isst-config.c index dd9056ddb016..652ef1f567ad 100644 --- a/tools/power/x86/intel-speed-select/isst-config.c +++ b/tools/power/x86/intel-speed-select/isst-config.c @@ -1744,6 +1744,9 @@ static int no_turbo(void) return parse_int_file(0, "/sys/devices/system/cpu/intel_pstate/no_turbo"); } +#define U32_MAX ((unsigned int)~0U) +#define S32_MAX ((int)(U32_MAX >> 1)) + static void adjust_scaling_max_from_base_freq(int cpu) { int base_freq, scaling_max_freq; @@ -1751,7 +1754,7 @@ static void adjust_scaling_max_from_base_freq(int cpu) scaling_max_freq = parse_int_file(0, "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_max_freq", cpu); base_freq = get_cpufreq_base_freq(cpu); if (scaling_max_freq < base_freq || no_turbo()) - set_cpufreq_scaling_min_max(cpu, 1, base_freq); + set_cpufreq_scaling_min_max(cpu, 1, S32_MAX); } static void adjust_scaling_min_from_base_freq(int cpu) From 392251e9820f5e113cb2721b67a92f9d1513f3ce Mon Sep 17 00:00:00 2001 From: Zhang Rui Date: Mon, 26 Jan 2026 08:27:01 +0800 Subject: [PATCH 41/45] tools/power/x86/intel-speed-select: Fix cpu extended family ID decoding commit df4a83543117c7fc27077fd7f4ffe870556b257b upstream. When decode and use CPU extended family ID in intel-speed-select, there are several potential issues, 1. Mask with 0x0f to get CPU extended family ID is bogus because CPU extended family ID takes 8 bits (bit 27:20). 2. Use CPU extended family ID fields without checking CPU family ID is risky. Because Intel SDM says, "The Extended Family ID needs to be examined only when the Family ID is 0FH." 3. Saving cpu family ID and cpu extended family ID separately doesn't align with Linux kernel. And it may bring extra complexity when making family specific changes in the future. Intel-SIG: commit df4a83543117 tools/power/x86/intel-speed-select: Fix cpu extended family ID decoding Sync intel-speed-select to v1.26 Signed-off-by: Srinivas Pandruvada [ Zhang Rui: amend commit log ] Signed-off-by: Zhang Rui --- tools/power/x86/intel-speed-select/isst-config.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tools/power/x86/intel-speed-select/isst-config.c b/tools/power/x86/intel-speed-select/isst-config.c index 652ef1f567ad..3f2573ecca76 100644 --- a/tools/power/x86/intel-speed-select/isst-config.c +++ b/tools/power/x86/intel-speed-select/isst-config.c @@ -26,7 +26,7 @@ static FILE *outf; static int cpu_model; static int cpu_stepping; -static int extended_family; +static int cpu_family; #define MAX_CPUS_IN_ONE_REQ 512 static short max_target_cpus; @@ -158,7 +158,7 @@ int is_icx_platform(void) static int is_dmr_plus_platform(void) { - if (extended_family == 0x04) + if (cpu_family == 19) return 1; return 0; @@ -167,13 +167,14 @@ static int is_dmr_plus_platform(void) static int update_cpu_model(void) { unsigned int ebx, ecx, edx; - unsigned int fms, family; + unsigned int fms; __cpuid(1, fms, ebx, ecx, edx); - family = (fms >> 8) & 0xf; - extended_family = (fms >> 20) & 0x0f; + cpu_family = (fms >> 8) & 0xf; + if (cpu_family == 0xf) + cpu_family += (fms >> 20) & 0xff; cpu_model = (fms >> 4) & 0xf; - if (family == 6 || family == 0xf) + if (cpu_family == 6 || cpu_family == 0xf) cpu_model += ((fms >> 16) & 0xf) << 4; cpu_stepping = fms & 0xf; From ea361a63315ddcfdc3eec08986bbfe7a8c391472 Mon Sep 17 00:00:00 2001 From: Zhang Rui Date: Thu, 19 Mar 2026 13:52:54 +0800 Subject: [PATCH 42/45] tools/power/x86/intel-speed-select: Fix some program return value commit 3e244dd513e26728577f1e4deca6fdf749b6f244 upstream. When running the "intel-speed-select -h" command, it returns 1. 0 when using a version that is API incompatible. 2. 1 when using a version that is API compatible. And this is confusing. Fix the program to return 0 for "-h" parameter, and return 1 whenever "Incompatible API versions" is detected. Intel-SIG: commit 3e244dd513e2 tools/power/x86/intel-speed-select: Fix some program return value Sync intel-speed-select to v1.26 Signed-off-by: Srinivas Pandruvada [ Zhang Rui: amend commit log ] Signed-off-by: Zhang Rui --- tools/power/x86/intel-speed-select/isst-config.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/power/x86/intel-speed-select/isst-config.c b/tools/power/x86/intel-speed-select/isst-config.c index 3f2573ecca76..b1376411cfa4 100644 --- a/tools/power/x86/intel-speed-select/isst-config.c +++ b/tools/power/x86/intel-speed-select/isst-config.c @@ -1139,7 +1139,7 @@ static int isst_fill_platform_info(void) if (isst_platform_info.api_version > supported_api_ver) { printf("Incompatible API versions; Upgrade of tool is required\n"); - return -1; + exit(1); } set_platform_ops: @@ -3195,7 +3195,7 @@ static void usage(void) printf("\tTo get full turbo-freq information dump:\n"); printf("\t\tintel-speed-select turbo-freq info -l 0\n"); } - exit(1); + exit(0); } static void print_version(void) From 0c7e54c5c74ee2200268518018a32e9524717d82 Mon Sep 17 00:00:00 2001 From: Zhang Rui Date: Thu, 19 Mar 2026 13:52:55 +0800 Subject: [PATCH 43/45] tools/power/x86/intel-speed-select: Print Version info when Incompatible API version is detected commit 93f5b44b416c7419a76a5e1311fb750fca585638 upstream. When running an old version intel-speed-select tool on newer platforms, even with "intel-speed-select -v", the tool only complains about "Incompatible API version", without giving the current version info. Print Version info whenever Incompatible API version is detected. Intel-SIG: commit 93f5b44b416c tools/power/x86/intel-speed-select: Print Version info when Incompatible API version is detected Sync intel-speed-select to v1.26 Signed-off-by: Srinivas Pandruvada [ Zhang Rui: amend commit log ] Signed-off-by: Zhang Rui --- tools/power/x86/intel-speed-select/isst-config.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tools/power/x86/intel-speed-select/isst-config.c b/tools/power/x86/intel-speed-select/isst-config.c index b1376411cfa4..1e156063141e 100644 --- a/tools/power/x86/intel-speed-select/isst-config.c +++ b/tools/power/x86/intel-speed-select/isst-config.c @@ -82,6 +82,11 @@ struct cpu_topology { static int read_only; +static void print_version(void) +{ + fprintf(outf, "Version %s\n", version_str); +} + static void check_privilege(void) { if (!read_only) @@ -1138,6 +1143,7 @@ static int isst_fill_platform_info(void) close(fd); if (isst_platform_info.api_version > supported_api_ver) { + print_version(); printf("Incompatible API versions; Upgrade of tool is required\n"); exit(1); } @@ -3198,12 +3204,6 @@ static void usage(void) exit(0); } -static void print_version(void) -{ - fprintf(outf, "Version %s\n", version_str); - exit(0); -} - static void cmdline(int argc, char **argv) { const char *pathname = "/dev/isst_interface"; @@ -3315,6 +3315,7 @@ static void cmdline(int argc, char **argv) break; case 'v': print_version(); + exit(0); break; case 'b': oob_mode = 1; From f304cfcf206f3013963b08e2931dff61782b1148 Mon Sep 17 00:00:00 2001 From: Zhang Rui Date: Thu, 19 Mar 2026 13:52:56 +0800 Subject: [PATCH 44/45] tools/power/x86/intel-speed-select: Fix output when running on unsupported CLX platforms commit 1b25f03f3daf7c26c37050a7b2b5858ad5f99cfc upstream. When running intel-speed-select on unsupported CLX platforms, it prints intel-speed-select: Invalid CPU model (85) : Success Because this is not a system error and errno is not set. Replace err() with exit(). Intel-SIG: commit 1b25f03f3daf tools/power/x86/intel-speed-select: Fix output when running on unsupported CLX platforms Sync intel-speed-select to v1.26 Signed-off-by: Srinivas Pandruvada [ Zhang Rui: amend commit log ] Signed-off-by: Zhang Rui --- tools/power/x86/intel-speed-select/isst-config.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/power/x86/intel-speed-select/isst-config.c b/tools/power/x86/intel-speed-select/isst-config.c index 1e156063141e..67878a08e116 100644 --- a/tools/power/x86/intel-speed-select/isst-config.c +++ b/tools/power/x86/intel-speed-select/isst-config.c @@ -3250,8 +3250,10 @@ static void cmdline(int argc, char **argv) } ret = update_cpu_model(); - if (ret) - err(-1, "Invalid CPU model (%d)\n", cpu_model); + if (ret) { + fprintf(stderr, "Invalid CPU model (%d)\n", cpu_model); + exit(1); + } printf("Intel(R) Speed Select Technology\n"); printf("Executing on CPU model:%d[0x%x]\n", cpu_model, cpu_model); From 258757c1fa75286ac1257e629c1fa243d40a750a Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Sun, 5 Apr 2026 11:54:25 -0700 Subject: [PATCH 45/45] tools/power/x86/intel-speed-select: v1.26 release commit ee69d9e32bdb0044b9444f1ae12107ff8b5ff95f upstream. This version includes the following changes: - Setting current base frequency as maximum for SST-BF with kernel QOS changes - Harmonize extended family decoded with the rest of the kernel - Minor changes for error codes and messages Intel-SIG: commit ee69d9e32bdb tools/power/x86/intel-speed-select: v1.26 release Sync intel-speed-select to v1.26 Signed-off-by: Srinivas Pandruvada [ Zhang Rui: amend commit log ] Signed-off-by: Zhang Rui --- tools/power/x86/intel-speed-select/isst-config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/power/x86/intel-speed-select/isst-config.c b/tools/power/x86/intel-speed-select/isst-config.c index 67878a08e116..2faff1aead52 100644 --- a/tools/power/x86/intel-speed-select/isst-config.c +++ b/tools/power/x86/intel-speed-select/isst-config.c @@ -16,7 +16,7 @@ struct process_cmd_struct { int arg; }; -static const char *version_str = "v1.25"; +static const char *version_str = "v1.26"; static const int supported_api_ver = 3; static struct isst_if_platform_info isst_platform_info;