Skip to content

Commit dd016f3

Browse files
Lifeng Zhengrafaeljw
authored andcommitted
cpufreq: Introduce a more generic way to set default per-policy boost flag
In cpufreq_online() of cpufreq.c, the per-policy boost flag is already set to mirror the cpufreq_driver boost during init but using freq_table to judge if the policy has boost frequency. There are two drawbacks to this approach: 1. It doesn't work for the cpufreq drivers that do not use a frequency table. For now, acpi-cpufreq and amd-pstate have to enable boost in policy initialization. And cppc_cpufreq never set policy to boost when going online no matter what the cpufreq_driver boost flag is. 2. If the CPU goes offline when cpufreq_driver boost is enabled and then goes online when cpufreq_driver boost is disabled, the per-policy boost flag will incorrectly remain true. Running set_boost at the end of the online process is a more generic way for all cpufreq drivers. Signed-off-by: Lifeng Zheng <[email protected]> Link: https://patch.msgid.link/[email protected] Acked-by: Viresh Kumar <[email protected]> [ rjw: Changelog edits ] Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 1608f02 commit dd016f3

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

drivers/cpufreq/cpufreq.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,10 +1410,6 @@ static int cpufreq_online(unsigned int cpu)
14101410
goto out_free_policy;
14111411
}
14121412

1413-
/* Let the per-policy boost flag mirror the cpufreq_driver boost during init */
1414-
if (cpufreq_boost_enabled() && policy_has_boost_freq(policy))
1415-
policy->boost_enabled = true;
1416-
14171413
/*
14181414
* The initialization has succeeded and the policy is online.
14191415
* If there is a problem with its frequency table, take it
@@ -1574,6 +1570,18 @@ static int cpufreq_online(unsigned int cpu)
15741570
if (new_policy && cpufreq_thermal_control_enabled(cpufreq_driver))
15751571
policy->cdev = of_cpufreq_cooling_register(policy);
15761572

1573+
/* Let the per-policy boost flag mirror the cpufreq_driver boost during init */
1574+
if (policy->boost_enabled != cpufreq_boost_enabled()) {
1575+
policy->boost_enabled = cpufreq_boost_enabled();
1576+
ret = cpufreq_driver->set_boost(policy, policy->boost_enabled);
1577+
if (ret) {
1578+
/* If the set_boost fails, the online operation is not affected */
1579+
pr_info("%s: CPU%d: Cannot %s BOOST\n", __func__, policy->cpu,
1580+
policy->boost_enabled ? "enable" : "disable");
1581+
policy->boost_enabled = !policy->boost_enabled;
1582+
}
1583+
}
1584+
15771585
pr_debug("initialization complete\n");
15781586

15791587
return 0;

0 commit comments

Comments
 (0)