Commit de7f9d3d authored by Srinivas Pandruvada's avatar Srinivas Pandruvada Committed by Andy Shevchenko

tools/power/x86/intel-speed-select: Use core count for base-freq mask

Some firmware implementation gives error when a command is sent get mask
for core count 32-61. So use core count to decide.

But there is no function to get core count. So introduce one function to
get core count.
Signed-off-by: default avatarSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
parent 7af5a95b
...@@ -338,6 +338,7 @@ void free_cpu_set(cpu_set_t *cpu_set) ...@@ -338,6 +338,7 @@ void free_cpu_set(cpu_set_t *cpu_set)
} }
static int cpu_cnt[MAX_PACKAGE_COUNT][MAX_DIE_PER_PACKAGE]; static int cpu_cnt[MAX_PACKAGE_COUNT][MAX_DIE_PER_PACKAGE];
static long long core_mask[MAX_PACKAGE_COUNT][MAX_DIE_PER_PACKAGE];
static void set_cpu_present_cpu_mask(void) static void set_cpu_present_cpu_mask(void)
{ {
size_t size; size_t size;
...@@ -362,13 +363,33 @@ static void set_cpu_present_cpu_mask(void) ...@@ -362,13 +363,33 @@ static void set_cpu_present_cpu_mask(void)
pkg_id = get_physical_package_id(i); pkg_id = get_physical_package_id(i);
if (pkg_id < MAX_PACKAGE_COUNT && if (pkg_id < MAX_PACKAGE_COUNT &&
die_id < MAX_DIE_PER_PACKAGE) die_id < MAX_DIE_PER_PACKAGE) {
int core_id = get_physical_core_id(i);
cpu_cnt[pkg_id][die_id]++; cpu_cnt[pkg_id][die_id]++;
core_mask[pkg_id][die_id] |= (1ULL << core_id);
}
} }
closedir(dir); closedir(dir);
} }
} }
int get_core_count(int pkg_id, int die_id)
{
int cnt = 0;
if (pkg_id < MAX_PACKAGE_COUNT && die_id < MAX_DIE_PER_PACKAGE) {
int i;
for (i = 0; i < sizeof(long long) * 8; ++i) {
if (core_mask[pkg_id][die_id] & (1ULL << i))
cnt++;
}
}
return cnt;
}
int get_cpu_count(int pkg_id, int die_id) int get_cpu_count(int pkg_id, int die_id)
{ {
if (pkg_id < MAX_PACKAGE_COUNT && die_id < MAX_DIE_PER_PACKAGE) if (pkg_id < MAX_PACKAGE_COUNT && die_id < MAX_DIE_PER_PACKAGE)
......
...@@ -335,12 +335,15 @@ int isst_set_tdp_level(int cpu, int tdp_level) ...@@ -335,12 +335,15 @@ int isst_set_tdp_level(int cpu, int tdp_level)
int isst_get_pbf_info(int cpu, int level, struct isst_pbf_info *pbf_info) int isst_get_pbf_info(int cpu, int level, struct isst_pbf_info *pbf_info)
{ {
int i, ret, core_cnt, max;
unsigned int req, resp; unsigned int req, resp;
int i, ret;
pbf_info->core_cpumask_size = alloc_cpu_set(&pbf_info->core_cpumask); pbf_info->core_cpumask_size = alloc_cpu_set(&pbf_info->core_cpumask);
for (i = 0; i < 2; ++i) { core_cnt = get_core_count(get_physical_package_id(cpu), get_physical_die_id(cpu));
max = core_cnt > 32 ? 2 : 1;
for (i = 0; i < max; ++i) {
unsigned long long mask; unsigned long long mask;
int count; int count;
......
...@@ -163,6 +163,7 @@ struct isst_pkg_ctdp { ...@@ -163,6 +163,7 @@ struct isst_pkg_ctdp {
extern int get_topo_max_cpus(void); extern int get_topo_max_cpus(void);
extern int get_cpu_count(int pkg_id, int die_id); extern int get_cpu_count(int pkg_id, int die_id);
extern int get_core_count(int pkg_id, int die_id);
/* Common interfaces */ /* Common interfaces */
extern void debug_printf(const char *format, ...); extern void debug_printf(const char *format, ...);
......
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