LINARO fixes for better ARM support. + small code corrections. by @bruce2728

https://github.com/bruce2728/kernel_lge_d802/commit/97280f182e1fbd1e36300727ae0ce50efa7f153f
https://github.com/bruce2728/kernel_lge_d802/commit/eee1f26f35502ca2f0fb3424309de7aea53d2c94
msm: hotplug: Underp input checks

Kids, don't drink and drive.
msm: smd: Use irq_set_affinity() API instead of the callback in irqchip.

When affinity is set by directly accessing the function pointer via
irqchip, the irq doesn't get migrated during hotplug and could result in
spurious wakeup of offlined cores. Switch to using irq_set_affinity
which ensures that the irq gets migrated during hotplug.

Change-Id: If700323f636d4ee4978b5e168077514e4d142cb9
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
(cherry picked from commit 00e4ba3a54e92cbb8f8353b8db38dd681332d2fe)
msm: vidc: Initialize kernel space stack variables

This change initializes kernel space stack variables
that are passed between kernel space and user space
using ioctls.
Non initialization of these variables may lead to
leakage of memory values from the kernel stack to
user space.

PS2-3: Correct authorship and date.

Change-Id: I5b45f3a7baf9c538fee2ec356cd8545f8b042b5e
CRs-fixed: 556771,563420
Signed-off-by: Deepak Verma <dverma@codeaurora.org>
diag: dci: Safeguard to prevent Integer Underflow and Memory Leak

At certain point in diag driver there can be integer underflow
thus can lead to memory leak. Added a safeguard for that.

Change-Id: I2a0304f5b9888fe12ca9ef5fbaa9a68ee4ab9c15
Crs-fixed: 556860
Signed-off-by: Katish Paran <kparan@codeaurora.org>
ARM: dts: msm: Add L2 perf monitor interrupts to bypass list

Corrected L2 perf monitor interrupt name to APCC_qgicL2PerfMonIrptReq in the list.

The L2 perf monitor interrupts can only come when the CPU subsystem is active
and powered on. So, put it in the bypass list so that XO shutdown is not
blocked to allow processing this interrupt when the CPU subsystem is power
collapsed.

Change-Id: I1ae4dc9e800ac2d7188d45ef7634530d93049340
Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
Signed-off-by: Girish Ghongdemath <girishsg@codeaurora.org>
gpu: ion: fix use-after-free in ion_heap_freelist_drain

The `buffer' variable is being used after being freed. Fix this.

Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
gpu: ion: Avoid using rt_mutexes directly

RT_MUTEXES can be configured out of the kernel, causing compile
problems with ION.

To quote Colin:
"rt_mutexes were added with the deferred freeing feature.  Heaps need
to return zeroed memory to userspace, but zeroing the memory on every
allocation was causing performance issues.  We added a SCHED_IDLE
thread to zero memory in the background after freeing, but locking the
heap from the SCHED_IDLE thread might block a high priority allocation
thread for a long time.

The lock is only used to protect the heap's free_list and
free_list_size members, and is not held for any long or sleeping
operations.  Converting to a spinlock should prevent priority
inversion without using the rt_mutex.  I'd also rename it to free_lock
to so it doesn't get used as a general heap lock."

Thus this patch converts the rt_mutex usage to a spinlock and
renames the lock free_lock to be more clear as to its use.

I also had to change a bit of logic in ion_heap_freelist_drain()
to safely avoid list corruption.

Acked-by: Colin Cross <ccross@android.com>
Cc: Android Kernel Team <kernel-team@android.com>
Reported-by: Jim Davis <jim.epost@gmail.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: mdss: fix race condition between shutdown thread and fb ioctl

Currently all entires into fb driver are synchronized with shutdown
context except fb ioctl context. fb ioctl is an asynchronous entry to
fb driver which can be called simultaneously from two different user
processes. Synchronize these fb ioctls and shutdown context to prevent
race condition.

Signed-off-by: Ujwal Patel <ujwalp@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: kgsl: Report correct GPU frequency in sysfs

Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
drivers: usb: Use Android device as USB keyboard/mouse

Adapt to 3.4.y 8974/hammerhead
Base project: https://github.com/pelya/android-keyboard-gadget
Required app: https://play.google.com/store/apps/details?id=remote.hid.keyboard.client

Steps:
* Start ADB Debugging
* Start app
* Connect device to system via USB cable

All credits to @pelya for this sweet hack.

Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: krait-regulator: handle efuse differences

Scaling factor version is valid for
- 8974 based devices when the version bits read 1
- 8974pro based devices when the version bits read 1 or 2
- 8084 based devices when the version bits read 0
- 8092 based devices when the version bits read 0

Moreover the three bit scaling factor data for
- 8974 based devices starts at bit 16
- 8974pro based devices starts at bit 16
- 8084 based devices starts at bit 14
- 8092 based devices starts at bit 14

Update the code to handle these differences.

[neo: Only required parts]

Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: krait-regulator: fix unnecessary calls to switch to LDO

When asked to set a LDO voltage the driver rounds it up to
the nearest step value. However, when checking if the requested voltage
is already set it doesn't account for the rounding up.

Fix this by rounding up the requested value, which avoids
unnecessary calls to set the LDO voltage and switch to LDO.

Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
MSM Hotplug: Added all code checks and fixes by @neobuddy89 thanks!

https://github.com/neobuddy89/hammerhead_kernel_caf/commit/3435c9fc98c71f287bb3256a53cb20921344521c
https://github.com/neobuddy89/hammerhead_kernel_caf/commit/23dca6333a3a340d52fb87269ac280a31405d1b6
https://github.com/neobuddy89/hammerhead_kernel_caf/commit/38d912dfcfaf99b3fa85f44f90521fdcffa7112b
https://github.com/neobuddy89/hammerhead_kernel_caf/commit/7f9290a5c5810f2f783ccc97ad81cb3e23bed56b
patch-3.4.90-91 using patch -p1 <
Merged F320 touch screen driver for KNOCK CODE. and set to build it.
Alucard Hotplug: Speed optimizations by DEV. thanks @Alucard24
Intelli Thermal: (intergated to msm_thermal) added new parameters and more.

Thanks Alucard24 for mods.
intelli_thermal_stats and some optimizations.

Dorimanx added:
I have merge intelli thermal as stand alone just for updates.
it's not actually used in my tree, all moved to msm_thermal
Fixed INTELLI_THERMAL_STATS Kconfig for my tree. and set OFF. not needed.