added dtbTool binary thanks to @Krabappel2548
added CPU voltage VDD control (thanks to @Faux123) ported to msm8974 platform
lowered MIN allowed voltage to 700mV
enabled VDD Control in defconfig
Remove Acer overvolt
added overclock upto 2.5GHz
cap bootup frequencies in defconfig
added CPU freq governor wheatley (thanks to @Ezekeel)
msm_cpu_freq_limit: module for controlling MSM quadcore cpus along with fixes (thanks to @faux123)

this module will allow proper max frequency control across all msm cores

Signed-off-by: faux123 <reioux@gmail.com>
overall_stats: add overall stats for all available cores

this is much more accurate stats tracking than just displaying core 0's
stats from most other kernels

Signed-off-by: faux123 <reioux@gmail.com>
overall_stats: make dual/quad core stats configurable via meunconfig

Signed-off-by: faux123 <reioux@gmail.com>
overall_stats: forward port to kernel 3.4+

by replacing deprecated functions with native add/sub for 64bit data types

Signed-off-by: faux123 <reioux@gmail.com>
block: add simple io scheduler
block: fiops ioscheduler core FIOPS (Fair IOPS) ioscheduler is IOPS based ioscheduler, so only targets for drive without I/O seek. It's quite similar like CFQ, but the dispatch decision is made according to IOPS instead of slice.

The algorithm is simple. Drive has a service tree, and each task lives in
the tree. The key into the tree is called vios (virtual I/O). Every request
has vios, which is calculated according to its ioprio, request size and so
on. Task's vios is the sum of vios of all requests it dispatches. FIOPS
always selects task with minimum vios in the service tree and let the task
dispatch request. The dispatched request's vios is then added to the task's
vios and the task is repositioned in the sevice tree.

Unlike CFQ, FIOPS doesn't have separate sync/async queues, because with I/O
less writeback, usually a task can only dispatch either sync or async requests.
Bias read or write request can still be done with read/write scale.

One issue is if workload iodepth is lower than drive queue_depth, IOPS
share of a task might not be strictly according to its priority, request
size and so on. In this case, the drive is in idle actually. Solving the
problem need make drive idle, so impact performance. I believe CFQ isn't
completely fair between tasks in such case too.

Signed-off-by: Shaohua Li <shaohua.li@intel.com>
block: fiops read/write request scale

read/write speed of Flash based storage usually is different. For example,
in my SSD maxium thoughput of read is about 3 times faster than that of
write. Add a scale to differenate read and write. Also add a tunable, so
user can assign different scale for read and write.

By default, the scale is 1:1, which means the scale is a noop.

Signed-off-by: Shaohua Li <shaohua.li@intel.com>
block: fiops sync/async scale

CFQ gives 2.5 times more share to sync workload. This matches CFQ.

Note this is different with the read/write scale. We have 3 types of
requests:
1. read
2. sync write
3. write
CFQ doesn't differentitate type 1 and 2, but request cost of 1 and 2
are usually different for flash based storage. So we have both sync/async
and read/write scale here.

Signed-off-by: Shaohua Li <shaohua.li@intel.com>
block: fiops add ioprio support

Add CFQ-like ioprio support. Priority A will get 20% more share than priority
A+1, which matches CFQ.

Signed-off-by: Shaohua Li <shaohua.li@intel.com>
block: fiops preserve vios key for deep queue depth workload

If the task has running request, even it's added into service tree newly,
we preserve its vios key, so it will not lost its share. This should work
for task driving big queue depth. For single depth task, there is no approach
to preserve its vios key.

Signed-off-by: Shaohua Li <shaohua.li@intel.com>
block: fiops bias sync workload

If there are async requests running, delay async workload. Otherwise
async workload (usually very deep iodepth) will use all queue iodepth
and later sync requests will get long delayed. The idea is from CFQ.

Signed-off-by: Shaohua Li <shaohua.li@intel.com>
block: fiops add some trace information

Add some trace information, which is helpful when I do debugging.

Signed-off-by: Shaohua Li <shaohua.li@intel.com>
added GPU O/C upto 533MHz
decouple overclock & CPU bin selection
add dependency for OC Ultimate
msm: acpuclock-8974: Modify L2 table for 8974

Currently 1.26 GHz and 1.49 GHz in the L2 tables for 8974
map to 800 MHz DDR. With this change the above frequencies
now get mapped to 614 MHz DDR. This change maps the above
two frequencies to lower DDR and will thereby help save power
for use cases which spend majority of time at above frequencies.

Change-Id: I7f1cbc12ff7dae28f65863d5c41e68de2db40bfe
Signed-off-by: Dilip Gudlur <dgudlur@codeaurora.org>
added GPU O/C freq 487.5MHz
cpufreq/cpufreq_intellidemand: intellidemand cpufreq
 governor (version 4.0)

Intellidemand is inspired by ondemand governor. Its main features are:

 - auto cpu hotplugging based on runnable thread average calculations
 - detection of browsing mode (long screen on activities with moderate run
   queue depth =< 45 )
 - limit max frequencies when in browsing mode to conserve battery for long
   duration tasks

Browsing State Determination:
 1- Browsing state is enabled as power-on default. Browsing state is disabled
    when run queue depth is > 45 (very high instantaneous spikes)

Browsing State Limit Max Freq Logic (sliding window algorithm):
 1- While Screen is ON > 3 min, and average load of the CPU is < 35%, then
    CPU Max frequencies will remain power-on default
 2- While Screen is On, if average CPU load > 35%, both CPUs max frequencies
    will be limited to a lower user configurable max value
 3- While Screen is On, After both CPUs' Max is limited to lowered max, when
    the average CPU load has dropped down to less than < 25%, then both CPUs
    Max freq will be restored to back to power-on default

