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

Commit 41e8a951 authored by Pavankumar Kondeti's avatar Pavankumar Kondeti
Browse files

cpufreq: schedutil: Fix for limits update with fast switch enabled



When the policy limits are applied with fast switch enabled, the
policy->cur is not updated. This can result in incorrect calculation
of the average capacity and any subsequent limit updates.

Update cpufreq_policy_apply_limits_fast() API to return a non-zero
value when the frequency is updated. Make use of this return value
and update policy->cur. While at it, print cpu_frequency trace point,
when frequency is changed due to change in limits.

Change-Id: I51732fa061aac11231d1f18ca70f31f252f0a0dd
Signed-off-by: default avatarPavankumar Kondeti <pkondeti@codeaurora.org>
parent 80d949a5
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -541,13 +541,17 @@ 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)
static inline unsigned int
cpufreq_policy_apply_limits_fast(struct cpufreq_policy *policy)
{
	unsigned int ret = 0;

	if (policy->max < policy->cur)
		cpufreq_driver_fast_switch(policy, policy->max);
		ret = cpufreq_driver_fast_switch(policy, policy->max);
	else if (policy->min > policy->cur)
		cpufreq_driver_fast_switch(policy, policy->min);
		ret = cpufreq_driver_fast_switch(policy, policy->min);

	return ret;
}

/* Governor attribute set */
+8 −1
Original line number Diff line number Diff line
@@ -1067,6 +1067,8 @@ static void sugov_limits(struct cpufreq_policy *policy)
{
	struct sugov_policy *sg_policy = policy->governor_data;
	unsigned long flags;
	unsigned int ret;
	int cpu;

	if (!policy->fast_switch_enabled) {
		mutex_lock(&sg_policy->work_lock);
@@ -1080,7 +1082,12 @@ static void sugov_limits(struct cpufreq_policy *policy)
		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);
		ret = cpufreq_policy_apply_limits_fast(policy);
		if (ret && policy->cur != ret) {
			policy->cur = ret;
			for_each_cpu(cpu, policy->cpus)
				trace_cpu_frequency(ret, cpu);
		}
		raw_spin_unlock_irqrestore(&sg_policy->update_lock, flags);
	}