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

Commit e34e3186 authored by Joel Fernandes's avatar Joel Fernandes
Browse files

Merge remote-tracking branch 'origin/android-4.9-eas-dev' into HEAD

Change-Id: Ibb1184075a0bc01ce86c747d239ba18873538cd9
parents ebc27895 a2ee4e79
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -27,6 +27,8 @@ const struct cpumask *cpu_coregroup_mask(int cpu);

#ifdef CONFIG_CPU_FREQ
#define arch_scale_freq_capacity cpufreq_scale_freq_capacity
#define arch_scale_max_freq_capacity cpufreq_scale_max_freq_capacity
#define arch_scale_min_freq_capacity cpufreq_scale_min_freq_capacity
#endif
#define arch_scale_cpu_capacity scale_cpu_capacity
extern unsigned long scale_cpu_capacity(struct sched_domain *sd, int cpu);
+0 −6
Original line number Diff line number Diff line
@@ -44,13 +44,7 @@ static DEFINE_PER_CPU(unsigned long, cpu_scale) = SCHED_CAPACITY_SCALE;

unsigned long scale_cpu_capacity(struct sched_domain *sd, int cpu)
{
#ifdef CONFIG_CPU_FREQ
	unsigned long max_freq_scale = cpufreq_scale_max_freq_capacity(cpu);

	return per_cpu(cpu_scale, cpu) * max_freq_scale >> SCHED_CAPACITY_SHIFT;
#else
	return per_cpu(cpu_scale, cpu);
#endif
}

static void set_capacity_scale(unsigned int cpu, unsigned long capacity)
+4 −1
Original line number Diff line number Diff line
@@ -35,7 +35,10 @@ struct sched_domain;
#ifdef CONFIG_CPU_FREQ
#define arch_scale_freq_capacity cpufreq_scale_freq_capacity
extern unsigned long cpufreq_scale_freq_capacity(struct sched_domain *sd, int cpu);
extern unsigned long cpufreq_scale_max_freq_capacity(int cpu);
#define arch_scale_max_freq_capacity cpufreq_scale_max_freq_capacity
extern unsigned long cpufreq_scale_max_freq_capacity(struct sched_domain *sd, int cpu);
#define arch_scale_min_freq_capacity cpufreq_scale_min_freq_capacity
extern unsigned long cpufreq_scale_min_freq_capacity(struct sched_domain *sd, int cpu);
#endif
#define arch_scale_cpu_capacity scale_cpu_capacity
extern unsigned long scale_cpu_capacity(struct sched_domain *sd, int cpu);
+0 −6
Original line number Diff line number Diff line
@@ -29,13 +29,7 @@ static DEFINE_PER_CPU(unsigned long, cpu_scale) = SCHED_CAPACITY_SCALE;

unsigned long scale_cpu_capacity(struct sched_domain *sd, int cpu)
{
#ifdef CONFIG_CPU_FREQ
	unsigned long max_freq_scale = cpufreq_scale_max_freq_capacity(cpu);

	return per_cpu(cpu_scale, cpu) * max_freq_scale >> SCHED_CAPACITY_SHIFT;
#else
	return per_cpu(cpu_scale, cpu);
#endif
}

static void set_capacity_scale(unsigned int cpu, unsigned long capacity)
+63 −20
Original line number Diff line number Diff line
@@ -315,43 +315,85 @@ static void adjust_jiffies(unsigned long val, struct cpufreq_freqs *ci)
 *********************************************************************/

static DEFINE_PER_CPU(unsigned long, freq_scale) = SCHED_CAPACITY_SCALE;
static DEFINE_PER_CPU(unsigned long, max_freq_cpu);
static DEFINE_PER_CPU(unsigned long, max_freq_scale) = SCHED_CAPACITY_SCALE;
static DEFINE_PER_CPU(unsigned long, min_freq_scale);

