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

Commit af541e19 authored by Saravana Kannan's avatar Saravana Kannan
Browse files

cpufreq: schedutil: Add freq_to_util helper function



Refactor repetitive code into a function.

Change-Id: I30d53adf0cb0c4ce099f7f1c25cbc8c2f6473769
Signed-off-by: default avatarSaravana Kannan <skannan@codeaurora.org>
parent f6686697
Loading
Loading
Loading
Loading
+12 −7
Original line number Diff line number Diff line
@@ -225,6 +225,13 @@ static void sugov_walt_adjust(struct sugov_cpu *sg_cpu, unsigned long *util,
		*util = max(*util, sg_cpu->walt_load.pl);
}

static unsigned long freq_to_util(struct sugov_policy *sg_policy,
				  unsigned int freq)
{
	return mult_frac(sg_policy->max, freq,
			 sg_policy->policy->cpuinfo.max_freq);
}

static void sugov_update_single(struct update_util_data *hook, u64 time,
				unsigned int flags)
{
@@ -322,12 +329,11 @@ static void sugov_update_shared(struct update_util_data *hook, u64 time,
	raw_spin_lock(&sg_policy->update_lock);

	if (sg_policy->max != max) {
		hs_util = mult_frac(max,
				    sg_policy->tunables->hispeed_freq,
				    sg_policy->policy->cpuinfo.max_freq);
		sg_policy->max = max;
		hs_util = freq_to_util(sg_policy,
					sg_policy->tunables->hispeed_freq);
		hs_util = mult_frac(hs_util, TARGET_LOAD, 100);
		sg_policy->hispeed_util = hs_util;
		sg_policy->max = max;
	}

	sg_cpu->util = util;
@@ -438,9 +444,8 @@ static ssize_t hispeed_freq_store(struct gov_attr_set *attr_set,

	tunables->hispeed_freq = val;
	list_for_each_entry(sg_policy, &attr_set->policy_list, tunables_hook) {
		hs_util = mult_frac(sg_policy->max,
				    sg_policy->tunables->hispeed_freq,
				    sg_policy->policy->cpuinfo.max_freq);
		hs_util = freq_to_util(sg_policy,
					sg_policy->tunables->hispeed_freq);
		hs_util = mult_frac(hs_util, TARGET_LOAD, 100);
		sg_policy->hispeed_util = hs_util;
	}