@@ -56,6 +56,7 @@ struct cpufreq_dom {
};
static LIST_HEAD_READ_MOSTLY(cpufreq_dom_list_head);
+bool __initdata cpufreq_governor_internal;
struct cpufreq_governor *__read_mostly cpufreq_opt_governor;
LIST_HEAD_READ_MOSTLY(cpufreq_governor_list);
@@ -120,6 +120,9 @@ static int __init cf_check cpufreq_gov_userspace_init(void)
{
unsigned int cpu;
+ if ( cpufreq_governor_internal )
+ return 0;
+
for_each_online_cpu(cpu)
per_cpu(cpu_set_freq, cpu) = userspace_cmdline_freq;
register_cpu_notifier(&cpufreq_userspace_cpu_nfb);
@@ -162,6 +165,9 @@ struct cpufreq_governor cpufreq_gov_performance = {
static int __init cf_check cpufreq_gov_performance_init(void)
{
+ if ( cpufreq_governor_internal )
+ return 0;
+
return cpufreq_register_governor(&cpufreq_gov_performance);
}
__initcall(cpufreq_gov_performance_init);
@@ -201,6 +207,9 @@ struct cpufreq_governor cpufreq_gov_powersave = {
static int __init cf_check cpufreq_gov_powersave_init(void)
{
+ if ( cpufreq_governor_internal )
+ return 0;
+
return cpufreq_register_governor(&cpufreq_gov_powersave);
}
__initcall(cpufreq_gov_powersave_init);
@@ -360,6 +360,9 @@ struct cpufreq_governor cpufreq_gov_dbs = {
static int __init cf_check cpufreq_gov_dbs_init(void)
{
+ if ( cpufreq_governor_internal )
+ return 0;
+
return cpufreq_register_governor(&cpufreq_gov_dbs);
}
__initcall(cpufreq_gov_dbs_init);
@@ -116,6 +116,8 @@ extern struct cpufreq_governor cpufreq_gov_powersave;
extern struct list_head cpufreq_governor_list;
+extern bool cpufreq_governor_internal;
+
extern int cpufreq_register_governor(struct cpufreq_governor *governor);
extern struct cpufreq_governor *__find_governor(const char *governor);
#define CPUFREQ_DEFAULT_GOVERNOR &cpufreq_gov_dbs
For hwp, the standard governors are not usable, and only the internal one is applicable. Add the cpufreq_governor_internal boolean to indicate when an internal governor, like hwp, will be used. This is set during presmp_initcall, and governor registration can be skipped when called during initcall. This way unusable governors are not registered, and only compatible governors are advertised to userspace. Signed-off-by: Jason Andryuk <jandryuk@gmail.com> --- v5: Check cpufreq_governor_internal and skip registration as applicable Remove internal flag v4: Rework to use an internal flag Removed Jan's Ack since the approach is different. v3: Switch to initdata Add Jan Acked-by Commit message s/they/the/ typo Don't register hwp-internal when running non-hwp - Marek v2: Switch to "-internal" Add blank line in header --- xen/drivers/cpufreq/cpufreq.c | 1 + xen/drivers/cpufreq/cpufreq_misc_governors.c | 9 +++++++++ xen/drivers/cpufreq/cpufreq_ondemand.c | 3 +++ xen/include/acpi/cpufreq/cpufreq.h | 2 ++ 4 files changed, 15 insertions(+)