static void
scale_freq_capacity(struct cpufreq_policy *policy, struct cpufreq_freqs *freqs)
scale_freq_capacity(const cpumask_t *cpus, unsigned long cur_freq,
		    unsigned long max_freq)
{
	unsigned long cur = freqs ? freqs->new : policy->cur;
	unsigned long scale = (cur << SCHED_CAPACITY_SHIFT) / policy->max;
	struct cpufreq_cpuinfo *cpuinfo = &policy->cpuinfo;
	unsigned long scale = (cur_freq << SCHED_CAPACITY_SHIFT) / max_freq;
	int cpu;

	pr_debug("cpus %*pbl cur/cur max freq %lu/%u kHz freq scale %lu\n",
		 cpumask_pr_args(policy->cpus), cur, policy->max, scale);

	for_each_cpu(cpu, policy->cpus)
	for_each_cpu(cpu, cpus) {
		per_cpu(freq_scale, cpu) = scale;
		per_cpu(max_freq_cpu, cpu) = max_freq;
	}

	pr_debug("cpus %*pbl cur freq/max freq %lu/%lu kHz freq scale %lu\n",
		 cpumask_pr_args(cpus), cur_freq, max_freq, scale);
}

	if (freqs)
unsigned long cpufreq_scale_freq_capacity(struct sched_domain *sd, int cpu)
{
	return per_cpu(freq_scale, cpu);
}

static void
scale_max_freq_capacity(const cpumask_t *cpus, unsigned long policy_max_freq)
{
	unsigned long scale, max_freq;
	int cpu = cpumask_first(cpus);

	if (cpu >= nr_cpu_ids)
		return;

	scale = (policy->max << SCHED_CAPACITY_SHIFT) / cpuinfo->max_freq;
	max_freq = per_cpu(max_freq_cpu, cpu);

	pr_debug("cpus %*pbl cur max/max freq %u/%u kHz max freq scale %lu\n",
		 cpumask_pr_args(policy->cpus), policy->max, cpuinfo->max_freq,
		 scale);
	if (!max_freq)
		return;

	for_each_cpu(cpu, policy->cpus)
	scale = (policy_max_freq << SCHED_CAPACITY_SHIFT) / max_freq;

	for_each_cpu(cpu, cpus)
		per_cpu(max_freq_scale, cpu) = scale;

	pr_debug("cpus %*pbl policy max freq/max freq %lu/%lu kHz max freq scale %lu\n",
		 cpumask_pr_args(cpus), policy_max_freq, max_freq, scale);
}

unsigned long cpufreq_scale_freq_capacity(struct sched_domain *sd, int cpu)
unsigned long cpufreq_scale_max_freq_capacity(struct sched_domain *sd, int cpu)
{
	return per_cpu(freq_scale, cpu);
	return per_cpu(max_freq_scale, cpu);
}

unsigned long cpufreq_scale_max_freq_capacity(int cpu)
static void
scale_min_freq_capacity(const cpumask_t *cpus, unsigned long policy_min_freq)
{
	return per_cpu(max_freq_scale, cpu);
	unsigned long scale, max_freq;
	int cpu = cpumask_first(cpus);

	if (cpu >= nr_cpu_ids)
		return;

	max_freq = per_cpu(max_freq_cpu, cpu);

	if (!max_freq)
		return;

	scale = (policy_min_freq << SCHED_CAPACITY_SHIFT) / max_freq;

	for_each_cpu(cpu, cpus)
		per_cpu(min_freq_scale, cpu) = scale;

	pr_debug("cpus %*pbl policy min freq/max freq %lu/%lu kHz min freq scale %lu\n",
		 cpumask_pr_args(cpus), policy_min_freq, max_freq, scale);
}

unsigned long cpufreq_scale_min_freq_capacity(struct sched_domain *sd, int cpu)
{
	return per_cpu(min_freq_scale, cpu);
}

static void __cpufreq_notify_transition(struct cpufreq_policy *policy,
@@ -461,7 +503,7 @@ void cpufreq_freq_transition_begin(struct cpufreq_policy *policy,

	spin_unlock(&policy->transition_lock);

	scale_freq_capacity(policy, freqs);
	scale_freq_capacity(policy->cpus, freqs->new, policy->cpuinfo.max_freq);
#ifdef CONFIG_SMP
	for_each_cpu(cpu, policy->cpus)
		trace_cpu_capacity(capacity_curr_of(cpu), cpu);
@@ -2261,7 +2303,8 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy,
	blocking_notifier_call_chain(&cpufreq_policy_notifier_list,
			CPUFREQ_NOTIFY, new_policy);

	scale_freq_capacity(new_policy, NULL);
	scale_max_freq_capacity(policy->cpus, policy->max);
	scale_min_freq_capacity(policy->cpus, policy->min);

	policy->min = new_policy->min;
	policy->max = new_policy->max;
Loading