cpufreq: add yankactive governor

Interactive governor with, fow now :

- hispeed_freq defaulting to lower than policy_max (1.73GHz)
- target_loads increased to 95
- min_sampling time reduced to 20ms
- above_hispeed_delay increased to 80ms
- timer_rate increased to 20ms

cpufreq: yankactive: Optimize sync_freq implementation

Don't let frequency drop below sync_freq if either load or
frequency among other cpus is above a certain threshold,
not necessarily both.

Credits : cyanogen
kernel/power/powersuspend: new PM kernel driver for Android w/o early_suspend v1.5 (Yank555.lu)

- fix hybrid-kernel mode cannot be set through sysfs

kernel/power/powersuspend: new PM kernel driver for Android w/o early_suspend v1.4 (Yank555.lu)

- add hybrid-kernel mode (autosleep and panel, first wins)
- default to hybrid-kernel mode
- harmonize debug message with my other stuff
- include all 3 modes as default, so it's only commenting out to change

- add an alternative hook for screen on / off detection in the display panel driver
(sleeps ~0.1s sooner, wakes up ~1s later then autosleep)

kernel/power/powersuspend: new PM kernel driver for Android w/o early_suspend v1.3 (Yank555.lu)

- fix stupid typo

- add an alternative hook for screen on / off detection in the display panel driver
(sleeps ~0.1s sooner, wakes up ~1s later then autosleep)

kernel/power/powersuspend: new PM kernel driver for Android w/o early_suspend v1.2 (Yank555.lu)

- make kernel / userspace mode switchable

kernel/power/powersuspend: new PM kernel driver for Android w/o early_suspend v1.1 (Yank555.lu)

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

kernel/power/powersuspend: new PM kernel driver for Android w/o early_suspend (faux123)

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>;

kernel/power/powersuspend: new PM kernel driver for Android w/o early_suspend (faux123)

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>;
intelli_plug: intelligent hotplug cpu driver with eco mode (faux123)

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>

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>

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>

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>

intelli_plug: add new power_suspend PM driver

bump version to 1.9

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>

intelli_plug: performance tune-up continued...

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 : bump to v3.2 (squashed, details below)

sched/cpuidle: reduce IPI store. Backport upstream 3.16 scheduler updates

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

Revert "scheduler: Re-compute time-average nr_running on read"

This reverts commit cc713f0f701c38dfd3512655e5237e6330112ca0.

Revert "proc: enhance time-average nr_running stats"

This reverts commit e95a97db5678052ba67b5ae4e50fbd8459186bdc.

Revert "scheduler: compute time-average nr_running per run-queue"

This reverts commit 7bff574c27b7b582f09431d8bbf64f1361264142.
intelli_plug: refactor stats calculation code to be less intrusive

this is done for those kernels which do not have 100% source code available
and must use existing closed source modules such as wifi drivers

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>

intelli_plug: add profiles support and misc code optimization

bump to version 3.0

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

Intelli_plug: kernel sched/core: add per cpu nr_running stats

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

intelli_plug: use per cpu nr_runnings stats for unplugging cores

bump version to 3.1

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

intelli_plug: allow cpu_nr_running_threshold to be user adjustable

bump version to 3.2

Signed-off-by: Paul Reioux <reioux@gmail.com>
intelli_plug : bump to v3.3 (squashed, details below)  (faux123)

intelli_plug: remove legacy msm_rq based code

just use the original algorithm based on nr_running_stats

bump version to 3.3

Signed-off-by: Paul Reioux <reioux@gmail.com>
intelli_plug: tweak cpu_nr_running threshold

and fix minor logic issues

Signed-off-by: Paul Reioux <reioux@gmail.com>
intelli_plug: bump version to 3.4 (squashed, details below) (faux123)

intelli_plug: add nr_running_thresholds based on thread capacity of SOC type

instead of hard coded nr_running_thresholds, perform compile time calculation
of thresholds based on thread capacity of SOC types.

bump version to 3.4

Signed-off-by: Paul Reioux <reioux@gmail.com>
intelli_plug: misc minor code fixup post 3.4 update

