Skip to content

Commit db6e432

Browse files
rafaeljwgregkh
authored andcommitted
cpufreq: Introduce CPUFREQ_NEED_UPDATE_LIMITS driver flag
commit 1c53435 upstream. Generally, a cpufreq driver may need to update some internal upper and lower frequency boundaries on policy max and min changes, respectively, but currently this does not work if the target frequency does not change along with the policy limit. Namely, if the target frequency does not change along with the policy min or max, the "target_freq == policy->cur" check in __cpufreq_driver_target() prevents driver callbacks from being invoked and they do not even have a chance to update the corresponding internal boundary. This particularly affects the "powersave" and "performance" governors that always set the target frequency to one of the policy limits and it never changes when the other limit is updated. To allow cpufreq the drivers needing to update internal frequency boundaries on policy limits changes to avoid this issue, introduce a new driver flag, CPUFREQ_NEED_UPDATE_LIMITS, that (when set) will neutralize the check mentioned above. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 345b28c commit db6e432

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

drivers/cpufreq/cpufreq.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2166,7 +2166,8 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy,
21662166
* exactly same freq is called again and so we can save on few function
21672167
* calls.
21682168
*/
2169-
if (target_freq == policy->cur)
2169+
if (target_freq == policy->cur &&
2170+
!(cpufreq_driver->flags & CPUFREQ_NEED_UPDATE_LIMITS))
21702171
return 0;
21712172

21722173
/* Save last value to restore later on errors */

include/linux/cpufreq.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ __ATTR(_name, 0644, show_##_name, store_##_name)
293293

294294
struct cpufreq_driver {
295295
char name[CPUFREQ_NAME_LEN];
296-
u8 flags;
296+
u16 flags;
297297
void *driver_data;
298298

299299
/* needed by all drivers */
@@ -417,6 +417,14 @@ struct cpufreq_driver {
417417
*/
418418
#define CPUFREQ_IS_COOLING_DEV BIT(7)
419419

420+
/*
421+
* Set by drivers that need to update internale upper and lower boundaries along
422+
* with the target frequency and so the core and governors should also invoke
423+
* the diver if the target frequency does not change, but the policy min or max
424+
* may have changed.
425+
*/
426+
#define CPUFREQ_NEED_UPDATE_LIMITS BIT(8)
427+
420428
int cpufreq_register_driver(struct cpufreq_driver *driver_data);
421429
int cpufreq_unregister_driver(struct cpufreq_driver *driver_data);
422430

0 commit comments

Comments
 (0)