DRIVERS: STAGING: LMK: Tune and disable Auto OOM
Signed-off-by: renderbroken <zkennedy87@gmail.com>
cpufreq: Move get_cpu_idle_time() to cpufreq.c

Governors other than ondemand and conservative can also use
get_cpu_idle_time() and they aren't required to compile
cpufreq_governor.c. So, move these independent routines to
cpufreq.c instead.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
[junjiew@codeaurora.org: update non-upstream files]
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
[neo: Update local drivers as well.]
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
CPUFREQ: INTERACTIVE: Re-sync to CAF and update

Revert "cpufreq: interactive: Remove unnecessary cpu_online() check"

This reverts commit 7b46e2e6d8a3c3c32706ee3c3c3b507d050bedfb.

Revert "cpufreq: interactive: Allow 1 ms error in above_hispeed_delay comparisons"

This reverts commit ff6af80775231f1dfab8353d0b665718222218bf.

Commit ff6af807 tries to avoid a corner case where frequency is stuck in
hispeed_freq for one additional window. For example, if timer_rate is
20ms, and go_hispeed_delay is 40ms, frequency might be stuck at
hispeed_freq for 60ms due to imprecision in jiffies. Same problem can be
easily solved by making go_hispeed_delay 1ms smaller instead of changing
the code.

Signed-off-by: Junjie Wu <junjiew@codeaurora.org>

cpufreq: interactive: Revert timer start modification

commit f8b276565ce95bd788af0fc8d060f92632590a40
(cpufreq: Sync on thread migration optimizations)
introduced a change to cpufreq_interactive_timer_start() in order
to reschedule the timer differently based on whether min or max
is changed. A better way is to reschedule the timer only when
necessary.

Revert timer start modification in preparation for the final fix.

Signed-off-by: Junjie Wu <junjiew@codeaurora.org>

Revert "cpufreq: interactive: Optimize sync_freq implementation"

This reverts commit 4da7f27d4dbd5bcfb8479467444f2cf198217933.

cpufreq: interactive: Revert sync on thread migration optimizations

Commit f8b276565ce95bd788af0fc8d060f92632590a40
(cpufreq: Sync on thread migration optimizations) is no longer needed
for targets with synchronous CPUs.

Part of that commit has already been reverted in
a913b3afcaa55356f5f793ae895312c8ae7e1f71
(cpufreq: interactive: Revert timer start modification)

This commit reverts the remaining changes.

Signed-off-by: Junjie Wu <junjiew@codeaurora.org>

cpufreq: interactive: Revert sync freq feature

Sync freq feature is not valid for a HMP system with clusters.

This commit reverts commit f3d1980b4db4c20f21acaed59cc511c2df84cec2
(cpufreq: interactive: sync freq feature for interactive governor)

Signed-off-by: Junjie Wu <junjiew@codeaurora.org>

cpufreq: interactive: Remove sampling_down_factor

Remove sampling_down_factor feature.

This commit revert d094d23694edf41fee50ebc544795d6116451643
(cpufreq: interactive: Add a sampling_down_factor for max frequencies)
and subsequent modifications related to sampling down factor.

Signed-off-by: Junjie Wu <junjiew@codeaurora.org>

Conflicts:
	drivers/cpufreq/cpufreq_interactive.c

Change-Id: I9e5fd451e7eaefe8ef7775365cc5a4527d37188f

cpufreq: interactive: Align timer windows for all CPUs …
Junjie Wu authored on Apr 28  myfluxi committed on Sep 16
It's more advantageous to evaluate all CPUs at same time so that
interactive governor gets a complete picture of the load on
each CPU at a specific time. It could also reduce number of speed
changes made if there are many CPUs controlled by same policy. In
addition, waking up all CPUs at same time would allow the cluster
to go into a deeper sleep state when it's idle.

Change-Id: I6915050c5339ef1af106eb906ebe4b7c618061e2
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>

cpufreq: interactive: Reset last evaluated jiffy in idle callback …
Junjie Wu authored on Aug 18  myfluxi committed on Sep 16
When CPU has been busy for a long time, last evaluated jiffy will be
quite behind because the timer would have been canceled. We don't want
to schedule a timer to fire in the past as load will always be 100%.

Reset last evaluated jiffy so that timer will be scheduled for the
next window.

Change-Id: Ie25e65eab1f16acdeda267987ca605d653f1f32a
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>

cpufreq: interactive: Round up timer_rate to match jiffy …
Junjie Wu authored on Aug 15  myfluxi committed on Sep 16
Timers are scheduled in unit of jiffies. Round up timer_rate so that
it matches the actual sampling period.

Change-Id: I47e666f835752528331f50b1e76784e6d67f8bcf
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>

cpufreq: interactive: Use del_timer/add_timer_on to rearm timers …
Junjie Wu authored on Aug 15  myfluxi committed on Sep 16
Replace mod_timer_pinned() with del_timer(), add_timer_on().
mod_timer_pinned() always adds timer onto current CPU. Interactive
governor expects each CPU's timers to be running on the same CPU.
If cpufreq_interactive_timer_resched() is called from another CPU,
the timer will be armed on the wrong CPU.

Replacing mod_timer_pinned() with del_timer() and add_timer_on()
guarantees timers are still run on the right CPU even if another
CPU reschedules the timer. This would provide more flexibility
for future changes.

Change-Id: I3a10be37632afc0ea4e0cc9c86323b9783b216b1
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>

cpufreq: interactive: Add max_freq_hysteresis feature …
Junjie Wu authored on Aug 29  myfluxi committed 7 days ago
Previously known as sampling down factor, max_freq_hysteresis
extends the period that interactive governor will stay at policy->max.
This feature is to accomodate short idle periods in an otherwise very
intensive workload.

When the feature is enabled, it ensures that once a CPU goes to max
frequency, it doesn't reduce the frequency for max_freq_hysteresis
microseconds from the time it first goes to idle.

Change-Id: Ia54985cb554f63f8c22d0b554a0a0f2ed2be038f
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>

cpufreq: interactive: Make window alignment optional …
Junjie Wu authored on Aug 29  myfluxi committed 7 days ago
Make sampling window alignment optional when scheduler inputs
are not enabled.

Change-Id: If69c111a3efe219cdd1e38c1f46f03404789c0bb
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>

Signed-off-by: renderbroken <zkennedy87@gmail.com>
msm: lpm_levels: Fix incorrect computation of next wakeup time

The next event timer wakeup was incorrectly computed when the hard timer
event doesn't exist. Fix by ensuring the next wakeup is computed only
when a timer event is valid

Change-Id: I40c1f372f84d8f43b2101e37dcfb592193d4b2e0
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
msm: lpm_levels: update suspend stats counters and time

suspend stats in the debug pm stats are not getting updated as
suspend stats in the suspend wake path is missing. This change
will add and update the suspend stats in the suspend wake path.

Signed-off-by: Anil kumar mamidala <amami@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: lpm_levels: fix incorrect mode select with next event time

Based on the next event timer value the best power mode will get
selected but there is a mismatch in calculation of selecting
the best mode. This change will fix that and selects the correct
mode based on the next wakeup time.

Signed-off-by: Anil kumar mamidala <amami@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: lpm_levels: fix driver compilation issue

Assigning an unsinged long value to unsinged int is not
correct and it cause driver compilation failure. Fix by
assigning a proper value.

Signed-off-by: Murali Nalajala <mnalajal@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: lpm_levels: Perform system_unprepare only system low power mode

system_unprepare() needs to execute operations related to system
unprepare only when the CPU subsystem was scheduled for a system low
power mode by the last core that went down. On the last core down, its
possible that residency conditions for system low power mode weren't met
and the system was never programmed to enter a low power mode. In these
scenarios, the system_unprepare() needn't execute any of the unprepare
functionalities.

Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: lpm_levels: remove rpm handshake in l2_gdhs mode

Remove rpm handshake in l2_gdhs mode and adjust the
latency values for l2_gdhs mode. Add a new dt entry to
inform lpm_levels driver to send sleep votes to rpm.

Signed-off-by: Anil kumar mamidala <amami@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: lpm_levels: remove debug print

remove a pr_info that was added for debug purpose. This is
causing excessive logging issues.

CRs-fixed: 589307
Change-Id: I1f7bcb5282b51734cb7bf30ff933d65714445cba
Signed-off-by: Venkat Devarasetty <vdevaras@codeaurora.org>
msm: Add CPU freq limiter driver

* When enabled, it will override max frequency on
  resume/suspend events and when explicitly set by user.
* When enabled, it will override min frequency on
  suspend event and when explicitly set by user.
* Enabled by default.
* Interface is generated here: /sys/kernel/msm_limiter

Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: limiter: Introduce initial multi cpu control

* This extends current functionality of the driver
  to save min/max freq for each core.
* Disabled by default.
* CPU0 is master boot core for 3.4 kernel and user
  should not reduce max freq of this core more than
  half of range.

Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
drivers: cpufreq: Remove get_cpu_idle_time from governors
Signed-off-by: renderbroken <zkennedy87@gmail.com>
Revert "msm: lpm_levels: remove rpm handshake in l2_gdhs mode"

This reverts commit 86a0d75fe67e623dc95a635e9962e8d99c0db211.
cpufreq / core: Fix printing of governor and driver name

Arrays for governer and driver name are of size CPUFREQ_NAME_LEN or 16.
i.e. 15 bytes for name and 1 for trailing '\0'.

When cpufreq driver print these names (for sysfs), it includes '\n' or ' ' in
the fmt string and still passes length as CPUFREQ_NAME_LEN. If the driver or
governor names are using all 15 fields allocated to them, then the trailing '\n'
or ' ' will never be printed. And so commands like:

root@linaro-developer# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_driver

will print something like:

cpufreq_foodrvroot@linaro-developer#

Fix this by increasing print length by one character.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
CPUFREQ: fix printing of governor and driver name in multi core code.

original change:
https://github.com/dorimanx/Dorimanx-LG-G2-D802-Kernel/commit/4b972f0b04eaae645b22d99479b9aea43c3d64e7
ARM acpuclk: Inline heavy used functions to reduce overhead. by duki994@xda
cpufreq: Add interface for gov change and upstream fixes

* Thanks @Dorimanx
* Interface can be used by drivers to change gov.

Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: limiter: Add controls for per cpu governor

* Requires hooks in CPUFREQ driver.
* Works without limiter enabled.

Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>