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

Commit 9104bb26 authored by Viresh Kumar's avatar Viresh Kumar Committed by Rafael J. Wysocki
Browse files

cpufreq: Don't traverse all active policies to find policy for a cpu



We reach here while adding policy for a CPU and enter into the 'if'
block only if a policy already exists for the CPU.

As cpufreq_cpu_data is set for all policy->related_cpus now, when the
policy is first added, we can use that to find the CPU's policy instead
of traversing the list of all active policies.

Acked-by: default avatarSaravana Kannan <skannan@codeaurora.org>
Signed-off-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 3914d379
Loading
Loading
Loading
Loading
+6 −9
Original line number Diff line number Diff line
@@ -1213,16 +1213,13 @@ static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif)
		return 0;

	/* Check if this CPU already has a policy to manage it */
	read_lock_irqsave(&cpufreq_driver_lock, flags);
	for_each_active_policy(policy) {
		if (cpumask_test_cpu(cpu, policy->related_cpus)) {
			read_unlock_irqrestore(&cpufreq_driver_lock, flags);
	policy = per_cpu(cpufreq_cpu_data, cpu);
	if (policy && !policy_is_inactive(policy)) {
		WARN_ON(!cpumask_test_cpu(cpu, policy->related_cpus));
		ret = cpufreq_add_policy_cpu(policy, cpu, dev);
		up_read(&cpufreq_rwsem);
		return ret;
	}
	}
	read_unlock_irqrestore(&cpufreq_driver_lock, flags);

	/*
	 * Restore the saved policy when doing light-weight init and fall back