adjust arch/arm/mach-msm/cpufreq.c
freezer: skip waking up tasks with PF_FREEZER_SKIP set

Android goes through suspend/resume very often (every few seconds when
on a busy wifi network with the screen off), and a significant portion
of the energy used to go in and out of suspend is spent in the
freezer.  If a task has called freezer_do_not_count(), don't bother
waking it up.  If it happens to wake up later it will call
freezer_count() and immediately enter the refrigerator.

Combined with patches to convert freezable helpers to use
freezer_do_not_count() and convert common sites where idle userspace
tasks are blocked to use the freezable helpers, this reduces the
time and energy required to suspend and resume.

Change-Id: I6ba019d24273619849af757a413271da3261d7db
Acked-by: Tejun Heo <tj@kernel.org>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Colin Cross <ccross@android.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
futex: use freezable blocking call

Avoid waking up every thread sleeping in a futex_wait call during
suspend and resume by calling a freezable blocking call.  Previous
patches modified the freezer to avoid sending wakeups to threads
that are blocked in freezable blocking calls.

This call was selected to be converted to a freezable call because
it doesn't hold any locks or release any resources when interrupted
that might be needed by another freezing task or a kernel driver
during suspend, and is a common site where idle userspace tasks are
blocked.

Change-Id: I9ccab9c2d201adb66c85432801cdcf43fc91e94f
Acked-by: Tejun Heo <tj@kernel.org>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Colin Cross <ccross@android.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
nanosleep: use freezable blocking call

Avoid waking up every thread sleeping in a nanosleep call during
suspend and resume by calling a freezable blocking call.  Previous
patches modified the freezer to avoid sending wakeups to threads
that are blocked in freezable blocking calls.

This call was selected to be converted to a freezable call because
it doesn't hold any locks or release any resources when interrupted
that might be needed by another freezing task or a kernel driver
during suspend, and is a common site where idle userspace tasks are
blocked.

Change-Id: I93383201d4dd62130cd9a9153842d303fc2e2986
Acked-by: Tejun Heo <tj@kernel.org>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Colin Cross <ccross@android.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
sigtimedwait: use freezable blocking call

Avoid waking up every thread sleeping in a sigtimedwait call during
suspend and resume by calling a freezable blocking call.  Previous
patches modified the freezer to avoid sending wakeups to threads
that are blocked in freezable blocking calls.

This call was selected to be converted to a freezable call because
it doesn't hold any locks or release any resources when interrupted
that might be needed by another freezing task or a kernel driver
during suspend, and is a common site where idle userspace tasks are
blocked.

Change-Id: Ic27469b60a67d50cdc0d0c78975951a99c25adcd
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Colin Cross <ccross@android.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Add extra free kbytes tunable

Add a userspace visible knob to tell the VM to keep an extra amount
of memory free, by increasing the gap between each zone's min and
low watermarks.

This is useful for realtime applications that call system
calls and have a bound on the number of allocations that happen
in any short time period.  In this application, extra_free_kbytes
would be left at an amount equal to or larger than than the
maximum number of allocations that happen in any burst.

It may also be useful to reduce the memory use of virtual
machines (temporarily?), in a way that does not cause memory
fragmentation like ballooning does.

[ccross]
Revived for use on old kernels where no other solution exists.
The tunable will be removed on kernels that do better at avoiding
direct reclaim.

Change-Id: I765a42be8e964bfd3e2886d1ca85a29d60c3bb3e
Signed-off-by: Rik van Riel<riel@redhat.com>
Signed-off-by: Colin Cross <ccross@android.com>
fix include/linux/freezer.h
silence some compiler warnings

Change-Id: I7607c7b2bf90d7eeaa1769a40403210de1724451
i2c: i2c-gpio: Add suspend/resume callbacks

Add suspend-resume callbacks and also provide
a callback to configure/un-configure hardware
resources such as gpio's.
Provide an API to configure the i2c-gpio's very
late into the power collapse sequence.

Change-Id: I5b2168ab568931cd406a92a95bdaaf9dd1526a6e
Signed-off-by: Anirudh Ghayal <aghayal@codeaurora.org>

Conflicts:
	arch/arm/mach-msm/board-qrd7627a.c

Conflicts:
	arch/arm/mach-msm/pm2.c
msm: cpr: Avoid suspend while executing the IRQ handler

The regulator operation is over i2c which can sleep.
Fail suspend if the CPR interrupt has not returned.

CRs-Fixed: 443675
Change-Id: I301c56349a58112384f5973d98643a98613002c7
Signed-off-by: Kaushal Kumar <kaushalk@codeaurora.org>
Signed-off-by: Murali Nalajala <mnalajal@codeaurora.org>

Conflicts:
	arch/arm/mach-msm/msm_cpr.c

Conflicts:
	arch/arm/mach-msm/pm2.c
msm: idle-v7: Write to SMEM only for PC

Write to shared memory structure only when
C0 attempts to do a PC

Change-Id: Ia9c2da78c0ab2f2500b79f3172ca393038d04512
Signed-off-by: Murali Nalajala <mnalajal@codeaurora.org>

Conflicts:
	arch/arm/mach-msm/idle-macros.S

Conflicts:
	arch/arm/mach-msm/pm2.c
msm: pm2: Restore interrupt subsystem from sleep.

Change-Id: Id5128e47e1e78688d0b608b64454555f26a65043
Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>
Signed-off-by: Baji Patthan <bpatth@codeaurora.org>
msm: pm2: Update SPC LPM stats correctly

Currently StandalonePC stats are updating incorrectly even
for successful cases. After debug found that compiler has
optimized some of the instructions where the return value
from "msm_pm_power_collapse_standalone()" being compared
incorrectly and always log the stats as failed even for
success cases. Change the "exit_stat" variable to "volatile"
to avoid any optimization.

CRs-Fixed: 433578
Signed-off-by: Murali Nalajala <mnalajal@codeaurora.org>
(cherry picked from commit f59048d29fd75a30cac8c294e068178d9d489af3)

Change-Id: If1f9313f7968e93f5dcd9fb33426496f5091d14a
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>

Conflicts:
	arch/arm/mach-msm/pm2.c
remove double bool low_power

Change-Id: I2df2a8cb90f4a9375237f5e62ec7c381ec7859ff
ARM: gic: Refactor code for gic_configure_and_raise

Currently the offset and bit calculation in the function was
hardcoded for IPC1 interrupt. To support other secondary cores
we have to refactor the code to calculate the offset and bits
as per the cpu and interrupt number.

Change-Id: I33de8f185c219fb6a8e9d7f9676e958f27d54a12
Signed-off-by: Taniya Das <tdas@codeaurora.org>

Conflicts:
	arch/arm/mach-msm/platsmp-8625.c

Conflicts:
	arch/arm/mach-msm/platsmp-8625.c
msm: platsmp-8625: Refactor code for multicore environment

Generic functions added to make code generic to suit multicore
environment.

Change-Id: I7ae5808682d9454a9bd761fc469d6c75cda4d1e2
Signed-off-by: Taniya Das <tdas@codeaurora.org>

Conflicts:
	arch/arm/mach-msm/platsmp-8625.c

Conflicts:
	arch/arm/mach-msm/platsmp-8625.c