Signed-off-by: Paul Reioux <reioux@gmail.com>
intelli_plug : bump to v3.6 (squashed, details below) (faux123)

intelli_plug : add automatic dual-core initializations

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

intelli_plug : deprecate eco mode. replaced by built-in profile

bump version to 3.5

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

intelli_plug : add eco-extreme profile for more dual core use options

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

intelli_plug : post 3.5 tweaks and code clean up

bump to version 3.6

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

intelli_plug : move to its own directory. It's been cross platform for a while

intelli_plug driver has been working on OMAP44xx, TEGRA 3, Exynos and
MSM Krait/Cortex multi-core SOCs.  So it doesn't make sense to patch on a per
SOC basis, move it to its own ARM platform independent folder so patches can
apply to all supported ARM platforms

Signed-off-by: Paul Reioux <reioux@gmail.com>
compress: add LZ4 support

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>
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>
zswap: use LZ4 if available

Signed-off-by: Paul Reioux <reioux@gmail.com>
mdnie: HIJACK MDNIE Profile v1.0b (Yank555.lu)

- change sysfs filerights to 666 by default

mdnie: HIJACK MDNIE Profile v1.0a (Yank555.lu)

- added WHATHUB's new control interface keeping the current interface at the same time (stay open)

mdnie lite control: revert back to stocklike disabled by default (Yank555.lu)

mdnie lite control: update single control for black level

- black is applied as a delta to actual black RGB values (-128 to +128)

mdnie lite control: add single control for black level

- slightly adapted to keep copy_mode (Yank555.lu)
- black kept at 0 by default as Natural is kept as base calibration (Yank555.lu)

mdnie lite control: override for all samsung scenarios and profiles (WhatHub)

- slightly adapted to keep copy_mode (Yank555.lu)

mdnie lite control: adjust calibration (WhatHub)

- slightly adapted to keep copy_mode (Yank555.lu)

Simple switchable mdnie lite control interface

- make hijacking STANDARD mode sysfs switchable, disabled by default (Yank555.lu)
- add copy curve information from existing mode
- add copy full mode from existing mode

Sysfs Interface : /sys/class/mdnie/mdnie/...

Simple mdnie lite control interface (WhatHub)

- mdnie lite control: use standard mode instead of movie mode
Forced Fast Charge for Samsung Note 3 v1.2 by Yank555.lu

- added support for wireless charger

SysFS interface :

 * /sys/kernel/fast_charge/force_fast_charge (rw)
 *
 *   0 - disabled (default)
 *   1 - substitute AC to USB
 *   2 - use custom mA configured through sysfs interface (see below)
 *
 * /sys/kernel/fast_charge/ac_charge_level (rw)
 *
 *   rate at which to charge when on AC (1.0A/h to 2.1A/h)
 *
 * /sys/kernel/fast_charge/usb_charge_level (r/w)
 *
 *   rate at which to charge when on USB (0.460A/h to 1.0A/h)
 *
 * /sys/kernel/fast_charge/wireless_charge_level (r/w)
 *
 *   rate at which to charge when on WIRELESS (0.650A/h to 1.2A/h)
 *
 * /sys/kernel/fast_charge/failsafe (rw)
 *
 *   0 - disabled - allow anything up to 2.1A/h to be used as AC / USB custom current
 *   1 - enabled  - behaviour as described above (default)
 *
 * /sys/kernel/fast_charge/ac_levels (ro)
 *
 *   display available levels for AC (for failsafe enabled mode)
 *
 * /sys/kernel/fast_charge/usb_levels (ro)
 *
 *   display available levels for USB (for failsafe enabled mode)
 *
 * /sys/kernel/fast_charge/wireless_levels (ro)
 *
 *   display available levels for WIRELESS (for failsafe enabled mode)
 *
 * /sys/kernel/fast_charge/version (ro)
 *
 *   display fast charge version information
 *
 * /sys/kernel/fast_charge/info (ro)
 *
 *   display complete fast charge configuration in human readable format

Forced Fast Charge for Samsung Note 3 v1.1 by Yank555.lu

