MSM Hotplug ( Thanks Myfluxi )

msm: hotplug: Check down lock for lowest load cpu

As reported by neobuddy89.
msm: hotplug: Add io_is_busy interface
msm: hotplug: Update default fast_lane_load

A value of 99% load catches almost all spikes and keeps spurious
onlinings to an absolute minimum.

Replace all instances of cputime64_t by u64 (see upstream commit
72a4ce340a7ebf39e1c6fdc8f5feb4f974d6c635).
msm: hotplug: Fix another derp
msm: hotplug: Use load dependent update rates
msm: hotplug: Readd suspend max cpus and frequency options

We had this ages ago.
msm: hotplug: Remove the redundant iowait check
msm: hotplug: On- and offline cpus only when enabled

I mean really, really enabled...
msm: hotplug: Underp input checks

Kids, don't drink and drive.
msm: hotplug: Simplify store_history_size()
msm: hotplug: Allow to disable the circular stats buffer

This option reduces latency a tiny bit more.
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.
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
msm: hotplug: Consider projected load after cpu offlined

Don't offline a cpu if we would drop under the lower
level's up threshold load. Also, add an optional hard
threshold load under which a cpu is never offlined.
Both is especially important for very short forced
online intervals.
msm: hotplug: Terminate load thresh table
msm: hotplug: Honor enabled toggle

Start workqueue only if enabled. Also queue remove down
lock work on cpu0, circumvent regular cpu down routine
when disabling hotplug work and remove complete nonsense
in store_min_cpus_online().
msm: hotplug: Remove unused include
msm: hotplug: Handle down lock per cpu

Handling down lock per cpu is more precise. We can now distinguish
between a regular interval and a generous time online after the last
input event, where it's likely that the user will interact with the
UI within then next few seconds again.
msm: hotplug: Add enable/disable toggle

This is mainly for debugging purposes, i.e. using mpdecision.
msm: hotplug: Cleanup probe function

After performing nicely for over a half year this
actually starts looking almost decent...
msm: hotplug: Fix licensing issue

I have no idea about licensing and I could care less
but this should be correct.
msm: hotplug: Protect load stats routine and cleanup
msm: hotplug: Consider load instead of frequency for slowest cpu
msm: hotplug: Revert to original thresholds
msm: hotplug: Update threshold values and down lock duration

* Power up additional cpus earlier
* Power down cpus later
* Keep cpus online at least 5 seconds
msm: hotplug: Fixup sysfs interface

* Use proper return values
* Fix store_down_lock_duration()
* Add some more checks
* Cleanup some mess
msm: hotplug: Fix symbol export
msm: hotplug: Add pm ops
msm: hotplug: Optimize hotplugging routines

- Power down the slowest cpu
- Move checks from callback to calling function
- Clean it up a bit
cpufreq: add new routine cpufreq_verify_within_cpu_limits()

Most of the users of cpufreq_verify_within_limits() calls it for
limiting with min/max from policy->cpuinfo. We can make that code
simple by introducing another routine which will do this for them
automatically.

This patch adds another routine cpufreq_verify_within_cpu_limits()
and updates others to use it.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Dirk Brandewie <dirk.j.brandewie@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
msm: hotplug: Cleanup hotplugging routines

Remove paroid atomic operations that were causing issues.
msm: hotplug: Remove deprecated msm_cpufreq_set_freq_limits
msm: hotplug: Add minimum interval for input boost
msm: hotplug: Add input boost handler

Add an input handler to hotplug additional cpus. Down lock will
take care of keeping the cpu boosted.
msm: hotplug: Use high-priority workqueue
msm: hotplug: Increase down lock duration and janitize
msm_hotplug: Remove touch boost
msm: hotplug: Schedule suspend/resume work

Dennis is right, this is the proper way to suspend and resume.
msm: hotplug: Stop hotplug work a tad later
msm: hotplug: Remove spinlock in load stats

It's too expensive and not nessecary.
msm: hotplug: Max 1036MHz during screen off
msm: hotplug: Add MSM Hotplug driver
msm: mdss: Adding lcd notifier
cpufreq: add new routine cpufreq_verify_within_cpu_limits()

Most of the users of cpufreq_verify_within_limits() calls it for
limiting with min/max from policy->cpuinfo. We can make that code
simple by introducing another routine which will do this for them
automatically.

This patch adds another routine cpufreq_verify_within_cpu_limits()
and updates others to use it.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Dirk Brandewie <dirk.j.brandewie@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
mdnie: HIJACK MDNIE Profile v1.1 (Thanks Yank555.lu)