msm:rq_stats: Register for Cpufreq policy notification

Currently the load of the system is calculated using the max
frequency that is read during startup(It does not get updated
when the policy changes). As a result, the average load of the
system is incorrectly calculated and the system might not bring
the cpus online to manage the additional load. This
reduces the performance of the system.

To fix this issue, register rq_stats to receive cpufreq policy
notifications. Update the policy's max frequency when a
notification is received and use that value to calculate the load.

Change-Id: Icc78e28c736c170e198f723fd96c13dfb2dafe8a
Signed-off-by: Archana Sathyakumar <asathyak@codeaurora.org>
Signed-off-by: Anji Jonnala <anjir@codeaurora.org>
msm: hotplug: Add MSM Hotplug driver
msm: hotplug: Consider load instead of frequency for slowest cpu

Conflicts:

	arch/arm/mach-msm/msm_hotplug.c
ALUCARD_HOTPLUG: Implemented use msm rq stats...
alucard_hotplug: use rq stats adjustment
CPU_UTILIZATION for all hotplug
msm: rq_stats: Use cpufreq API to get the current frequency

Since the acpuclock APIs are deprecated, use the cpufreq to
get the current frequency of CPUs to calculate the cpu
normalized load value.

Signed-off-by: Archana Sathyakumar <asathyak@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: rq_stats: Fix wrong usage of cpufreq_quick_get()

cpufreq_quick_get() returns frequency in KHz, which is exactly what
cur_freq expect. Remove the wrong multiplication.

Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: hotplug: Optimize latencies

Before this patch it took the algorithm too long to
react on sudden load spikes, although only noticable
in benchmarks. We would cycle 5-6 times until the
buffer average was finally high enough to trigger a
new target.  Improve latencies by instantly onlining
all cpus if current load on any cpu is above a certain
threshold.

fast_lane_load should not be higher than 78 as load
per cpu won't be above this value in our metric.

First cycle in hackbench
Before: 1.253sec
After: 0.796sec

Conflicts:

	arch/arm/mach-msm/msm_hotplug.c
msm: hotplug: Refactor load calculation

* Move core load calculations to this file and optimize.
* Calculate load based on current policy->max, not cpuinfo.max_freq
  which explains the strange 78% maximum load value before.
* Recalculate thresholds and fast_lane_load accordingly.
* Cleanup some ambiguous namings and other minor stuff.
* EXPORT_SYMBOL_* is useless for static functions.

Conflicts:

	arch/arm/mach-msm/msm_hotplug.c
msm: rq_stats: Calculate load based on current freq limit

We are not using rq_stats any more so this commit is just for the
sake of completeness.  Prior to this patch, load has been calculated
based on an initial value of policy.cpuinfo.max_freq. This value may
change for several reasons: userspace settings, thermal throttling
(hello hammerhead!) or extended frequency tables where the absolute
maximum level is often not used during regular operations. This
results in unreliable calculations. Consider current policy.max to
fix this behaviour.
msm: rq_stats: Disable hotplug and stats by default

Userspace closed source mpdecision binary is nessecary for PowerHAL to work.
As it depends on rq_stats, let's at least disable hotplugging and stats
collection by default. /sys/devices/system/cpu/cpu0/rq-stats/hotplug_disable
is now writable, so hotplug can be reenabled.

Also, add some bits related to current cpu policy.
Fixed msm_rq_stats disabling enabling.
msm_rq_stats: acpuclk_get_rate() for cur_freq.
Small Cleanup in arch/arm/mach-msm/msm_rq_stats.c
soc: qcom: rq_stats: remove the redundant iowait check

Iowait_time check is redundant and it would lead to heavy load
due to miscaluculation of idle time. Hence remove this check
as iowait will considered based on io_busy flag.

[myfluxi: Adapt to msm 8974]

Change-Id: I4dd9f9c79205eca588daea8cc0fe892394a83391
CRs-fixed: 662052
Signed-off-by: Anji Jonnala <anjir@codeaurora.org>
msm_rq_stats: Removed useless cur_iowait_time references.
Add correct IO IS BUSY set for CPU Govs and HotPlugs.

Conflicts:

	arch/arm/mach-msm/msm_hotplug.c
	drivers/cpufreq/cpufreq_conservative.c
	drivers/cpufreq/cpufreq_interactive.c
	drivers/cpufreq/cpufreq_ondemand.c
	drivers/cpufreq/cpufreq_ondemandplus.c