cpufreq: interactive: Fix race in sync freq feature

When we switch to the interactive governor, the kernel will panic
because the policy object is NULL on affected cpus. Add a check to
avoid this situation.

Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
switch do_fsync() to fget_light()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
ARM: sched_clock: Load cycle count after epoch stabilizes

There is a small race between when the cycle count is read from
the hardware and when the epoch stabilizes. Consider this
scenario:

 CPU0                           CPU1
 ----                           ----
 cyc = read_sched_clock()
 cyc_to_sched_clock()
                                 update_sched_clock()
                                  ...
                                  cd.epoch_cyc = cyc;
  epoch_cyc = cd.epoch_cyc;
  ...
  epoch_ns + cyc_to_ns((cyc - epoch_cyc)

The cyc on cpu0 was read before the epoch changed. But we
calculate the nanoseconds based on the new epoch by subtracting
the new epoch from the old cycle count. Since epoch is most likely
larger than the old cycle count we calculate a large number that
will be converted to nanoseconds and added to epoch_ns, causing
time to jump forward too much.

Fix this problem by reading the hardware after the epoch has
stabilized.

Change-Id: I995133b229b2c2fedd5091406d1dc366d8bfff7b
Cc: Russell King <linux@arm.linux.org.uk>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Git-commit: 336ae1180df5f69b9e0fb6561bec01c5f64361cf
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
[sboyd: reworked for file movement kernel/time -> arm/kernel]
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>

Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
mako_hotplug: cleanups and code improvements to do less calls when there's no need for.

Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
Implement kexec-hardboot by. All work done by @Tasssadar

Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
Revert "msm: idle-v7: flush non secure L1 cache lines for l2 GDHS LPM mode"

This reverts commit 5d9d25dd25f41e527e6ee034e9c0f52e825413aa.
msm: pm-8x60: Use generic clk apis during power collapse

The power management code calls in acpuclk code directly to switch to a
always on clock source during power collapse there by turning off the
HFPLL during any power collapse. The Krait clock management is switching
to use clocks ops model. To necessitate the change, the power management
code will register for CPU/L2 clock sources and disables the
corresponding clocks during power collapse.

Add a DT node to indicate if the clock sources are synchronized across
the cores/L2, to prevent querying on clock sources that might not be
available on certain targets. Also, clk_get() doesn't currently support
deferred probe, change the compile order to include pm-8x60 after clocks
driver to ensure that clock drivers get probed before pm-8x60.

Change-Id: I671296064dda93f1d2226e6ae059d827c4c00890
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
Signed-off-by: Vikram Mulukutla <markivx@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
msm: idle: Use ARM suspend/resume APIs to restore during warmboot

ARM generic cpu_suspend/resume APIs restore the necessary CP15 registers
to a known state when resuming from a reset state. Use of generic
suspend/resume APIs allows the msm warmboot code to not care about
restoring core registers used by ARM kernel. Also, the PM subsystem no
longer needs to allocate page table or uncached memory to save CPU
registers.

While at it convert most of the assembler code into respective C
function except for warmboot code that executes with MMU turned off.
Also, the idle subsystem no longer needs to manage a  page table or
uncached memory to save CPU registers.

Change-Id: I78a75d0a3c703390eec476199c7ca2786360e12a
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
Signed-off-by: Karthik Parsha <kparsha@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
msm: pm: Rename pm-8x60.c to msm-pm.c

pm-8x60.c doesn't accurately reflect the current list of targets that
are supported. So renaming them to msm-pm.c to be more inline with the
msm chipsets.

Change-Id: Iefa8150885f8da136de7cba4a122ec901a171a02
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
msm: pm: Clean up idle-v7

Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
mako_hotplug: fix a bug where if timestamp was not initialized with jiffies then the cpu_smash() would not offline cpus until jiffies caught up. Also use the stantard API to timer check if its after jiffies or not.

Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
cpufreq: interactive: make sure boosted_time is initialized with jiffies and use standard jiffies API to detect if time is after or before jiffes.

Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
msm: kgsl: no need to cast long because jiffies and window_time are already long.

Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
thermal: code cleanup.

Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
Revert "msm: pm: Clean up idle-v7"

This reverts commit e8c9ac17c2bec9958116569519ef7f25675a8ea8.
Revert "msm: pm: Rename pm-8x60.c to msm-pm.c"

This reverts commit 739dac9d9a2f6f9a3f8d197356af27eb50fa58dc.
Revert "msm: idle: Use ARM suspend/resume APIs to restore during warmboot"

This reverts commit 6ab6107e70d266ca53bf04ab61c81bf029f5e16a.
Revert "msm: pm-8x60: Use generic clk apis during power collapse"

This reverts commit 931f119199397c61be109086b170b06f4e8e4460.
Revert "Revert "msm: idle-v7: flush non secure L1 cache lines for l2 GDHS LPM mode""

This reverts commit 057eaf3ed6fb760707c5428c9c78bfe52b9af9fb.
Revert "ARM: kernel: update cpu_suspend code to use cache LoUIS operations"

This reverts commit 97d19eeac5185319c4f595ae0a460ff456344f0a.