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

Commit baf191f8 authored by Jonathan Avila's avatar Jonathan Avila
Browse files

cpufreq: schedutil: Rework the fast switch limits logic



Due to certain misunderstandings about the workings of the cpufreq driver,
the original fast switch logic had several bugs in place. Instead of
creating multiple changes to address them, redesign the fast switch limits
code properly.

Change-Id: I8eb8835d63ecd4ae6c6b406a8e2b33409e856a80
Signed-off-by: default avatarJonathan Avila <avilaj@codeaurora.org>
parent d3d6e9be
Loading
Loading
Loading
Loading
+0 −9
Original line number Diff line number Diff line
@@ -540,15 +540,6 @@ static inline void cpufreq_policy_apply_limits(struct cpufreq_policy *policy)
		__cpufreq_driver_target(policy, policy->min, CPUFREQ_RELATION_L);
}

static inline void cpufreq_policy_apply_limits_fast(struct cpufreq_policy
						    *policy)
{
	if (policy->max < policy->cur)
		cpufreq_driver_fast_switch(policy, policy->max);
	else if (policy->min > policy->cur)
		cpufreq_driver_fast_switch(policy, policy->min);
}

/* Governor attribute set */
struct gov_attr_set {
	struct kobject kobj;
+12 −4
Original line number Diff line number Diff line
@@ -1329,7 +1329,8 @@ static void sugov_stop(struct cpufreq_policy *policy)
static void sugov_limits(struct cpufreq_policy *policy)
{
	struct sugov_policy *sg_policy = policy->governor_data;
	unsigned long flags;
	unsigned long flags, now;
	unsigned int freq;

	if (!policy->fast_switch_enabled) {
		mutex_lock(&sg_policy->work_lock);
@@ -1341,9 +1342,16 @@ static void sugov_limits(struct cpufreq_policy *policy)
		mutex_unlock(&sg_policy->work_lock);
	} else {
		raw_spin_lock_irqsave(&sg_policy->update_lock, flags);
		sugov_track_cycles(sg_policy, sg_policy->policy->cur,
				   ktime_get_ns());
		cpufreq_policy_apply_limits_fast(policy);
		freq = policy->cur;
		now = ktime_get_ns();

		/*
		 * cpufreq_driver_resolve_freq() has a clamp, so we do not need
		 * to do any sort of additional validation here.
		 */
		freq = cpufreq_driver_resolve_freq(policy, freq);
		sg_policy->cached_raw_freq = freq;
		sugov_fast_switch(sg_policy, now, freq);
		raw_spin_unlock_irqrestore(&sg_policy->update_lock, flags);
	}