Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dabce2be authored by Michael Turquette's avatar Michael Turquette Committed by Dmitry Shmidt
Browse files

ANDROID: cpufreq: introduce cpufreq_driver_is_slow



Some architectures and platforms perform CPU frequency transitions
through a non-blocking method, while some might block or sleep. Even
when frequency transitions do not block or sleep they may be very slow.
This distinction is important when trying to change frequency from
a non-interruptible context in a scheduler hot path.

Describe this distinction with a cpufreq driver flag,
CPUFREQ_DRIVER_FAST. The default is to not have this flag set,
thus erring on the side of caution.

cpufreq_driver_is_slow() is also introduced in this patch. Setting
the above flag will allow this function to return false.

[smuckle@linaro.org: change flag/API to include drivers that are too
 slow for scheduler hot paths, in addition to those that block/sleep]

Cc: Rafael J. Wysocki <rafael@kernel.org>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: default avatarMichael Turquette <mturquette@baylibre.com>
Signed-off-by: default avatarSteve Muckle <smuckle@linaro.org>
Signed-off-by: default avatarAndres Oportus <andresoportus@google.com>
parent 4c6a8248
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -117,6 +117,12 @@ bool have_governor_per_policy(void)
}
EXPORT_SYMBOL_GPL(have_governor_per_policy);

bool cpufreq_driver_is_slow(void)
{
	return !(cpufreq_driver->flags & CPUFREQ_DRIVER_FAST);
}
EXPORT_SYMBOL_GPL(cpufreq_driver_is_slow);

struct kobject *get_governor_parent_kobj(struct cpufreq_policy *policy)
{
	if (have_governor_per_policy())
+9 −0
Original line number Diff line number Diff line
@@ -177,6 +177,7 @@ u64 get_cpu_idle_time(unsigned int cpu, u64 *wall, int io_busy);
int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu);
int cpufreq_update_policy(unsigned int cpu);
bool have_governor_per_policy(void);
bool cpufreq_driver_is_slow(void);
struct kobject *get_governor_parent_kobj(struct cpufreq_policy *policy);
void cpufreq_enable_fast_switch(struct cpufreq_policy *policy);
void cpufreq_disable_fast_switch(struct cpufreq_policy *policy);
@@ -359,6 +360,14 @@ struct cpufreq_driver {
 */
#define CPUFREQ_NEED_INITIAL_FREQ_CHECK	(1 << 5)

/*
 * Indicates that it is safe to call cpufreq_driver_target from
 * non-interruptable context in scheduler hot paths.  Drivers must
 * opt-in to this flag, as the safe default is that they might sleep
 * or be too slow for hot path use.
 */
#define CPUFREQ_DRIVER_FAST		(1 << 6)

int cpufreq_register_driver(struct cpufreq_driver *driver_data);
int cpufreq_unregister_driver(struct cpufreq_driver *driver_data);