arm: mach-tegra: resolve tegra_cpu_lock race condition

Problem description:

 - lock used in cpuquiet, cpu-tegra3.c, tegra2-throttle.c, and tegra3_throttle
   originate from cpu-tegra.c, tegra_cpu_lock
 - edp_update_limit and tegra_auto_hotplug_governor need a protection from
   tegra_cpu_lock. These are also called by tegra_cpu_set_speed_cap
 - Some callers of tegra_cpu_set_speed_cap do not acquire tegra_cpu_lock,
   but some do

Fix description:

 - Create a locked variant and unlocked variant of tegra_cpu_set_speed_cap
   to make it explicit that tegra_cpu_lock is needed for tegra_cpu_set_speed_cap
 - Replace existing calls with new variants of tegra_cpu_set_speed_cap appropriately

Bug 1225764

Change-Id: I8aa6356df278375e3a9105023f66c8286e3fdbef
Signed-off-by: Sang-Hun Lee <sanlee@nvidia.com>
Reviewed-on: http://git-master/r/199238
(cherry picked from commit 91bdd64c3c80480195a5ccdb8cef969ca5a18afc)
Reviewed-on: http://git-master/r/207640
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>

Conflicts:
	arch/arm/mach-tegra/cpu-tegra.c
	arch/arm/mach-tegra/cpu-tegra.h
	arch/arm/mach-tegra/cpu-tegra3.c
	arch/arm/mach-tegra/tegra3_throttle.c
ARM: tegra: cpuquiet: augment no_lp to force both LP and G

- tegra_cpuquiet 'no_lp' node now accepts '-1' to force LP cluster on
- when a cluster is forced the switches take place immediately without
  any delay

Bug 1247636

Change-Id: I1ec07acc3cf51419a4770542c6a1c90b92e0bf66
Signed-off-by: Simo Melenius <smelenius@nvidia.com>
Reviewed-on: http://git-master/r/208772
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
(cherry picked from commit ab16bbb6f581da538448d2a64e03dd272b8fb985)
Reviewed-on: http://git-master/r/210358
ARM: tegra: cpuquiet: make no_lp = -1 always force cluster switch

When setting the no_lp sysfs node to -1 the system would attempt to
switch to the LP cluster. This can fail if the frequency or the number
of online cores are too high.

This change ensure the frequency and number of online cores are first
brought down, such that a cluster switch on no_lp = -1 always
succeeds.

Bug 1247636
Bug 1253920

Change-Id: If6af671e8defdfc8172e8d9356ddf03d54bae98d
Signed-off-by: Peter Boonstoppel <pboonstoppel@nvidia.com>
Reviewed-on: http://git-master/r/217033
(cherry picked from commit a712c562fb66c3f964783410e6b482bfebbb33fc)
Reviewed-on: http://git-master/r/221636
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Diwakar Tundlam <dtundlam@nvidia.com>

Conflicts:
	arch/arm/mach-tegra/cpuquiet.c
ARM: tegra: cpuquiet: WQ_RESCUER has been removed

Signed-off-by: Dan Willemsen <dwillemsen@nvidia.com>
ARM: Tegra: cpuquiet: use nr_cpu_ids isntead of NR_CPUS

Bug 1307544

Change-Id: Icf58253bd145e58d48692178bf2ca244202931d3
Signed-off-by: Graziano Misuraca <gmisuraca@nvidia.com>
Reviewed-on: http://git-master/r/238616
(cherry picked from commit 7402f99b1de7a622d29c564926bd37a4808a3121)
Reviewed-on: http://git-master/r/240685
(cherry picked from commit fdc876d21128c344d91c964566016d7c71466422)
Reviewed-on: http://git-master/r/249747
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Thomas Cherry <tcherry@nvidia.com>

Conflicts:
	arch/arm/mach-tegra/cpuquiet.c
Cpuquiet: Fix min_cpus == 1 not forcing G cluster

Refactored the logic that decides when to cluster switch
in order to enforce cluster switching priority given
different constraints. Following is the priority

highest to lowest priority:

  - no_lp sysfs node: -1 = LP; 1 = G; 0 = no constraint
  - min_cpus = 1 forces G cluster
  - frequency changes when on a single core

Bug 1348717

Change-Id: I9a4951808f1916a1929180c45a7dd58640c62a66
Signed-off-by: Sai Gurrappadi <sgurrappadi@nvidia.com>
Reviewed-on: http://git-master/r/277346
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Peter Boonstoppel <pboonstoppel@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Diwakar Tundlam <dtundlam@nvidia.com>
(cherry picked from commit c59c0b45244c9e6fc7e2c264b11ac82424e19c24)
Signed-off-by: Ajay Nandakumar <anandakumarm@nvidia.com>
ARM: tegra: cpuquiet: Reject invalid pmqos request

Guard against invalid pmqos requests.

Bug 1393159

Change-Id: Ic67cd8a9cbe9ab461cb83f6d0072998a0a9706f5
Signed-off-by: Sai Gurrappadi <sgurrappadi@nvidia.com>
Reviewed-on: http://git-master/r/328489
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Diwakar Tundlam <dtundlam@nvidia.com>