summaryrefslogtreecommitdiffstats
path: root/tools/power
diff options
context:
space:
mode:
authorSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>2020-03-05 14:45:17 -0800
committerAndy Shevchenko <andriy.shevchenko@linux.intel.com>2020-03-20 14:46:20 +0200
commit864dc09e692f55fc7a5a87c7411da0a348ac1094 (patch)
tree0cbae58f92c261c9670be7851e500fb5e1895ae1 /tools/power
parent696691985c3191f2c4c76f09b1c7c5f3ca99d5ed (diff)
downloadlinux-stable-864dc09e692f55fc7a5a87c7411da0a348ac1094.tar.gz
linux-stable-864dc09e692f55fc7a5a87c7411da0a348ac1094.tar.bz2
linux-stable-864dc09e692f55fc7a5a87c7411da0a348ac1094.zip
tools/power/x86/intel-speed-select: Max CPU count calculation when CPU0 is offline
Currently /sys/devices/system/cpu/cpu0/topology/thread_siblings is used to get the max CPU count. But when CPU0 is offline, then this file will be absent. So add processing so that we can get count from any first CPU in the system. which is online. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Diffstat (limited to 'tools/power')
-rw-r--r--tools/power/x86/intel-speed-select/isst-config.c18
1 files changed, 16 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 b8f4846d7c78..c773c6cc02a5 100644
--- a/tools/power/x86/intel-speed-select/isst-config.c
+++ b/tools/power/x86/intel-speed-select/isst-config.c
@@ -316,10 +316,24 @@ static void set_max_cpu_num(void)
{
FILE *filep;
unsigned long dummy;
+ int i;
topo_max_cpus = 0;
- filep = fopen_or_exit(
- "/sys/devices/system/cpu/cpu0/topology/thread_siblings", "r");
+ for (i = 0; i < 256; ++i) {
+ char path[256];
+
+ snprintf(path, sizeof(path),
+ "/sys/devices/system/cpu/cpu%d/topology/thread_siblings", i);
+ filep = fopen(path, "r");
+ if (filep)
+ break;
+ }
+
+ if (!filep) {
+ fprintf(stderr, "Can't get max cpu number\n");
+ exit(0);
+ }
+
while (fscanf(filep, "%lx,", &dummy) == 1)
topo_max_cpus += BITMASK_SIZE;
fclose(filep);