Runnable Thread Auto-hotplug (fast hotplug / slow unplug algorithm):
 1- When average number of running thread is < threshold, 2nd cpu will be
    unplugged.
 2- When > threshold, 2nd cpu will be hotplugged.
 3- The logic applies a fast hotplug and slow unplug algorithm so 2nd core
    will stay enabled longer to help deal with performance spikes

changes from Ver 2.0 -> Ver 3.0:
  - remove GPU Busy dependency for browsing state detection (this will make
    the governor more portable to other platforms without specific GPU
    architecture knowledge)

dependencies:
  -- Qualcomm's run queue average logic (SOC independent logic)
  -- TI's runnable thread average logic (SOC independent logic)

forward ported to Linux 3.4 for use on S-800

Signed-off-by: Paul Reioux <reioux@gmail.com>
intellidemand: Add boost pulse capability

Boost pulse increases UI performance by increasing CPU freq and
reduce sampling time.

forward ported for Linux 3.4 for use on Mako
Signed-off-by: faux123 <reioux@gmail.com>
intellidemand: add bug fixes

 - Fix crash input event handler on governor switch
 - Fix panic when setting sampling rate

Signed-off-by: faux123 <reioux@gmail.com>
intellidemand: add a run queue persistence to determine browsing state

persistence will allow for better browsing state detection rather than just
purely based on run queue depth alone

Signed-off-by: faux123 <reioux@gmail.com>
intellidemand: add minimum cpu performance lock

a minimum cpu frequency performance lock is add to ensure smooth
operations when only 1 core is active

Signed-off-by: faux123 <reioux@gmail.com>

Conflicts:
	drivers/cpufreq/Kconfig

Conflicts:

	drivers/cpufreq/Kconfig
Intellidemand: update for quadcore operations. bump version to 4.0

Signed-off-by: faux123 <reioux@gmail.com>
intellidemand: code derps clean up!

Signed-off-by: faux123 <reioux@gmail.com>
Intellidemand: put cores 1~3 to sleep while screen is off

Signed-off-by: faux123 <reioux@gmail.com>
intellidemand: increase boost duration to 2.5 seconds from 1.5

Signed-off-by: faux123 <reioux@gmail.com>
intellidemand: add eco mode (dual core operations) bump version to 4.1

Signed-off-by: faux123 <reioux@gmail.com>
intellidemand: tweak for not using min performance lock

Signed-off-by: faux123 <reioux@gmail.com>
Intellidemand: adjust the nr_run hysteresis for better UI response

Signed-off-by: faux123 <reioux@gmail.com>
cpufreq: Avoid using smp_processor_id() in preemptible context

Even though this work item runs on only one cpu at a time (due to
queue_work_on()) it is possible for the work item to be preempted
and so use of smp_processor_id() is illegal.

BUG: using smp_processor_id() in preemptible [00000000]
code: kworker/3:1/4162 caller is dbs_refresh_callback+0xc/0x188
[<c00151b0>] (unwind_backtrace+0x0/0x120) from [<c0279058>]
(debug_smp_processor_id+0xbc/0xf0)
[<c0279058>] (debug_smp_processor_id+0xbc/0xf0) from [<c0454b54>]
(dbs_refresh_callback+0xc/0x188)
[<c0454b54>] (dbs_refresh_callback+0xc/0x188) from [<c0087290>]
(process_one_work+0x354/0x648)
[<c0087290>] (process_one_work+0x354/0x648) from [<c0089754>]
(worker_thread+0x1a8/0x2a8)
[<c0089754>] (worker_thread+0x1a8/0x2a8) from [<c008e480>]
(kthread+0x90/0xa0)
[<c008e480>] (kthread+0x90/0xa0) from [<c000f438>]
(kernel_thread_exit+0x0/0x8)

The intent of the code is to determine which CPU this work item
is running on, which we can easily do by passing that information
in a wrapper struct around the work struct. Do this so we avoid
this problem.

Change-Id: I05ca0ff2b3cbaa239930463ea0760e3e9d75145f
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
adapted for Intellidemand from CAF reference

Signed-off-by: faux123 <reioux@gmail.com>
intellidemand: Add support to consider other cpu load when scaling frequencies

Currently only current cpu load is considered when frequency scaling.
As a side effect of this when scheduler migrates a thread to a slower
core, the execution time increases unexpectedly.

The new algorithm not only considers current cpu load for frequency
scaling, but also takes into account load of other online cpus. The
treshold for this can be controlled using up_threshold_any_cpu_load.
When the up_threshold_any_cpu_load is crossed in any cpu then the
current cpu is set to sync_freq.

Also, when more than one cpu is online a two step ramp-up mechanism
is used. When the up_threshold_multi_core is crossed the cpu is ramped
up to optimal_freq which is less than policy->max and set to a power
friendly value.

Change-Id: I64bed1b142cde1f239e73aa1f78981c78aaf59ce
Signed-off-by: Narayanan Gopalakrishnan <nargop@codeaurora.org>

intellidemand: Fix kernel warning in cpufreq_governor_dbs

GOV_STOP event destroys the timer_mutex and is not initialized back
upon GOV_START event.
The Kernel complains at mutex_lock(during GOV_LIMITS event) after
mutex_destroy.

