msm: remote_spinlock: Add support for remote_spin_lock_rlock_id()
remote_spin_lock_rlock_id() and remote_spin_unlock_rlock() are
added to acquire/release a raw remote lock (without a local
spinlock). This is useful when ownership of a lock must transfer
between different execution environments, such as when a lock is
used to guarantee atomicity of a set of actions spread across
different execution environments.

Specifically, these APIs are added to support a new lock which
must be acquired in Linux but released by TrustZone software.

Because no local spinlock is acquired, each thread must use a
different ID so that only one thread can proceed through the
lock at a time.

Support for these new APIs is presently implemented only for
SFPB locks.

Change-Id: Ifc5b1f552090051d2e975107e56e21e22df08924
Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
Build: Update Build Script
Signed-off-by: renderbroken <zkennedy87@gmail.com>
msm: msm-pm: Remove timeout waiting for cpu to power collapse

The delays in the CPU_DYING notication path could result in the core
initiating the hotplug to send out CPU_DEAD notifications after
msm_pm_wait_cpu_shutdown() times out. This could result in a unknown
resets when regulator/clocks are disabled in the CPU_DEAD path. To
prevent unknown resets, wait infinitely to enter power collapse but
throw a warning after the 1ms mark.

The platform_cpu_kill() path is also executed in the reboot path when a
core tries to stop secondary cores. In these cases, platform_cpu_kill
shouldn't wait infinitely for the secondary cores to power collapse. To
circumvent this scenario, track dying cpus as a part of the hotplug
notification and skip waiting for the core to power collpase during
reboot path.

Change-Id: I6a7fbeeea0d50b5f1fc76a02a39f161b40a67b6c
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
arm: msm: Rectify timeout initialization
This doesn't make sense to start timeout from 10ms
and count upto 20ms.

Initialize with 0ms to fix this.
Signed-off-by: renderbroken <zkennedy87@gmail.com>
arm: msm: Increase timeout to 2.5ms

CPU Boost of 2 ms has been increased to 2.5 ms to slightly improve performance.
So, also increase msm-pm timeout to prevent false warnings.

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>

Conflicts:
	arch/arm/mach-msm/lpm_levels.c
mm: Added filesystem dynamic read-ahead
 * Credits to Chad Gooldman
 * Thanks Pinkflozd for sharing this!
Signed-off-by: renderbroken <zkennedy87@gmail.com>
kernel/power/powersuspend: LCD screen on/off hooks (Yank555.lu)
- add an alternative hook for screen on / off detection in the display
  pannel driver
- sleeps  ~0.1s sooner, wakes up ~1s later then autosleep
- clean up source formatting a bit (Paul Reioux)

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

Conflicts:
	kernel/power/powersuspend.c
kernel/power/powersuspend: cumulative update to version 1.5
- 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

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

Signed-off-by: Paul Reioux <reioux@gmail.com>
mdss_dsi_panel.c: add powersuspend hooks
Signed-off-by: Paul Reioux <reioux@gmail.com>
staging: Allow logcat termination on suspend
* To have bypass for debugs
* Save little more power

Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
sched: Add sysinterface for GENTLE_FAIR_SLEEPERS
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
Signed-off-by: Luka Karinja <lk@varjanta.com>
Signed-off-by: renderbroken <zkennedy87@gmail.com>
lpm_levels: Do not allow power collapse when multi cores online

When any core power collapse is not selected, no need to allow
idle power collapse on cpu0 when multi cores online. It may leads to
stability issues.

Signed-off-by: Anji Jonnala <anjir@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
Ramdisk_AOSP: Update Render Script

 * Make Timer Values more conservative. This will not affect performance but should save us even more juice! (Oh Yeah!)
 * Make Simple_Ondemand the default GPU Governor
 * Change Scheduler to Deadline

Signed-off-by: renderbroken <zkennedy87@gmail.com>
Defconfig Updates

 * Re-enable Falcon_Hotplug (Disable Intelliplug)
 * CONFIG_WQ_POWER_EFFICIENT_DEFAULT=y
 * CONFIG_PM_DEVFREQ=y
 * CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND=y
 * CONFIG_DEVFREQ_GOV_PERFORMANCE=y
 * CONFIG_DEVFREQ_GOV_POWERSAVE=y
 * CONFIG_DEVFREQ_GOV_USERSPACE=y
 * CONFIG_DEVFREQ_GOV_MSM_ADRENO_TZ=y
 * CONFIG_DEVFREQ_GOV_MSM_CPUFREQ=y

Signed-off-by: renderbroken <zkennedy87@gmail.com>
staging:android:lmk: Use for_each_thread helper

* Based on Faux's commit: https://github.com/faux123/Nexus_5/commit/2b75ffef20ecaee344726461b1ed3c0e2752b077

Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
staging: lmk: Fine tune OOM for screen on/off

* Increase no. of parmeters handled by minfree
* Add interface to set different OOM values for screen on/off
* Add parameter to turn on/off auto set of different OOM values

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

Conflicts:
	drivers/staging/android/lowmemorykiller.c
android/lowmemorykiller: Account for total_swapcache_pages

The lowmemorykiller relies on NR_FILE_PAGES when measureing
the amount of reclaimable memory in the system.
However when swap is enabled swap cache pages are counted
in NR_FILE_PAGES, and swap cache pages aren't as reclaimable
in low memory as file cache pages. Therefore a large swap
cache can result in the lowmemorykiller not running and
an OOM occuring.

In order to ensure the lowmemorykiller properly evaluates the
amount of reclaimable memory don't count the swap cache pages.

Signed-off-by: Liam Mark <lmark@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
mm, oom: change type of oom_score_adj to short

The maximum oom_score_adj is 1000 and the minimum oom_score_adj is -1000,
so this range can be represented by the signed short type with no
functional change.  The extra space this frees up in struct signal_struct
will be used for per-thread oom kill flags in the next patch.

** Modified to merge with Chaos Kernel

Signed-off-by: David Rientjes <rientjes@google.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Reviewed-by: Michal Hocko <mhocko@suse.cz>
Cc: Anton Vorontsov <anton.vorontsov@linaro.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
staging: android: LMK: Skip killing core apps

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