Skip to content

Commit f5739cb

Browse files
committed
cpufreq: Fix policy initialization for internal governor drivers
Before commit 1e4f63a ("cpufreq: Avoid creating excessively large stack frames") the initial value of the policy field in struct cpufreq_policy set by the driver's ->init() callback was implicitly passed from cpufreq_init_policy() to cpufreq_set_policy() if the default governor was neither "performance" nor "powersave". After that commit, however, cpufreq_init_policy() must take that case into consideration explicitly and handle it as appropriate, so make that happen. Fixes: 1e4f63a ("cpufreq: Avoid creating excessively large stack frames") Link: https://lore.kernel.org/linux-pm/[email protected]/ Reported-by: Artem Bityutskiy <[email protected]> Cc: 5.4+ <[email protected]> # 5.4+ Signed-off-by: Rafael J. Wysocki <[email protected]> Acked-by: Viresh Kumar <[email protected]>
1 parent f8788d8 commit f5739cb

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

drivers/cpufreq/cpufreq.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,9 +1076,17 @@ static int cpufreq_init_policy(struct cpufreq_policy *policy)
10761076
pol = policy->last_policy;
10771077
} else if (def_gov) {
10781078
pol = cpufreq_parse_policy(def_gov->name);
1079-
} else {
1080-
return -ENODATA;
1079+
/*
1080+
* In case the default governor is neiter "performance"
1081+
* nor "powersave", fall back to the initial policy
1082+
* value set by the driver.
1083+
*/
1084+
if (pol == CPUFREQ_POLICY_UNKNOWN)
1085+
pol = policy->policy;
10811086
}
1087+
if (pol != CPUFREQ_POLICY_PERFORMANCE &&
1088+
pol != CPUFREQ_POLICY_POWERSAVE)
1089+
return -ENODATA;
10821090
}
10831091

10841092
return cpufreq_set_policy(policy, gov, pol);

0 commit comments

Comments
 (0)