backport mach-msm/hotplug updates from codeaurora msm-3.4 kernel
ARM: msm: convert logical CPU numbers to physical numbers

This patch uses the new cpu_logical_map() macro for converting logical
CPU numbers into physical numbers when dealing with the pen_release
variable in the SMP boot and CPU hotplug paths.

Tested-and-acked-by: David Brown <davidb@codeaurora.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
_____________

msm: hotplug: Support cpu hotplug in no PM cases

Add support for hotplug operations to take secondary
CPUs online/offline when CONFIG_PM is turned off.

Change-Id: Iae591f7307a3ea574e3f512714a08da23bcf069b
Signed-off-by: Sathish Ambley <sambley@codeaurora.org>
_____________

msm: pm-8x60: Move hotplug related code out of pm code.

Move hotplug related code into hotplug.c and compile hotplug.c only when
CONFIG_HOTPLUG_CPU is defined.

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

msm: qdss: CP14 based save and restore of debug and trace registers

Accessing Krait debug registers from memory mapped interface requires
qdss_pclkdbg_clk and qdss_h_clk clocks apart from the ETM clock. This
means either:

1. requesting or releasing qdss clocks for every save and restore
or
2. leaving the qdss clocks on all the time
or
3. using the CP14 interface which is based on just the ETM clock and
   doesn't require the qdss clocks

We choose to use CP14 interface to avoid the pitfalls for 1. and 2. above.

Moreover, we make the save-restore autodetect the debug and trace
architecture and do the needful based on it and hence consolidate the
code for 8660 and 8960.

Change-Id: If2a383e6f755c9ed893031966fa7ef6de41a5699
Signed-off-by: Pratik Patel <pratikp@codeaurora.org>
___________________

msm: move pm and cpuidle to machine include directory

Some drivers need to know if a cpu exited out from a idle sleep.
Move the cpuidle.h which contains prototypes for the notifier registration
and pm.h which contains the sleep state definitions to include/mach.

The drivers interested in knowing exit and entry in to idle states need to
register with the notifier using msm_cpuidle_register_notifier.

Change-Id: I204860313a57840c32f2256bd8682eafe678dad8
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
_________________

ARM: 7293/1: logical_cpu_map: decouple CPU mapping from SMP

It turns out that the logical CPU mapping is useful even when !CONFIG_SMP
for manipulation of devices like interrupt and power controllers when
running a UP kernel on a CPU other than 0. This can happen when kexecing
a UP image from an SMP kernel.

In the future, multi-cluster systems running AMP configurations will
require something similar for mapping cluster IDs, so it makes sense to
decouple this logic in preparation for this support.

Acked-by: Yang Bai <hamo.by@gmail.com>
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
Reported-by: Joerg Roedel <joerg.roedel@amd.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
________________________

msm: pm: Move pm.h back into "mach-msm" from "mach-msm/include/mach"

APIs in this header are no longer needed outside of mach-msm.
Move the header out of include/mach to discourage use of it
in device drivers.

Change-Id: Id87eab2c909d01e4146d79d62f9c61a80e66fd64
Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
__________________

msm: pm-8x60: Expose additional APIs through pm.h

The following two non-static APIs should be exposed in a header
file but are not. Fix this. When the pm-8x60 driver is not used,
use stubs in their place that always return success.

    int msm_pm_wait_cpu_shutdown(unsigned int cpu)
    bool msm_pm_verify_cpu_pc(unsigned int cpu)

msm_pm_set_rpm_wakeup_irq(unsigned int irq) is also specific to
the pm-8x60 driver, so stub it out for targets without pm-8x60,
too.

Change-Id: I257a458a7e435b5cbc3b058a9fb245ea8704ca1a
Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
________________

msm: hotplug: Wait for power collapse completion in platform_cpu_kill()

Call msm_pm_wait_cpu_shutdown() to wait for the CPU to be fully
power-collapsed before returning from platform_cpu_kill(). This is
necessary to prevent CPU_DEAD and CPU_DEAD_FROZEN notifiers from
executing until the CPU is fully collapsed. Otherwise, some drivers
may turn off hardware resources before it is safe to do so. For
example, acpuclock-8960's hotplug handler turns off CPU clocks as
part of CPU_DEAD. If this happens before the collapse is complete,
it may result in a hang.

The call to msm_pm_wait_cpu_shutdown() will return immediately for
hotplugs that do not involve power-collapse and therefore has no
impact for those scenarios.

Change-Id: I88bf28f01fb02ad7dfcb8234c745570e5085585a
Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
_________________

msm: hotplug: support hotplug with wfi only power collapse

Currently the pen_release is not set to -1 after we return from
msm_pm_cpu_enter_lowpower. This doesn't happen when we actually power
collapse, but it does when we only wfi. This will cause the next hotplug
attempt to fail and crash the system, as the cpu comes up when the
system is not expecting it. Fix this by explicitly setting the
pen_release when we wake up in this manner.

Change-Id: Ib39c406091412b04510df5de660fd6346763f2b8
Signed-off-by: Jeff Ohlstein <johlstei@codeaurora.org>
_____________

msm: hotplug/platsmp: Fix cpu invaldation pointer arithmetic

These functions take two void pointers indicating where to start
and end the invalidation and cache flush. The pointer arithmetic
is considering the pen_release pointer as an int pointer so
adding sizeof(pen_release) is adding 16 bytes to the pointer and
specifying that as the end. This inadvertently invalidates data
next to the pen_release variable which could be bad. Fix the
pointer math to only invalidate or clean the region for the
pen_release variable.

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

msm: smp: Remove WFE/SEV from secondary core bootup

During the cold boot path once the secondary core is released
out of reset we keep looping for the pen release variable.
The wfe+sev in this path are just unnecessary as they provide
negligible power savings, and the latency cost is not worth it.
During the hotplug path the secondary core will be in wfi and
only an interrupt will be able to bring the core out.
Removing the wfe effectively lowers the hotplug latency.

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

msm: hotplug: Change the pen variable in one place

Other WFI based hotplug implementations set the pen variable to
-1 in C code and do the appropriate flushing operations in one
location. They also don't try to invalidate the cache on a
spurious wakeup and report how many spurious wakeups there were.
Let's do the same in our code so that we can remove our
dependence on the dmac_{inv,flush}_range() functions (which are
no longer upstream) and easily report spurious wakeups to the
kernel logs.

This does delay the time we set the pen back to its default
value, but that doesn't actually matter because generic ARM
hotplug code already waits for a completion before continuing.

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

Conflicts:
	arch/arm/common/gic.c
	arch/arm/configs/i_atnt_org_defconfig
	arch/arm/mach-msm/Kconfig
	arch/arm/mach-msm/Makefile
	arch/arm/mach-msm/devices.h
	arch/arm/mach-msm/hotplug.c
	arch/arm/mach-msm/jtag.c
	arch/arm/mach-msm/pm-8x60.c
	arch/arm/mach-msm/pm.h
	arch/arm/mach-msm/qdss.h
	lge/lge_board/i_vzw/board_i_vzw.c