[<c0014918>] (unwind_backtrace+0x0/0x11c)
[<c007c004>] (warn_slowpath_common+0x4c/0x64)
[<c007c034>] (warn_slowpath_null+0x18/0x1c)
[<c079eef8>] (__mutex_lock_slowpath+0x130/0x3c4)
[<c079f1ac>] (mutex_lock+0x20/0x3c) from [<c0540900>]
[<c0540900>] (cpufreq_governor_dbs+0x3c8/0x468)
[<c053d500>] (__cpufreq_governor+0x90/0xe0)
[<c053d774>] (__cpufreq_set_policy+0x224/0x258)
[<c053da58>] (cpufreq_add_dev_interface+0x2b0/0x308)
[<c053e784>] (cpufreq_add_dev+0x500/0x56c)
[<c079247c>] (cpufreq_cpu_callback+0x88/0x9c)
[<c07a2ca8>] (notifier_call_chain+0x38/0x68)
[<c007ded0>] (__cpu_notify+0x28/0x40)
[<c0790024>] (_cpu_up+0xe4/0x118)
[<c0790024>] (cpu_up+0x64/0x80)
[<c0765840>] (store_online+0x48/0x78)
[<c038d0c8>] (dev_attr_store+0x18/0x24)
[<c017be40>] (sysfs_write_file+0x108/0x13c)
[<c012cdfc>] (vfs_write+0xb0/0x128)
[<c012d034>](sys_write+0x38/0x64)

Change-Id: Ie2a796b17209243de731ccf2ab04b7f9e7048df8
Signed-off-by: Anji Jonnala <anjir@codeaurora.org>

Adapted for Intellidemand from CAF reference

Signed-off-by: faux123 <reioux@gmail.com>
intellidemand: give intellidemand's cpu_dbs_info its own name

Signed-off-by: Paul Reioux <reioux@gmail.com>
cpufreq: enable sibling cpu policy sharing

disable Qualcomm's cpu policy restore (conflicts with sibling sharing)

Signed-off-by: Paul Reioux <reioux@gmail.com>
intellidemand: add default values for dbs sync and optimal tuneables

Signed-off-by: faux123 <reioux@gmail.com>
intellidemand: remove cpu cores autoplug capability (replaced by intelli_plug)

Signed-off-by: faux123 <reioux@gmail.com>

Conflicts:
	drivers/cpufreq/Kconfig
intellidemand: remove eco mode option (replaced by intelli_plug)

Signed-off-by: faux123 <reioux@gmail.com>
intellidemand: remove unused min performance lock defines

Signed-off-by: faux123 <reioux@gmail.com>
intellidemand: Don't update the policy->cur upon cpufreq driver failure

Signed-off-by: faux123 <reioux@gmail.com>
msm: cpufreq: make the gov stop part fully atomic

In the function cpufreq_governor_dbs, the case CPUFREQ_GOV_STOP
is not completely atomic. The removal of sysfs is outside the
critical path. If a START/STOP done frequently from user space
then there is chance of adding the sysfs interface before removal.
This creates a warning from sysfs saying creating an already
existing entry.

Also once it fails to create, cpufreq_governor_dbs returns with
error code. The dbs_enable value is incremented which is not
rolled back and cpufreq core tries to set the old
governor. This might create further problems.

Hence the removal of sysfs entry should happen in the critical
path.

CRs-fixed: 440969
Change-Id: I98891756caf2ce0b85e39e9b4f58034af1ed97ce
Signed-off-by: Venkat Devarasetty <vdevaras@codeaurora.org>
Signed-off-by: faux123 <reioux@gmail.com>
arch/arm/mach-msm/cpufreq: remove deprecated logic

Signed-off-by: Paul Reioux <reioux@gmail.com>
intellidemand: allow clean compilation when LMF is disabled

bumped version to 4.2

Signed-off-by: faux123 <reioux@gmail.com>

Conflicts:
	arch/arm/mach-msm/cpufreq.c
intellidemand: change boost tunable scope from global to local

Signed-off-by: faux123 <reioux@gmail.com>
intellidemand: change permission for boostpulse from root to system

for use with Android PowerHAL

Signed-off-by: faux123 <reioux@gmail.com>
intellidemand: fix permission for sampling_rate as well

to work with Android's PowerHAL

Signed-off-by: faux123 <reioux@gmail.com>
cpufreq: ondemand: Set MIN_LATENCY_MULTIPLIER to 20

Currently MIN_LATENCY_MULTIPLIER is set defined as 100 and so on a system with
transition latency of 1 ms, the minimum sampling time comes to be around 100 ms.
That is quite big if you want to get better performance for your system.

Redefine MIN_LATENCY_MULTIPLIER to 20 so that we can support 20ms sampling rate
for such platforms.

Signed-off-by: faux123 <reioux@gmail.com>
cpufreq: intellidemand: Set MIN_LATENCY_MULTIPLIER to 20

Currently MIN_LATENCY_MULTIPLIER is set defined as 100 and so on a system with
transition latency of 1 ms, the minimum sampling time comes to be around 100 ms.
That is quite big if you want to get better performance for your system.

Redefine MIN_LATENCY_MULTIPLIER to 20 so that we can support 20ms sampling rate
for such platforms.

Signed-off-by: faux123 <reioux@gmail.com>
cpufreq: conservative: Set MIN_LATENCY_MULTIPLIER to 20

Currently MIN_LATENCY_MULTIPLIER is set defined as 100 and so on a system with
transition latency of 1 ms, the minimum sampling time comes to be around 100 ms.
That is quite big if you want to get better performance for your system.

Redefine MIN_LATENCY_MULTIPLIER to 20 so that we can support 20ms sampling rate
for such platforms.

Signed-off-by: faux123 <reioux@gmail.com>
intelli_plug: intelligent hotplug cpu driver with eco mode

Signed-off-by: Paul Reioux <reioux@gmail.com>
intelli_plug: tweak for faster wakeup from suspend

bump version to 1.1

Signed-off-by: faux123 <reioux@gmail.com>
intelli_plug: increase cores on persistence

also replace hardcoded values with Macros for ease of updating later

Signed-off-by: faux123 <reioux@gmail.com>
intelli_plug: make it gcc-4.6.x eabi compatible :p

Signed-off-by: faux123 <reioux@gmail.com>
ARM: 7583/1: decompressor: Enable unaligned memory access for v6 and above

Modern GCC can generate code which makes use of the CPU's native
unaligned memory access capabilities.  This is useful for the C
decompressor implementations used for unpacking compressed kernels.

This patch disables alignment faults and enables the v6 unaligned
access model on CPUs which support these features (i.e., v6 and
later), allowing full unaligned access support for C code in the
decompressor.

The decompressor C code must not be built to assume that unaligned
access works if support for v5 or older platforms is included in
the kernel.

For correct code generation, C decompressor code must always use
the get_unaligned and put_unaligned accessors when dealing with
unaligned pointers, regardless of this patch.

Signed-off-by: Dave Martin <dave.martin@linaro.org>
Acked-by: Nicolas Pitre <nico@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
arch/arm/Kconfig: enable unaligned capability for ARM

Signed-off-by: faux123 <reioux@gmail.com>
switch the protection of percpu_counter list to spinlock

... making percpu_counter_destroy() non-blocking

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
intelli_plug: use rq_stats to help detect artificial or constant loads

benchmarks often create fake / artificial loads at a constant rate.  These
type of loads are not detected corectly by run average algorithms. Use
the run queue stats to help detect these cases and bring up the cores in
correspondence.

bump version to 1.2

Signed-off-by: faux123 <reioux@gmail.com>
intelli_plug: use mp_decision() algorithm for core 3 and 4

This replaces the simplistic check for run queue thresholds with a more
sophisticate algorithm with time awareness

bump version to 1.3

Signed-off-by: faux123 <reioux@gmail.com>
intelli_plug: tweak mp_decsion parameters and remove unused logic

Signed-off-by: faux123 <reioux@gmail.com>
intelli_plug: bump threshold slightly for better response

Signed-off-by: faux123 <reioux@gmail.com>
wip: intelli_plug: change logic for better benchmark performance

Signed-off-by: faux123 <reioux@gmail.com>
intelli_plug: use mp_decision to reduce online persistence count for cores

this should bring down the cores faster when run queue is low
also optimized code a bit using local vars

Signed-off-by: faux123 <reioux@gmail.com>
intelli_plug: disable by default

let the user enable via sysfs so it won't clash with mpdecision which is
enabled by default for qualcomm phones

Signed-off-by: faux123 <reioux@gmail.com>
intelli_plug: slow down hotplug activity from 50ms to 200ms

this will reduce the hotplug chaos which may in turn save more power

Signed-off-by: faux123 <reioux@gmail.com>

Conflicts:
	arch/arm/mach-msm/intelli_plug.c
intelli_plug: code clean up and minor bug fixes

bump to version 1.6

Signed-off-by: Paul Reioux <reioux@gmail.com>
cpufreq: allow for low CPU clock policy when hotplugging new cores

Signed-off-by: faux123 <reioux@gmail.com>

Conflicts:
	arch/arm/mach-msm/cpufreq.c
cpufreq: intellidemand: Fix optimal_freq logic on ramp down

When ondemand governor decides to ramp down the frequency, the missing
check for frequency being lower than optimal_freq was causing frequency
to be ramped down to optimal_freq even if the frequency decided by ondemand
governor was higher.

Change-Id: I00f9ae4c61ccda4039f3338dee2c29b8cb790be4
Signed-off-by: Veena Sambasivan <veenas@codeaurora.org>
Signed-off-by: Paul Reioux <reioux@gmail.com>
intellidemand: tweak optimal for krait 600 series

Signed-off-by: Paul Reioux <reioux@gmail.com>
intellidemand: enable sec_touchscreen input boosting

Signed-off-by: Paul Reioux <reioux@gmail.com>
intellidemand: set default sampling rate to 50k

Signed-off-by: Paul Reioux <reioux@gmail.com>
intellidemand: re-enable performance lock option

with low freq enabled kernels, minimum performance lock will help music
playback to be smooth and glitch free

Signed-off-by: Paul Reioux <reioux@gmail.com>
Intellidemand: limit min cpu perflock to boot cpu only

Signed-off-by: Paul Reioux <reioux@gmail.com>
cpufreq: Save user policy min/max instead of policy min/max during hotplug

When a CPU is hotplugged off, various fields of the policy are saved so
that they can be restored when the CPU is hotplugged back in.

The existing code saves the policy min/max field during hotplug remove and
restores it into user policy min/max during hotplug add. This results in
the loss of the user policy min/max values across a hotplug remove/add.

Fix it by saving the user policy min/max instead of policy min/max during
hotplug remove. During a hotplug add, after user policy min/max is
restored, the policy min/max is already recomputed. So, there's no risk of
going beyound any limits imposed by the CPUFREQ_ADJUST/INCOMPATIBLE
notifiers.

Change-Id: Ib8e09fa324c1f80f095c5754b5dcf2685e8e4a66
Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
Signed-off-by: Paul Reioux <reioux@gmail.com>
drivers/cpufreq/cpufreq.c: re-enable cpu policy restore

original bug FINALLY fixed by:
  cpufreq: Save user policy min/max instead of policy min/max during hotplug

Signed-off-by: Paul Reioux <reioux@gmail.com>
cpufreq: intellidemand: remove deprecated early_suspend drivers

and also remove LMF since it depended on early_suspend driver

bump version to 4.3

Signed-off-by: Paul Reioux <reioux@gmail.com>
mach-msm: cpufreq: remove deprecated early_suspend drivers

Signed-off-by: Paul Reioux <reioux@gmail.com>
intelliplug: replaced deprecated early_suspend driver with userspace interface

early_suspend has been deprecated, so move original functionality to sysfs
interfae and have userspace app to replicate the early_suspend functionality

bump version to 1.7

Signed-off-by: Paul Reioux <reioux@gmail.com>
cpufreq: intellidemand: update default settings for Snapdragon 800 Socs

Signed-off-by: Paul Reioux <reioux@gmail.com>
cpufreq: intellidemand: more default settings for Snapdragon 800 Socs

