Revert "cpufreq: interactive: Simplify frequency calculations"

This reverts commit dec880a2c9dac95b74a6a892f75e211bef03c482.

Signed-off-by: Dan Trifan <jimsth@gmail.com>
cpufreq: interactive: Allow go_hispeed to be disabled

Specify 0 for go_hispeed_load to disable it.

Change-Id: I4ea0f0e593a195bebceaa2a3d826cdf533aeb101
Signed-off-by: Dan Trifan <jimsth@gmail.com>
cpufreq: interactive: Add target_loads_down freq selection

Using a single set of target loads causes an excessive number
of frequency changes.  Reduce by having a mode that allows
for separate load factos for "up" frequency selection and
"down" frequency selection.

If user-space specifies target_loads_down then the new
duel mode frequency selection will be used and frequencies
will be scaled up to meet the load requirements but they
will only be scaled down if the can be scaled down without
violating the down target loads.

If user-space does not store a value in target_loads_down
then this change makes no functional difference in the
governor.

Change-Id: I817fe4e18dfb4fa58df871a5262a9f23813d6e70
Signed-off-by: Dan Trifan <jimsth@gmail.com>
sched: Compute avg_nr_running

Change-Id: I7443da4ba49634fea8c65eb19ca295a5eb8ee812
cpufreq: interactive: merge https://github.com/android/kernel_common/commit/4c7894cb01c7544225d5fcfb0fcb1d11fd2d1777 and fix a small code shit.

Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
cpufreq: interactive: this governor is fundamentally different from Ondemand and by norm its a bit more sensitive to load changes in terms of which freqs are chosen, but even though sometimes it can be a little stupid and non react to load changes that linearly as one could hope for (even though it's better than Ondemand) so for that reason let's try to use this new formula by @stratosk found in this commit: https://github.com/stratosk/kernel_msm/commit/9df03b662b9c213c75ac082138f5ab8afadb9d94 make sure you read his commit message for better understanding of this.

Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
cpufreq: interactive: calculate the load based on max (which is volatile) and not cpuinfo.max_freq, which is always 3GHz.

Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
cpufreq: Introduce new relation for freq selection

Introduce CPUFREQ_RELATION_C for frequency selection.
It selects the frequency with the minimum euclidean distance
to target. In case of equal distance between 2 frequencies,
it will select the greater freq.

Signed-off-by: Stratos Karafotis <stratosk@semaphore.gr>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
Signed-off-by: Dan Trifan <jimsth@gmail.com>