Skip to content

Commit f667433

Browse files
spandruvadagregkh
authored andcommitted
tools/power/x86/intel-speed-select: Set scaling_max_freq to base_frequency
[ Upstream commit f981dc1 ] When BIOS disables turbo, The scaling_max_freq in cpufreq sysfs will be limited to config level 0 base frequency. But when user selects a higher config levels, this will result in higher base frequency. But since scaling_max_freq is still old base frequency, the performance will still be limited. So when the turbo is disabled and cpufreq base_frequency is higher than scaling_max_freq, update the scaling_max_freq to the base_frequency. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Link: https://lore.kernel.org/r/20201221071859.2783957-2-srinivas.pandruvada@linux.intel.com Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 0c1a24a commit f667433

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

‎tools/power/x86/intel-speed-select/isst-config.c‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,6 +1245,8 @@ static void dump_isst_config(int arg)
12451245
isst_ctdp_display_information_end(outf);
12461246
}
12471247

1248+
static void adjust_scaling_max_from_base_freq(int cpu);
1249+
12481250
static void set_tdp_level_for_cpu(int cpu, void *arg1, void *arg2, void *arg3,
12491251
void *arg4)
12501252
{
@@ -1263,6 +1265,9 @@ static void set_tdp_level_for_cpu(int cpu, void *arg1, void *arg2, void *arg3,
12631265
int pkg_id = get_physical_package_id(cpu);
12641266
int die_id = get_physical_die_id(cpu);
12651267

1268+
/* Wait for updated base frequencies */
1269+
usleep(2000);
1270+
12661271
fprintf(stderr, "Option is set to online/offline\n");
12671272
ctdp_level.core_cpumask_size =
12681273
alloc_cpu_set(&ctdp_level.core_cpumask);
@@ -1279,6 +1284,7 @@ static void set_tdp_level_for_cpu(int cpu, void *arg1, void *arg2, void *arg3,
12791284
if (CPU_ISSET_S(i, ctdp_level.core_cpumask_size, ctdp_level.core_cpumask)) {
12801285
fprintf(stderr, "online cpu %d\n", i);
12811286
set_cpu_online_offline(i, 1);
1287+
adjust_scaling_max_from_base_freq(i);
12821288
} else {
12831289
fprintf(stderr, "offline cpu %d\n", i);
12841290
set_cpu_online_offline(i, 0);
@@ -1436,6 +1442,21 @@ static int set_cpufreq_scaling_min_max(int cpu, int max, int freq)
14361442
return 0;
14371443
}
14381444

1445+
static int no_turbo(void)
1446+
{
1447+
return parse_int_file(0, "/sys/devices/system/cpu/intel_pstate/no_turbo");
1448+
}
1449+
1450+
static void adjust_scaling_max_from_base_freq(int cpu)
1451+
{
1452+
int base_freq, scaling_max_freq;
1453+
1454+
scaling_max_freq = parse_int_file(0, "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_max_freq", cpu);
1455+
base_freq = get_cpufreq_base_freq(cpu);
1456+
if (scaling_max_freq < base_freq || no_turbo())
1457+
set_cpufreq_scaling_min_max(cpu, 1, base_freq);
1458+
}
1459+
14391460
static int set_clx_pbf_cpufreq_scaling_min_max(int cpu)
14401461
{
14411462
struct isst_pkg_ctdp_level_info *ctdp_level;

0 commit comments

Comments
 (0)