Signed-off-by: Paul Reioux <reioux@gmail.com>
intelli/msm_thermal: initial coding for Qualcomm Snapdragon 800 devices

an intelligent MSM thermal throttling kernel driver designed to replace the
closed sourced thermald(aemon) from Qualcomm.

The current driver can throttle the SOC via core frequency scaling or via
core hotplug with user configurable sysfs entries to adjust the throttling
temperature thresholds for each.

Derived from Qualcomm's Open source repo.

Signed-off-by: Paul Reioux <reioux@gmail.com>

Conflicts:

	arch/arm/mach-msm/board-8974-sec.c

Ported to Z1

Signed-off-by: DooMLoRD <metoo.mememe@gmail.com>
intellidemand: more SOC 8794 specific tweaks

Signed-off-by: Paul Reioux <reioux@gmail.com>
intelli_plug: add dynamic load sampling rate logic

Add dynamic sampling logic based on load. If load is high and required more
than 2 cores, increase the sampling rate for a duration of 3 seconds to help
manage the load better during this time.  Once duration expires, revert back
to lazier sampling rate for better batter performance.

Signed-off-by: Paul Reioux <reioux@gmail.com>
kernel/power/powersuspend: new PM kernel driver for Android w/o early_suspend

Android early_suspend/late_resume PM kernel driver framework has been
deprecated by Google. This new powersuspend PM kernel driver is a replacement
for it and existing early_suspend drivers can be easily adapted to use this
new replacement driver

Signen-off-by: Paul Reioux <reioux@gmail.com>
intellidemand: add new power_suspend PM driver

bump version to 4.4

Signed-off-by: Paul Reioux <reioux@gmail.com>
intelli_plug: add new power_suspend PM driver

bump version to 1.9

Signed-off-by: Paul Reioux <reioux@gmail.com>
powersuspend: fix logci derps :p

Signed-off-by: Paul Reioux <reioux@gmail.com>
kernel/power/powersuspend: remove userspace dependency from powersuspend

make powersuspend not depend on a userspace initiator anymore, but use a hook
in autosleep instead.

Signed-off-by: Paul Reioux <reioux@gmail.com>
kernel/power/powersuspend: add back userpace control w/ default kernel control

make kernel / userspace mode switchable

Signed-off-by: Paul Reioux <reioux@gmail.com>
kernel/power/powersuspend: default to userspace for now

Signed-off-by: Paul Reioux <reioux@gmail.com>
intelli_plug: add touch input logic

changed intelli_plug sampling rates and bump to version 2.0

Signed-off-by: Paul Reioux <reioux@gmail.com>
intelli_plug: use a context safe function call instead

Signed-off-by: Paul Reioux <reioux@gmail.com>
exp: intellidemand 5.0

Signed-off-by: Paul Reioux <reioux@gmail.com>
exp: intellidemand 5.0 fixups

Signed-off-by: Paul Reioux <reioux@gmail.com>
intelli_plug: performance tune-up continued...

Signed-off-by: Paul Reioux <reioux@gmail.com>
decompressor: Add LZ4 decompressor module

Date	Tue, 26 Feb 2013 15:24:27 +0900

This patch adds support for LZ4 decompression in the Linux Kernel.
LZ4 Decompression APIs for kernel are based on LZ4 implementation
by Yann Collet.

LZ4 homepage : http://fastcompression.blogspot.com/p/lz4.html
LZ4 source repository : http://code.google.com/p/lz4/

Signed-off-by: Kyungsik Lee <kyungsik.lee@lge.com>

v2:
- Clean up code
- Enable unaligned access for ARM v6 and above with
  CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
- Add lz4_decompress() for faster decompression with
  uncompressed output size

Signed-off-by: Paul Reioux <reioux@gmail.com>
lib: Add support for LZ4-compressed kernel

Date	Tue, 26 Feb 2013 15:24:28 +0900

This patch adds support for extracting LZ4-compressed kernel images,
as well as LZ4-compressed ramdisk images in the kernel boot process.

This depends on the patch below
decompressor: Add LZ4 decompressor module

Signed-off-by: Kyungsik Lee <kyungsik.lee@lge.com>

v2:
- Clean up code
- Use lz4_decompress() for LZ4-compressed kernel during boot-process

Signed-off-by: Paul Reioux <reioux@gmail.com>
arm: Add support for LZ4-compressed kernel

Date	Tue, 26 Feb 2013 15:24:29 +0900

This patch integrates the LZ4 decompression code to the arm pre-boot code.
And it depends on two patchs below

lib: Add support for LZ4-compressed kernel
decompressor: Add LZ4 decompressor module

Signed-off-by: Kyungsik Lee <kyungsik.lee@lge.com>

v2:
- Apply CFLAGS, -Os to decompress.o to improve decompress
  performance during boot-up process

Signed-off-by: Paul Reioux <reioux@gmail.com>

Conflicts:

	arch/arm/boot/compressed/.gitignore
lib: Add lz4 compressor module

From	Chanho Min <>

This patch adds support for LZ4 compression in the Linux Kernel.
LZ4 Compression APIs for kernel are based on LZ4 implementation
by Yann Collet and changed with kernel coding style.

LZ4 homepage : http://fastcompression.blogspot.com/p/lz4.html
LZ4 source repository : http://code.google.com/p/lz4/
svn revision : r90

Two APIs are added:
lz4_compress() support basic lz4 compression whereas lz4hc_compress() support
high compression or CPU performance get lower but compression ratio get higher.
Also, we require the pre-allocated working memory with the defined size and
destination buffer must be allocated with the size of lz4_compressbound.

Signed-off-by: Chanho Min <chanho.min@lge.com>

Signed-off-by: Paul Reioux <reioux@gmail.com>
crypto: Add lz4 Cryptographic API

From	Chanho Min <>

