Commit cf3b8e8f authored by Srinivas Pandruvada's avatar Srinivas Pandruvada Committed by Hans de Goede

tools/power/x86/intel-speed-select: cpufreq reads on offline CPUs

Due to some recent kernel changes, reading cpufreq attributes like
scaling_max_freq on offline CPUs returns error. So avoid reading
cpufreq attributes on offline CPUs.
Signed-off-by: default avatarSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
parent 689dfc9e
...@@ -413,6 +413,33 @@ int get_topo_max_cpus(void) ...@@ -413,6 +413,33 @@ int get_topo_max_cpus(void)
return topo_max_cpus; return topo_max_cpus;
} }
static unsigned int is_cpu_online(int cpu)
{
char buffer[128];
int fd, ret;
unsigned char online;
snprintf(buffer, sizeof(buffer),
"/sys/devices/system/cpu/cpu%d/online", cpu);
fd = open(buffer, O_RDONLY);
if (fd < 0)
return fd;
ret = read(fd, &online, sizeof(online));
close(fd);
if (ret == -1)
return ret;
if (online == '1')
online = 1;
else
online = 0;
return online;
}
void set_cpu_online_offline(int cpu, int state) void set_cpu_online_offline(int cpu, int state)
{ {
char buffer[128]; char buffer[128];
...@@ -1603,6 +1630,9 @@ static void set_scaling_min_to_cpuinfo_max(struct isst_id *id) ...@@ -1603,6 +1630,9 @@ static void set_scaling_min_to_cpuinfo_max(struct isst_id *id)
if (!is_cpu_in_power_domain(i, id)) if (!is_cpu_in_power_domain(i, id))
continue; continue;
if (is_cpu_online(i) != 1)
continue;
adjust_scaling_max_from_base_freq(i); adjust_scaling_max_from_base_freq(i);
set_cpufreq_scaling_min_max_from_cpuinfo(i, 1, 0); set_cpufreq_scaling_min_max_from_cpuinfo(i, 1, 0);
adjust_scaling_min_from_base_freq(i); adjust_scaling_min_from_base_freq(i);
...@@ -1617,6 +1647,9 @@ static void set_scaling_min_to_cpuinfo_min(struct isst_id *id) ...@@ -1617,6 +1647,9 @@ static void set_scaling_min_to_cpuinfo_min(struct isst_id *id)
if (!is_cpu_in_power_domain(i, id)) if (!is_cpu_in_power_domain(i, id))
continue; continue;
if (is_cpu_online(i) != 1)
continue;
adjust_scaling_max_from_base_freq(i); adjust_scaling_max_from_base_freq(i);
set_cpufreq_scaling_min_max_from_cpuinfo(i, 0, 0); set_cpufreq_scaling_min_max_from_cpuinfo(i, 0, 0);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment