CPU: tegra3_thermal: Add mutex_lock and mutex_unlock.

Conflicts:
	arch/arm/mach-tegra/tegra3_thermal.c
ARM: tegra: dvfs: Update Tegra3 CPU DVFS tables

Bug 817679
Bug 841336

Change-Id: I9a9d9e7a03b64774b1d2ebd8533be85582827515
Signed-off-by: Alex Frid <afrid@nvidia.com>
Reviewed-on: http://git-master/r/71755
Reviewed-by: Simone Willett <swillett@nvidia.com>
Tested-by: Simone Willett <swillett@nvidia.com>

Conflicts:

	arch/arm/mach-tegra/tegra3_clocks.c
	arch/arm/mach-tegra/tegra3_dvfs.c

Conflicts:
	arch/arm/mach-tegra/tegra3_clocks.c
Stop crying about undefined reference

Conflicts:
	include/linux/cpu_debug.h
sync.c: add fsync() toggle module

Conflicts:
	fs/sync.c
cpu-tegra.c: we have several changes in here. The first and most notable is the removal of the early_suspend functions that were connected to the governors. What was NVIDIAs idea to have several functions to change governors based on screen on/off? No gain comes from it and it only wastes processing time because the path goes something like this: turn screen off -> save previous governor and its settings in an auxiliary function -> change to low power cpu cluster -> change to interactive/conservative governors based on the config choice. Then the other way around when screen is on... This path is pretty much dumbed down, theres much more going on, so why waste it in this procedure? So this is removed and replaced by two simple early_suspend functions that are tied to the Tegra cpu_driver struct that caps the policy->max to 475Mhz on screen off, and returns max to 1,5Ghz on screen on. This is way cleaner and screams much less problems. I also cleaned up some procedures that didn't make any sense like messing with threads/process priorities. Also did a little policy->max and policy->min settings on cpufreq_init to make sure the device boots with the correct frequencies.

Conflicts:
	arch/arm/mach-tegra/Kconfig
	arch/arm/mach-tegra/common.c
	arch/arm/mach-tegra/cpu-tegra.c
ARM: tegra: emc: Reduce DDR3 min rate to 25.5MHz. - from NVIDIA

Conflicts:
	arch/arm/mach-tegra/tegra3_emc.c
tegra3_clocks.c: refactor CPU frequency tables and ajust EMC clock ratios

Conflicts:
	arch/arm/mach-tegra/tegra3_clocks.c
edp.c: make all cores to go 1,5Ghz max

Conflicts:
	arch/arm/mach-tegra/edp.c
cpufreq.c: add userspace voltage control. Original implementation from faux123 (which was based on Michael Huang's OMAP4460 work). Interface cleaned up, made more robust and secure

Conflicts:
	drivers/cpufreq/cpufreq.c
tegra3_dvfs.c: reduce minimum voltage allowed for the CPU from 850mV to 600mV

Conflicts:
	arch/arm/mach-tegra/tegra3_dvfs.c

Conflicts:
	arch/arm/mach-tegra/tegra3_dvfs.c
cpufreq: fix wrong report of the frequency table in the UV interface.

Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
tegra: includes fixup.
mutex: Place lock in contended state after fastpath_lock failure

ARM recently moved to asm-generic/mutex-xchg.h for its mutex
implementation after the previous implementation was found to be missing
some crucial memory barriers. However, this has revealed some problems
running hackbench on SMP platforms due to the way in which the
MUTEX_SPIN_ON_OWNER code operates.

The symptoms are that a bunch of hackbench tasks are left waiting on an
unlocked mutex and therefore never get woken up to claim it. This boils
down to the following sequence of events:

        Task A        Task B        Task C        Lock value
0                                                     1
1       lock()                                        0
2                     lock()                          0
3                     spin(A)                         0
4       unlock()                                      1
5                                   lock()            0
6                     cmpxchg(1,0)                    0
7                     contended()                    -1
8       lock()                                        0
9       spin(C)                                       0
10                                  unlock()          1
11      cmpxchg(1,0)                                  0
12      unlock()                                      1

At this point, the lock is unlocked, but Task B is in an uninterruptible
sleep with nobody to wake it up.

This patch fixes the problem by ensuring we put the lock into the
contended state if we fail to acquire it on the fastpath, ensuring that
any blocked waiters are woken up when the mutex is released.

Signed-off-by: Will Deacon <will.deacon@arm.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Chris Mason <chris.mason@fusionio.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: <stable@vger.kernel.org>
Reviewed-by: Nicolas Pitre <nico@linaro.org>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/n/tip-6e9lrw2avczr0617fzl5vqb8@git.kernel.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
tegra: add GPU clocks interface.

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

Conflicts:
	arch/arm/mach-tegra/common.c
	drivers/cpufreq/cpufreq.c

Conflicts:
	arch/arm/mach-tegra/common.c
tegra: clocks: add new pll_c entries if we overclock the GPU further.

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

Conflicts:
	arch/arm/mach-tegra/tegra3_clocks.c

Conflicts:
	arch/arm/mach-tegra/tegra3_clocks.c
tegra: add CPU_LP max_rate interface.

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

Conflicts:
	drivers/cpufreq/cpufreq.c
tegra: set new voltage tables for certain gpu clock ranges for stability purposes.

Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
tegra: remove some safety mechanisms to facilitate  GPU overclocking from userspace.

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

Conflicts:
	arch/arm/mach-tegra/dvfs.c
	drivers/video/tegra/host/nvhost_acm.c
tegra: decrease GPU clocks to nearly stock values. Also refactor most code to make it simpler. We get rid of the voltages arrays and update the millivolts table dynamically. For that we had to get rid of the const variable type or the compiler wouldn't let it build for obvious reasons. Also changes how to change the frequency of the GPU as it only outputs one value instead of the whole array of frequencies. Makes it much easier for users to use and much easy on the code complexity. Thanks @morfic for the pll_c tables.

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

Conflicts:
	arch/arm/mach-tegra/common.c
	arch/arm/mach-tegra/dvfs.h
	arch/arm/mach-tegra/tegra3_clocks.c
	arch/arm/mach-tegra/tegra3_dvfs.c

Conflicts:
	arch/arm/mach-tegra/common.c
	arch/arm/mach-tegra/tegra3_clocks.c
	arch/arm/mach-tegra/tegra3_dvfs.c
restore tegra3_thermal.c