Revert "msm: board-8960: Disable idle standalone PC"

This reverts commit 05c962aa7c12b25e68fa97a9b182eadf4cdba275.
msm: pm: backport Retention mode code from 4 to 2 cores
att/spr board: port pm sleep mode tweaks to ATT and SPR
board-m2-att/spr: apply the same two sleep state commits from vzw

commits 092598f & 5e96151
msm: m2: remove dead simulation code
msm: 8960: Set last sleep mode variable for WFI

Set the last sleep mode variable correctly when
entering WFI sleep mode.

Change-Id: I68bbb09b46fe5d7229fbbc67f636294f0d9e92d6
Signed-off-by: Girish Mahadevan <girishm@codeaurora.org>
msm: pm-8x60: Don't restore ACPU frequency for hotplug cases.

During hotplug if power collapse fails don't try to restore the
ACPU clock frequency. For normal hotplug exit ACPU drivers save
and restore as part of hotplug notifications.

CRs-fixed: 334002
Change-Id: I94aee59b7769fb06614d4804797ce62e952437e3
Signed-off-by: Girish Mahadevan <girishm@codeaurora.org>
msm: pm: Support for Krait Retention

Introduce a new low power state for Krait, retention.
This state will lower the voltage to the Krait core to
retention voltage in addition to clock gating. This state
will be in between WFI and Standalone power collapse in
terms of time overhead and power savings.

Change-Id: I6b1f0a0d2e4954a705a047fd4a07f4dd1fb3518a
Signed-off-by: Girish Mahadevan <girishm@codeaurora.org>

Conflicts:

	arch/arm/mach-msm/pm-8x60.c
msm: pm-8x60: Fix bug where device enter low power mode

An incorrect ordering in the check of allowed modes, results in
standalone power collapse not getting selected when the secondary
cores are online.

Change-Id: Idc7177b78bd0ce7563cc27afbf6c12d3bc1f9f9a
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>

Conflicts:

	arch/arm/mach-msm/pm-8x60.c
msm: pm: Add support for retention on each core

Allow each core on 8974 to enter retention and retain
the state of the CPU. On 8960 as hardware restriction does
not permit all cores to enter retention at the same time,
allow only core 0 to enter retention when all other cores
are offline to maintain backward compatibility.

Change-Id: I6690e901afc9fa3a27010c264fa3acc9a0722c1a
Signed-off-by: Priyanka Mathur <pmathur@codeaurora.org>
msm: pm: Remove idle wakelock checking

Now that all users of idle wakelocks are migrated to pm_qos we
can remove the idle wakelock checks from the pm code.

Change-Id: I19cca1d0b28a2943178b9d9eade2b594fd94a139
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>

Conflicts:

	arch/arm/mach-msm/pm-8x60.c
	arch/arm/mach-msm/pm2.c
8960-regulator: fix voltage range constraints
d2: Updates (mpdecision overhaul)

Thanks to show-p1984(Daniel Rassmann) the stock mpdecision binary is being
scrapped in replace of this more battery friendly and cpu load based alternative.

* Disabled intellidemand for now for reported reason.
* Replaced stock mpdecision binary with msm_mpdecision
* -O2 to -O3 Compiler flags (HOSTCFLAGS & HOSTCXXFLAGS)

Requires I617f909a88571f3c69192f6e4b0b6540ddac2269 merge prior
mach-msm: Add msm_mpdecision

This currently only does the following thing:
Screen on -> CPU1 online
Screen off -> CPU1 offline

More to come.

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

mach-msm: mpdecision: small cleanup

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

mach-msm: mpdecision: add load based decision making

This now works like the mpdecision binary from QCOM.
CPU hotplugging/unplugging based on system load.

A sysfs interface will be built in with a later commit.

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

mach-msm: mpdecision: restructure locks, add delay

The new delay allows the CPU to come up before any other action is taken.
This prevents fast plugging and also ensures the CPU hotplug process
is really done, before trying to unplug it again (or plug it).

The new locks are more efficient, and only used if necessary.

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

mach-msm: mpdecision: pause if CPU is unplugged outside of mpdecision

This fixes cpu wars if something else tries to control the cpus.
default delay: 10000ms

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

mach-msm: mpdecision: change early_suspend_level to blank_screen

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

mach-msm: mpdecision: don't start immediately

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

mach-msm: mpdecision: show cpumask after up/down

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

mach-msm: mpdecision: always set the suspend var

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

mach-msm: mpdecision: remove up/down delay, our default delay is large enough

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

mach-msm: mpdecision: add email to (c)

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

mach-msm: mpdecision: fix foreign hotplug/unplug detection

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

Conflicts:

	arch/arm/mach-msm/msm_mpdecision.c

mach-msm: mpdecision: show how long the cpu was online

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

mach-msm: mpdecision: rename msm_mpdec_suspend to msm_mpdec_cpudata