This patch adds support for lz4 and lz4hc compression algorithm
using the lib/lz4/* codebase.
Signed-off-by: Chanho Min <chanho.min@lge.com>

Signed-off-by: Paul Reioux <reioux@gmail.com>
lib/lz4/lz4_compress: fix macro usage error

Signed-off-by: Paul Reioux <reioux@gmail.com>
LZ4: compression/decompression signedness mismatch (v2)

LZ4 compression and decompression functions require different
in signedness input/output parameters: unsigned char for
compression and signed char for decompression.

Change decompression API to require "(const) unsigned char *".

v2: minor coding style fix.

Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>

Signed-off-by: Paul Reioux <reioux@gmail.com>
GPU Simple Governor: adapt GPU Simple Governor for Snapdrgaon 800 SOCs

initial coding for a Simple GPU governor based on my own work 2 years ago
from Sensation GB kernel commit: c1ea8f6

Signed-off-by: Paul Reioux <reioux@gmail.com>
kgsl: Implement conservative scaling policy

This behaves similarly to the conservative cpufreq governor,
which is similar to how most Mali GPU scaling algorithms behave.

The "trustzone" policy that is default relies on an undocumented
black box to make scaling decisions.

How to enable:
echo conservative > /sys/devices/platform/kgsl-3d0.0/kgsl/kgsl-3d0/pwrscale/policy

Conservative attr group:
/sys/devices/platform/kgsl-3d0.0/kgsl/kgsl-3d0/pwrscale/policy_config/conservative

Polling interval (10-1000):
/sys/devices/platform/kgsl-3d0.0/kgsl/kgsl-3d0/pwrscale/policy_config/conservative/polling_interval

Enable stats printing (causes microlags on low polling intervals):
echo 1 > /sys/devices/platform/kgsl-3d0.0/kgsl/kgsl-3d0/pwrscale/policy_config/conservative/print_stats

NOTE:
- perms are set to 666 for testing purposes

Change-Id: I9d854a73981515fc9850104302804928b04c4687
Signed-off-by: Andrew Dodd <atd7@cornell.edu>

Conflicts:

	drivers/gpu/msm/kgsl_pwrscale.c
Simple GPU governor: fix a merge derp

Signed-off-by: Paul Reioux <reioux@gmail.com>
cpufreq: Add cpu-boost driver

When certain bursty and important events take place, it might take a while
for the current cpufreq governor to notice the new load and react to it.
That would result in poor user experience. To alleviate this, the cpu-boost
driver boosts the frequency of a CPU for a short duration to maintain good
user experience while the governor catches up.

Specifically, this commit deals with ensuring that when "important" tasks
migrate from a fast CPU to a slow CPU, the frequency of the slow CPU is
boosted to be at least as high as the fast CPU for a short duration.

Since this driver enforces the boost by hooking into standard cpufreq
ADJUST notifiers, it has several advantages:
- More portable across kernel versions where the cpufreq internals might
  have been rewritten.
- Governor agnostic and hence works with multiple governors like
  conservative, ondemand, interactive, etc.
- Does not affect the sampling period/logic of existing governors.
- Can have the boost period adjusted independent of governor sampling
  period.

Change-Id: Ibd814a20043d0aba64ee7637a4a79b9ffa1b0991
Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
cpufreq: Add a sync limit to cpu-boost

Perform frequency synchronization only when source CPU's frequency
is less than sync_threshold, else sync to the sync_threshold.

Change-Id: I544c414568d4e015b80ce5891dd215275bac95da
Signed-off-by: Rohit Gupta <rohgup@codeaurora.org>
Revert "cpufreq: Add a sync limit to cpu-boost"

This reverts commit 6dc04f4c1cb149700e5c483a52fa57f59683098e.
Revert "cpufreq: Add cpu-boost driver"

This reverts commit 261ca0d28d4e06cdc05ada612529fa0ecc2ea152.
fs/dyn_sync_cntrl: dynamic sync control

The dynamic sync control interface uses new power_suspend interface

While screen is on, file sync is disabled
when screen is off, a file sync is called to flush all outstanding writes
and restore file sync operation as normal.

updated for 8974 kernels

Signed-off-by: Paul Reioux <reioux@gmail.com>

Conflicts:

	fs/Kconfig

Signed-off-by: DooMLoRD <metoo.mememe@gmail.com>
revert: kgsl: Implement conservative scaling policy
mach-msm:cpufreq_limit: fix merge derp and minor code clean up

Signed-off-by: Paul Reioux <reioux@gmail.com>
cpufreq_limit: adapted for use as built-in kernel option

set default stock frequency and remove unnecessary debug messages

bump version to 1.2

Signed-off-by: Paul Reioux <reioux@gmail.com>
cpufreq: intelliactive: initial coding and introduction!

intelliactive is based on Latest Google Interactive cpufreq governor from
Google.  The original Interactive provides smooth UI operations but suffers
slight battery drain due to its aggressive policies.  Intelliactive is an
improvement built on top of it.

It has the following enhancements added:
1. self-boost capability from input drivers (no need for PowerHAL assist)
2. two phase scheduling (idle/busy phases to prevent from jumping directly to
   max freq
3. Checks for offline cpus and short circuits some unnecessary checks to
   improve code execution paths
4. removed trace calls

Signed-off-by: Paul Reioux <reioux@gmail.com>
intelliactive: fix race condition when unregistering input handlers

Signed-off-by: Paul Reioux <reioux@gmail.com>
intelliactive: add upstream patches

Signed-off-by: Paul Reioux <reioux@gmail.com>
added new cpufreq governor SmartAssv2 (thanks to @Erasmux, @faux123 & @androdguide)
added new cpufreq governor LionHeart (thanks to @knzo & @androdguide)
added new cpufreq governor LagFree (thanks to @androdguide)
msm_turbo: initial coding for turbo boost on MSM architectures

adapted for 8974 arch

Signed-off-by: Paul Reioux <reioux@gmail.com>
msm_turbo: initial coding for turbo boost on MSM architectures (part 2)
cpufreq: inject cpu turbo boost

Signed-off-by: Paul Reioux <reioux@gmail.com>
cpufreq: fix a logic derp with turbo boost

also enforce cpu limit at all times

Signed-off-by: Paul Reioux <reioux@gmail.com>
bringing back CPU OC upto 2.3 GHz
fix msm_thermal headers for intelli-thermal
Add BFQ/SIO/FIOPS/ZEN/VR IO Schedulers
Add BFQ/ZEN/VR IO Schedulers (part 2)
mach-msm: Add msm_mpdecision Kconfig & Makefile hooks Also rename qcom's mpdecision to stay in place and be used if CONFIG_MSM_MPDEC is not set

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

Conflicts:
	arch/arm/mach-msm/Makefile
mach-msm: added MP-Decision by @showp1984

squashed the following commits:
mdpec: fix missing ifdefs when compiling with earlysuspend
msm_mpdecision: opt out early if we are thermal throttled
msm_mpdecision: add locking to early_suspend related code, even if we
msm_mpdecision: fix early_suspend compilation
msm_mpdecision: add input boost triggers
msm_mpdecision: add missing #ifdefs around thermal related code
msm_mpdecision: fix boost_time not respecting sysfs changes
msm_mpdecision: also verify that boost frequencies are > minfreq
msm_mpdecision: move startdelay to init to save cycles on each work call
msm_mpdecision: early continue get_slowest_cpu() and _rate() to save
msm_mpdecision: fix whitespaces throughout the file to comply with li
msm_mpdecision: fix definitions for earlysuspend/lcd callback switch
msm_mpdecision: offload definitions to header
msm_mpdecision: remove per_cpu suspend value
msm_mpdecision: switch to lcd callback and improve sus/res code
msm_mpdecision: update inputboost frequencies
thermal/mpdec: export throttle indicator and don't input boost if we
msm_mpdecision: add fb callback, keep earlysuspend
msm_mpdecision: boost: if we are not boosted, revib_wq does not need
msm_mpdecision: fix changing boost freq sets min = boost freq
msm_mpdecision: several changes [read more]
msm_mpdecision: min_cpus & max_cpus should on/offline affected cpus
msm_mpdecision: change frequencies for input boost
msm_mpdecision: increasing the check delay to 130ms
msm_mpdecision: boost: don't schedule more check than needed
msm_mpdecision: boost: detect changed min frequency and update accord
msm_mpdecision: tune hotplug values
msm_mpdecision: input event boost: fix not resetting boost if cpu was
msm_mpdecision: add sysfs interface for input event boost
msm_mpdecision: add input event boost [read more]
msm_mpdecision: stats: if cpu is online, add current ontime to stats
msm_mpdecision: fix spacing across the whole file
Revert "msm_mpdecision: remove early_suspend, add fb callback"
msm_mpdecision: fix sleep, don't use pause
msm_mpdecision: add stats & expose to sysfs
Revert "mpdecision: don't use sleep, cancel/resume wq instead"
mpdecision: update copyright
mpdecision: checking every 100ms is enough
mpdecision: don't use sleep, cancel/resume wq instead
msm_mpdecision: tweak hotplug values
msm_mpdecision: on resume pull up cpu1
msm_mpdecision: turn on cpu1 early
msm_mpdecision: we can't turn off cpu0
msm_mpdecision: when returning from sleep, start immediately
msm_mpdecision: remove early_suspend, add fb callback
msm_mpdecision: disable debug
msm_mpdecision: various fixes and tweaks
msm_mpdecision: fix merge errors
msm_mpdecision: add get_rate()
msm_mpdecision: decrease delay between checks to 70ms
msm_mpdecision: use CONFIG_NR_CPUS for max_cpu sysfs
msm_mpdecision: add max/min cpu limits to sysfs
msm_mpdecision: use unique lock names
msm_mpdecision: cancel/resume main work thread on ES/LR
msm_mpdecision: use own workqueues
msm_mpdecision: remove useless locking
msm_mpdecision: fix disabling mpdecision over sysfs for multicore
msm_mpdecision: export the new, larger nwns/twts arrays to sysfs
msm_mpdecision: update header to include full feature list
msm_mpdecision: make earlysuspend/lateresume core independent
msm_mpdecision: don't let msm_mpdec_work_thread() run if we are still
msm_mpdecision: update core data on first call
msm_mpdecision: decrease decision delay
msm_mpdecision: decrease startup delay
msm_mpdecision: make debug output more compact & informative
msm_mpdecision: fix get_slowest_cpu()
msm_mpdecision: make msm_mpdec_work_thread() core independent
msm_mpdecision: make mpdecision() core independent
msm_mpdecision: add debug output
msm_mpdecision: fix check for khz/mhz value (idle_freq sysfs)
mach-msm: mpdecision: don't turn on cpu1 if cpu0 freq is below idle_freq
mach-msm: mpdecision: fixup: move idle block to mpdecision()
mach-msm: mpdecision: don't turn off cpu1 if freq > idle
mach-msm: mpdecision: sysfs: check if cpu is offline before hotpluggi
mach-msm: mpdecision: increase up threshold for Sense
mach-msm: mpdecision: increase start delay for Sense
mach-msm: mpdecision: allow mpdecision to be disabled (sysfs)
mach-msm: mpdecision: fix foreign cpu control detection
mach-msm: mpdecision: adjust thresholds for sense
mach-msm: mpdecision: increase startdelay for sense
mach-msm: mpdecision: remove debug output
mach-msm: mpdecision: add sysfs interface
mach-msm: mpdecision: rename msm_mpdec_suspend to msm_mpdec_cpudata
mach-msm: mpdecision: show how long the cpu was online
mach-msm: mpdecision: fix foreign hotplug/unplug detection
mach-msm: mpdecision: add email to (c)
mach-msm: mpdecision: remove up/down delay, our default delay is larg
mach-msm: mpdecision: always set the suspend var
mach-msm: mpdecision: show cpumask after up/down
mach-msm: mpdecision: don't start immediately
mach-msm: mpdecision: change early_suspend_level to blank_screen
mach-msm: mpdecision: pause if CPU is unplugged outside of mpdecision
mach-msm: mpdecision: restructure locks, add delay
mach-msm: mpdecision: add load based decision making
mach-msm: mpdecision: small cleanup
mach-msm: Add msm_mpdecision

Signed-off-by: DooMLoRD <metoo.mememe@gmail.com>
ksm: check and skip page, if it is already scanned

On system like Android where most of the process are forked
from parent w/o execve, KSM can scan same page multiple times
in one scan cycle. There is no advantage in scanning same page
multiple times for merging. During testing with Android, it was
observed around 60% pages are skipped for each scan cycle.

Change-Id: I0cf01802f0b4d61fcab92558beb9e1c660dc9a77
Link: http://lkml.kernel.org/r/CAMrOTPgBtANS_ryRjan0-dTL97U7eRvtf3dCsss=Kn+Uk89fuA@mail.gmail.com
Signed-off-by: Pradeep Sawlani <sawlani@amazon.com>

Signed-off-by: Paul Reioux <reioux@gmail.com>
ksm: check and skip page, if it is already scanned (part 2)
scheduler: compute time-average nr_running per run-queue

Compute the time-average number of running tasks per run-queue for a
trailing window of a fixed time period. The detla add/sub to the
average value is weighted by the amount of time per nr_running value
relative to the total measurement period.

Change-Id: I076e24ff4ed65bed3b8dd8d2b279a503318071ff
Signed-off-by: Diwakar Tundlam <dtundlam@nvidia.com>
(cherry picked from commit 3a12d7499cee352e8a46eaf700259ba3c733f0e3)
Reviewed-on: http://git-master/r/111635
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Sai Gurrappadi <sgurrappadi@nvidia.com>
Tested-by: Sai Gurrappadi <sgurrappadi@nvidia.com>
Reviewed-by: Peter Boonstoppel <pboonstoppel@nvidia.com>
Reviewed-by: Yu-Huan Hsu <yhsu@nvidia.com>

forward ported to Linux 3.4 for use on Mako

Signed-off-by: Paul Reioux <reioux@gmail.com>
intelli_plug: switch to use dedicated high priority workqueue

from the shared global workqueue.  This should prevent hang ups while the
global workqueue is busy and cleaned up some logic issues.

give input boost its own workqueue

bump to version 2.2

Signed-off-by: Paul Reioux <reioux@gmail.com>
intelli_plug: code review clean up

set def sampling rate to something sane rather than zero (instantaneous
rescheduling is not good if intelli_plug is disabled)

make touch input more generic rather than tied to a touchscreen driver

remove unused code

thanks to @dorimanx for the code reviews and suggestions

bump to version 2.3

Signed-off-by: Paul Reioux <reioux@gmail.com>
Intelli_plug: add wakeup cpufreq boost for quicker wakeup

bump version to 2.4

Signed-off-by: Paul Reioux <reioux@gmail.com>
intelli_plug: add screen off max controls

bump to version 2.5

Signed-off-by: Paul Reioux <reioux@gmail.com>
intelli_plug: add parameter to control touch boost on/off

bump version to 2.6

Signed-off-by: Paul Reioux <reioux@gmail.com>
proc: enhance time-average nr_running stats

Add time-average nr_running to loadavg printout

Bug 958978

Change-Id: I5c6904efb52a86f4964eb66c1576fc91f60f5b1d
Signed-off-by: Alex Frid <afrid@nvidia.com>
(cherry picked from commit 86f3642cc44a69d1e4798719bd9182cd6923f526)
Reviewed-on: http://git-master/r/111636
Reviewed-by: Sai Gurrappadi <sgurrappadi@nvidia.com>
Tested-by: Sai Gurrappadi <sgurrappadi@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Peter Boonstoppel <pboonstoppel@nvidia.com>
Reviewed-by: Yu-Huan Hsu <yhsu@nvidia.com>
scheduler: Re-compute time-average nr_running on read

Re-compute time-average nr_running when it is read. This would
prevent reading stalled average value if there were no run-queue
changes for a long time. New average value is returned to the reader,
but not stored to avoid concurrent writes. Light-weight sequential
counter synchronization is used to assure data consistency for
re-computing average.

Change-Id: I8e4ea1b28ea00b3ddaf6ef7cdcd27866f87d360b
Signed-off-by: Alex Frid <afrid@nvidia.com>
(cherry picked from commit 527a759d9b40bf57958eb002edd2bb82014dab99)
Reviewed-on: http://git-master/r/111637
Reviewed-by: Sai Gurrappadi <sgurrappadi@nvidia.com>
Tested-by: Sai Gurrappadi <sgurrappadi@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Peter Boonstoppel <pboonstoppel@nvidia.com>
Reviewed-by: Yu-Huan Hsu <yhsu@nvidia.com>

forward ported to Linux 3.4 for use on Mako

Signed-off-by: faux123 <reioux@gmail.com>

Conflicts:

	kernel/sched/sched.h
added prima WLAN drivers from SlimRom
modify Kconfig/Makefile for prima WLAN
driver: qpnp-vibrator: implement sysfs interface for intensity

Change-Id: Ic5e72ad51223e3e18fff86a10ebe5efe7d75b02c
Simple GPU Algorithm: Initial coding for devfreq based Adreno Drivers

This is an open source user configurable simple GPU Control Algorithm used to
replace the closed sourced Qualcomm TrustZone GPU controller

Signed-off-by: Paul Reioux <reioux@gmail.com>