- redone fast charge for new KK kernel sourcedrop
Forced Fast Charge for Samsung Note 3 v1.2 by Yank555.lu

- added support for wireless charger

SysFS interface :

 * /sys/kernel/fast_charge/force_fast_charge (rw)
 *
 *   0 - disabled (default)
 *   1 - substitute AC to USB
 *   2 - use custom mA configured through sysfs interface (see below)
 *
 * /sys/kernel/fast_charge/ac_charge_level (rw)
 *
 *   rate at which to charge when on AC (1.0A/h to 2.1A/h)
 *
 * /sys/kernel/fast_charge/usb_charge_level (r/w)
 *
 *   rate at which to charge when on USB (0.460A/h to 1.0A/h)
 *
 * /sys/kernel/fast_charge/wireless_charge_level (r/w)
 *
 *   rate at which to charge when on WIRELESS (0.650A/h to 1.2A/h)
 *
 * /sys/kernel/fast_charge/failsafe (rw)
 *
 *   0 - disabled - allow anything up to 2.1A/h to be used as AC / USB custom current
 *   1 - enabled  - behaviour as described above (default)
 *
 * /sys/kernel/fast_charge/ac_levels (ro)
 *
 *   display available levels for AC (for failsafe enabled mode)
 *
 * /sys/kernel/fast_charge/usb_levels (ro)
 *
 *   display available levels for USB (for failsafe enabled mode)
 *
 * /sys/kernel/fast_charge/wireless_levels (ro)
 *
 *   display available levels for WIRELESS (for failsafe enabled mode)
 *
 * /sys/kernel/fast_charge/version (ro)
 *
 *   display fast charge version information
 *
 * /sys/kernel/fast_charge/info (ro)
 *
 *   display complete fast charge configuration in human readable format

Forced Fast Charge for Samsung Note 3 v1.1 by Yank555.lu

- redone fast charge for new KK kernel sourcedrop
Simple GPU Algorithm: Initial coding for devfreq based Adreno Drivers (faux123)

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>
kthermal  thanks ktoonsez
Async I/O latency to a ssd greatly increased, 34% gain (Creds: kleikamp)
sched: Make GENTLE_FAIR_SLEEPERS configurable thru sysfs
CHROMIUM: mm: Fix calculation of dirtyable memory

The system uses global_dirtyable_memory() to calculate
number of dirtyable pages/pages that can be allocated
to the page cache.  A bug causes an underflow thus making
the page count look like a big unsigned number.  This in turn
confuses the dirty writeback throttling to aggressively write
back pages as they become dirty (usually 1 page at a time).

Fix is to ensure there is no underflow while doing the math.

Signed-off-by: Sonny Rao <sonnyrao@chromium.org>
Signed-off-by: Puneet Kumar <puneetster@chromium.org>

BUG=chrome-os-partner:16011
TEST=Manual; boot kernel, powerwash, login with testaccount and
make sure no jank occurs on sync of applications

Change-Id: I614e7c3156e014f0f28a4ef9bdd8cb8a2cd07b2a
Reviewed-on: https://gerrit.chromium.org/gerrit/37612
Reviewed-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Olof Johansson <olofj@chromium.org>
Commit-Ready: Puneet Kumar <puneetster@chromium.org>
Reviewed-by: Puneet Kumar <puneetster@chromium.org>
Tested-by: Puneet Kumar <puneetster@chromium.org>
msm: kgsl: Fix nice level for higher priority GPU start thread

Before, we were actually setting the lowest possible priority.

Change-Id: I3a52de949eee0faea8061dd91ed303fa8231f0d4

Signed-off-by: flar2 <asegaert@gmail.com>

Conflicts:
	drivers/gpu/msm/adreno.c

Signed-off-by: Matt Filetto <matt.filetto@gmail.com>
PM: devfreq: Use high priority workqueue

It does not make sense to run kgsl on high and devfreq on regular
priority.

Signed-off-by: flar2 <asegaert@gmail.com>
mmc: disable CRC check

Change-Id: I7ca7c522c4b824cf05bbe7ec627168dddc565ad9
Signed-off-by: flar2 <asegaert@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>