Since this is being used for more than suspend stuff the old name
just isn't accurate anymore.

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

mach-msm: mpdecision: add sysfs interface

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

mach-msm: mpdecision: remove debug output

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

mach-msm: mpdecision: fix foreign cpu control detection

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

mach-msm: mpdecision: allow mpdecision to be disabled (sysfs)

This allows disabling/enabling of mpdecision over sysfs.

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

mach-msm: mpdecision: sysfs: check if cpu is offline before hotplugging it

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

mach-msm: mpdecision: don't turn off cpu1 if freq > idle

This fixes cpu1 being turned off though it is still working
with a high frequency. The idle_freq can be modified through sysfs.

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

mach-msm: mpdecision: fixup: move idle block to mpdecision()

This belongs in mp_decision() because this influences the decision
mpdecision is about to make.

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

mach-msm: mpdecision: don't turn on cpu1 if cpu0 freq is below idle_freq
If the clock of cpu0 is below the set idle_freq don't enable cpu1 and
disregard the runqueue value.

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

msm_mpdecision: fix check for khz/mhz value (idle_freq sysfs)

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

msm_mpdecision: add debug output

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

msm_mpdecision: make mpdecision() core independent

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

msm_mpdecision: make msm_mpdec_work_thread() core independent

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

msm_mpdecision: fix get_slowest_cpu()

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

msm_mpdecision: make debug output more compact & informative

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

msm_mpdecision: decrease startup delay

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

msm_mpdecision: decrease decision delay

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

msm_mpdecision: update core data on first call

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

msm_mpdecision: don't let msm_mpdec_work_thread() run if we are still booting

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

msm_mpdecision: make earlysuspend/lateresume core independent

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

msm_mpdecision: update header to include full feature list

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

msm_mpdecision: export the new, larger nwns/twts arrays to sysfs

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

msm_mpdecision: fix disabling mpdecision over sysfs for multicore

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

msm_mpdecision: remove useless locking

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

msm_mpdecision: use own workqueues

This will alter mpdecision to alloc it's own wq rather than using
the predefined queue which is a shared resource.

The WQ is not bound to the issuer CPU (=high-priority), has a
rescue worker task and is freezable.
Also destroy the workqueue on exit, and rename msm_mpdec to
msm_mpdec_init.

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

msm_mpdecision: cancel/resume main work thread on ES/LR

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

msm_mpdecision: use unique lock names

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

msm_mpdecision: add max/min cpu limits to sysfs

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

msm_mpdecision: use CONFIG_NR_CPUS for max_cpu sysfs

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

msm_mpdecision: decrease delay between checks to 70ms

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

msm_mpdecision: add get_rate()

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

msm_mpdecision: fix merge errors

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

msm_mpdecision: various fixes and tweaks

- fix get_slowest_cpu_rate(): don't cut off rate to int
- fix get_slowest_cpu_rate(): don't use values from an offline cpu
- fix get_slowest_cpu(): don't return cpu0.
- tweak hotplug thresholds

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

msm_mpdecision: disable debug

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

msm_mpdecision: when returning from sleep, start immediately

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

msm_mpdecision: we can't turn off cpu0

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

msm_mpdecision: turn on cpu1 early

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

msm_mpdecision: on resume pull up cpu1

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

msm_mpdecision: tweak hotplug values

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

mach-msm: Add msm_mpdecision Kconfig & Makefile hooks

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

Conflicts:

	arch/arm/mach-msm/Kconfig

Makefile: Set -O3 for HOSTCFLAGS AND HOSTCXXFLAGS

defconfigs: Dont use intellidemand yet

Causes more battery drain than id like

d2: Enable msm_mpdecision

Conflicts:

	arch/arm/configs/aokp_d2_defconfig
	arch/arm/configs/aokp_d2usc_defconfig
	arch/arm/configs/aokp_d2vzw_defconfig

Signed-off-by: Luis Cruz <ljc2491@gmail.com>
mpdecision: don't use sleep, cancel/resume wq instead

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>
mpdecision: checking every 100ms is enough

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

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>
msm: kgsl: Always send fence sync the timestamp it expects

Fence sync seems to react badly when it gets a unexpected timestamp
on a timeline.  When a event expires always send the expected timestamp
even if the event expired because the context was destroyed.

Change-Id: Ic0dedbad770363a00257d62c4940f7743bc33060
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: Calculate busy interval considering GPU freq as float

GPU freq could be non-integral value and treating it as an integer
to calculate GPU busy insterval leads to higher busy interval
and more often we see negative idle stats. This change caculates
busy interval by treating gpu freq to the correct precision.

Change-Id: Ic54130803d7a0436b4ba31b09915eb7165d16590
CRs-fixed: 454972
Signed-off-by: Vinay Roy <vroy@codeaurora.org>